mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 19:29:33 +01:00
fix(story-mode): the rest of the PR review: lookups, polling, frame budget, linear links
From review round 7 (PR review): - With no hook path (normal after a server restart), the transcript was looked up by conversation id only; it now also tries the Codeman id and a recovered session's `restored-<fragment>` transcript, as last-response does, and keeps what it found briefly (a lookup reads every project folder; a miss is kept only 4 s). - A session Story Mode cannot draw is not polled, and a page with nothing drawn yet is polled like a finished one (every 15 s), not every 4 s. - Helper steps: one request per helper is drawn, the newest; a failed refetch never writes over steps already shown. - The Director's cut toggle, a skin change and the fonts arriving redraw within the frame budget, not every panel in one task. - A bare name under an `ls` header finds its folder in one pass over the lines; a search per link over the text before it was quadratic (about 1.5 s for 700 links on agent output). - A page of many questions still keeps to 12 panels: questions fold last. - Opening Story Mode while it is open never starts a second runtime; the status announcer carries data-i18n-skip; the turn key in the ETag is clipped. - The crafted-input timing test runs at sizes where the old code took 6 to 29 s and the new one under 10 ms, with a 1.5 s bound. - Docs: `older`, `origin` (`scheduled`), which route answers a 500; mobile.css's stale comment; an orphaned doc comment. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e7ce3b8e56
commit
42d1c75a19
10 files changed
+191
-41
No files matched your search
@@ -8,7 +8,7 @@ import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||
import { createRouteTestHarness } from './_route-test-utils.js';
|
||||
import { registerStoryRoutes } from '../../src/web/routes/story-routes.js';
|
||||
import { clearStoryLookupCache, registerStoryRoutes } from '../../src/web/routes/story-routes.js';
|
||||
import { clearStoryReaderCache, readStoryEntries } from '../../src/story-reader.js';
|
||||
import { claudeProjectsDir } from '../../src/utils/claude-transcript.js';
|
||||
import { bash, demoTurn, edit, end, prompt, read, resetClock, result, said, tool } from '../story-fixtures.js';
|
||||
@@ -32,6 +32,7 @@ async function setup(opts: { hookPath?: string | null; mode?: string; remote?: u
|
||||
beforeEach(() => {
|
||||
resetClock();
|
||||
clearStoryReaderCache();
|
||||
clearStoryLookupCache();
|
||||
// Where Claude Code writes transcripts (under the test's temp HOME): the only place a hook path is read.
|
||||
mkdirSync(claudeProjectsDir(), { recursive: true });
|
||||
dir = mkdtempSync(join(claudeProjectsDir(), 'story-route-'));
|
||||
@@ -202,6 +203,14 @@ describe('GET /api/sessions/:id/story', () => {
|
||||
expect(res.json().data).toMatchObject({ supported: true, turns: [], page: null });
|
||||
});
|
||||
|
||||
it('with no hook path, finds the transcript by the Codeman id too (as last-response does)', async () => {
|
||||
const byId = join(dir, 'test-session-1.jsonl');
|
||||
writeFileSync(byId, jsonl(demoTurn()));
|
||||
const { app } = await setup({ hookPath: null });
|
||||
const body = (await app.inject({ method: 'GET', url: URL })).json();
|
||||
expect(body.data.page?.panels.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('says when the list leaves turns out past the 60 it shows, even in a small file', async () => {
|
||||
const lines: unknown[] = [];
|
||||
for (let i = 0; i < 80; i++) lines.push(prompt(`job ${i}`), said('ok'), end(1000));
|
||||
|
||||
Reference in new issue
Block a user