refactor(app): extract prompt-input commands+mode into commands-mode.ts#1091
Conversation
Slice 2 of the prompt-input.tsx slimming line. Pure extraction, no
behavior/DOM/aria/copy/storage-key change.
Moves the file-pick action, mode switch, and the command.register(
"prompt-input", ...) registration into createPromptCommandsAndMode(deps),
returning only { pick } (setMode and the mode keybinds have no external
consumers). The factory is invoked synchronously at the cluster's original
position so command.register's onCleanup stays bound to the component owner
and registration order is unchanged.
addPickedPaths is produced by createPromptAttachments later in the file, so
it is injected as the accessor thunk () => addPickedPaths and resolved as
addPickedPaths() inside pick — preserving the pre-existing forward-reference
closure timing. editorRef and the file-input click are injected as getters/
callbacks. The only textual changes are those three injection seams.
prompt-input.tsx 637 -> 601.
|
Warning Review limit reached
More reviews will be available in 9 minutes and 41 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/commands-mode.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.
…ffect.ts (#1093) 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. Change boundary: - New prompt-input/edit-load-effect.ts exposing createEditLoadEffect(deps): sets up the deferred createEffect that loads an edit/followup draft into the editor (keyed on props.edit?.id). Returns void. - prompt-input.tsx calls the factory synchronously at the effect's original position, so it registers in the component owner with { defer: true } intact and no ordering change. All deps (prompt, setStore, editorRef getter, queueScroll, editDraft, onEditLoaded) are available there — no late-binding. Injection seams (the only textual changes): - props.edit -> editDraft (accessor () => props.edit); the on() source () => editDraft()?.id still tracks props.edit?.id, so reactivity is unchanged. - editorRef.focus() -> editorRef().focus(); setCursorPosition(editorRef, ...) -> setCursorPosition(editorRef(), ...) (editorRef injected as a getter). - props.onEditLoaded?.() -> onEditLoaded() (injected thunk wrapping the optional call; fire timing preserved — synchronously after scheduling the rAF). The 7 copied context fields, the four setStore calls, prompt.set, and the rAF block are verbatim. props.edit / props.onEditLoaded are used only by this effect. prompt-input.tsx 601 -> 572; edit-load-effect.ts +63. Verification: typecheck 8/8, eslint clean on both files, targeted tests 404 pass / 2 pre-existing dev-base failures (command-prepend, path-b-integration: these deterministically fail locally because they value-import prompt.tsx which loads @solidjs/router, a client-only module that throws in bun's server test env without a router mock — neither imports the changed files, zero regression; a standalone fix PR is queued next). Independent review (codex, xhigh) GATE PASS, no P1/P2: byte-faithful effect body, equivalent reactivity, preserved defer, owner-scoped registration, correct imports. Residual risk: none — pure extraction.
Summary
Slice 2 of the serial prompt-input.tsx slimming line (slice 1 = #1083). Pure extraction — no behavior/DOM/aria/copy/storage-key change.
Moves the "commands + mode" cluster out of
prompt-input.tsxinto a new factoryprompt-input/commands-mode.ts(createPromptCommandsAndMode):pick()file-picker actionsetMode()and theshellModeKey/normalModeKeyconstantscommand.register("prompt-input", ...)registration (file.attach/prompt.mode.shell/prompt.mode.normal)The factory returns only
{ pick }—setModeand the mode keybinds have no external consumers (only the command handlers call them).pickis still consumed by the keydown handler and the attach button.Why it stays behavior-neutral
command.register's owner-scopedonCleanupand the registration order (relative tocreatePromptAttachmentsand theprops.editeffect) are unchanged.addPickedPathsis produced bycreatePromptAttachmentslater in the file, so it is injected as the accessor thunk() => addPickedPathsand resolved asaddPickedPaths()insidepick— preserving the pre-existing forward-reference closure timing (pick only runs post-mount).editorRefand the file-input click are injected as getters/callbacks.addPickedPaths→addPickedPaths(),editorRef?.focus()→editorRef()?.focus(),() => fileInputRef?.click()→fallbackInputClick. Command ids, themod+u/mod+shift+x/mod+shift+ekeybinds,language.tkeys, and the threedisabledexpressions are verbatim.canUseNativeFilePickerandpickAttachmentsimports fromprompt-input.tsx(keptusePlatform); both live in the new module.prompt-input.tsx637 → 601 lines;commands-mode.ts+84.Verification
bun run typecheck8/8 successfulbun test src/components/prompt-input/ session-action-readiness no-mode-picker→ 394 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)Residual risk
None — pure extraction. The file-picker fallback hits native paths (
platform.openFilePickerDialog), but that code is unchanged; a desktop walk of the attach flow can confirm if desired.