Move-only (TASK-rectification-code-split-20260926 T1/T4). No behavior, API,
copy, DB, Skill or scoring change.
- rectification-agentic-chat.tsx: 2043 -> 737 lines; component body
1625 -> 630; useState 35 -> 12, useRef 16 -> 9, effects 9 -> 5,
useCallback 12 -> 6.
- Snapshot sync -> hooks/use-rectification-case-snapshot.ts; board layout
and live label clock -> two small hooks.
- send / submitStructuredChoice / acceptCandidate bodies ->
lib/rectification-chat-{turn,choice,accept}-run.ts parameter functions
(bodies verbatim, deps destructured to the same names); copy/regenerate,
question repair, pure transcript and snapshot helpers and the per-render
view derivation -> lib/rectification-chat-*.ts (no React hooks).
- Question-gap blocks and the read-only range line ->
components/rectification-question-gap-notices.tsx.
- Dependency arrays kept exactly as before (lint warnings +3, listed in
PROGRESS); no dep added to appease the linter.
- Tests: whole-source contracts read tests/rectification-chat-surface.ts
(container + split files, like home-surface.ts); slices of moved code now
call the extracted functions or render the extracted block, each with a
原值/新值/原因 comment. New tests/rectification-growth-contract.test.ts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
36 lines
2.1 KiB
TypeScript
36 lines
2.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
import { rectificationChatSurface } from "./rectification-chat-surface.ts";
|
|
|
|
// 原值: 读 rectification-agentic-chat.tsx 单文件。新值: rectificationChatSurface(容器 + 拆出的 hook / 参数函数 / 块,见 rectification-chat-surface.ts)。原因: TASK-rectification-code-split-20260926 只搬不改,整文件断言跟着代码走;切片断言另行改为调用函数。
|
|
const chat = rectificationChatSurface;
|
|
const agentRun = readFileSync(
|
|
new URL("../src/lib/rectification-agentic/v9/agent-run.ts", import.meta.url),
|
|
"utf8",
|
|
);
|
|
|
|
test("live and persisted assistant text stay verbatim after spoken-answer removal", () => {
|
|
assert.match(chat, /const raw = failed \? "" : turn\.text \?\? ""/);
|
|
assert.match(chat, /text: raw,/);
|
|
assert.doesNotMatch(chat, /spoken-answer/);
|
|
assert.doesNotMatch(chat, /splitRectificationSpokenAndThinking|settleRectificationSpokenAndThinking|finalizeRectificationSpokenAndThinking/);
|
|
assert.match(agentRun, /answerText = visible;/);
|
|
assert.doesNotMatch(agentRun, /splitRectificationSpokenAndThinking|settleRectificationSpokenAndThinking|finalizeRectificationSpokenAndThinking/);
|
|
});
|
|
|
|
test("structured current_question, not model prose, owns the visible question on the turn", () => {
|
|
assert.match(chat, /current_question\?: unknown/);
|
|
assert.match(chat, /setCurrentQuestion\(nextQuestion\)/);
|
|
assert.doesNotMatch(chat, /className="rectification-question-slot"/);
|
|
assert.match(chat, /currentQuestion\?\.kind === "collect_spoken"/);
|
|
assert.match(chat, /<RectificationChoiceCard/);
|
|
assert.doesNotMatch(chat, /message\.text\.(?:includes|match|search)\(/);
|
|
});
|
|
|
|
test("answer deltas expose the model text without a parser or regex cleanup", () => {
|
|
assert.match(chat, /raw = event\.replace === true \? event\.text : raw \+ event\.text/);
|
|
assert.match(chat, /text: raw,/);
|
|
assert.doesNotMatch(chat, /splitRectificationSpokenAndThinking|settleRectificationSpokenAndThinking|finalizeRectificationSpokenAndThinking/);
|
|
});
|