Skip to content

Desktop sessions land in wrong project with remote gateway #57911

Description

@Tyrix59490

Describe the bug

When using Hermes Desktop Windows connected to a remote Ubuntu gateway, new sessions (Cmd+N or global "New Session" when not scoped into a project) land in the wrong project's workspace directory.

Example: A configuration discussion thread lands in the TradingView project because the session's CWD resolves to the tradingview directory instead of being detached or using the configured default.

In local mode (gateway on Windows), this does not happen — sessions are correctly detached when no explicit default is set.

Root Cause

workspaceCwdForNewSession() in apps/desktop/src/store/session.ts:341-353 special-cases remote mode:

export const workspaceCwdForNewSession = (): string => {
  if ($connection.get()?.mode === "remote") {
    return getRememberedWorkspaceCwd()  // ← stale localStorage value
  }
  return getConfiguredDefaultProjectDir()
}

In remote mode, the function completely ignores the configured default project directory and uses only the remembered workspace CWD from localStorage. This CWD can be from a completely different project (e.g., tradingview).

Flow

  1. User presses Cmd+N or clicks global "New Session" without being scoped into a project
  2. resolveNewSessionCwd()$projectScope === ALL_PROJECTS → falls through
  3. workspaceCwdForNewSession() → remote mode → returns stale getRememberedWorkspaceCwd()
  4. session.create is called with this wrong CWD
  5. Server maps the CWD to a different project via project_tree.py

Expected behavior

workspaceCwdForNewSession() should behave identically in local and remote mode — new sessions should be detached when no explicit default project directory is configured, matching the local mode behavior.

Proposed Fix

Remove the remote-mode special case. The getRememberedWorkspaceCwd() is already scoped by connection (baseUrl + profile via workspaceCwdKey), so it remains safely available for resume/restore flows (ensureDefaultWorkspaceCwd). A bare new chat should always be detached when no explicit default is set:

export const workspaceCwdForNewSession = (): string => {
  return getConfiguredDefaultProjectDir()
}

Environment

  • Hermes version: v0.18.0 (2026.7.1)
  • Desktop: Windows 11 (Tauri)
  • Gateway: Ubuntu 24.04 (remote via Tailscale)
  • Connection mode: remote

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havearea/sessionsSession lifecycle, resume, persistence, historycomp/desktopElectron desktop app (apps/desktop/*)type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions