feat: store working directory (cwd) per session#19292
Open
SHL0MS wants to merge 1 commit into
Open
Conversation
Record os.getcwd() when creating session rows so external tools (agf, sessions list, sessions browse) can identify which project directory a session was launched from. Changes: - hermes_state.py: add cwd TEXT column to sessions schema (auto-migrated via _reconcile_columns on next startup) - hermes_state.py: accept cwd param in create_session() - run_agent.py: pass cwd=os.getcwd() at session creation (both initial and compression-continuation paths) - cli.py: pass cwd=os.getcwd() for /new and /branch sessions - tui_gateway/server.py: pass cwd=os.getcwd() for TUI sessions - hermes_cli/main.py: display cwd in sessions list when present; include cwd in sessions browse search matching
Collaborator
Collaborator
|
Related: #19154 — competing approach to same feature. |
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
Record
os.getcwd()when creating session rows sohermes sessions list,hermes sessions browse, and external tools (e.g. agf) can identify which project directory a session was launched from.See also #19154 which addresses the same gap — this PR takes a simpler approach (single
cwdcolumn, no schema version bump) and adds TUI session creation,sessions listdisplay, andsessions browsesearch support.Changes
hermes_state.pycwd TEXTcolumn to sessions schema (auto-migrated via_reconcile_columns— no version bump needed)hermes_state.pycwdparam increate_session()run_agent.pycwd=os.getcwd()at session creation (initial + compression-continuation paths)cli.pycwd=os.getcwd()for/newand/branchsessionstui_gateway/server.pycwd=os.getcwd()for TUI sessions (both new and branch)hermes_cli/main.pycwdcolumn insessions listwhen any session has one; includecwdinsessions browsesearch matchingDesign decisions
cwd) rather than two (workspace_path+last_cwd). The initial working directory is the meaningful identifier for "which project was this session about." Mid-session directory changes viacdin the terminal tool don't change the project context._reconcile_columns()mechanism (lines 339-381 of hermes_state.py) automatically detects the new column inSCHEMA_SQLand runsALTER TABLE ADD COLUMNon next startup. Version-gated migrations are only needed for non-declarative changes (FTS rebuilds, data transforms).sessions listonly adds the Directory column when at least one session has acwdvalue, so the output is unchanged for existing sessions until new ones are created._match()function now includescwdin its search text, so users can type a project directory name to filter sessions.Motivation
Hermes sessions currently have no record of which directory they were launched from. This means:
hermes sessions listcan't show project contexthermes sessions browsecan't filter by project~/.hermesinstead of the actual project pathmodel_configJSON for IDE sessions — this extends the same concept to CLI/TUI with a proper column