You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirmed that print_startup_config() already prints state dir : {STATE_DIR} at line 590 of api/config.py, so the path is visible � but there is no signal when it points to the wrong directory.
Adding a _warn_state_dir_divergence() helper that checks for empty SESSION_DIR + populated sibling gives users a clear actionable message without changing any data-access paths.
What Changed
api/config.py: added _warn_state_dir_divergence() helper that scans siblings of STATE_DIR for session data when the active session store is empty; called from print_startup_config() wrapped in try/except so filesystem errors never block startup
Why It Matters
Users who accidentally start the server with a different STATE_DIR (common when switching between bootstrap.py, ./ctl.sh, and systemd) now see an immediate, actionable startup warning that names the likely correct directory, eliminating the "projects vanished" confusion.
Adds a _warn_state_dir_divergence() helper to api/config.py that fires at startup when the active session store is empty but a sibling state directory contains session files, giving users a clear actionable message when HERMES_WEBUI_STATE_DIR diverges across launch methods.
_warn_state_dir_divergence() checks SESSION_DIR and SESSION_INDEX_FILE for emptiness, then scans STATE_DIR.parent siblings for a sessions/ subtree with non-index JSON files; prints a recovery hint naming the likely correct directory.
The helper is called from print_startup_config() inside a try/except (in addition to its own internal guard), so filesystem errors can never block startup.
A comprehensive 11-case test file covers detection, false-positive guards, and exception resilience.
Confidence Score: 5/5
Safe to merge — the change is purely additive diagnostic output with no data-access path changes, and all failure modes are silently swallowed.
The new code never mutates state, writes files, or alters any existing code path. The double try/except wrapping ensures filesystem errors cannot block startup. The only finding is the unquoted path in the suggested shell command, which is a display issue in a warning message and does not affect correctness.
No files require special attention.
Important Files Changed
Filename
Overview
api/config.py
Adds _warn_state_dir_divergence() helper that scans sibling directories for session data when the active session store is empty; called from print_startup_config() with double try/except safety. One minor issue: the suggested shell export command is unquoted.
tests/test_issue3915_state_dir_warning.py
New test suite with 11 cases covering the divergence warning: positive detection, false-positive guards (index file content, no siblings), exception handling (missing dir, PermissionError, glob errors). Coverage is thorough for the added helper.
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[print_startup_config] --> B[_warn_state_dir_divergence]
B --> C{SESSION_DIR exists?}
C -- No --> D[session_dir_empty = True]
C -- Yes --> E{Any *.json besides _index.json?}
E -- Yes --> F[session_dir_empty = False]
E -- No --> D
D --> G{SESSION_INDEX_FILE exists?}
F --> G
G -- No --> H[index_file_empty = True]
G -- Yes --> I{Content is empty or null or curly or array}
I -- Yes --> H
I -- No --> J[index_file_empty = False]
H --> K{Both empty?}
J --> L[No warning - return]
K -- No --> L
K -- Yes --> M[Iterate STATE_DIR.parent siblings]
M --> N{Sibling has sessions JSON besides _index.json?}
N -- No --> O[Next sibling]
O --> N
N -- Yes --> P[Print divergence warning with export suggestion]
P --> Q[return]
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
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.
Thinking Path
print_startup_config()already printsstate dir : {STATE_DIR}at line 590 ofapi/config.py, so the path is visible � but there is no signal when it points to the wrong directory.HERMES_WEBUI_STATE_DIRwas not preserved across restart methods._warn_state_dir_divergence()helper that checks for emptySESSION_DIR+ populated sibling gives users a clear actionable message without changing any data-access paths.What Changed
api/config.py: added_warn_state_dir_divergence()helper that scans siblings ofSTATE_DIRfor session data when the active session store is empty; called fromprint_startup_config()wrapped in try/except so filesystem errors never block startupWhy It Matters
Users who accidentally start the server with a different
STATE_DIR(common when switching betweenbootstrap.py,./ctl.sh, and systemd) now see an immediate, actionable startup warning that names the likely correct directory, eliminating the "projects vanished" confusion.Verification
Risks / Follow-ups
Model Used
Claude Opus 4.6 via Claude Code CLI