Skip to content

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

TypeScript

diff tests and README: the wheel over the list, the dialog's rows

poteat65bf3fe99084
diff --git a/mods/diff/README.md b/mods/diff/README.md
index 6696b457..6afab1db 100644
--- a/mods/diff/README.md
+++ b/mods/diff/README.md
@@ -5,8 +5,9 @@ beside the transcript, one row per changed file and every file's hunks
beneath, and closes it again; each toggle leaves `Diff panel shown` or
`Diff panel hidden` in the transcript. The header, the file list and its
toggles stay put while the wheel moves the hunks under them three rows a
-tick (the plugin answers the pane's `ui.scroll` itself); a row's click puts
-that file's hunks at the top; past eight rows the list scrolls under the
+tick, or the list a file a tick while the wheel is over a list longer than
+its eight rows (the plugin answers the pane's `ui.scroll` itself); a row's
+click puts that file's hunks at the top; the list also scrolls under the
built-in's list keys (`ctrl+up`/`ctrl+down`, `opt+up`/`opt+down`), and
`ctrl+x b` moves the comparison base on, as the built-in's chord does: both
through Buttons that declare the engine's own actions. The pane refreshes
@@ -19,9 +20,11 @@ where the terminal is wide enough (144 columns when the person never chose,
Under the fullscreen layout a terminal under 110 columns gets the
built-in's line asking for a wider one and nothing opens. Without that
layout (`CLAUDE_CODE_NO_FLICKER=0`, which `/diff` learns from the command's
-`presentation`) the pane opens inline at any width, focused, in the
-built-in dialog's shape: the title, the count, the file rows, the key
-hints; the arrows walk the rows, Enter shows that file's hunks alone,
+`presentation`) the pane opens inline at any width, focused and as tall
+as its content (the open's `rows`), in the built-in dialog's shape: the
+title, the count, five file rows at a time between `more files` rows that
+page them, the key hints; the arrows walk the rows, Enter shows that
+file's hunks alone,
Escape backs out to the list and then closes, leaving `Diff dialog
dismissed`; toasts are held while it is up. A file's ask button arms that
file: its hunks ride the next prompt as context, once.
@@ -48,7 +51,7 @@ asked for; a rename lists as git prints it. Outside a git repository
| `ui.render` of `Pane` | Draws the pane: docked, the header, base line, source picker, file list and toggles over the window of hunks; inline, the dialog. |
| `command.run` of `diff` | Opens or closes the pane (focused and closing on Escape without the fullscreen layout), says which, and remembers the choice. |
| `ui.close` of the pane | Backs out of the dialog's detail view instead of closing; else remembers the person's close as `/diff`'s. |
-| `ui.scroll` of the pane | Docked, moves the hunks under the pinned header and list (three rows a wheel tick, a page a page key) and keeps the engine's window still. |
+| `ui.scroll` of the pane | Docked, moves the hunks under the pinned header and list (three rows a wheel tick, a page a page key), or the list when the wheel is over it, and keeps the engine's window still. |
| `command.run` of `clear`, `resume` | Closes the pane and forgets the session's state. |
| `tool.call` of `Edit`, `Write`, `NotebookEdit` | After the edit, refreshes an open pane; the session's first successful edit opens it. |
| `tool.call` of `Bash`, `PowerShell` | After the command, refreshes an open pane. |
diff --git a/mods/diff/tests/fixtures/index.ts b/mods/diff/tests/fixtures/index.ts
index 2cac3e94..45b4f52d 100644
--- a/mods/diff/tests/fixtures/index.ts
+++ b/mods/diff/tests/fixtures/index.ts
@@ -24,6 +24,7 @@ export * from './settle-ms.js'
export * from './starts-session.js'
export * from './text-of.js'
export * from './two-files.js'
+export * from './wheel-over-list.js'
export * from './wheel-tick.js'
export * as default from '.'
diff --git a/mods/diff/tests/fixtures/wheel-over-list.ts b/mods/diff/tests/fixtures/wheel-over-list.ts
new file mode 100644
index 00000000..80ab7b58
--- /dev/null
+++ b/mods/diff/tests/fixtures/wheel-over-list.ts
@@ -0,0 +1,12 @@
+import type { UiScrollInput } from 'claude-code'
+
+import { WHEEL_TICK } from './wheel-tick.js'
+
+/**
+ * The same wheel tick with the pointer over the docked list's third row
+ * (top pad, header, the list's margin, then the rows).
+ */
+export const WHEEL_OVER_LIST: UiScrollInput = {
+ ...WHEEL_TICK,
+ pointer: { column: 10, row: 5 },
+}
diff --git a/mods/diff/tests/register.test.ts b/mods/diff/tests/register.test.ts
index ef0fdc06..9df630b5 100644
--- a/mods/diff/tests/register.test.ts
+++ b/mods/diff/tests/register.test.ts
@@ -148,15 +148,14 @@ describe('register', () => {
expect(await $.command.run(Fixtures.DIALOG_DIFF)).toEqual({})
- expect(world.opened).toEqual([
- {
- id: 'diff',
- title: 'Diff',
- holdToasts: true,
- focus: true,
- closeOnEscape: true,
- },
- ])
+ expect(world.opened[0]).toEqual({
+ id: 'diff',
+ title: 'Diff',
+ holdToasts: true,
+ closeOnEscape: true,
+ rows: expect.any(Number),
+ focus: true,
+ })
expect(await $.command.run(Fixtures.DIALOG_DIFF)).toEqual({
text: 'Diff dialog dismissed',
diff --git a/mods/diff/tests/views.test.ts b/mods/diff/tests/views.test.ts
index 122017d8..74632ea8 100644
--- a/mods/diff/tests/views.test.ts
+++ b/mods/diff/tests/views.test.ts
@@ -66,6 +66,24 @@ describe('views', () => {
expect(after).toContain('-const v = 0')
expect(after).toContain('10 files changed +10 -10')
+ expect(after, 'the list stays').not.toContain('more above')
+ })
+
+ test('docked, the wheel over a long list moves the list', async ($, on) => {
+ const world = Fixtures.inRepository(on, Fixtures.MANY_FILES)
+
+ await $.session.start(Fixtures.SESSION)
+ await $.command.run(Fixtures.DIFF)
+ await world.clock.advance(Fixtures.SETTLE_MS)
+ await $.ui.render(Fixtures.PANE)
+
+ expect(await $.ui.scroll(Fixtures.WHEEL_OVER_LIST)).toEqual({})
+
+ const after = Fixtures.textOf(await $.ui.render(Fixtures.PANE))
+
+ expect(after).toContain('\u2191 1 more above')
+ expect(after).toContain('file8.ts')
+ expect(after.split('file0.ts'), 'the body stays').toHaveLength(2)
})
test('past eight files the docked list scrolls by key', async ($, on) => {
@@ -129,6 +147,14 @@ describe('views', () => {
expect(drawn).toContain(
'\u2191/\u2193 to select \u00b7 Enter to view \u00b7 Esc to close',
)
+
+ expect(world.opened.at(-1), 'sized to its rows once listed').toEqual({
+ id: 'diff',
+ title: 'Diff',
+ holdToasts: true,
+ closeOnEscape: true,
+ rows: 8,
+ })
})
test('narrow under the fullscreen layout, the resize line', async ($, on) => {