tui: recover local state db startup failures#22734
Merged
Merged
Conversation
ddr-oai
reviewed
May 15, 2026
| let Some(retry_startup_error) = local_state_db_startup_error(&retry_err) else { | ||
| return Err(retry_err); | ||
| }; | ||
| if local_state_db_is_locked(retry_startup_error.detail()) { |
Contributor
There was a problem hiding this comment.
this is like mini version of above code -- just loop back and retry once?
Collaborator
Author
There was a problem hiding this comment.
Addressed. I collapsed this into a single bounded retry loop with an attempted_repair flag, so startup failure classification now lives in one place while still guaranteeing we only offer repair once.
ddr-oai
approved these changes
May 15, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Why
#22580 made app-server startup fail when the local SQLite state database cannot be initialized. Embedded/local TUI startup still continued on the permissive path, which left the CLI inconsistent and could hide a real startup problem behind unrelated UI. This brings local TUI startup onto the same fail-closed behavior while keeping recovery humane for the two failure modes we are seeing in practice: damaged database files and startup stalls caused by another process holding the database write lock.
What changed
state_db::try_init(...)and returns a typedLocalStateDbStartupErrorthat preserves the affected database path plus the underlying failure detail.tui/src/startup_error.rs, while CLI recovery policy and focused recovery tests live incli/src/state_db_recovery.rs.Verification
cargo test -p codex-tui embedded_state_db_failure_is_typed_for_cli_recoverycargo test -p codex-cli state_db_recoverystate_5.sqliteand confirmed the CLI shows lock-specific guidance without offering repair.sqlite_homeand confirmed it backs up the blocking path and resumes startup.