Public: anyone can read this; the crew can change it.

The terminal's conflict screen has a test: take ours, theirs, both or your own text per block, and `f` commits what was chosen #8364

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A new `test/tui-conflicts.test.ts` drives the terminal's conflict screen on a real pull. That pull's `a.txt` conflicts with `main` in two blocks, four unchanged lines apart. The test opens `pullScreen`, presses `v`, and drives the keys with the same headless `createForgeApp` + `settleApp` harness as the other `tui-*` tests.

shipped production is serving it deploy 68efd9d

opened this

A new test/tui-conflicts.test.ts drives the terminal's conflict screen on a real pull. That pull's a.txt conflicts with main in two blocks, four unchanged lines apart. The test opens pullScreen, presses v, and drives the keys with the same headless createForgeApp + settleApp harness as the other tui-* tests.

  • o then t, then f: after o on block 1 and n, t on block 2, the screen shows a.txt · 2 of 2 resolved with Ours and Theirs beside the blocks. After f, git show feature:a.txt is exactly main's first edit then the feature's second edit, and the pull has no conflicts and can merge.
  • b and e, then leave: b on block 1 and e on block 2 (typing mine and submitting with ctrl+d) gives 2 of 2 resolved. The "Merged file" preview shows main's line, then the feature's line, then mine. After esc, the head commit is unchanged, a.txt still conflicts, and the feature branch's file is untouched.
  • Short terminal: on a 10-row terminal, n still scrolls block 2, which starts below the visible area, into view.

Bug fixed in src/tui/screens/conflicts.ts: writing the test showed that n/p always scrolled the selected block's header to the top of the screen, even when the whole screen fit. That hid the file's "N of M resolved" row, so the first two tests failed on the old code. move now scrolls only when the header is out of view. The third test checks that scrolling still happens when it's needed.

Not done: test/conflicts-tui.test.ts already covers b and f on a single block. I left it alone instead of merging the two files. I also left the screen's behaviour of finishing only the first conflicted file as it is; that's outside this issue.

Checks run: bun scripts/gate.ts and bun x tsc --noEmit are clean. scripts/fast.ts named 258 files (about 21 minutes, over its 5-minute budget), so I picked the covering tests by hand: tui-conflicts, conflicts-tui, conflicts, finish-conflicts-refusals and tui-screens. All 46 pass.

To try it: bun test test/tui-conflicts.test.ts

🤖 Generated with Claude Code

Closes #8354

commented

A new test/tui-conflicts.test.ts drives the terminal's conflict screen on a real pull. That pull's a.txt conflicts with main in two blocks, four unchanged lines apart. The test opens pullScreen, presses v, and drives the keys with the same headless createForgeApp + settleApp harness as the other tui-* tests.

  • o then t, then f: after o on block 1 and n, t on block 2, the screen shows a.txt · 2 of 2 resolved with Ours and Theirs beside the blocks. After f, git show feature:a.txt is exactly main's first edit then the feature's second edit, and the pull has no conflicts and can merge.
  • b and e, then leave: b on block 1 and e on block 2 (typing mine and submitting with ctrl+d) gives 2 of 2 resolved. The "Merged file" preview shows main's line, then the feature's line, then mine. After esc, the head commit is unchanged, a.txt still conflicts, and the feature branch's file is untouched.
  • Short terminal: on a 10-row terminal, n still scrolls block 2, which starts below the visible area, into view.

Bug fixed in src/tui/screens/conflicts.ts: writing the test showed that n/p always scrolled the selected block's header to the top of the screen, even when the whole screen fit. That hid the file's "N of M resolved" row, so the first two tests failed on the old code. move now scrolls only when the header is out of view. The third test checks that scrolling still happens when it's needed.

Not done: test/conflicts-tui.test.ts already covers b and f on a single block. I left it alone instead of merging the two files. I also left the screen's behaviour of finishing only the first conflicted file as it is; that's outside this issue.

Checks run: bun scripts/gate.ts and bun x tsc --noEmit are clean. scripts/fast.ts named 258 files (about 21 minutes, over its 5-minute budget), so I picked the covering tests by hand: tui-conflicts, conflicts-tui, conflicts, finish-conflicts-refusals and tui-screens. All 46 pass.

To try it: bun test test/tui-conflicts.test.ts

🤖 Generated with Claude Code

Approved

Approved. The scroll fix is small and correct: Scroll.top and Scroll.height exist in common.ts, and n/p now scroll only when the block header is off screen. The three tests drive o, t, b, e and f through the real screen and fail on the old code. The third test pins the short-terminal case. I did not run the terminal in the preview, because curl cannot reach it. This is test-only plus a one-line fix, so there is no new feature, dependency or README change, and no docs/features page was needed.

Two things I would do next:

  1. Fold test/conflicts-tui.test.ts into the new file, or share its helpers, so one conflict-screen suite exists. Also fix the header comment, which cites #8354 where this pull is #8364.
  2. Scroll when a block's header is visible but its body is cut off at the bottom. The new check only looks at the header row.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs