Files
Jyotisha/frontend/tests/rectification-chat-surface.ts
T
Jesse_ChenandClaude Opus 5.5 3a66c39f48 refactor(rectification): split the chat component into hooks, parameter functions and blocks
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
2026-09-26 19:23:52 +08:00

35 lines
1.6 KiB
TypeScript

import { readFileSync } from "node:fs";
/**
* The rectification chat surface as source text: the container component and
* the hooks, parameter functions and blocks it was split into
* (TASK-rectification-code-split-20260926). Same idea as `home-surface.ts`:
* a whole-source contract that held on `rectification-agentic-chat.tsx`
* before the split holds on this concatenation after it, because the code is
* the same code in more files. Slices between two anchors do not survive the
* split; those tests call the extracted functions instead.
*/
export const rectificationChatSurfaceFiles = [
"../src/components/rectification-agentic-chat.tsx",
"../src/components/rectification-question-gap-notices.tsx",
"../src/hooks/use-rectification-case-snapshot.ts",
"../src/hooks/use-rectification-board-layout.ts",
"../src/hooks/use-rectification-live-activity.ts",
"../src/lib/rectification-chat-messages.ts",
"../src/lib/rectification-chat-snapshot.ts",
"../src/lib/rectification-chat-turn-run.ts",
"../src/lib/rectification-chat-choice-run.ts",
"../src/lib/rectification-chat-accept-run.ts",
"../src/lib/rectification-chat-message-actions.ts",
"../src/lib/rectification-chat-question-repair.ts",
"../src/lib/rectification-chat-view.ts",
] as const;
export function readRectificationChatFile(relativePath: (typeof rectificationChatSurfaceFiles)[number]): string {
return readFileSync(new URL(relativePath, import.meta.url), "utf8");
}
export const rectificationChatSurface = rectificationChatSurfaceFiles
.map((relativePath) => readRectificationChatFile(relativePath))
.join("\n");