fix(desktop): configured working directory overrides stale remembered workspace cwd - #56928
Merged
Conversation
Follow-up to the #39227 salvage: config refreshes fire mid-session too (gateway events, settings saves), so applying terminal.cwd unconditionally would yank the workspace out from under an attached session. Gate the override on activeSessionIdRef like the sibling reasoning/tier settings, keep branch refresh on the live cwd, and add coverage for the active-session path. Also lint-polish the new test file (typed config mock, prettier formatting).
This was referenced Jul 2, 2026
19 tasks
13 tasks
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
Desktop
Settings → Workspace → Working Directory(terminal.cwd) now overrides a stale remembered workspace cwd in renderer localStorage, so new sessions start in the configured folder instead of whereverhermes.desktop.workspace-cwdwas last pointed.Fixes #38855. Salvages #39227 by @sahibzada-allahyar (cherry-picked, authorship preserved) with a follow-up guard.
Root cause:
$currentCwdseeds from localStorage at module load, andrefreshHermesConfig()only appliedterminal.cwdwhen the current value was empty (prev || cwd) — the stale remembered value always won, and new-session creation prefers$currentCwd.Changes
apps/desktop/src/app/session/hooks/use-hermes-config.ts: apply configuredterminal.cwdover a stale remembered cwd — but only when no session is active (activeSessionIdRefgate, same pattern as the sibling reasoning/tier settings), so mid-session config refreshes can't yank the workspace out from under an attached session. SincesetCurrentCwdpersists back to localStorage, the stale key self-heals.apps/desktop/src/app/session/hooks/use-hermes-config.test.ts(new, from fix(desktop): prefer configured workspace cwd #39227 + extended): 6 tests — stale-localStorage override, active-session guard, empty config,"."handling, branch refresh for both idle and active-session paths.scripts/release.py: AUTHOR_MAP entry for the contributor.Validation
vitest run --environment jsdom use-hermes-config.test.ts src/store/session.test.tsnpm run typecheck(apps/desktop)eslint+prettier --checkon touched filesInfographic