Skip to content

feat(api): add throwIfAborted helper and completePrompt options regression tests - #1288

Merged
edelauna merged 6 commits into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:feat/abort-r1-foundation
Sep 5, 2026
Merged

feat(api): add throwIfAborted helper and completePrompt options regression tests#1288
edelauna merged 6 commits into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:feat/abort-r1-foundation

Conversation

@easonLiangWorldedtech

@easonLiangWorldedtech easonLiangWorldedtech commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Add the missing throwIfAborted fast-fail guard and the shared abort-detection / abort-error helpers to the abort-signal utilities (#1008 merged the merge helpers but not this guard), plus regression tests for the CompletePromptOptions interface added by #901.

  • src/api/providers/utils/abort-signal.ts:
    • new throwIfAborted(signal?) — throws Error with name = "AbortError" when the signal is already aborted
    • new shared isRequestAborted(error, signal?) — true when the caller signal fired, a native AbortError / OpenAI SDK APIUserAbortError was raised, or the message is exactly "Request was aborted."
    • new shared createAbortError(providerName) — fresh AbortError with a provider-specific message ending in "aborted", satisfying the Task.ts abort contract
    • new exported OpenAiRequestOptions type
  • src/api/providers/utils/__tests__/abort-signal.spec.ts: 3 throwIfAborted tests (undefined / not aborted / aborted) + 7 new tests for the shared helpers
  • src/api/providers/__tests__/complete-prompt-options.spec.ts: new regression spec (4 tests) for the interface surface

Part of the abort-signal series (round 1). Builds on #674, #901, #1008. Addresses #404.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: fa28e9f3-4885-4251-b9f0-328d13cee5f1

📥 Commits

Reviewing files that changed from the base of the PR and between 74ecee0 and 3b63433.

📒 Files selected for processing (1)
  • src/api/providers/utils/__tests__/abort-signal.spec.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: platform-unit-test (windows-latest)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: compile
  • GitHub Check: Build test VSIX
  • GitHub Check: platform-unit-test (ubuntu-latest)
  • GitHub Check: e2e-mock
  • GitHub Check: mutation-diff
🧰 Additional context used
📓 Path-based instructions (5)
Treat model, provider, MCP, path, command, and tool data as untrusted.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/utils/__tests__/abort-signal.spec.ts
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/utils/__tests__/abort-signal.spec.ts
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/utils/__tests__/abort-signal.spec.ts
Verify extension/webview contracts, cancellation and error propagation, VS Code lifecycle correctness, and behavior under retries and partial failure.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/utils/__tests__/abort-signal.spec.ts
Act as an adversarial second-opinion reviewer.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/utils/__tests__/abort-signal.spec.ts
🔇 Additional comments (1)
src/api/providers/utils/__tests__/abort-signal.spec.ts (1)

133-133: LGTM!


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added support for request cancellation signals alongside timeout options.
    • Added consistent detection and provider-specific errors for cancelled requests.
  • Bug Fixes

    • Improved handling and reporting of cancellation across supported request and error formats.
  • Tests

    • Expanded coverage for cancellation signals, timeout options, combined settings, empty configurations, and cancellation error handling.

Walkthrough

The provider API now includes abort-signal guards, detection, and error creation utilities. Tests cover abort behavior and valid CompletePromptOptions combinations.

Changes

Provider API updates

Layer / File(s) Summary
Abort-signal utilities
src/api/providers/utils/abort-signal.ts
Added throwIfAborted, OpenAiRequestOptions, isRequestAborted, and createAbortError.
Abort-signal behavior coverage
src/api/providers/utils/__tests__/abort-signal.spec.ts
Expanded tests for signal states, native and SDK abort errors, exact abort messages, unrelated errors, and normalized error instances.
Completion option coverage
src/api/providers/__tests__/complete-prompt-options.spec.ts
Added tests for abortSignal, timeoutMs, both properties, and an empty options object.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 3b634

The abort-signal utility regression coverage is strengthened without introducing an identified runtime or API risk. The change is ready to merge.

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files.
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.
Regression Evidence ✅ Passed PASS. The changed abort utilities have focused unit coverage at the utility layer. throwIfAborted covers undefined, active, and already-aborted signals, including AbortError name and message. `isR…
Trust And Persistence Invariants ✅ Passed PASS. The PR adds only abort classification, normalized error creation, a type, and tests. throwIfAborted only checks an AbortSignal and throws a local error. isRequestAborted only reads error m…
Title check ✅ Passed The title is concise, specific, and accurately describes the abort guard and CompletePromptOptions regression tests. It does not mention every shared helper, but it remains clearly related to the main…
Description check ✅ Passed The description explains the implementation, issue context, affected files, and test coverage. It does not follow the full template because it omits the checklist and dedicated template sections, but …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ssion tests

Add a fast-fail throwIfAborted guard to the shared abort-signal utilities and regression tests for the CompletePromptOptions interface (added by Zoo-Code-Org#901).
@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

Series follow-up flag: adopt RequestConfigBuilder for abort/timeout option construction

This PR currently builds its abort/timeout request options directly with mergeAbortSignalAndTimeout(...) from src/api/providers/utils/abort-signal.ts. That is behaviorally identical to the RequestConfigBuilder path (src/api/providers/config-builder/request-config-builder.ts, introduced in #1008) - the builder wraps the same utility. The series plan is to make the builder the canonical call site for SDK request-option construction (typed TOptions variants per SDK), so this PR is flagged for that update.

Status: series foundation - nothing to migrate here. This PR ships the abort-signal utilities (including throwIfAborted and the timeout guard) that the builder delegates to; provider-side adoption is tracked on the individual provider PRs.

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

Round 1 — final status: all checks green, changed-line coverage verified

Part of the abort-signal series addressing #404 (builds on #674, #901, #1008). Foundation PR — canonical abort-signal utilities + CompletePromptOptions.

Final verified 2026-08-20: all CI checks green on this head (0 pending / 0 failed), CodeRabbit review clean, and zero new bot findings after this commit.

…o abort-signal utils

The OpenAI-family provider PRs (Zoo-Code-Org#1309, Zoo-Code-Org#1311) carry per-provider copies of the same abort-detection helper (isRequestAborted) and the same abort-error constructor (createAbortError); only the provider name in the message differs. Per the CodeRabbit maintainability finding on Zoo-Code-Org#1309 (extract the shared abort helpers into utils/abort-signal.ts), these are now shared in the foundation utility:
- isRequestAborted(error, signal?) - true when the caller signal fired, a native AbortError / OpenAI SDK APIUserAbortError was raised, or the message is exactly "Request was aborted." (exact match; a substring match would misclassify unrelated errors that merely mention aborting)
- createAbortError(providerName) - fresh error with name === "AbortError" and message "The <providerName> request was aborted", satisfying the Task.ts abort contract
- exported OpenAiRequestOptions type
7 new tests (isRequestAborted 4, createAbortError 3).
easonLiangWorldedtech added a commit to easonLiangWorldedtech/Zoo-Code that referenced this pull request Aug 21, 2026
…tudio and qwen-code

The per-provider copies of isRequestAborted / createAbortError /
OpenAiRequestOptions were extracted into src/api/providers/utils/abort-signal.ts by foundation PR Zoo-Code-Org#1288 (commit a0117fb) following the CodeRabbit maintainability finding on this PR; the providers now import the shared helpers. createAbortError takes the provider name as a parameter; provider behavior and abort messages are unchanged.
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: Awaiting fresh human maintainer or CODEOWNER approval.

Automated review is complete for the latest commit but does not replace human approval.

Review-state labels are managed by this workflow; do not edit them manually.

@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit awaiting-review PR changes are ready and waiting for maintainer re-review and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Aug 29, 2026
@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

@coderabbitai approve

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Comments resolved. Approval is disabled; enable reviews.request_changes_workflow to allow explicit top-level @coderabbitai resolve or @coderabbitai approve commands.

@github-actions github-actions Bot removed the coderabbit-review-active Required CI passed; CodeRabbit review is active label Sep 2, 2026
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions github-actions Bot removed the awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit label Sep 2, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 2, 2026
@github-actions github-actions Bot added the awaiting-maintainer CodeRabbit approved; waiting for a human maintainer label Sep 2, 2026
@edelauna
edelauna dismissed coderabbitai[bot]’s stale review September 4, 2026 01:06

bypassed review - will update ci

@edelauna edelauna added awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit and removed awaiting-maintainer CodeRabbit approved; waiting for a human maintainer labels Sep 4, 2026
@github-actions github-actions Bot added the coderabbit-review-active Required CI passed; CodeRabbit review is active label Sep 4, 2026
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit and removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Sep 4, 2026
The mutation-diff gate reports a surviving StringLiteral mutant on the throwIfAborted message literal. Assert the exact message so a blanked literal fails the suite.
@github-actions github-actions Bot removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Sep 4, 2026
@github-actions github-actions Bot added the awaiting-maintainer CodeRabbit approved; waiting for a human maintainer label Sep 4, 2026

@edelauna edelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-maintainer CodeRabbit approved; waiting for a human maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants