fix TUI diff context line accounting

This commit is contained in:
kingwl
2026-07-31 11:41:16 +08:00
parent 7239a2201e
commit e98cd522ee
12 changed files with 153 additions and 49 deletions

View File

@@ -31,9 +31,9 @@ buffer
style 0-10 bold
14| "- old line "
style 0-9 fg=red
15| "… +3 lines (Ctrl+O to expand) "
15| "… +2 lines (Ctrl+O to expand) "
style 0-28 dim
16| "└ +2 -2 · 1 file "
16| "└ +1 -1 · 1 file "
style 0-15 dim
17| <blank>
18| "● Tool / subagent"

View File

@@ -1,7 +1,7 @@
terminal 100x40 buffer=normal length=43 base=3 viewport=3
terminal 100x40 buffer=normal length=42 base=2 viewport=2
lifecycle started=1 stopped=0 progress=inactive
title "DSH snapshot"
cursor hidden column=7 viewportRow=39 bufferRow=42
cursor hidden column=7 viewportRow=39 bufferRow=41
buffer
0| " DEEPSEEK HARNESS"
style 1-8 fg=bright-magenta bold
@@ -37,54 +37,52 @@ buffer
style 0-10 bold
17| "- old line "
style 0-9 fg=red
18| "- keep "
style 0-5 fg=red
19| "+ new line "
18| "+ new line "
style 0-9 fg=green
20| "+ keep "
style 0-5 fg=green
21| "└ +2 -2 · 1 file "
19| " keep "
style 0-5 dim
20| "└ +1 -1 · 1 file "
style 0-15 dim
22| <blank>
23| "● Tool / subagent"
21| <blank>
22| "● Tool / subagent"
style 0-16 fg=green
24| "Delegate renderer audit "
23| "Delegate renderer audit "
style 0-99 dim
25| "The renderer has explicit lifecycle ownership. "
24| "The renderer has explicit lifecycle ownership. "
style 0-99 dim
26| <blank>
27| "● Tool / task_output"
25| <blank>
26| "● Tool / task_output"
style 0-19 fg=green
28| "Read output from background task subagent-7 "
27| "Read output from background task subagent-7 "
style 0-99 dim
29| " "
30| "console "
28| " "
29| "console "
style 0-6 dim
31| " started background task bash-5 "
30| " started background task bash-5 "
style 0-1 dim
style 2-31 fg=cyan dim
style 32-99 dim
32| " "
33| <blank>
34| "● Tool / skill"
31| " "
32| <blank>
33| "● Tool / skill"
style 0-13 fg=green
35| "Load skill dsh-code-review "
34| "Load skill dsh-code-review "
style 0-99 dim
36| "Loaded review instructions. "
35| "Loaded review instructions. "
style 0-99 dim
37| "Model wait 0.0s "
36| "Model wait 0.0s "
style 0-14 dim
38| <blank>
39| "Tool and context cards expanded. "
37| <blank>
38| "Tool and context cards expanded. "
style 0-31 dim
40| <blank>
41| "/workspace/project (tui-staging) deepseek-v4-flash ↑0 ↓0 0% context"
39| <blank>
40| "/workspace/project (tui-staging) deepseek-v4-flash ↑0 ↓0 0% context"
style 0-17 fg=bright-magenta bold
style 18-31 dim
style 34-50 dim
style 53-57 dim
style 60-69 dim
42| " dsh > "
41| " dsh > "
style 1-3 fg=bright-magenta bold
style 5-6 dim
style 7-7 inverse

View File

@@ -4315,7 +4315,11 @@ describe('tool cards and surface replay', () => {
presentCall: () => ({
card: 'diff',
title: 'Edit src/only.ts',
diffs: [{ path: 'src/only.ts', oldText: 'old', newText: 'new' }],
diffs: [{
path: 'src/only.ts',
oldText: 'my: my-MM\nne: ne-NP\nnl: nl-NL\nnb: no-NO\npa: pa-Guru-IN\npl: pl-PL\npt_pt: pt-PT',
newText: 'my: my-MM\nne: ne-NP\nnl: nl-NL\nnb: nb-NO\npa: pa-Guru-IN\npl: pl-PL\npt_pt: pt-PT',
}],
}),
},
generic: {
@@ -4622,7 +4626,7 @@ describe('tool cards and surface replay', () => {
})
it('names a single-file diff in the body once, under a fixed Tool header', async () => {
const result = await setup({ tools })
const result = await setup({ tools, config: { maxToolOutputLines: 20 } })
appendUser(result.session, 'edit one file')
appendAssistant(result.session, [
{ type: 'text', text: 'Editing' },
@@ -4638,9 +4642,12 @@ describe('tool cards and surface replay', () => {
expect(output).toContain('Tool / singleDiff')
expect(output).not.toContain('Edit src/only.ts')
expect(output.split('src/only.ts').length - 1).toBe(1)
expect(output).toContain('- old')
expect(output).toContain('+ new')
expect(output).toContain('· 1 file')
expect(output).toContain(' my: my-MM')
expect(output).not.toContain('- my: my-MM')
expect(output).not.toContain('+ my: my-MM')
expect(output).toContain('- nb: no-NO')
expect(output).toContain('+ nb: nb-NO')
expect(output).toContain('└ +1 -1 · 1 file')
await dispose(result)
})