Skip to content

File- and hunk-level staging before commit/PR #191

Closed

Description

@currentbits

What Emdash does

File- and hunk-level staging in diff review: stage individual files or hunks and commit only what is approved (docs).

Solenta today

Commit is all-or-nothing: the merge path "stages with add -A anyway" (electron/worktrees.js:193-194), and the behavior is literally tested as "commit stages everything" (electron/test/worktrees-commit.test.js:54).

Why it matters

Agents routinely mix a wanted change with drive-by edits; without selective staging the only recourse is an external git tool, breaking the "review and land without leaving Solenta" loop.

Fix direction

Checkboxes per file in the diff view (hunk-level as a second step); commit/merge stages only the selected paths.

Activity

  1. added
    enhancement
    plan:todo
    on Aug 16, 2026
  2. currentbits commented on Aug 19, 2026

    @currentbits
    OwnerAuthor

    Codex's diff pane ships this as chunk-level staging and revert, sitting next to native commit/push/PR (26.415 writeup): "diff display with inline commenting, chunk-level staging/reverting, and native commit/push/PR creation."

    The revert half is the piece missing from this issue and it is the more valuable one for agent work: the common case is not "commit half of this", it is "keep the fix, throw away the four files it touched on the way there." Per-hunk revert is also a much smaller blast radius than #149's checkpoint restore and needs no checkpoint at all.

    Pairs with #363 (commit-push-PR chain) — staging selection is the input to that chain.

  3. added
    plan:doing
    and removed
    plan:todo
    on Aug 22, 2026
  4. currentbits commented on Aug 23, 2026

    @currentbits
    OwnerAuthor

    File-level staging is in this worktree (hunk-level left as the follow-up the issue already named).

    Git pane: a checkbox per file, default all staged, plus a stage-all control. Commit sends only the checked paths. Unchecking everything disables Commit. The label becomes "Commit N files" when it is a subset.

    git.commit / git.mergeWorktree: optional paths. Omitted still add -A (orchestration and a Git-tab Merge that never opened the pane). A path list stages those files only. Merge then refuses if the worktree is still dirty, so squash-and-delete cannot eat unselected files.

    Hunk-level git add -p is not in this change. "Mark reviewed" on a hunk remains the review-itinerary flag, not a stage.

  5. added
    plan:done
    and removed
    plan:doing
    on Aug 23, 2026
  6. added
    plan:todo
    and removed
    plan:done
    on Oct 3, 2026
  7. currentbits commented on Oct 3, 2026

    @currentbits
    OwnerAuthor

    Moved back to plan:todo (2026-10-03 board cleanup).

    File-level staging is on main:

    • A per-file checkbox, stage-all, and an "N/M staged" count (src/components/ThreadView.tsx:3877, 4188-4209).
    • Commit sends only the selected paths through git commit -- paths (electron/worktrees.js:1305-1313).
    • Per-file revert via git.revertFile (src/useCoder.ts:3138-3144).

    Still missing: hunk-level staging (git add -p / apply --cached) and per-hunk revert, which the comments above call the more valuable part. Nothing hunk-related exists yet in worktrees.js, preload or the IPC channels.

  8. added
    plan:doing
    and removed
    plan:todo
    on Oct 10, 2026
  9. currentbits commented on Oct 10, 2026

    @currentbits
    OwnerAuthor

    Hunk-level staging and per-hunk discard are in commit ee428d4 on branch coder/file-and-hunk-level-staging-before-commi-8bf7ba. Not merged yet.

    Git pane: each hunk has a stage checkbox and a ↩ discard button. Unticking some hunks shows the file checkbox as mixed (–). Unticking every hunk unstages the file. The file checkbox and stage-all stay all-or-nothing. Hunk controls are hidden when the diff is truncated.

    Backend:

    • git.commit accepts patches: [{path, patch}] for partially staged files. The commit is built in a throwaway GIT_INDEX_FILE seeded from HEAD, so the user's real index and anything already staged elsewhere are untouched. Afterwards the committed paths are reset to the new HEAD, the same as commit --only.
    • New git.revertHunk runs git apply -R on one hunk against the worktree. Both apply paths use --include=<path> and --recount.

    Merge stays file-level. A partially staged file is left out of the merge path list, so merge refuses on the leftover instead of squashing hunks the user unticked.

    Known gaps:

    • Hunk staging and discard don't work on WSL repos: the temp files go in os.tmpdir(), which git inside WSL can't see.
    • Untracked files have no hunks in git diff HEAD, so they stay file-level only.

    Tests: electron worktrees and IPC tests 108/108; renderer 2695/2695 (run at concurrency 4, because the machine's load average was about 229 and files hit the default 20s timeout); typecheck, IPC sync check and vite build pass. The renderer patch was also checked end to end against real git: discard the middle hunk, commit the last one, and the first stays in the worktree.

  10. added
    plan:done
    and removed
    plan:doing
    on Oct 10, 2026
  11. currentbits commented on Oct 10, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "File- and hunk-level staging before commit/PR" (PR #1576). Closed on merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions