Skip to content

fix: enforce onComplete requirement in audio recorder overloads - #1082

Merged
AlemTuzlak merged 2 commits into
TanStack:mainfrom
harshlocham:fix/audio-recorder-transforming-overload
Aug 21, 2026
Merged

fix: enforce onComplete requirement in audio recorder overloads#1082
AlemTuzlak merged 2 commits into
TanStack:mainfrom
harshlocham:fix/audio-recorder-transforming-overload

Conversation

@harshlocham

@harshlocham harshlocham commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #1001

🎯 Changes

The transforming useAudioRecorder overload could previously match options that did not provide onComplete. For example, passing only { onError } could select the transforming overload and cause recording / stop() to be inferred as unknown.

This updates the transforming overload across React, Vue, Solid, Svelte, and Angular so that onComplete is required when that overload is selected.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Fixed audio recorder type inference across Angular, Svelte, React, Solid, and Vue integrations.
    • Audio recordings now retain their correct types when options such as error handling are provided without a completion callback.
    • Transformed recording types continue to work correctly when an onComplete callback is supplied.
  • Tests

    • Added compile-time coverage for default, transformed, and callback-based audio recorder usage across supported integrations.

@coderabbitai

coderabbitai Bot commented Aug 11, 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5601a7a1-7008-4ad7-acc9-57bd8ae1c5b2

📥 Commits

Reviewing files that changed from the base of the PR and between f7c67a8 and 4fdea07.

📒 Files selected for processing (11)
  • .changeset/soft-teams-work.md
  • packages/ai-angular/src/inject-audio-recorder.ts
  • packages/ai-angular/tests/inject-audio-recorder-types.test.ts
  • packages/ai-react/src/use-audio-recorder.ts
  • packages/ai-react/tests/use-audio-recorder.test.tsx
  • packages/ai-solid/src/use-audio-recorder.ts
  • packages/ai-solid/tests/use-audio-recorder.test.ts
  • packages/ai-svelte/src/create-audio-recorder.svelte.ts
  • packages/ai-svelte/tests/create-audio-recorder.test.ts
  • packages/ai-vue/src/use-audio-recorder.ts
  • packages/ai-vue/tests/use-audio-recorder.test.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • packages/ai-solid/src/use-audio-recorder.ts
  • packages/ai-angular/src/inject-audio-recorder.ts
  • .changeset/soft-teams-work.md
  • packages/ai-solid/tests/use-audio-recorder.test.ts
  • packages/ai-vue/src/use-audio-recorder.ts
  • packages/ai-vue/tests/use-audio-recorder.test.ts
  • packages/ai-svelte/tests/create-audio-recorder.test.ts
  • packages/ai-react/src/use-audio-recorder.ts
  • packages/ai-angular/tests/inject-audio-recorder-types.test.ts
  • packages/ai-svelte/src/create-audio-recorder.svelte.ts
  • packages/ai-react/tests/use-audio-recorder.test.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The transforming audio-recorder overloads in Angular, React, Solid, Svelte, and Vue now require onComplete. Type tests verify raw AudioRecording inference for unrelated options and transformed output types when onComplete is supplied.

Changes

Audio recorder typing

Layer / File(s) Summary
Require onComplete for transforming overloads
packages/ai-angular/src/inject-audio-recorder.ts, packages/ai-react/src/use-audio-recorder.ts, packages/ai-solid/src/use-audio-recorder.ts, packages/ai-svelte/src/create-audio-recorder.svelte.ts, packages/ai-vue/src/use-audio-recorder.ts
The transforming overload in each adapter now requires onComplete. Calls with unrelated options resolve to the raw AudioRecording overload.
Validate overload inference
packages/ai-angular/tests/inject-audio-recorder-types.test.ts, packages/ai-react/tests/use-audio-recorder.test.tsx, packages/ai-solid/tests/use-audio-recorder.test.ts, packages/ai-svelte/tests/create-audio-recorder.test.ts, packages/ai-vue/tests/use-audio-recorder.test.ts, .changeset/soft-teams-work.md
Compile-time tests verify raw and transformed recording types, including recording and stop() results. The changeset records patch releases for the five packages.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 4fdea

This localized change makes onComplete required for the transforming audio-recorder overload across supported frameworks and adds corresponding tests; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 10 files. (1 skipped: 1 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: requiring onComplete for transforming audio recorder overloads.
Description check ✅ Passed The description explains the problem and fix, includes the relevant checklist items, and documents release impact and the changeset.
Linked Issues check ✅ Passed The changes satisfy issue #1001 across React, Vue, Solid, Svelte, and Angular, with regression tests and preserved untransformed overload behavior.
Out of Scope Changes check ✅ Passed All code, tests, and changeset updates directly support issue #1001 and the stated overload inference fix.
✨ 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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ai-angular/tests/inject-audio-recorder-types.test.ts`:
- Around line 1-8: Move the tests beside their related source modules and update
imports and Vitest discovery as needed:
packages/ai-angular/tests/inject-audio-recorder-types.test.ts (lines 1-8) beside
packages/ai-angular/src/inject-audio-recorder.ts;
packages/ai-react/tests/use-audio-recorder.test.tsx (lines 155-186) beside
packages/ai-react/src/use-audio-recorder.ts;
packages/ai-solid/tests/use-audio-recorder.test.ts (lines 125-141) beside
packages/ai-solid/src/use-audio-recorder.ts;
packages/ai-svelte/tests/create-audio-recorder.test.ts (lines 84-111) beside
packages/ai-svelte/src/create-audio-recorder.svelte.ts; and
packages/ai-vue/tests/use-audio-recorder.test.ts (lines 137-152) beside
packages/ai-vue/src/use-audio-recorder.ts. Preserve each test’s behavior and use
the adjacent *.test.ts naming convention.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 96cba639-9119-457f-ba91-cd306119069f

📥 Commits

Reviewing files that changed from the base of the PR and between 79d8812 and 3c3757e.

📒 Files selected for processing (11)
  • .changeset/soft-teams-work.md
  • packages/ai-angular/src/inject-audio-recorder.ts
  • packages/ai-angular/tests/inject-audio-recorder-types.test.ts
  • packages/ai-react/src/use-audio-recorder.ts
  • packages/ai-react/tests/use-audio-recorder.test.tsx
  • packages/ai-solid/src/use-audio-recorder.ts
  • packages/ai-solid/tests/use-audio-recorder.test.ts
  • packages/ai-svelte/src/create-audio-recorder.svelte.ts
  • packages/ai-svelte/tests/create-audio-recorder.test.ts
  • packages/ai-vue/src/use-audio-recorder.ts
  • packages/ai-vue/tests/use-audio-recorder.test.ts

Comment on lines +1 to +8
/**
* Type-level tests for `injectAudioRecorder` overload selection (issue #1001).
* Scenario functions are never executed (the injectable requires an injection
* context at runtime), so `expectTypeOf` runs as a no-op and `tsc`
* (`test:types`) is what validates them.
*/
import { describe, expectTypeOf, it } from 'vitest'
import { injectAudioRecorder } from '../src/inject-audio-recorder'

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Co-locate the new type tests with their source modules.

These tests are in package-level tests/ directories. Move each test beside its related source module. Update relative imports and test discovery configuration if required.

  • packages/ai-angular/tests/inject-audio-recorder-types.test.ts#L1-L8: Move the test beside packages/ai-angular/src/inject-audio-recorder.ts.
  • packages/ai-react/tests/use-audio-recorder.test.tsx#L155-L186: Move the test beside packages/ai-react/src/use-audio-recorder.ts.
  • packages/ai-solid/tests/use-audio-recorder.test.ts#L125-L141: Move the test beside packages/ai-solid/src/use-audio-recorder.ts.
  • packages/ai-svelte/tests/create-audio-recorder.test.ts#L84-L111: Move the test beside packages/ai-svelte/src/create-audio-recorder.svelte.ts.
  • packages/ai-vue/tests/use-audio-recorder.test.ts#L137-L152: Move the test beside packages/ai-vue/src/use-audio-recorder.ts.

As per coding guidelines, “Test files should be placed alongside source code as *.test.ts files using Vitest with happy-dom for DOM testing.”

📍 Affects 5 files
  • packages/ai-angular/tests/inject-audio-recorder-types.test.ts#L1-L8 (this comment)
  • packages/ai-react/tests/use-audio-recorder.test.tsx#L155-L186
  • packages/ai-solid/tests/use-audio-recorder.test.ts#L125-L141
  • packages/ai-svelte/tests/create-audio-recorder.test.ts#L84-L111
  • packages/ai-vue/tests/use-audio-recorder.test.ts#L137-L152
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ai-angular/tests/inject-audio-recorder-types.test.ts` around lines 1
- 8, Move the tests beside their related source modules and update imports and
Vitest discovery as needed:
packages/ai-angular/tests/inject-audio-recorder-types.test.ts (lines 1-8) beside
packages/ai-angular/src/inject-audio-recorder.ts;
packages/ai-react/tests/use-audio-recorder.test.tsx (lines 155-186) beside
packages/ai-react/src/use-audio-recorder.ts;
packages/ai-solid/tests/use-audio-recorder.test.ts (lines 125-141) beside
packages/ai-solid/src/use-audio-recorder.ts;
packages/ai-svelte/tests/create-audio-recorder.test.ts (lines 84-111) beside
packages/ai-svelte/src/create-audio-recorder.svelte.ts; and
packages/ai-vue/tests/use-audio-recorder.test.ts (lines 137-152) beside
packages/ai-vue/src/use-audio-recorder.ts. Preserve each test’s behavior and use
the adjacent *.test.ts naming convention.

Source: Coding guidelines

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR, @harshlocham! 🙌 @tombeckenham will take a look.

Automated pre-review checks

  • ✅ CI passing
  • ✅ No merge conflicts
  • ✅ Changeset present
  • ⚠️ No E2E test changes detected — behavior changes need coverage under testing/e2e/ (see CONTRIBUTING)

Automated triage — a human review follows.

@github-actions github-actions Bot added the waiting-on: maintainer The ball is in the maintainers’ court label Aug 13, 2026
@harshlocham
harshlocham force-pushed the fix/audio-recorder-transforming-overload branch from 91a9599 to 987b9db Compare August 15, 2026 14:27
@tombeckenham
tombeckenham force-pushed the fix/audio-recorder-transforming-overload branch from 987b9db to 0cb6c33 Compare August 20, 2026 10:12
@coderabbitai

coderabbitai Bot commented Aug 20, 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.

@nx-cloud

nx-cloud Bot commented Aug 20, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4fdea07

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 19s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-21 03:54:40 UTC

@tombeckenham
tombeckenham force-pushed the fix/audio-recorder-transforming-overload branch from 343b75d to 6680705 Compare August 20, 2026 10:49
@github-actions github-actions Bot added waiting-on: author Waiting for the author to respond or update and removed waiting-on: maintainer The ball is in the maintainers’ court labels Aug 20, 2026
harshlocham and others added 2 commits August 21, 2026 13:29
Updated the audio recorder functions across multiple frameworks to require the `onComplete` option in their overloads. This change prevents type inference issues where unrelated options could lead to collapsing the `recording` and `stop()` types to `unknown`. Added type-level tests to ensure correct behavior and maintain the `AudioRecording` type when options do not include `onComplete`. Addresses issue TanStack#1001.
@tombeckenham
tombeckenham force-pushed the fix/audio-recorder-transforming-overload branch from 6680705 to 4fdea07 Compare August 21, 2026 03:29
@coderabbitai

coderabbitai Bot commented Aug 21, 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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@1082

@tanstack/ai-acp

npm i https://pkg.pr.new/@tanstack/ai-acp@1082

@tanstack/ai-angular

npm i https://pkg.pr.new/@tanstack/ai-angular@1082

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@1082

@tanstack/ai-bedrock

npm i https://pkg.pr.new/@tanstack/ai-bedrock@1082

@tanstack/ai-byteplus

npm i https://pkg.pr.new/@tanstack/ai-byteplus@1082

@tanstack/ai-claude-code

npm i https://pkg.pr.new/@tanstack/ai-claude-code@1082

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@1082

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@1082

@tanstack/ai-code-mode-snippets

npm i https://pkg.pr.new/@tanstack/ai-code-mode-snippets@1082

@tanstack/ai-codex

npm i https://pkg.pr.new/@tanstack/ai-codex@1082

@tanstack/ai-cohere

npm i https://pkg.pr.new/@tanstack/ai-cohere@1082

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@1082

@tanstack/ai-durable-stream

npm i https://pkg.pr.new/@tanstack/ai-durable-stream@1082

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@1082

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@1082

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@1082

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@1082

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@1082

@tanstack/ai-grok-build

npm i https://pkg.pr.new/@tanstack/ai-grok-build@1082

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@1082

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@1082

@tanstack/ai-isolate-daytona

npm i https://pkg.pr.new/@tanstack/ai-isolate-daytona@1082

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@1082

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@1082

@tanstack/ai-isolate-quickjs-bun

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs-bun@1082

@tanstack/ai-mcp

npm i https://pkg.pr.new/@tanstack/ai-mcp@1082

@tanstack/ai-memory

npm i https://pkg.pr.new/@tanstack/ai-memory@1082

@tanstack/ai-mistral

npm i https://pkg.pr.new/@tanstack/ai-mistral@1082

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@1082

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@1082

@tanstack/ai-opencode

npm i https://pkg.pr.new/@tanstack/ai-opencode@1082

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@1082

@tanstack/ai-perplexity

npm i https://pkg.pr.new/@tanstack/ai-perplexity@1082

@tanstack/ai-persistence

npm i https://pkg.pr.new/@tanstack/ai-persistence@1082

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@1082

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@1082

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@1082

@tanstack/ai-sandbox

npm i https://pkg.pr.new/@tanstack/ai-sandbox@1082

@tanstack/ai-sandbox-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-sandbox-cloudflare@1082

@tanstack/ai-sandbox-daytona

npm i https://pkg.pr.new/@tanstack/ai-sandbox-daytona@1082

@tanstack/ai-sandbox-docker

npm i https://pkg.pr.new/@tanstack/ai-sandbox-docker@1082

@tanstack/ai-sandbox-local-process

npm i https://pkg.pr.new/@tanstack/ai-sandbox-local-process@1082

@tanstack/ai-sandbox-sprites

npm i https://pkg.pr.new/@tanstack/ai-sandbox-sprites@1082

@tanstack/ai-sandbox-vercel

npm i https://pkg.pr.new/@tanstack/ai-sandbox-vercel@1082

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@1082

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@1082

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@1082

@tanstack/ai-utils

npm i https://pkg.pr.new/@tanstack/ai-utils@1082

@tanstack/ai-vercel-gateway

npm i https://pkg.pr.new/@tanstack/ai-vercel-gateway@1082

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@1082

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@1082

@tanstack/openai-base

npm i https://pkg.pr.new/@tanstack/openai-base@1082

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@1082

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@1082

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@1082

commit: 4fdea07

@tombeckenham tombeckenham added waiting-on: maintainer The ball is in the maintainers’ court and removed waiting-on: author Waiting for the author to respond or update labels Aug 21, 2026
@AlemTuzlak
AlemTuzlak merged commit 849d666 into TanStack:main Aug 21, 2026
9 checks passed
@harshlocham
harshlocham deleted the fix/audio-recorder-transforming-overload branch August 21, 2026 08:36
@github-actions github-actions Bot mentioned this pull request Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on: maintainer The ball is in the maintainers’ court

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useAudioRecorder: transforming overload matches options without onComplete, collapsing recording/stop() to unknown

3 participants