spacehub

surshar / claude-code

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.

Built by Anthropic · github.com/anthropics

diff: the dialog's fetch asks its seat first, and a generated file opens tooBrowse files
poteat authored 24 days ago parent a56c3b1 · commit 1bc9a5f22932
5 changed files+49 -8compared with a56c3b1
Mmods/diff/hooks/drawn-files-of/drawn-files-of.ts
Mmods/diff/hooks/register.ts
Mmods/diff/tests/fixtures/index.ts
Amods/diff/tests/fixtures/with-lockfile.ts
Mmods/diff/tests/views.test.ts
@@ -18,11 +18,16 @@
1818 model: PaneState.PaneModel,
1919 ): readonly Git.FileStat[] {
2020 const files = model.data?.files ?? []
21- const listed = Views.dialogEntriesOf(model).map(entry => entry.path)
22- const start = Views.dialogWindowOf(model, listed)
23- const windowed = listed.slice(start, start + Limits.MAX_VISIBLE_FILES)
24- const isTurn = PaneState.pickedTurnOf(model) !== undefined
2521
22+ if (model.placement === 'inline') {
23+ const isTurn = PaneState.pickedTurnOf(model) !== undefined
24+ const listed = Views.dialogEntriesOf(model).map(entry => entry.path)
25+ const start = Views.dialogWindowOf(model, listed)
26+ const windowed = listed.slice(start, start + Limits.MAX_VISIBLE_FILES)
27+
28+ return files.filter(file => !isTurn && windowed.includes(file.path))
29+ }
30+
2631 const partition = PaneState.partitionOf(
2732 files,
2833 model.isNoiseShown ? 'shown' : 'hidden',
@@ -32,8 +37,5 @@
3237 model.isPreSessionShown &&
3338 partition.preSession.length <= Limits.PRE_SESSION_BODY_CAP
3439
35- const docked = [...partition.shown, ...(isBodied ? partition.preSession : [])]
36- const inDialog = files.filter(file => !isTurn && windowed.includes(file.path))
37-
38- return model.placement === 'inline' ? inDialog : docked
40+ return [...partition.shown, ...(isBodied ? partition.preSession : [])]
3941 }
@@ -728,6 +728,11 @@
728728
729729 columns = e.viewport?.columns ?? columns
730730
731+ /**
732+ * A seat that changed since the last drawing lists other rows, whose
733+ * bodies are read once: the model takes the new seat in this same pass,
734+ * so the drawing that read asks for finds the seat unchanged.
735+ */
731736 const isReseated = e.props.placement !== model.placement
732737
733738 model = {
@@ -61,6 +61,7 @@
6161 export * from './vs-main.js'
6262 export * from './wheel-over-list.js'
6363 export * from './wheel-tick.js'
64+export * from './with-lockfile.js'
6465 export * from './worktree'
6566 export * from './wrapped-lines'
6667
@@ -1,0 +1,10 @@
1+import { answersOf } from './answers-of.js'
2+
3+/**
4+ * Git's output in /work where a source file and a lockfile changed, the
5+ * lockfile a generated file the docked pane hides until asked.
6+ */
7+export const WITH_LOCKFILE = answersOf('1\t1\tapp.ts\0' + '1\t1\tbun.lock\0', {
8+ 'app.ts': '@@ -1 +1 @@\n-const a = 1\n+const a = 2\n',
9+ 'bun.lock': '@@ -1 +1 @@\n-"left": "1.0.0"\n+"left": "1.0.1"\n',
10+})
@@ -124,6 +124,29 @@
124124 expect(drawn).not.toContain('+d')
125125 })
126126
127+ test('inline, a file the docked pane hides opens too', async ($, on) => {
128+ const world = Fixtures.inRepository(on, Fixtures.WITH_LOCKFILE)
129+
130+ await $.session.start(Fixtures.SESSION)
131+ await $.command.run(Fixtures.DIALOG_DIFF)
132+ await world.clock.advance(Fixtures.SETTLE_MS)
133+ await $.ui.render(Fixtures.INLINE_PANE)
134+
135+ expect(await $.ui.press({ plugin: 'diff', key: 'file:bun.lock' })).toEqual({
136+ element: 'file:bun.lock',
137+ })
138+
139+ await world.clock.advance(Fixtures.SETTLE_MS)
140+
141+ const drawn = Fixtures.textOf(await $.ui.render(Fixtures.INLINE_PANE))
142+
143+ expect(drawn, 'generated, and still a listed row').not.toContain(
144+ 'Loading diff',
145+ )
146+
147+ expect(drawn).toContain('+"left": "1.0.1"')
148+ })
149+
127150 test('docked, a wheel tick moves the body, not the list', async ($, on) => {
128151 const world = Fixtures.inRepository(on, Fixtures.MANY_FILES)
129152