Skip to content

refactor(screens): extract idle-return-hint useEffect body (audit 1.1.1 slice #34) - #207

Merged
dahai80 merged 1 commit into
mainfrom
refactor/screens-idle-return-hint-extract
Aug 29, 2026
Merged

dahai80 merged 1 commit into
mainfrom
refactor/screens-idle-return-hint-extract

Conversation

@dahai80

@dahai80 dahai80 commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Slice #34 of #170 REPL god-module split.

Change

Extract the idle-return-hint useEffect body (5 early-return guards + setTimeout with 5 stale-closure-bypass positional args generating Ink <Text> JSX for the hint_v2 variant + logEvent + cleanup) into maybeScheduleIdleReturnHint() in src/screens/idleReturnHint.tsx.

Class: PURE-ROUTING SUB-BLOCK (6th, like slice #29 maybeSendIdleNotification). The function returns the setTimeout handle so the kept-thin useEffect cleanup (clearTimeout + removeNotification + ref reset) still works byte-identically. JSX-generating extract → .tsx + Text import from ../ink.js.

Extraction pattern

  • 5 setTimeout-arg + 2 guard dep + removeNotification pass via ctx object
  • getFeatureValue_CACHED_MAY_BE_STALE/logEvent/AnalyticsMetadata/getGlobalConfig/getTotalInputTokens/formatTokens imported directly (NOT via ctx)
  • useEffect kept as thin shell: const timer = maybeScheduleIdleReturnHint({...}); return () => { if (timer) clearTimeout(timer); ... }

Import cleanup

  • formatTokens became import-only in REPL (sole user moved) → removed from REPL (slice feat: 代码生成 API — 供协作空间调用 #22 import-cleanup-after-extraction lesson)
  • getFeatureValue/getGlobalConfig/getTotalInputTokens/Text/logEvent/AnalyticsMetadata still multi-use → kept

Gates

  • bun run typecheck → 0 errors
  • bun test src/__tests__/ → 921 pass, 0 fail
  • bunx biome check on new file only → clean (--write applied to new file only per churn-avoidance rule)
  • bun run build:dev → pass

Impact

REPL 5754 → 5703 (−51 net: −59 body, +8 thin shell). Byte-identical behavior.

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

….1 slice #34)

Slice #34 of #170 REPL god-module split. Extract the idle-return-hint
useEffect body (5 early-return guards + setTimeout with 5 stale-closure-bypass
positional args generating Ink <Text> JSX for the hint_v2 variant + logEvent +
cleanup) into maybeScheduleIdleReturnHint() in src/screens/idleReturnHint.tsx.

PURE-ROUTING SUB-BLOCK class (6th, like slice #29 maybeSendIdleNotification).
The function returns the setTimeout handle so the kept-thin useEffect cleanup
(clearTimeout + removeNotification + ref reset) still works byte-identically.
JSX-generating extract -> .tsx + Text import from ../ink.js.

5 setTimeout-arg + 2 guard dep + removeNotification pass via ctx object;
getFeatureValue_CACHED_MAY_BE_STALE/logEvent/AnalyticsMetadata/getGlobalConfig/
getTotalInputTokens/formatTokens imported directly. removeNotifications path
checked: formatTokens became import-only (sole user moved) -> removed from
REPL; getFeatureValue/getGlobalConfig/getTotalInputTokens/Text/logEvent/
AnalyticsMetadata still multi-use -> kept.

Gates: typecheck 0 errors / 921 pass / biome new-file-clean / build:dev pass.
REPL 5754 -> 5703 (-51 net: -59 body, +8 thin shell). Byte-identical behavior.

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 15cafb0 into main Aug 29, 2026
1 check passed
@dahai80
dahai80 deleted the refactor/screens-idle-return-hint-extract branch August 29, 2026 16:00
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