Skip to content

Git pane: file-level staging before commit and merge - #676

Merged
currentbits merged 1 commit into
mainfrom
coder/fork-file-and-hunk-level-staging-before--5b3173
Aug 23, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/fork-file-and-hunk-level-staging-before--5b3173

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Commit and merge now land only the files you check in the Changes panel. Hunk-level staging is still the follow-up the issue named.

What changed

UI (src/components/ThreadView.tsx, ThreadView.module.css)

  • Checkbox per file row plus a tri-state "N/M staged" header checkbox.
  • Everything defaults to staged; files that appear in a later diff auto-stage.
  • Commit button reads "Commit 3 files" when a subset is selected, and is disabled at zero staged.

Backend (electron/worktrees.js, electron/ipc.js, src/shared/ipc.ts, src/useCoder.ts)

  • git.commit and git.mergeWorktree take an optional paths[]. Omitted = the old git add -A behaviour, so every existing caller is unchanged.
  • Selected paths are staged and committed with git add -A -- <paths> / git commit -- <paths>.
  • useCoder remembers the pane's staged list per thread so a Git-tab merge stages the same subset.

Path validation

  • New shared assertRelPathInCwd rejects empty, absolute, ..-escaping and leading-dash pathspecs (git reads those as flags even after --). revertFile now routes through it too, replacing its own inline copy.

Merge safety

  • With paths, mergeWorktree re-checks git status --porcelain -uall after the session commit and refuses the merge if anything dirty remains, listing the files. The worktree is never deleted with uncommitted work.

Known gaps

  • Hunk-level staging is not implemented.
  • The staged list is captured when the Changes panel last loaded a diff. If the agent writes new files afterwards, a Git-tab merge can refuse with "Uncommitted files remain" until the panel is reopened. Fails safe, and the message names the files.

Size

623 lines across 10 files, over the 400 cap; opened with allowOversize by explicit user decision. ~270 of those lines are the new tests, and the backend and UI halves only make sense reviewed together.

Verification

Run in the worker's worktree:

  • npx tsc --noEmit — clean
  • test/changesPanel.test.tsx — 8/8 pass
  • electron/test/worktrees-commit.test.js + electron/test/worktrees.test.js — 62/62 pass

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 8d4fdea into main Aug 23, 2026
5 of 6 checks passed
currentbits pushed a commit that referenced this pull request Aug 23, 2026
…-0a26ff

Keep both Git-pane behaviors in ThreadView: inline diff comments (#162)
and staged-path checkboxes from #676.
@currentbits
currentbits deleted the coder/fork-file-and-hunk-level-staging-before--5b3173 branch October 3, 2026 16:07
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.

1 participant