Repository navigation
fix(core): clear api_error instead of latching it - #467
Merged
Merged
Conversation
`App::handle_error` was the only writer of `api_error` and no site in the repo cleared it. The TUI hid this because the user dismisses the error route; a consumer that renders the field from state instead latches the first failure for the life of the process. - `handle_error` stamps a 60s lifetime alongside the message. - `clear_api_error()` is the single dismissal primitive: it drops the message, its lifetime, and every navigation frame still showing it. Clearing the string alone would leave an error page with nothing on it. - `pop_navigation_stack` calls it when the frame it popped was `Error`, so the escape key, the configurable back key and a script's `Back` all dismiss identically, and a frontend with no back key is not the odd one out. Keyed on the popped frame, not the new top: opening the device picker from the error page and coming back still shows the message. - `update_on_tick` retires an expired error next to the existing status-message expiry, guarded on the clock alone. Guarding on the route would never fire for a consumer that never pops, which is the case this exists for. The text moves to the status bar only when the error frame is the current screen. - `drop_error_routes` matches on the id *and* the block: the search key rewrites the error frame in place to an input field, and removing that frame would drop live keystrokes into the global bindings. - `flush_state_save` reports to the status bar instead of the error page. The tick calls it every frame and a failed save re-arms its own deadline, so as a modal an unwritable state dir is an inescapable app. The report is latched to once per failure run; repeating it at the retry rate would hold `status_message_is_error` and silently drop every ordinary status message for the rest of the session. CLI behavior is unchanged: it builds no driver and pops no routes, so a non-empty `api_error` remains its failure signal.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughChangesError lifecycle
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change gives API errors explicit dismissal and expiry behavior while preserving CLI failure signaling; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant App
participant NavigationStack
participant StatusBar
App->>App: update_on_tick()
App->>App: expire_api_error()
App->>NavigationStack: drop_error_routes()
App->>StatusBar: transfer expired visible error
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
App::handle_erroris the only writer ofapi_error, and no site in the repocleared it. The TUI hides this because the user dismisses the error route, but
the field itself stays set forever — so anything that renders app state rather
than reacting to a keypress latches the first failure for the life of the
process. This gives the field a lifetime and a dismissal path, both owned by
core/appso they work without a route stack or an Esc key.handle_errorstamps a 60s lifetime alongside the message. One editcovers all ~88 call sites and changes none of them.
clear_api_error()is the single dismissal primitive: it drops themessage, its lifetime, and every navigation frame still showing it. Clearing
the string on its own would leave an error page with nothing rendered on it.
pop_navigation_stackcalls it when the frame it popped wasError, sothe escape key, the configurable back key and a script's
Backall dismissidentically with no changes under
src/tui/. Keyed on the frame that waspopped rather than the new top, so pressing
dfrom the error page (therecovery the page itself advertises) and coming back still shows the message.
update_on_tickretires an expired error next to the existingstatus-message expiry, guarded on the clock alone. Guarding on the route
would never fire for a consumer that never pops, which is exactly the case
this exists for. The text moves to the status bar only when the error frame
is the screen the user is on; one that expired buried under another screen
goes quietly.
drop_error_routesmatches on the id and the block. The search keyrewrites the error frame in place into an input field rather than pushing,
so an id-only match would delete a frame holding live text-input focus and
drop the user's next keystrokes into the global bindings.
flush_state_savereports to the status bar instead of the error page.The tick calls it every frame and a failed save re-arms its own deadline, so
as a modal an unwritable state dir is an app you cannot escape. The report is
latched to once per failure run: repeating it at the retry rate would hold
status_message_is_error, andset_status_messagerefuses to overwrite alive error, so every ordinary status message would be dropped for the rest of
the session.
CLI behavior is unchanged. It builds no driver and pops no routes, so a
non-empty
api_errorremains its failure signal.Testing
cargo fmt --all -- --checkcargo clippy --no-default-features --features telemetry,tui -- -D warnings(also default and headless): clean
cargo test --no-default-features --features telemetry,tui: 610 passedcargo test --no-default-features --features telemetry(headless): 329passed, zero warnings
cargo test(default): 908 passedcargo test --no-default-features --features telemetry,tui,mcp-server: 729passed
cargo test --no-default-features --features telemetry,tui,ai-dj: 869 passedaudio-vizswapped foraudio-viz-cpal(the legitself is Linux-only): 1344 passed, plus the known pre-existing Windows-only
infra::local::tests::uri_round_tripfailuretools/check_gates_ratchet.shvs main ok;Cargo.lockuntouchedfails, as it should
the device picker from it and coming back preserves the message; the 60s
backstop retires the page and hands the text to the status bar; a buried
error frame is cleaned up rather than resurfacing; CLI exit codes unchanged
Additional notes
edit lands in
src/core/app/**, outside all of their measurement scopes.### Errorssection in the three docs writes down the rule formoving a call site off
handle_error, since a non-emptyapi_erroris theCLI's only failure signal and demoting a CLI-reachable site silently turns a
failing command into exit 0.
api_errorbetween the shared CLIpreamble and the subcommand. It looks like a free fix for a preamble failure
discarding a subcommand that succeeded, but
list --devicesperforms nofetch of its own and reads only the preamble's
GetDevices, so clearingturns a failed device fetch into "No devices available" and exit 0;
playback --togglelikewise consumes preamble state and returns(). Thatneeds its own change and its own verification.
handle_errorcall sites are unconverted on purpose. Thelatched-error defect is closed by the lifetime on the single writer, and a
broad conversion is a behavioral change per site with a real exit-code trap.
💬 Questions or want to chat with other contributors? Join the spotatui Discord.
Summary by CodeRabbit