Skip to content

fix(app): show the canonical branch for Local sessions - #55787

Closed
udayasree25 wants to merge 1 commit into
anomalyco:devfrom
udayasree25:local-branch-label
Closed

udayasree25 wants to merge 1 commit into
anomalyco:devfrom
udayasree25:local-branch-label

Conversation

@udayasree25

@udayasree25 udayasree25 commented Oct 15, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #55327

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Local now reads and refreshes VCS data for the per-location canonical checkout, matching the current composer destination. A shared project's root can belong to another clone, so using that root alone is not sufficient. Existing-worktree and new-worktree branch behavior is unchanged; unrelated worktrees are not warmed.

I'm leaning toward matching the existing destination contract here; happy to adjust if Local's semantics change in #51805. This PR does not change session placement and is independent of #55782.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

From packages/app:

  • bun test --conditions=solid --isolate --preload ./happydom.ts ./src/new-session — passed, 20 tests, including an isolated runner for three browser-runtime cases. The wrong-branch and missing canonical-refresh regressions fail before the fix.
  • bun typecheck — passed.

From the repository root:

  • sh .husky/pre-push — passed: Bun version check, lint, and all 36 workspace typecheck tasks.
  • bun x --no-install prettier --check packages/app/src/new-session/workspace/controller.ts packages/app/src/new-session/workspace/controller.test.ts packages/app/test-browser/fixtures/new-session-workspace.ts — passed.
  • git diff --check — passed.

Browser-runtime cases cover cold canonical VCS data, avoiding duplicate/unrelated refreshes, a separate clone sharing the project ID, and switching between Local, an existing worktree, and new-worktree creation.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Real workspace selector and branch resolver with fixture checkout data. Cold-cache/controller wiring is covered by the browser-runtime tests; this is not a full Desktop end-to-end run.

Before After
Before: Local incorrectly shows the inherited feature branch After: Local correctly shows its canonical checkout's dev branch

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.


Added by the opencode bot (AI-generated).

Related: #42976

Use the per-location canonical checkout for Local branch lookup and VCS refresh, matching session creation rather than a shared project record. Preserve existing and new-worktree behavior and avoid warming unrelated worktrees.

Co-authored-by: Copilot <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot 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.

Looks good. I reproduced #55327 at the code level using a real git repo with the main checkout on dev and a worktree on feature. On the base, Local resolved to feature. With this change it resolves to dev. Your new browser-runtime test fails on the base for the session opened from the worktree and passes here. The src/new-session tests and bun typecheck in packages/app also pass. Local now uses the same project.canonical directory that composer-adapter.ts already sends Local sessions to. That keeps the label consistent with where the session starts. Skipping the extra refresh when the canonical directory is the current one is fine, because the existing effect already refreshes it.

Public API: unchanged. The new projectDirectory argument of resolveNewSessionBranch is app-internal.

One small, optional point: the existing model-selection runner lives in test-browser/, while this one is spawned from the unit test file controller.test.ts. Moving it to test-browser/ would keep the unit and browser suites separate.

I couldn't run the desktop app here. If you can, please add before/after screenshots from a real Desktop run.

Related: #42976

@usrnk1

usrnk1 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for this fix. #62061 addresses the same issue (#55327) on current dev: this branch now conflicts with dev in controller.ts, where New worktree has since moved to the main checkout's branch. #62061 also makes submitting use the same directory as the label, and adds an e2e regression in place of the mock.module fixture. It credits your earlier work.

@usrnk1 usrnk1 closed this Nov 5, 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.

desktop(v2): selecting Local in New Session shows branch from last selected worktree instead of main worktree

2 participants