Files
claude-agent-acp/src/tests/session-timing.test.ts
nikita-ashihmin f5e79f55f8 fix: restore session forks and speed up loading (#1089)
## Summary

- resolve AIR fork points from the complete persisted transcript when
the target is outside the active parent chain
- support message fingerprints and repeated assistant content when
resolving persisted fork points
- restore resumed models from the same local assistant transcript record
Claude Code uses
- remove all automatic `getContextUsage` control requests; use
`compact_metadata.post_tokens` after compaction
- add structured timing logs for fork, load, replay, and session
creation phases

## Performance

Cold-loading the reproduced 69-message forked session dropped from 20–29
seconds to 1.9 seconds. Transcript model lookup took 5 ms and replay
took 14 ms; the remaining time was SDK initialization.

## Tests

- `env -u ANTHROPIC_BASE_URL npm run test:run` (1230 passed, 27 skipped)
- `npm run build`
- `npm run lint`
- Prettier check for all changed files
- real ACP cold-load probe against the reproduced forked session
2026-09-05 16:43:25 +04:00

18 lines
588 B
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { SessionTiming } from "../session-timing.js";
describe("SessionTiming", () => {
afterEach(() => vi.restoreAllMocks());
it("includes work completed before construction when given a start time", () => {
vi.spyOn(performance, "now").mockReturnValue(175);
const log = vi.fn();
new SessionTiming({ log }, "create", "session-id", 100).phase("validate-cwd");
expect(log).toHaveBeenCalledWith(
"[session/create] sessionId=session-id phase=validate-cwd durationMs=75 totalMs=75",
);
});
});