mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 03:09:33 +01:00
perf(story-mode): no long tasks while stepping through turns; the rest of review round 4
Stepping through 40 turns made 46 long tasks of 51 to 286 ms, enough for
the app's guard to drop the terminal's WebGL renderer for the rest of the
page's life. Drawing switched off made none: the cost was canvas raster at
paint time, which the per-frame JS budget never saw. Now:
- Panel backgrounds are shared between panels and turns (kind × size ×
palette), and a new one is built in four bands, one per frame (a wide
halftone at 2x was ~35 ms in one go; a band is ~8 ms).
- At most two panels are drawn per frame, the first one served rotating so
none starves; clocks still run for all.
- Measured on 20 turns stepped 40 times at 2x: 1 long task (52 ms), against
39; the settled overlay is still ~2% of a core.
Also from round 4:
- The turn picker says when older turns were not loaded (`older` in the
response: the transcript is longer than the part that was read).
- A compaction after the last turn closes that turn; a local command's
output is the final panel's balloon ("Compacted"), without its markdown
ticks, and a turn under a second reads "Done.".
- Exact durations keep their seconds past an hour, so the two captions never
disagree on the minute ("1 h 10 min." / "1 h 9 min 39 s").
- A turn that arrives already finished is announced as new too.
- Whole files written by here-documents read "Claude writes 3 files."; the
advisor's caption reads "a second opinion" instead of repeating its name.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
846749a912
commit
0effbb9ce4
15 files changed
+188
-44
No files matched your search
@@ -43,7 +43,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude calls in 2 helpers.",
|
||||
"director": "Advisor · Agent · advisor + general-purpose · 6 calls inside",
|
||||
"director": "Advisor · Agent · a second opinion · general-purpose · 6 calls inside",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 2
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
@@ -116,7 +116,7 @@
|
||||
"ok": null,
|
||||
"story": "Done in 24 seconds.",
|
||||
"director": "local command · 24 s · 0 tool calls",
|
||||
"balloon": null,
|
||||
"balloon": "Compacted",
|
||||
"tests": null,
|
||||
"events": 0
|
||||
}
|
||||
@@ -166,7 +166,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
@@ -42,7 +42,7 @@
|
||||
{
|
||||
"kind": "fix",
|
||||
"ok": null,
|
||||
"story": "Claude changes 3 files.",
|
||||
"story": "Claude writes 3 files.",
|
||||
"director": "Bash · pyproject.toml +11 · .gitignore +11 · __init__.py +3",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
@@ -112,7 +112,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
@@ -64,7 +64,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
@@ -103,7 +103,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
@@ -220,7 +220,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
@@ -82,7 +82,7 @@
|
||||
"kind": "backup",
|
||||
"ok": null,
|
||||
"story": "Claude asks the advisor for a second opinion.",
|
||||
"director": "Advisor · advisor",
|
||||
"director": "Advisor · a second opinion",
|
||||
"balloon": null,
|
||||
"tests": null,
|
||||
"events": 1
|
||||
|
||||
@@ -153,6 +153,22 @@ describe('GET /api/sessions/:id/story', () => {
|
||||
expect(page.panels[0].kind).toBe('mission');
|
||||
});
|
||||
|
||||
it('says when older turns were not read', async () => {
|
||||
const big = 'x'.repeat(100_000);
|
||||
const lines: unknown[] = [prompt('an old turn')];
|
||||
for (let i = 0; i < 90; i++) lines.push(...bash(`b${i}`, `cat big${i}.txt`, `Show file ${i}`, big));
|
||||
lines.push(end(60_000), prompt('the newest turn'), ...bash('n1', 'ls', 'List', 'a'), end(1000));
|
||||
writeFileSync(transcript, jsonl(lines));
|
||||
const { app } = await setup();
|
||||
const data = (await app.inject({ method: 'GET', url: URL })).json().data;
|
||||
expect(data.page.prompt).toBe('the newest turn');
|
||||
expect(data.older).toBe(true);
|
||||
|
||||
writeFileSync(transcript, jsonl([prompt('one'), end(1000)]));
|
||||
const small = (await app.inject({ method: 'GET', url: URL })).json().data;
|
||||
expect(small.older).toBeUndefined();
|
||||
});
|
||||
|
||||
it('a live turn grows as the transcript grows', async () => {
|
||||
writeFileSync(transcript, jsonl([prompt('go'), ...read('r1', '/w/a.ts')]));
|
||||
const { app } = await setup();
|
||||
|
||||
@@ -194,6 +194,9 @@ describe('text helpers', () => {
|
||||
expect(exactDuration(432_000)).toBe('7 min 12 s');
|
||||
expect(roughDuration(4_000)).toBe('4 seconds');
|
||||
expect(roughDuration(3_900_000)).toBe('1 h 5 min');
|
||||
// Past an hour the exact one keeps its seconds, so the two never disagree on the minute.
|
||||
expect(roughDuration(4_179_269)).toBe('1 h 10 min');
|
||||
expect(exactDuration(4_179_269)).toBe('1 h 9 min 39 s');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -683,6 +686,22 @@ describe('buildStoryTurns', () => {
|
||||
expect(page.panels.some((p) => /you add \d+ things?/.test(p.caption.story))).toBe(true);
|
||||
});
|
||||
|
||||
it('an automatic compaction after the last turn closes that turn', () => {
|
||||
const [turn] = buildStoryTurns(
|
||||
entriesOf([
|
||||
prompt('one'),
|
||||
end(1000),
|
||||
{
|
||||
type: 'system',
|
||||
subtype: 'compact_boundary',
|
||||
timestamp: '2026-10-18T10:00:00.000Z',
|
||||
compactMetadata: { trigger: 'auto' },
|
||||
},
|
||||
])
|
||||
);
|
||||
expect(turn.events.map((e) => e.intent)).toEqual(['prompt', 'compact']);
|
||||
});
|
||||
|
||||
it('an interrupt ends the turn', () => {
|
||||
const turns = buildStoryTurns(
|
||||
entriesOf([prompt('go'), ...bash('b', 'ls', 'List', 'a'), prompt('[Request interrupted by user]')])
|
||||
|
||||
Reference in new issue
Block a user