Skip to content

refactor(repl): extract apiMetrics capture sub-block (audit §1.1.1 slice #25) - #195

Merged
dahai80 merged 1 commit into
mainfrom
audit/repl-split-slice25-api-metrics
Aug 29, 2026
Merged

dahai80 merged 1 commit into
mainfrom
audit/repl-split-slice25-api-metrics

Conversation

@dahai80

@dahai80 dahai80 commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

Audit §1.1.1 god-module split — slice #25. Extracts the apiMetrics capture sub-block (38 LOC, inside onQueryImpl) to a new captureApiMetrics() helper in src/utils/apiMetricsCapture.ts.

PURE-ROUTING SUB-BLOCK class (proven safe via slice #19 onCompactProgress): no React hooks, no JSX, no await. Behavior-identical.

Changes

  • NEW src/utils/apiMetricsCapture.ts — captureApiMetrics(ctx) relocates the L3300-3337 block verbatim. Helper imports 9 module symbols directly (6 getTurn* timing fns / median / isInternalBuild / createApiMetricsMessage / getGlobalConfigWriteCount). ctx carries 3 REPL closure deps (apiMetricsRef + loadingStartTimeRef + setMessages).
  • MOD src/screens/REPL.tsx — block → thin call captureApiMetrics({ apiMetricsRef, loadingStartTimeRef, setMessages }). Removes 8 sole-user imports (6 getTurn* + getGlobalConfigWriteCount + createApiMetricsMessage); keeps isInternalBuild (18 uses) + median (6 uses).

LOC

REPL 6215 → 6172 (−43). Cumulative since slice #1: −924.

Gates

  • bun run typecheck — 0 errors
  • bun test src/__tests__/ — 914 pass / 0 fail
  • bunx biome check — new file clean (0/0); REPL 0 churn
  • bun run build:dev — 3781 modules, success

Context

Part of audit §1.1.1 (~/fusion/audit/fusion-code-audit-result-0827.md) — god-module split of src/screens/REPL.tsx (was 7096 LOC). 25 slices landed, cumulative −924. Continues per "把设计级的任务做完在停下来,持续推进".

Co-Authored-By: Claude Fable 5 [email protected]

…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]>
@dahai80
dahai80 merged commit 96bf932 into main Aug 29, 2026
1 check passed
@dahai80
dahai80 deleted the audit/repl-split-slice25-api-metrics branch August 29, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant