Skip to content

refactor(app): extract prompt-input commands+mode into commands-mode.ts#1091

Merged
Astro-Han merged 1 commit into
devfrom
claude/prompt-input-commands-mode
Jun 3, 2026
Merged

refactor(app): extract prompt-input commands+mode into commands-mode.ts#1091
Astro-Han merged 1 commit into
devfrom
claude/prompt-input-commands-mode

Conversation

@Astro-Han
Copy link
Copy Markdown
Owner

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.tsx into a new factory prompt-input/commands-mode.ts (createPromptCommandsAndMode):

  • the pick() file-picker action
  • setMode() and the shellModeKey/normalModeKey constants
  • the command.register("prompt-input", ...) registration (file.attach / prompt.mode.shell / prompt.mode.normal)

The factory returns only { pick }setMode and the mode keybinds have no external consumers (only the command handlers call them). pick is still consumed by the keydown handler and the attach button.

Why it stays behavior-neutral

  • The factory is invoked synchronously at the cluster's original position, so command.register's owner-scoped onCleanup and the registration order (relative to createPromptAttachments and the props.edit effect) are 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 (pick only runs post-mount). editorRef and the file-input click are injected as getters/callbacks.
  • The only textual changes are those three injection seams: addPickedPathsaddPickedPaths(), editorRef?.focus()editorRef()?.focus(), () => fileInputRef?.click()fallbackInputClick. Command ids, the mod+u/mod+shift+x/mod+shift+e keybinds, language.t keys, and the three disabled expressions are verbatim.
  • Removed the now-unused canUseNativeFilePicker and pickAttachments imports from prompt-input.tsx (kept usePlatform); both live in the new module.

prompt-input.tsx 637 → 601 lines; commands-mode.ts +84.

Verification

  • bun run typecheck 8/8 successful
  • eslint clean on both files
  • targeted tests: bun test src/components/prompt-input/ session-action-readiness no-mode-picker → 394 pass / 2 pre-existing dev-base failures (command-prepend, path-b-integrationisPromptEqual not found bun ESM load-order flake; neither imports the changed files, zero regression)
  • independent review (codex, xhigh): GATE PASS, no P1/P2 — confirmed byte-faithful logic, no construction-time TDZ on the thunk, owner-scoped registration preserved, reactivity preserved, imports correct, registration order unchanged

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.

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.
@Astro-Han Astro-Han added the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label Jun 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d92e9a3-16b8-4aef-9be7-18d417f8341a

📥 Commits

Reviewing files that changed from the base of the PR and between dc84074 and 93a8140.

📒 Files selected for processing (2)
  • packages/app/src/components/prompt-input.tsx
  • packages/app/src/components/prompt-input/commands-mode.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/prompt-input-commands-mode

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added app Application behavior and product flows ui Design system and user interface P2 Medium priority labels Jun 3, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Astro-Han Astro-Han merged commit a88d3d7 into dev Jun 3, 2026
36 of 37 checks passed
@Astro-Han Astro-Han deleted the claude/prompt-input-commands-mode branch June 3, 2026 01:35
Astro-Han added a commit that referenced this pull request Jun 3, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows P2 Medium priority task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work ui Design system and user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant