Skip to content

Desktop: profile switch ignores terminal.cwd, uses wrong profile's working directory #40334

Closed

Description

@bigleon2026

Bug Description

When switching between profiles in Hermes Desktop, the terminal.cwd configured in the target profile is ignored. Instead, the terminal session inherits the cwd from a previously-used profile.

Environment

  • Hermes version: 0.16.0
  • OS: Windows 10
  • Desktop App: Hermes Desktop (native Electron app)

Steps to Reproduce

  1. Have two profiles with different terminal.cwd:
    • Profile A (mahjong): terminal.cwd: D:\Cursor project\Mahjong
    • Profile B (ef-design): terminal.cwd: D:\P4-ProjectEF\Design\策划文档md
  2. Use Profile A in Desktop first (works correctly).
  3. Switch to Profile B in Desktop.
  4. Start a new session (/reset).
  5. Ask the agent: "What is the current working directory?"
  6. Run pwd in terminal.

Expected Behavior

Profile B's terminal session uses D:\P4-ProjectEF\Design\策划文档md as configured.

Actual Behavior

The terminal session uses Profile A's cwd (D:\Cursor project\mahjong). Earlier sessions (before persistent_shell was configured) fell back to the default profile's cwd (C:\Users\shenlihang).

Evidence from agent.log

Profile B's agent.log shows correct .env loading but wrong cwd:

13:44:03 Loaded environment variables from ...\profiles\ef-design\.env
13:47:09 Session snapshot created (session=e984f874882b, cwd=D:\Cursor project\mahjong)

The cwd D:\Cursor project\mahjong belongs to Profile A.

For comparison, Profile A's agent.log correctly uses its own cwd:

13:24:48 Session snapshot created (session=ab83d9e087ea, cwd=D:\Cursor project\mahjong)

Verified Config

Profile B's config.yaml terminal section is identical to Profile A's (except cwd), and hermes config show --profile ef-design reports the correct Working dir: D:\P4-ProjectEF\Design\策划文档md. The active_profile file also correctly points to ef-design.

Workaround

Setting terminal.shell_init_files to a script that does cd on init works as a temporary fix, but the root cause should be addressed.

Activity

  1. added
    type/bugSomething isn't working
    P2Medium — degraded but workaround exists
    comp/gatewayGateway runner, session dispatch, delivery
    tool/terminalTerminal execution and process management
    area/configConfig system, migrations, profiles
    on Jun 6, 2026
  2. added 2 commits that reference this issue on Jun 8, 2026
    9fb1e5c
    fc69e57
  3. added a commit that references this issue on Jun 10, 2026
    93340fa
  4. added a commit that references this issue on Jun 14, 2026
    14902c7
  5. added a commit that references this issue on Jun 15, 2026
    30ca9da
  6. added a commit that references this issue on Jun 17, 2026
    d547ab2
  7. added a commit that references this issue on Jun 18, 2026
    804c38d
  8. Omnichannel-nz commented on Jun 30, 2026

    @Omnichannel-nz

    We reproduced a shared-dashboard/shared-remote-backend profile-switch bug where the selected profile changes but the execution workspace does not. In our environment, the dashboard switched to marketing, but the embedded session still executed with cwd /home/oc/.hermes/profiles/infrastructure/workspace and loaded the infrastructure workspace AGENTS.md. A controlled CLI test also confirmed that Hermes correctly keeps SOUL.md profile-scoped while AGENTS.md remains cwd-scoped, so the observed failure mode is a mixed-context session: marketing identity plus infrastructure workspace.

    Further source inspection shows that the upstream tui_gateway fix for honoring the target profile's terminal.cwd on desktop profile switch is already present in the installed build. That suggests the remaining issue is likely in Desktop-side profile-switch cwd reseeding or stale client state rather than the old backend fallback alone. The client appears able to create a new session with a stale explicit cwd from the previously active profile, which then overrides the backend's corrected fallback logic. This appears consistent with issue #40334, with related UI/workspace-pane symptoms matching #49291 / #49293.

    Reproduce steps: Hermes Desktop with Remote Gateway, or Hermes Dashboard, using a shared backend with multiple profiles. After switching profiles, a new session can retain a stale workspace/cwd from the previously active profile. In the reproduced case, the selected profile was marketing, but the reported working directory remained /home/oc/.hermes/profiles/infrastructure/workspace.

    This demonstrates a mixed-context session where the active profile changes but the workspace/cwd remains from the previous profile.

    P.S. Apologies if this is not the place for it. Noob git-user, not familiar with protocol/workflow.

  9. added a commit that references this issue on Jul 2, 2026
    f98681d
  10. added a commit that references this issue on Jul 13, 2026
    f9d6699
  11. added a commit that references this issue on Jul 13, 2026
    b1fede0
  12. added a commit that references this issue on Jul 21, 2026
    2e64bfc
  13. added a commit that references this issue on Aug 7, 2026
    98b74d9
  14. added a commit that references this issue on Sep 3, 2026
    deb2973
  15. added a commit that references this issue on Oct 6, 2026
    19ad0ba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/gatewayGateway runner, session dispatch, deliverytool/terminalTerminal execution and process managementtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions