Repository navigation
refactor(repl): extract apiMetrics capture sub-block (audit §1.1.1 slice #25) - #195
Merged
Merged
Conversation
…ice #25) 从 REPL.tsx onQueryImpl apiMetrics capture 子块 (L3300-3337, 38 LOC) 抽出到 src/utils/apiMetricsCapture.ts 的 captureApiMetrics() helper。 PURE-ROUTING SUB-BLOCK class (像 slice #19 onCompactProgress): - 行为等价,无 React hooks/JSX/await。 - helper 直接 import 9 module symbols (6 getTurn* timing fn / median / isInternalBuild / createApiMetricsMessage / getGlobalConfigWriteCount); ctx 携带 3 REPL 闭包依赖 (apiMetricsRef + loadingStartTimeRef + setMessages)。 - guard 移入 helper (isInternalBuild() && length>0),REPL 保留薄调用。 REPL 清理 8 个 sole-user import (6 getTurn* + getGlobalConfigWriteCount + createApiMetricsMessage),isInternalBuild(18 用)/median(6 用) 保留。 LOC: REPL 6215→6172 (−43),cumulative −881→−924。 4 gates: typecheck 0 / 914 pass / biome clean(new) / build:dev 3781 mods。 Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit §1.1.1 god-module split — slice #25. Extracts the
apiMetrics capturesub-block (38 LOC, insideonQueryImpl) to a newcaptureApiMetrics()helper insrc/utils/apiMetricsCapture.ts.PURE-ROUTING SUB-BLOCK class (proven safe via slice #19
onCompactProgress): no React hooks, no JSX, no await. Behavior-identical.Changes
src/utils/apiMetricsCapture.ts—captureApiMetrics(ctx)relocates the L3300-3337 block verbatim. Helper imports 9 module symbols directly (6getTurn*timing fns /median/isInternalBuild/createApiMetricsMessage/getGlobalConfigWriteCount). ctx carries 3 REPL closure deps (apiMetricsRef+loadingStartTimeRef+setMessages).src/screens/REPL.tsx— block → thin callcaptureApiMetrics({ apiMetricsRef, loadingStartTimeRef, setMessages }). Removes 8 sole-user imports (6getTurn*+getGlobalConfigWriteCount+createApiMetricsMessage); keepsisInternalBuild(18 uses) +median(6 uses).LOC
REPL 6215 → 6172 (−43). Cumulative since slice #1: −924.
Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 914 pass / 0 failbunx biome check— new file clean (0/0); REPL 0 churnbun run build:dev— 3781 modules, successContext
Part of audit §1.1.1 (
~/fusion/audit/fusion-code-audit-result-0827.md) — god-module split ofsrc/screens/REPL.tsx(was 7096 LOC). 25 slices landed, cumulative −924. Continues per "把设计级的任务做完在停下来,持续推进".Co-Authored-By: Claude Fable 5 [email protected]