refactor(app): extract prompt-input edit-load effect into edit-load-effect.ts#1093
Conversation
…ffect.ts
Slice 3 of the prompt-input.tsx slimming line. Pure extraction, no
behavior/DOM/aria/copy/storage-key change.
Moves the deferred createEffect that loads an edit/followup draft into the
editor (keyed on props.edit?.id) into createEditLoadEffect(deps) (returns
void). The factory is called synchronously at the effect's original position
so the effect registers in the component owner with { defer: true } intact.
props.edit and props.onEditLoaded are injected as editDraft (accessor) and
onEditLoaded (thunk wrapping the optional call); editorRef is injected as a
getter. The only textual changes are those injection seams:
props.edit -> editDraft(), editorRef.focus() -> editorRef().focus(),
setCursorPosition(editorRef, ...) -> setCursorPosition(editorRef(), ...),
props.onEditLoaded?.() -> onEditLoaded(). The on() source still tracks
props.edit?.id, so reactivity is unchanged.
prompt-input.tsx 601 -> 572.
|
Warning Review limit reached
More reviews will be available in 55 minutes and 46 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Suggested priority: P2 (includes user-path files (packages/app/src/components/prompt-input.tsx, packages/app/src/components/prompt-input/edit-load-effect.ts)).
P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.
Summary
Slice 3 of the serial prompt-input.tsx slimming line (slice 1 = #1083, slice 2 = #1091). Pure extraction — no behavior/DOM/aria/copy/storage-key change.
Moves the deferred
createEffectthat loads an edit/followup draft into the editor (keyed onprops.edit?.id) out ofprompt-input.tsxinto a new moduleprompt-input/edit-load-effect.ts(createEditLoadEffect, returns void).Why it stays behavior-neutral
{ defer: true }intact and no ordering change. All injected deps (prompt,setStore,editorRefgetter,queueScroll,editDraft,onEditLoaded) are available there — no late-binding.props.edit→ injected as the accessoreditDraft: () => props.edit; theon()source() => editDraft()?.idstill tracksprops.edit?.idreactively, so the effect re-runs only on id change.props.onEditLoaded→ injected as the thunk() => props.onEditLoaded?.(), called unconditionally asonEditLoaded()— optional-chaining no-op semantics and the fire timing (synchronously after scheduling the rAF) are preserved.props.edit→editDraft(),editorRef.focus()→editorRef().focus(),setCursorPosition(editorRef, ...)→setCursorPosition(editorRef(), ...),props.onEditLoaded?.()→onEditLoaded(). The 7 copied context fields, the foursetStorecalls,prompt.set, and the rAF block are verbatim.props.edit/props.onEditLoadedare used ONLY by this effect (verified), so no external surface changes. No newly-unused imports inprompt-input.tsx(setCursorPosition,on,promptLengthall still used elsewhere).prompt-input.tsx601 → 572 lines;edit-load-effect.ts+63.Verification
bun run typecheck8/8 successfulbun test src/components/prompt-input/ use-session-followups session-action-readiness→ 404 pass / 2 pre-existing dev-base failures (command-prepend,path-b-integration:isPromptEqual not foundbun ESM load-order flake; neither imports the changed files, zero regression — a standalone PR to fix that flake is queued next){ defer: true }, owner-scoped registration, correct/complete importsResidual risk
None — pure extraction.