Skip to content

fix(app): keep new local sessions in the selected directory - #46713

Merged
Hona merged 1 commit into
anomalyco:v2from
Hona:new-session-path
Sep 2, 2026
Merged

fix(app): keep new local sessions in the selected directory#46713
Hona merged 1 commit into
anomalyco:v2from
Hona:new-session-path

Conversation

@Hona

@Hona Hona commented Sep 2, 2026

Copy link
Copy Markdown
Member
  • Keep new Local sessions in the folder selected for the draft, rather than substituting the project's cached canonical path.
  • Preserve explicit workspace choices and new-workspace defaults. Existing session history is unchanged.
  • Scope: new-session directory selection. The issue references include broader reports; this does not relocate existing sessions, separate clone histories, or resolve unrelated defects within multi-issue reports.
flowchart LR
  Open["Open C:/Projects/repo"] --> Local["Local session"]
  Local --> Fixed["Create session in C:/Projects/repo"]
  Local -. "previous behavior" .-> Stale["Cached canonical: D:/Projects/repo"]
Loading
Viewport Before After
Desktop
Mobile
  • Screenshots use the production UI with an isolated API fixture: the old directory fails admission; the selected directory accepts it.
Production Home -> new session, Windows Chromium Before (74eda7f950) After
Ready, median 143.10 ms 200.30 ms
Ready, p95 194.30 ms 225.60 ms
Stable, median 174.20 ms 225.90 ms
Stable, p95 224.40 ms 255.90 ms
  • Three serial samples per build; diagnostic measurements, not a performance claim.
Issue references: 57 related reports, including 22 already closed

@Hona
Hona requested a review from Brendonovich as a code owner September 2, 2026 02:00
Copilot AI lite review requested due to automatic review settings September 2, 2026 02:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The controller still uses the cached project.worktree for branch listing and VCS sync after removing normalization, which can keep hitting the stale path and fail to sync the selected directory’s VCS state.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes new-session workspace selection so that new Local sessions are created in the directory selected for the draft, instead of being redirected to a stale cached project worktree path; this aligns the desktop app behavior with user intent when projects are moved/re-added.

Changes:

  • Simplifies resolveNewSessionWorktree to stop normalizing "main" to the cached project.worktree.
  • Updates the workspace controller to persist the selected worktree value directly.
  • Adjusts and adds tests to reflect the new worktree resolution behavior.
File summaries
File Description
packages/app/src/new-session/workspace/controller.ts Removes cached-worktree normalization from new-session worktree selection and updates worktree persistence logic.
packages/app/src/new-session/workspace/controller.test.ts Updates unit tests to validate the new worktree resolution behavior under stale cached-path conditions.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 11 to 15
import {
isWorkspaceDirectory,
isWorkspaceSelection,
sameDirectory,
workspaceDefaultSelection,
workspaceDirectories,
Comment on lines 79 to 83
const value = createMemo(() =>
resolveNewSessionWorktree({
enabled: visible(),
selected: selected(),
directory: sdk().directory,
projectWorktree: currentProject()?.worktree,
fallback: fallback(),
Comment on lines +29 to 33
test("keeps local selection when the cached project path is stale", () => {
const input = { enabled: true, directory: "C:/Projects/repo", projectWorktree: "D:/Projects/repo" }
expect(resolveNewSessionWorktree(input)).toBe("main")
expect(resolveNewSessionWorktree({ ...input, selected: "/worktree" })).toBe("/worktree")
})
@Hona
Hona merged commit 34e40cc into anomalyco:v2 Sep 2, 2026
12 checks passed
This was referenced Sep 2, 2026
This was referenced Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants