fix(tui): degrade gracefully when state.db init fails#14135
Merged
Conversation
Collaborator
Collaborator
OutThisLife
approved these changes
Apr 23, 2026
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
…ptional fix(tui): degrade gracefully when state.db init fails
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…ptional fix(tui): degrade gracefully when state.db init fails
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…ptional fix(tui): degrade gracefully when state.db init fails
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…ptional fix(tui): degrade gracefully when state.db init fails
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…ptional fix(tui): degrade gracefully when state.db init fails
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.
What does this PR do?
Prevents
hermes --tuifrom hard-failing whenstate.dbcannot be opened during TUI startup. The TUI gateway was the odd path out: classic CLI and gateway already treatSessionDB()init failure as non-fatal, but TUI let the exception bubble out of_get_db()and surface asagent init failed: locking protocol.This change makes the TUI gateway degrade gracefully when
SessionDB()init fails, lets chat continue without state-backed session indexing, and returns explicitstate.db unavailableRPC errors only for TUI features that actually require the database.Related Issue
Fixes #
Type of Change
Changes Made
tui_gateway.server._get_db()catchSessionDB()init failures and returnNoneinstead of aborting TUI startupcreate_session(...)during TUI session bootstrap whenstate.dbis unavailablestate.db unavailable: ...RPC errors for DB-backed TUI methods like session list, resume, title, branch, and insightsSessionDB()init, successfulsession.createwithoutstate.db, and clean TUI errors for DB-backed commandsHow to Test
SessionDB()init in the TUI path so_get_db()cannot openstate.db.hermes --tuiand confirm the session still comes up instead of showingagent init failed: locking protocol./resumeor session listing now fail with a clearstate.db unavailable: ...message instead of killing the TUI session.scripts/run_tests.sh tests/test_tui_gateway_server.py tests/tui_gateway/test_protocol.py -n 4.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
TUI currently surfaced raw startup failures like:
agent init failed: locking protocolafter
SessionDB()initialization failed intui_gateway/server.py.Targeted coverage for this change passed:
source venv/bin/activate && scripts/run_tests.sh tests/test_tui_gateway_server.py tests/tui_gateway/test_protocol.py -n 4Repo-wide hermetic coverage was also run:
source venv/bin/activate && scripts/run_tests.sh -n 4That full run is currently red on this checkout with 55 failing tests and 14443 passing tests. The failures observed in that run were spread across unrelated areas including gateway approval flows, DingTalk, Discord bot filtering, MiniMax, Anthropic/Codex response paths, backup, browser/camofox, Tirith, write-deny, and zombie cleanup.