Skip to content

fix(app): improve workspace display for JJ colocated repos and git worktrees#17105

Closed
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:feat/workspace-jj
Closed

fix(app): improve workspace display for JJ colocated repos and git worktrees#17105
sjawhar wants to merge 1 commit intoanomalyco:devfrom
sjawhar:feat/workspace-jj

Conversation

@sjawhar
Copy link
Copy Markdown

@sjawhar sjawhar commented Mar 11, 2026

Issue for this PR

Closes #16474
Related: #5008

Type of change

  • Bug fix

What does this PR do?

Fixes workspace/worktree display in the sidebar for JJ colocated repos and git worktrees that report detached HEAD.

Problem: In JJ colocated repos, git rev-parse --abbrev-ref HEAD returns HEAD (detached). The sidebar displayed this literal string instead of a useful name. Additionally, navigating to a sandbox directory didn't auto-expand the workspace view.

Changes:

  • Filter HEAD branch names in sidebar labels — fall through to the directory name instead of displaying "HEAD".
  • Auto-enable workspace sidebar expansion when navigating to a sandbox directory (not the project root).
  • Navigate directly to a workspace's latest session when opening a specific workspace, instead of searching across all workspaces.
  • Show workspace directory name in the session header when in a sandbox.
  • Show actual working directory (not project root) in the new session view.

Why this works: JJ colocated repos use git's worktree mechanism internally — each workspace has a .git file pointing to the main repo's .git/worktrees/<name>. Git commands in these directories report HEAD as the branch. The fix treats HEAD as equivalent to "no branch" and falls through to directory-based naming, which is the correct behavior for JJ workspaces.

How did you verify your code works?

  • Tested with a JJ colocated repo with multiple workspaces (jj workspace list shows default, voice, etc.).
  • Verified sidebar shows workspace directory names instead of "HEAD".
  • Verified auto-expansion when navigating to a sandbox workspace.
  • Verified session header shows correct workspace name.
  • bun typecheck passes.

Screenshots / recordings

N/A — changes are to sidebar label logic and navigation, no visual design changes.

Checklist

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

@sjawhar sjawhar requested a review from adamdotdevin as a code owner March 11, 2026 23:00
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@sjawhar sjawhar force-pushed the feat/workspace-jj branch from 2d790b0 to 83cdf89 Compare March 26, 2026 11:55
@TomLucidor
Copy link
Copy Markdown

Please continue with this and have a functional e2e

@sjawhar sjawhar closed this Apr 2, 2026
@sjawhar sjawhar deleted the feat/workspace-jj branch April 2, 2026 14:34
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.

Branch display shows main repo branch instead of worktree branch when opening a git worktree directory

2 participants