Skip to content

fix(app): show the main checkout's branch for Local in new sessions - #62061

Merged
usrnk1 merged 1 commit into
devfrom
local-branch-label
Nov 5, 2026
Merged

usrnk1 merged 1 commit into
devfrom
local-branch-label

Conversation

@usrnk1

@usrnk1 usrnk1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A new session opened from a worktree session keeps that worktree as its directory. With Local selected, the branch label read that worktree, while submitting started the session in the main checkout. Local now reads the main checkout's branch, and the label and submit use the same directory, so they can't disagree again.

Fixes #55327

This supersedes #55787, which fixes the same label but conflicts with dev and expects the old New worktree behavior that dev has since changed. Thanks @udayasree25 for the earlier fix.

Changes

  • new-session/workspace/controller.ts: Local and New worktree take their branch from the main checkout, and Local's branch is refreshed when it isn't the draft's own directory.
  • new-session/composer-adapter.ts: submitting uses that same directory instead of working it out separately.
  • E2E keeper case in e2e/regression/new-session.spec.ts: a draft opened in a worktree shows the main checkout's branch beside Local and submits there. It fails on dev.

Checks

  • bun typecheck (packages/app): passes
  • bun test ./src/new-session (packages/app): 75 pass
  • bun run lint:changed origin/dev: 0 problems
  • e2e/regression/new-session.spec.ts (built): 38 of 39 pass. The one failure, "the title and message stay stable through worktree creation", fails the same way on dev without this change.

Before / after

Draft opened in .worktrees/quiet-river (branch worktree-branch), main checkout on checkout-branch, Local selected.

Before:

After:

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
  <rect x="12" y="24" width="60" height="24" rx="6" stroke-opacity=".5"/>
  <text x="42" y="40" fill="currentColor" stroke="none" font-size="11" text-anchor="middle" font-family="sans-serif">Local</text>
  <path d="M96 24H228" stroke-opacity=".9"/>
  <path d="M128 24C148 24 148 52 168 52H228" stroke-opacity=".3"/>
  <circle cx="200" cy="24" r="5" fill="currentColor" stroke="none">
    <animate attributeName="cy" values="52;52;24;24" keyTimes="0;.35;.6;1" dur="3s" repeatCount="indefinite"/>
    <animate attributeName="opacity" values=".4;.4;1;1" keyTimes="0;.35;.6;1" dur="3s" repeatCount="indefinite"/>
  </circle>
  <path d="M72 36H90" stroke-opacity=".5" stroke-dasharray="3 3"/>
</svg>

Added by the opencode bot (AI-generated).

Related: #51992

@opencodejr opencodejr 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.

The fix works. In a draft opened from a worktree session with Local selected, the branch label now shows the main checkout's branch, and submitting still starts the session in the main checkout.

How I checked: I ran the new e2e case on this branch, where it passes, and on dev, where it fails because the label shows the worktree's branch. The screenshots below show the same draft on each. The new-session unit tests (75 pass) and tsc -b in packages/app also pass.

The label and submit now read the same root, so they can't drift apart again, and the added e2e case is small and on point.

Public API: unchanged (app-internal only).

No concerns.

Related: #51992

Before

After

@usrnk1
usrnk1 merged commit fa2843f into dev Nov 5, 2026
23 checks passed
@usrnk1
usrnk1 deleted the local-branch-label branch November 5, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

1 participant