Skip to content

refactor(app): extract prompt-input edit-load effect into edit-load-effect.ts#1093

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

refactor(app): extract prompt-input edit-load effect into edit-load-effect.ts#1093
Astro-Han merged 1 commit into
devfrom
claude/prompt-input-edit-load

Conversation

@Astro-Han
Copy link
Copy Markdown
Owner

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 createEffect that loads an edit/followup draft into the editor (keyed on props.edit?.id) out of prompt-input.tsx into a new module prompt-input/edit-load-effect.ts (createEditLoadEffect, returns void).

Why it stays behavior-neutral

  • The factory is called synchronously at the effect's original position, so the effect registers in the component owner with { defer: true } intact and no ordering change. All injected deps (prompt, setStore, editorRef getter, queueScroll, editDraft, onEditLoaded) are available there — no late-binding.
  • props.edit → injected as the accessor editDraft: () => props.edit; the on() source () => editDraft()?.id still tracks props.edit?.id reactively, so the effect re-runs only on id change.
  • props.onEditLoaded → injected as the thunk () => props.onEditLoaded?.(), called unconditionally as onEditLoaded() — optional-chaining no-op semantics and the fire timing (synchronously after scheduling the rAF) are preserved.
  • The only textual changes are those injection seams: props.editeditDraft(), editorRef.focus()editorRef().focus(), setCursorPosition(editorRef, ...)setCursorPosition(editorRef(), ...), props.onEditLoaded?.()onEditLoaded(). 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 (verified), so no external surface changes. No newly-unused imports in prompt-input.tsx (setCursorPosition, on, promptLength all still used elsewhere).

prompt-input.tsx 601 → 572 lines; edit-load-effect.ts +63.

Verification

  • bun run typecheck 8/8 successful
  • eslint clean on both files
  • targeted tests: bun 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 found bun ESM load-order flake; neither imports the changed files, zero regression — a standalone PR to fix that flake is queued next)
  • independent review (codex, xhigh): GATE PASS, no P1/P2 — confirmed byte-faithful effect body, equivalent reactivity tracking, preserved { defer: true }, owner-scoped registration, correct/complete imports

Residual risk

None — pure extraction.

…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.
@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 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 @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: d122e3d3-4072-4972-9dba-877be1d0b3ac

📥 Commits

Reviewing files that changed from the base of the PR and between ab54578 and 16de17e.

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

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/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.

@Astro-Han Astro-Han merged commit cd78b3e into dev Jun 3, 2026
36 of 37 checks passed
@Astro-Han Astro-Han deleted the claude/prompt-input-edit-load branch June 3, 2026 02:04
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