Skip to content

fix(git-log): default commits to current worktree branch - #838

Merged
xintaofei merged 5 commits into
xintaofei:mainfrom
dawNotPoi:fix/commits-default-current-620
Sep 28, 2026
Merged

xintaofei merged 5 commits into
xintaofei:mainfrom
dawNotPoi:fix/commits-default-current-620

Conversation

@dawNotPoi

Copy link
Copy Markdown
Contributor

Summary

  • Default the Commits tab to the current worktree's dynamic HEAD filter, so the first log query follows the active checkout instead of running git log --all.
  • Preserve a deliberate All Branches choice across reopen, while treating missing or malformed saved selections as the new HEAD default.
  • Fall back to HEAD when a saved named branch is deleted. Ignore stale branch refresh responses and hide old branch metadata while switching worktrees.

Result

On a fresh Commits tab, the first gitLog request uses branch=HEAD and allBranches=false. Selecting All Branches uses allBranches=true and remains selected after remount. Delayed branch responses cannot replace a newer selection or show the previous worktree's branch.

Verification

  • Relevant Vitest suites: 23 passed (including mounted-component query, persistence, out-of-order refresh, and worktree-switch cases)
  • pnpm exec tsc --noEmit
  • pnpm lint .
  • Prettier check on changed files
  • git diff 2774a7e..HEAD --check
  • Independent read-only review completed; its two findings were fixed and reviewed again.

This addresses the Commits filtering described in #620. Detecting worktrees modified by an agent and merging the Git tabs remain separate concerns, as discussed in the issue.

Closes #620

@dawNotPoi
dawNotPoi marked this pull request as ready for review September 25, 2026 05:39
@dawNotPoi

Copy link
Copy Markdown
Contributor Author

@xintaofei PR #838 is ready for review. For #620, a fresh Commits tab now queries this worktree’s HEAD instead of all branches; an explicit All Branches choice still persists across reopen. I also fixed a branch-refresh race found during independent review, so stale responses cannot replace a newer selection or show the previous worktree’s branch. The mounted-component regression and related tests pass (23/23), along with TypeScript, lint, and formatting checks. GitHub CI is still running.

@dawNotPoi
dawNotPoi force-pushed the fix/commits-default-current-620 branch from 67f77b3 to df93789 Compare September 28, 2026 07:02
The old writer stored an author picked on the then-default all-branches
view as {"branch":null,"author":…} and deleted a null/null entry, so an
unversioned null branch was never a choice. Reading it as an explicit
All branches kept exactly the users with an author filter on git log
--all while everyone else got the HEAD default.

Saved selections now carry a version; only a versioned null means an
explicit All branches choice, and an unversioned one opens on HEAD like
a folder with no entry.
A branch refresh answered while the live active folder differed from
the deferred one was dropped. When the active folder goes A→B→A before
the deferred render ever commits B, the deferred folder never leaves A,
so refreshBranches keeps its identity and nothing asks for A's branches
again: the header lost its branch and author pills and reset stayed
disabled until the next git event, and a manual refresh did not help.

The metadata is tagged with its path and hidden until the view catches
up, and the sequence and deferred-path checks already drop superseded
or other-folder responses, so the refresh no longer consults the live
active folder.
"New branch..." runs `git checkout -b <name> <commit>`, which moves
HEAD. The handler only refreshed branch metadata, on the grounds that
the all-branches commit set is unchanged — true for the old default,
not for the HEAD view that is now the default: the pill named the new
branch while the list kept the previous branch's commits until the
10 s HEAD poll noticed.

The HEAD view now reloads inline. The reload is issued before the
branch refresh is awaited, while the modal dialog has kept the filter
unchanged, so a filter picked once the dialog closes is not overwritten
by a reload built from the old one.
@xintaofei

Copy link
Copy Markdown
Owner

codeg work task 245 is done — #838 (3 files, +218/-17).

@xintaofei
xintaofei merged commit a9684ca into xintaofei:main Sep 28, 2026
7 checks passed
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.

feat: Commits tab should default to current worktree branch instead of all branches

2 participants