Skip to content

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

@bigleon2026

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.

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions