Skip to content

feat: merge a pull request from the terminal - #65

Merged
kukv merged 16 commits into
mainfrom
worktree-fluttering-cuddling-papert
Sep 7, 2026
Merged

feat: merge a pull request from the terminal#65
kukv merged 16 commits into
mainfrom
worktree-fluttering-cuddling-papert

Conversation

@kukv

@kukv kukv commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Phase 3 の 2 本目。詳細ビューの m から PR をマージできるようにする。
実装計画は docs/superpowers/plans/2026-09-08-phase3-merge.md

入るもの

  • mergePullRequest / enablePullRequestAutoMerge / disablePullRequestAutoMergegh pr merge は使わない)
  • リポジトリが許した方式だけを並べるポップアップ。mergeable: UNKNOWN は「計算中」で、r で取り直せる
  • auto-merge の有効化と解除。使えないときはその理由を出す
  • マージ後は詳細ビューを閉じて Work 板を取り直す

3 本目(各スレッドの comments のページング)の計画も一緒に入っている。実装は次の PR。

spec の誤りを 2 つ直した

どちらも 2026-09-08 の introspection の実測で分かったもので、docs/superpowers/specs/2026-09-05-octoscope-standalone-design.md §4.4.4 を訂正してある。

  • MergePullRequestInput に delete-branch の入力は無い。 モックアップの [x] ブランチを削除する は実装できない。削除はリポジトリの deleteBranchOnMerge に従って GitHub 側が行うので、その値を読み取り専用の 1 行として見せる
  • MergeStateStatusDRAFT は無い。 draft は isDraft で見分け、enter を塞ぐ理由の 1 つとして扱う

enablePullRequestAutoMergemergeStateStatusCLEAN の PR を GitHub が断るので、その場合は選択肢ごと落として理由を出す。

全体レビューで見つけて直したもの

タスク別のレビューは全部通っていたが、継ぎ目を通しで見て 6 件出た。重いのは 1 件目:

  1. 選んでいない方式でマージが走る経路。 r で取り直すとカーソルが squash に戻り、答えが 2 本走ると古いほうが後から上書きしていた。取り消せない操作なので、contextMsg に世代番号を持たせて古い答えを落とし、カーソルは 0 に戻さずクランプする
  2. ErrorMsg が PR も世代も持たず、閉じたポップアップの失敗が次のポップアップに着地していた
  3. 空の MergeContext が「計算中」と区別できず、**マージ済みの PR で m を押すと永久に「計算中です」**と出ていた。open な PR でだけ m を出す
  4. ポップアップのキーバーが、そのキーの実際の動作と食い違っていた(auto-merge が有効なのに enter:マージ と出る等)。状態からヒントを組み立てる形にした
  5. autoLine() が、権限が無いときに「待つものはありません」という別の理由を出していた
  6. auto-merge を有効化・解除しただけで詳細ビューから蹴り出されていた。PR はまだ open なので、取り直して留まる

確かめていないこと

実端末で見ていない。 このブランチを書いているあいだ kukv/octoscope に open な PR が 1 つも無く、ポップアップは golden の目視でしか確認できていない。
autoMergeAllowed: false なので auto-merge の 2 経路もこのリポジトリでは動かせない。

受け渡しの手順は docs/superpowers/2026-09-08-phase3-merge-handoff.md にある。マージは戻せないので、試すなら捨ててよい PR を先に作ること。

分かっていて残したもの

  • ja 80 桁では m:マージ を入れた分だけ x:クローズr:更新 がキーバーから落ちる(キー自体は効く)
  • internal/tui/review/render.go のポップアップ幅に、merge 側で見つけたのと同じずれがあるかもしれない。範囲外として触っていない

🤖 Generated with Claude Code

kukv and others added 16 commits September 8, 2026 05:06
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds PRMergeContext, which reads what the repository allows to merge
(methods, delete-branch-on-merge, auto-merge) and what state the pull
request is in (mergeable, mergeStateStatus, reviewDecision, whether
auto-merge is already on), for the merge popup.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… box

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two fetches for the same pull request can be in flight -- r starts one
while the first is still out, and a popup that was closed and opened
again leaves another behind. Their answers were indistinguishable, so an
older one could redraw the popup and move the cursor off the method the
user had chosen, and an older failure could clear a second popup's
loading flag and put a stale message in the detail view's footer. Every
fetch now carries a number that never repeats, and what the user chose
survives a refetch instead of being reset.

The merge message now says which of the three things happened. Only the
merge itself leaves nothing to read; joining or leaving the auto-merge
queue leaves the pull request open, so the detail view stays and the
popup asks GitHub what the state is now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
An empty merge context reads as a repository with no auto-merge on a
pull request GitHub is still working the answer out for -- none of which
was measured. A failed fetch left one behind, and so did pressing m on a
merged pull request, which GitHub answers UNKNOWN for, so the popup said
"still computing" for ever and r never changed it. The key is now
offered, and the popup opened, only while the pull request is open, and
a popup with no answer draws no options at all; the holder shows the
failure under it.

The key bar named the same four keys in every state, three of which did
nothing while merging was blocked, while auto-merge was unavailable, or
while the fetch was still out. It is now built from the state.

An auto-merge the viewer may not enable said auto-merge had nothing left
to wait for, which is a different pull request's reason. It says why,
and the scene is recorded: the goldens only ever had the two flags set
together, so nothing was watching that line.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The wheel case sat above the forward that hands the merge popup every
message the detail view cannot name, so it claimed the wheel while the
popup was open. Nothing scrolled -- wheel() declines every mode but the
body's -- but the reading "everything left over while it is open is its"
was not true of the wheel.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
With the auto-merge box ticked, enter sends enablePullRequestAutoMerge,
not the merge -- the same lie the bar told on a pull request whose
auto-merge was already on. It now names the key by what it will do.

The wording is at the width limit: at 80 columns the box leaves 46, and
both catalogues' bars come to exactly that. Anything longer and
FitKeyBar drops esc off the end.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The Japanese key bar sits at exactly the width the box leaves, and
FitKeyBar drops from the tail, so the first hint to vanish on any future
wording change is esc -- the only way out of the popup. The key would go
on working with nothing on screen to say so, and nothing caught it:
TestGolden only if a human reads the diff, the golden refresh not at
all, and the width guard measures columns rather than what survives.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Code Metrics Report

Coverage Test Execution Time
87.4% 39s

Code coverage of files in pull request scope (91.2%, patch 86.5%)

Files Coverage Patch Coverage
internal/gh/cli/merge.go 93.1% 92.0%
internal/gh/merge.go 100.0% 100.0%
internal/tui/app/app.go 91.1% 100.0%
internal/tui/detail/detail.go 92.8% 87.0%
internal/tui/detail/render.go 95.9% 83.3%
internal/tui/icon/icon.go 97.5% 100.0%
internal/tui/merge/merge.go 87.0% 82.9%
internal/tui/merge/render.go 89.5% 89.4%
internal/usecase/usecase.go 63.4% 22.2%

Reported by octocov

@kukv
kukv merged commit 89242a9 into main Sep 7, 2026
3 checks passed
@kukv
kukv deleted the worktree-fluttering-cuddling-papert branch September 7, 2026 22:25
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