Skip to content

fix(desktop): configured working directory overrides stale remembered workspace cwd - #56928

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-0c883b91
Jul 2, 2026
Merged

fix(desktop): configured working directory overrides stale remembered workspace cwd#56928
teknium1 merged 3 commits into
mainfrom
hermes/hermes-0c883b91

Conversation

@teknium1

@teknium1 teknium1 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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 wherever hermes.desktop.workspace-cwd was last pointed.

Fixes #38855. Salvages #39227 by @sahibzada-allahyar (cherry-picked, authorship preserved) with a follow-up guard.

Root cause: $currentCwd seeds from localStorage at module load, and refreshHermesConfig() only applied terminal.cwd when 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 configured terminal.cwd over a stale remembered cwd — but only when no session is active (activeSessionIdRef gate, same pattern as the sibling reasoning/tier settings), so mid-session config refreshes can't yank the workspace out from under an attached session. Since setCurrentCwd persists 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

Check Result
vitest run --environment jsdom use-hermes-config.test.ts src/store/session.test.ts 25/25 passed
npm run typecheck (apps/desktop) clean
eslint + prettier --check on touched files clean

Infographic

infographic

sahibzada-allahyar and others added 3 commits July 2, 2026 01:37
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).
@alt-glitch alt-glitch added type/bug Something isn't working comp/desktop Electron desktop app (apps/desktop/*) area/config Config system, migrations, profiles sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state P3 Low — cosmetic, nice to have labels Jul 2, 2026
@teknium1
teknium1 merged commit 8b1ad38 into main Jul 2, 2026
36 checks passed
@teknium1
teknium1 deleted the hermes/hermes-0c883b91 branch July 2, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop Working Directory setting does not override stale remembered workspace cwd

3 participants