Skip to content

feat(git-graph): commit 行の右クリックメニューに reset --mixed を追加#658

Merged
miyaoka merged 3 commits into
mainfrom
feat/git-graph-reset-mixed-menu
May 31, 2026
Merged

feat(git-graph): commit 行の右クリックメニューに reset --mixed を追加#658
miyaoka merged 3 commits into
mainfrom
feat/git-graph-reset-mixed-menu

Conversation

@miyaoka

@miyaoka miyaoka commented May 31, 2026

Copy link
Copy Markdown
Owner

概要

Git Graph の commit 行に右クリック ( control+click ) メニューを追加し、「Reset (mixed) to <hash>」でその commit へ git reset --mixed を実行できるようにする。

背景

これまで Git Graph は commit の閲覧・選択・diff 表示のみで、HEAD を任意の commit に巻き戻す操作は端末で git reset を打つしかなかった。Files / Changes 行には ( #640 ) で右クリックメニューを導入済みで、同じ popover + light-dismiss 回避パターンが確立している。commit 行にも同じ経路でよく使う git 操作を載せるのが自然な拡張になる。

最初の操作として、working tree のファイルを壊さず ( reflog で復元可能 ) branch ref と index だけを動かす --mixed を選んだ。

変更内容

proto ( SSOT )

  • git_ops.protoGitResetMixedRequest { dir, hash } / GitResetMixedResponse {} を追加し、buf generate で TS / Swift 生成物を更新
  • proto-ts/src/index.ts のバレル ( 手動 re-export ) に新型を追加

native ( Swift )

  • GitOps.resetMixed(dir:hash:) を追加。lsTree と同じ規律で hash を検証する ( 空文字 / all-zero hex を reject、validateRev- 始まりの option 注入・非 hex を弾く )。git reset --mixed <hash> -- を実行し、-- で pathspec 誤解釈を排除
  • RpcDispatcher/git/resetMixed ルートと handleGitResetMixed を追加

renderer ( Vue )

  • useCommitContextMenu.ts — commit 行専用の popover singleton。menu kind ごとに独立した singleton を持つ popover 設計指針に従う
  • CommitContextMenu.vue — 「Reset (mixed) to here」アクション。snapshot した dir / hash に rpcGitResetMixed を発行し、失敗時は notify.error
  • GitGraphPane.vue — commit 行に @contextmenu を追加、pointerup once-capture リスナーで WebKit の light-dismiss を回避、右クリック時点で dir / hash を snapshot。macOS control+click が button=0 の click として届くため ( webkit bugzilla 52174 )、onRowClickctrlKey 早期 return して選択変更を抑止
  • rpc.tsrpcGitResetMixed を追加

ドキュメント

  • docs/git.md の RPC 一覧に rpcGitResetMixed を追記
  • GitGraphPane.vue<doc> ブロックに右クリックメニューの記述を追加

今回は対応しない

reset 前の確認ダイアログ

--mixed は working tree のファイルを書き換えず reflog で復元可能なため、( #640 ) の最小メニューパターンに合わせて確認なしで即実行する。branch ref を動かす操作のため確認を挟みたい要望が出たら別途追加する。

reset --soft / --hard

今回は --mixed 1 種類のみ。--hard は working tree を破壊するため、導入するなら確認ダイアログとセットで別途検討する。

確認事項

  • commit 行を右クリック → カーソル位置にメニューが開く
  • 「Reset (mixed) to ...」実行 → branch ref がその commit に移動し、変更が unstage される ( working tree のファイルは保持 )
  • reset 後に Git Graph が自動で再描画される ( gitStatusChange / branchChange push 経由 )
  • macOS control+click でメニューが開き、かつ commit 選択が変わらない
  • 右クリック直後に worktree を切り替えても、右クリック時点の dir / hash で reset される ( snapshot が効いている )

intent(git-graph): commit 行から HEAD をその commit に戻す操作を UI で行いたい
decision(git-graph): Files/Changes (PR #640) と同じ popover singleton + pointerup once-capture で実装し、light-dismiss 回避規律を共有
decision(git-ops): hash は validateRev + isAllZeroHex で検証し、`git reset --mixed <hash> --` の `--` で pathspec 誤解釈を排除
rejected(git-graph): 確認ダイアログは挟まない。--mixed は working tree を壊さず reflog で復元可能なため最小メニューに倒す
constraint(git-graph): branch ref / index の変化は per-worktree FSWatch が gitStatusChange / branchChange で拾うため、reset 後の再描画は既存 watcher に委ね response に追加データを載せない
@miyaoka miyaoka self-assigned this May 31, 2026
@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@miyaoka, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 580c8f87-b494-4147-826e-068ecc992b17

📥 Commits

Reviewing files that changed from the base of the PR and between 9e130a6 and f74ac38.

📒 Files selected for processing (3)
  • apps/native/Tests/GozdCoreTests/GitOpsTests.swift
  • apps/renderer/src/features/git-graph/GitGraphPane.vue
  • apps/renderer/src/features/git-graph/useCommitContextMenu.ts
📝 Walkthrough

Walkthrough

このPRは git reset --mixed コマンド実行機能を追加します。プロトコルメッセージスキーマとして GitResetMixedRequest・Response を定義し、ネイティブ側で GitOps.resetMixed() メソッドと RpcDispatcher ハンドラーを実装。フロントエンドでは rpcGitResetMixed RPC ラッパーを追加し、useCommitContextMenu コンポーザブルと CommitContextMenu.vue コンポーネントでコンテキストメニュー UI を構築。GitGraphPane でコンテキストメニューイベント処理と pending 管理を統合し、各コミット行の右クリックから reset を実行できるようにしました。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PRのタイトルは「commit 行の右クリックメニューに reset --mixed を追加」と、変更セットの主要な変更内容を明確に要約しており、簡潔で具体的です。
Description check ✅ Passed PR説明は背景、変更内容、対応しない項目、確認事項を含み、変更セットと完全に関連しており、十分な情報が提供されています。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/git-graph-reset-mixed-menu

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

miyaoka added 2 commits May 31, 2026 18:24
…cstrings

decision(git-graph): useCommitContextMenu.ts と GitGraphPane.vue の light-dismiss 不変条件リストに「pointerdown で pending を reset する経路を追加しない」条項を転記し、移植元 NavigatorPane の 4 条項と揃える
constraint(git-graph): pending が積まれた状態で別経路の pointerdown (左 click 等) が来ると pending を即消去し、次の pointerup での消化が起きなくなるため、状態遷移は pointerup のみで完結させる
intent(git-graph): reset --mixed の入口検証と核心の副作用がテストで一度も踏まれていなかった
decision(reset-mixed): lsTree integration suite と対称に、入口 reject 4 ケース + 正常系 1 ケースで構成する
decision(reset-mixed): 正常系は c1/c2 二段 commit を作り c1 へ reset し、HEAD 移動 / working tree 保持 / index reset の 3 副作用を独立に assert
learned(reset-mixed): mixed reset 後の index reset は porcelain の ` M`(working 変更) と `??`(c1 不在ファイルの untracked 化) で観測できる
constraint(reset-mixed): nonExistentHash は空 repo だと別経路の fatal になり得るため seed commit を 1 個置いてから reset を呼ぶ
@miyaoka miyaoka merged commit d17588b into main May 31, 2026
7 checks passed
@miyaoka miyaoka deleted the feat/git-graph-reset-mixed-menu branch May 31, 2026 10:20
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