Skip to content

refactor(app): extract abort + pending registry from submit.ts - #1071

Merged
Astro-Han merged 2 commits into
devfrom
claude/submit-abort
Jun 2, 2026
Merged

refactor(app): extract abort + pending registry from submit.ts#1071
Astro-Han merged 2 commits into
devfrom
claude/submit-abort

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

Slice S3 of the submit.ts slimming production line (#1066). Pure extraction, no behavior change.

  • New packages/app/src/components/prompt-input/submit-abort.ts holds the AbortSource/PendingPrompt types, the shared pending map, the private emitAbortDiagnostic helper, and a createAbort(deps) factory containing the verbatim abort body.
  • submit.ts drops those definitions, imports { createAbort, pending } from the new module, and wires createAbort({ abortReady, sessionID, onAbort, client: sdk.client }). pending stays a shared module singleton (waitForWorktree's set/delete and the catch path keep using the imported map).
  • Dropped now-unused imports from submit.ts: sessionAbortDiagnosticEvent, the entire @/session/abort-source line (rendererAbortDiagnosticSource, RendererAbortSource). emitRendererDiagnostic stays (still used by the submit diagnostic).

No DOM/aria/copy/storage-key changes. abort behavior is covered by the existing submit.test.ts abort cases.

Test plan

  • bun run typecheck clean
  • bun test src/components/prompt-input/ — 382 pass / 2 pre-existing isPromptEqual fails (unchanged from baseline)
  • eslint clean on submit.ts + submit-abort.ts

Summary by CodeRabbit

  • Refactor
    • Internal restructuring of prompt submission abort handling to improve code organization and maintainability.

Move the AbortSource/PendingPrompt types, the shared pending map, and the
abort closure out of prompt-input/submit.ts into a new submit-abort.ts as a
createAbort(deps) factory. Pure extraction, no behavior change; submit.ts
imports the pending registry and wires createAbort with its existing deps.
@Astro-Han Astro-Han added the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label Jun 2, 2026
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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 24 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: 062ce4cc-08d4-4c51-8a6b-e3b7ae16d487

📥 Commits

Reviewing files that changed from the base of the PR and between 1f819be and 81233c0.

📒 Files selected for processing (2)
  • packages/app/src/components/prompt-input/submit-abort.ts
  • packages/app/src/components/prompt-input/submit.ts
📝 Walkthrough

Walkthrough

Extracts prompt submission abort handling logic into a dedicated module with shared types and factory pattern. Creates AbortSource type, PendingPrompt shape, and createAbort factory; then refactors submit.ts to use these helpers instead of inline abort code.

Changes

Abort handling extraction and refactoring

Layer / File(s) Summary
Abort types and shared state
packages/app/src/components/prompt-input/submit-abort.ts
Defines AbortSource as a constrained union of renderer abort origins, introduces PendingPrompt type to track in-flight abort controllers with cleanup callbacks, and establishes a shared pending map for session-keyed state management.
Abort factory and handler logic
packages/app/src/components/prompt-input/submit-abort.ts
Implements createAbort factory that returns an async abort handler; the handler validates readiness and session presence, optionally invokes a callback, handles queued prompts by canceling via the abort controller and running cleanup, or calls the SDK session abort endpoint and emits appropriate diagnostics ("aborted" or "ignored_awaiting_question") based on the response.
Integrate abort helper into prompt submission
packages/app/src/components/prompt-input/submit.ts
Updates imports to add createAbort and pending from the new module, removes the local abort implementation, and wires the abort handler by invoking createAbort with dependency-injected abort readiness, session ID, optional callback, and SDK client.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Astro-Han/pawwork#1043: Both PRs modify packages/app/src/components/prompt-input/submit.ts's createPromptSubmit submission lifecycle—this PR reworks abort handling to use shared createAbort/pending logic, while the other PR changes draft clear/restore behavior in the same submit flow.
  • Astro-Han/pawwork#556: Both PRs refactor the prompt-submission abort flow by centralizing abort diagnostics around createAbort and in-flight abortables, but PR #556 additionally introduces soft vs hard mode propagation into session.abort.
  • Astro-Han/pawwork#575: Both PRs touch the prompt-input abort flow in packages/app/src/components/prompt-input/submit.ts—this PR moves abort/diagnostic logic into the new submit-abort helper, while the other PR updates abort diagnostic emission to use sessionAbortDiagnosticEvent and pass route/visible/timeline session IDs.

Suggested labels

app, task, tech-debt

Poem

🐰 A helper born to handle the quit,
When fingers press escape or abort with grit,
No longer tangled in submit's embrace,
Clean separation finds its place,
Abort rejoices in its own space!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and does not follow the required template structure with critical sections missing or incomplete. Add missing required sections: set Human Review Status (currently missing), complete Review Focus section, replace example verification block with actual test results, confirm type/routing/priority labels in checklist, and verify all checklist items are completed before requesting review.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: extracting abort handling and the pending registry from submit.ts into a new module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/submit-abort

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.

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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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/submit-abort.ts, packages/app/src/components/prompt-input/submit.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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the prompt submission abort logic by extracting it from submit.ts into a new dedicated file submit-abort.ts. Feedback recommends updating the state tracking mechanism by deleting the session from the pending map before executing the abort and cleanup callbacks to prevent potential issues with synchronous re-entrant calls.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/app/src/components/prompt-input/submit-abort.ts
sdk.client is a directory-dependent getter, not a stable reference; capturing
it once at factory time would let a long-lived submit instance abort against a
stale workspace client. Read it lazily via () => sdk.client so the abort call
resolves the current client each invocation, matching the pre-extraction
behavior exactly.
@Astro-Han
Astro-Han merged commit b6d58be into dev Jun 2, 2026
33 of 34 checks passed
@Astro-Han
Astro-Han deleted the claude/submit-abort branch June 2, 2026 19:19
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