Skip to content

Reliability P1s: audio deadlock, bounded capture queue, download/script/provider hardening - #71

Merged
GalaxyRuler merged 8 commits into
mainfrom
codex/reliability-hardening-phase7
Jul 12, 2026
Merged

Reliability P1s: audio deadlock, bounded capture queue, download/script/provider hardening#71
GalaxyRuler merged 8 commits into
mainfrom
codex/reliability-hardening-phase7

Conversation

@GalaxyRuler

Copy link
Copy Markdown
Owner

Before Submitting This PR

Please confirm you have done the following:

  • I have searched existing issues and pull requests (including closed ones) to ensure this isn't a duplicate
  • I have read CONTRIBUTING.md

Human Written Description

After the main reliability pass I did a full A-to-Z audit of the codebase and it turned up a handful of "this will bite someone eventually" issues — a lock-ordering bug in the mic mute path that could deadlock recording, downloads that ignore Cancel because they never set a timeout, an external paste script that runs on the UI thread and can freeze the app, and provider URLs that would send your transcript and API key in plaintext over the network. None are everyday crashes, but each is the kind of latent fault that turns into a bad bug report. This finishes the hardening by closing them.

Related Issues/Discussions

Bug-fix work (top priority per CONTRIBUTING). Addresses the P1 findings from an internal full-codebase assessment (the two P0s from that same assessment already shipped in #69).

Fixes #
Discussion:

Testing

TDD throughout; full Rust library suite passes 700/700. Notable coverage:

  • Deadlock (P1-02): a barrier test proves the old two-lock order (mic-open vs mic-mute) could deadlock, and that the new single-mutex lifecycle completes 8 concurrent transitions without hanging.
  • Bounded audio queue (P1-07): slow-consumer stress test confirms memory stays bounded (drop-newest, overruns counted) and end-of-stream is still delivered on a separate reliable path when the sample queue is full.
  • Downloads (P1-05): stalled-server test confirms Cancel and read-timeout actually abort.
  • Provider TLS (P1-06): non-loopback http:// is rejected unless an explicit insecure-LAN opt-in is set, and no API key is attached over insecure transport.

Screenshots/Videos (if applicable)

N/A (backend/reliability changes).

AI Assistance

  • AI was used (please describe below)

If AI was used:

  • Tools used: OpenAI Codex (implementation, test-first) and Claude (assessment meta-review, per-change code review, rebase/conflict resolution).
  • How extensively: implemented against a reviewed assessment; every change independently code-reviewed before inclusion.

What's in this PR

  • P1-02 audio deadlock: unified the microphone open/mute lifecycle under a single mutex (removes the ABBA lock-order inversion) plus a mute-API serialization lock.
  • P1-03 UI-thread freeze: external-script insertion now runs off the Tauri main thread with stdin/completion deadlines, cancellation polling, and kill-on-drop.
  • P1-04 stuck modifiers: RAII pressed-key guard releases Ctrl/Cmd/Shift on every injection error path.
  • P1-05 download cancellation: four download paths centralized behind one client with connect/read/total + cancellation deadlines.
  • P1-06 provider transport: require HTTPS for non-loopback provider URLs; explicit insecure-LAN opt-in that forbids attaching API keys.
  • P1-07 realtime audio: bounded non-blocking capture queue with a defined overrun policy and separate reliable end-of-stream signaling.

Final phase of the reliability effort (builds on #69 and #70).

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73a4781ca8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/download.rs
Comment on lines +86 to +87
if cancelled.load(Ordering::Relaxed) {
return Err(anyhow!("download cancelled while reading"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat user cancellations as successful aborts

When the user clicks Cancel during a model download, cancel_download only flips this flag; the active loops then call next_chunk(...).await? (for example in ModelManager) and this Err propagates to commands::models::download_model, which emits model-download-failed and rejects the promise. Previous code returned Ok(()) on cancellation and preserved the partial file for resume, so normal cancels now surface as failed downloads; the Android and local-LLM download paths use the same helper and hit the same behavior.

Useful? React with 👍 / 👎.

label
));
}
validate_post_process_base_url(&base_url, allow_insecure_lan)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expose the insecure-LAN opt-in before enforcing it

This validation rejects http://192.168... custom provider URLs unless allow_insecure_lan_post_process is already true, but this commit does not add the new setting/command to src/bindings.ts or any React settings UI (rg finds no frontend references). The existing base URL field calls changePostProcessBaseUrlSetting, so users of LAN LLM servers have no UI path to enable the opt-in before saving the URL and are effectively blocked unless they hand-edit persisted settings.

Useful? React with 👍 / 👎.

GalaxyRuler and others added 2 commits July 12, 2026 10:44
check:public-hygiene flags RFC 1918 private IPs (192.168.x) left in source.
The P1-06 provider-TLS tests only need a NON-LOOPBACK host; swap 192.168.1.20
for 203.0.113.20 (TEST-NET-3, reserved for documentation) to keep the test
semantics while passing the published-surface hygiene gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… setting

P1-06 added the change_post_process_insecure_lan_setting command and the
allow_insecure_lan_post_process AppSettings field; regenerate the specta
TypeScript bindings so check:bindings drift passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@GalaxyRuler
GalaxyRuler merged commit 936a8a5 into main Jul 12, 2026
15 checks passed
@GalaxyRuler
GalaxyRuler deleted the codex/reliability-hardening-phase7 branch July 12, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant