fix(app): keep new local sessions in the selected directory - #46713
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 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
resolveNewSessionWorktreeto stop normalizing"main"to the cachedproject.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") | ||
| }) |
This was referenced Sep 2, 2026
Closed
Closed
This was referenced Sep 2, 2026
Closed
Closed
Closed
Closed
Closed
Closed
6 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
74eda7f950)Issue references: 57 related reports, including 22 already closed
project.worktreeafter project folder is renamed on disk; remote clients keep reopening the dead path #35240opencode -cfails with "Unexpected server error" after project directory is renamed/deleted #40677worktreepath in project DB, causing persistent 500 errors on relaunch #41420worktreeinprojecttable — project shows "no git" and all prompts fail with ENOENT #46330