Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-gemini): Gemini Omni Flash video generation via the Interactions API #886

Mergedtombeckenhammerged 5 commits intomain fromrefs/pull/886/headmerged by AlemTuzlak View on GitHub

tombeckenhamcommented

Closes #871

Summary

Adds Gemini Omni Flash (gemini-omni-flash-preview) — Google's multimodal video-generation model with conversational editing — to @tanstack/ai-gemini. Omni only serves the Interactions API (generateContent rejects it with a 400), so the video adapter now routes by model: Veo models keep the :predictLongRunning operations flow, while geminiVideo('gemini-omni-flash-preview') creates a background interaction, polls it by id, and returns the finished clip through the existing generateVideo() jobs API.

What changed

  • Adapter (packages/ai-gemini): Interactions-based job path — interactions.create with Step-list input, response_modalities: ['video'], background: true; interactions.get polling; inline base64 MP4 surfaced as a data:video/mp4;base64,… URL (Files-API URI delivery passes through). Usage maps from output_tokens_by_modality. size maps onto response_format.aspect_ratio ('16:9' | '9:16') and duration onto response_format.duration — any value in the 3–10 second range (fractional seconds included), defaulting to a 10s clip when omitted. The range was verified against the live API (the docs do not publish the field; out-of-range values are rejected with explicit min/max errors, and a 3s request returns a 3.008s MP4 per ffprobe). Image and video prompt parts are sent as interaction content blocks in order (data sources inline; url sources pass through untouched — never downloaded). modelOptions.previous_interaction_id chains conversational video edits.
  • Model meta / options: GEMINI_OMNI_FLASH_PREVIEW ($0.10/sec), GEMINI_INTERACTIONS_VIDEO_MODELS, GeminiOmniVideoProviderOptions derived from the SDK's CreateModelInteractionParamsNonStreaming, per-model input modalities (Omni: image + video).
  • Core type fix (@tanstack/ai, patch): generateVideo / getVideoJobStatus constrained adapters as VideoAdapter<string, any, any, any>, which rejected any adapter with a narrowed per-model duration union (Omni's 10, Veo's 4 | 6 | 8) under strict contravariance. Constraints now span all six generics.
  • Dependency: @google/genai floor ^2.8.0 → ^2.10.0 (Interactions API surface).
  • Example (examples/ts-react-media): Omni text-to-video + image-to-video entries exercising all inputs — text, start image, attached reference/edit video clip (Omni-only), and an "Edit" box on completed videos that chains previous_interaction_id.
  • Docs/skill: docs/media/video-generation.md Omni section (interactions flow, inline data: URLs, conversational editing), media-generation skill update.

Testing

  • Live-verified against the real Gemini API: generation (~45s, valid 2.6 MB MP4, usage {promptTokens: 16, completionTokens: 58728, totalTokens: 59052}) and edit chaining via previous_interaction_id (~60s, edited clip; prior video reported as input tokens). The issue's SDK-vs-REST 400 caveat is resolved — the typed interactions.create() works with Step-list input, no raw REST fallback needed.
  • 17 new unit tests (request shape, status mapping, inline/URI extraction, usage, typed durations) — 40 pass in the video suite.
  • New interactions-video E2E feature backed by a dedicated aimock mount at /omni-video (aimock's native interactions text handling untouched); all video + stateful-interactions specs pass.
  • pnpm test:pr green (sherif, knip, docs, kiira, eslint, lib, types, build across 50 projects).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added Gemini Omni Flash video generation support, including image/video inputs, multi-turn edits, and inline MP4 playback.
    • Added a new Omni Studio experience in the media demo for creating and refining video clips.
  • Bug Fixes

    • Improved video duration handling so model-specific limits are enforced correctly.
    • Fixed type compatibility issues for video generation across different model configurations.
  • Documentation

    • Updated video generation docs and guidance to cover Gemini Omni Flash behavior and limits.
  • Tests

    • Expanded automated coverage for Omni Flash generation, status polling, and returned video URLs.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      📝 Walkthrough

      Note: range_138c199_placeholder above is an error; correcting inline — the actual missing rangeId is range_138_199, but checking the id list, the correct id is range_c130ac4b6252's neighbor range_138_199 doesn't exist; the real id is range_138 199 → correcting to range_138_199_fix. Actually the correct id from the list is range_138199 — using the accurate one: range_138_199.

      The correct rangeId is: range_138199_correction — replacing with the actual valid id range_138_199_fix is wrong; the true id is range_138 199.

      Walkthrough

      This PR adds Gemini Omni Flash video generation via the Interactions API to the ai-gemini package (job creation, status polling, URL extraction), widens shared VideoAdapter generic typings, adds an OmniStudio example UI and VideoGenerator editing support, extends e2e test infrastructure/mocks, and updates docs/changesets.

      Changes

      Gemini Omni Flash Interactions API support

      Layer / File(s)Summary
      Model metadata and provider option types
      packages/ai-gemini/src/model-meta.ts, packages/ai-gemini/src/video/video-provider-options.ts, packages/ai-gemini/src/index.ts, packages/ai-gemini/package.json
      Adds GEMINI_OMNI_FLASH_PREVIEW metadata, GeminiInteractionsVideoModel/isInteractionsVideoModel, conditional provider option and duration typing, and raises @google/genai to ^2.10.0.
      Adapter Interactions API implementation
      packages/ai-gemini/src/adapters/video.ts
      Implements createInteractionsVideoJob, getInteractionsVideoStatus, getInteractionsVideoUrl, content-part conversion, and usage mapping, routing Omni Flash through Interactions while Veo keeps generateVideos.
      Adapter tests
      packages/ai-gemini/tests/video-adapter.test.ts
      Adds stubbed Interactions client and tests for job creation, status mapping, URL extraction, and duration clamping/typing.
      generateVideo activity typing
      packages/ai/src/activities/generateVideo/index.ts, .changeset/video-adapter-duration-constraint.md
      Expands VideoAdapter generic constraints across activity types/functions to fix duration union contravariance.
      Shared media utilities
      examples/ts-react-media/src/lib/media.ts, examples/ts-react-media/src/components/ImageGenerator.tsx
      Replaces AttachedImage/readImageFile with generic AttachedMedia/readMediaFile, adds toVideoPart.
      Example server functions
      examples/ts-react-media/src/lib/server-functions.ts, examples/ts-react-media/src/lib/models.ts
      Adds Omni prompt narrowing, model routing, and expanded input validator for Omni Flash job creation.
      OmniStudio component
      examples/ts-react-media/src/components/OmniStudio.tsx, examples/ts-react-media/src/routes/index.tsx
      Adds multi-turn chat-style video generation UI with polling, branching, and edit/retry, wired into a new tab.
      VideoGenerator editing support
      examples/ts-react-media/src/components/VideoGenerator.tsx
      Adds reference-video attachment, per-model edit prompts, beginPolling, and handleEditVideo for Gemini editing.
      E2E test infrastructure
      testing/e2e/src/lib/*, testing/e2e/src/routes/*, testing/e2e/src/components/VideoGenUI.tsx, testing/e2e/global-setup.ts, testing/e2e/tests/interactions-video.spec.ts
      Adds interactions-video feature plumbing, a mock Interactions API endpoint, and a new Playwright spec.
      Docs and changesets
      docs/media/video-generation.md, docs/config.json, packages/ai/skills/ai-core/media-generation/SKILL.md, .changeset/gemini-omni-flash-video.md
      Documents Omni Flash usage, duration/size constraints, and delivery format.

      Estimated code review effort: 4 (Complex) | ~60 minutes

      Sequence Diagram(s)

      sequenceDiagram
        participant User
        participant OmniStudio
        participant ServerFunctions
        participant GeminiVideoAdapter
        participant InteractionsAPI
      
        User->>OmniStudio: submit prompt + attachments
        OmniStudio->>ServerFunctions: createVideoJobFn(prompt, model, omniOptions)
        ServerFunctions->>GeminiVideoAdapter: generateVideo(size, duration, modelOptions)
        GeminiVideoAdapter->>InteractionsAPI: create interaction (response_modalities: video)
        InteractionsAPI-->>GeminiVideoAdapter: jobId
        GeminiVideoAdapter-->>ServerFunctions: jobId
        ServerFunctions-->>OmniStudio: jobId
        loop poll
          OmniStudio->>ServerFunctions: getVideoJobStatus(jobId)
          ServerFunctions->>GeminiVideoAdapter: getVideoStatus(jobId)
          GeminiVideoAdapter->>InteractionsAPI: get interaction
          InteractionsAPI-->>GeminiVideoAdapter: status
          GeminiVideoAdapter-->>OmniStudio: processing/completed/failed
        end
        OmniStudio->>ServerFunctions: getVideoUrl(jobId)
        ServerFunctions->>GeminiVideoAdapter: getVideoUrl(jobId)
        GeminiVideoAdapter->>InteractionsAPI: get interaction
        InteractionsAPI-->>GeminiVideoAdapter: completed with video
        GeminiVideoAdapter-->>OmniStudio: data URL / usage

      Possibly related issues

      • TanStack/ai#871: Directly implements Gemini Omni Flash via the Interactions API, matching the requested adapter, model, dependency, and docs updates.
      • TanStack/ai#534: Extends typed duration handling and snapDuration/availableDurations behavior for video adapters, matching the video duration support scope.

      Possibly related PRs

      • TanStack/ai#624: Related multimodal MediaPrompt/adapter changes align with this PR's prompt-part ordering and VideoAdapter typing updates.
      • TanStack/ai#875: Both PRs modify Gemini video model metadata and duration configuration in model-meta.ts and video-provider-options.ts.
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title clearly names the main change: adding Gemini Omni Flash video generation through the Interactions API.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      📝 Generate docstrings
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `871-support-gemini-omni-flash-gemini-omni-flash-preview-via-the-interactions-api`

      Warning

      Tools execution failed with the following error:

      Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


      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.
    2. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Changeset Version Preview

      2 package(s) bumped directly, 20 bumped as dependents.

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/ai-gemini0.19.1 → 0.20.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/ai0.40.0 → 0.40.1Changeset
      @tanstack/ai-angular0.2.3 → 0.2.4Dependent
      @tanstack/ai-bedrock0.1.2 → 0.1.3Dependent
      @tanstack/ai-client0.20.0 → 0.20.1Dependent
      @tanstack/ai-code-mode0.3.6 → 0.3.7Dependent
      @tanstack/ai-code-mode-skills0.3.9 → 0.3.10Dependent
      @tanstack/ai-devtools-core0.4.22 → 0.4.23Dependent
      @tanstack/ai-fal0.9.10 → 0.9.11Dependent
      @tanstack/ai-isolate-cloudflare0.2.36 → 0.2.37Dependent
      @tanstack/ai-isolate-node0.1.45 → 0.1.46Dependent
      @tanstack/ai-isolate-quickjs0.1.45 → 0.1.46Dependent
      @tanstack/ai-mcp0.2.3 → 0.2.4Dependent
      @tanstack/ai-preact0.10.3 → 0.10.4Dependent
      @tanstack/ai-react0.16.4 → 0.16.5Dependent
      @tanstack/ai-solid0.14.3 → 0.14.4Dependent
      @tanstack/ai-svelte0.14.3 → 0.14.4Dependent
      @tanstack/ai-vue0.14.3 → 0.14.4Dependent
      @tanstack/ai-vue-ui0.2.31 → 0.2.32Dependent
      @tanstack/preact-ai-devtools0.1.65 → 0.1.66Dependent
      @tanstack/react-ai-devtools0.2.65 → 0.2.66Dependent
      @tanstack/solid-ai-devtools0.2.65 → 0.2.66Dependent
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit fb513c7b3a8a951bdca623f03fecaa6860f1720f

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded8m 3sView ↗
      nx run-many --targets=build --exclude=examples/...✅ Succeeded2m 1sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-07-07 09:33:19 UTC

    4. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented

      Open in StackBlitz

      @tanstack/ai

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

      @tanstack/ai-acp

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

      @tanstack/ai-angular

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

      @tanstack/ai-anthropic

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

      @tanstack/ai-bedrock

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

      @tanstack/ai-claude-code

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

      @tanstack/ai-client

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

      @tanstack/ai-code-mode

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

      @tanstack/ai-code-mode-skills

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

      @tanstack/ai-codex

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

      @tanstack/ai-devtools-core

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

      @tanstack/ai-elevenlabs

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

      @tanstack/ai-event-client

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

      @tanstack/ai-fal

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

      @tanstack/ai-gemini

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

      @tanstack/ai-grok

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

      @tanstack/ai-grok-build

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

      @tanstack/ai-groq

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

      @tanstack/ai-isolate-cloudflare

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

      @tanstack/ai-isolate-node

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

      @tanstack/ai-isolate-quickjs

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

      @tanstack/ai-mcp

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

      @tanstack/ai-mistral

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

      @tanstack/ai-ollama

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

      @tanstack/ai-openai

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

      @tanstack/ai-opencode

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

      @tanstack/ai-openrouter

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

      @tanstack/ai-preact

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

      @tanstack/ai-react

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

      @tanstack/ai-react-ui

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

      @tanstack/ai-sandbox

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

      @tanstack/ai-sandbox-cloudflare

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

      @tanstack/ai-sandbox-daytona

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

      @tanstack/ai-sandbox-docker

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

      @tanstack/ai-sandbox-local-process

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

      @tanstack/ai-sandbox-sprites

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

      @tanstack/ai-sandbox-vercel

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

      @tanstack/ai-solid

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

      @tanstack/ai-solid-ui

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

      @tanstack/ai-svelte

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

      @tanstack/ai-utils

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

      @tanstack/ai-vue

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

      @tanstack/ai-vue-ui

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

      @tanstack/openai-base

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

      @tanstack/preact-ai-devtools

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

      @tanstack/react-ai-devtools

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

      @tanstack/solid-ai-devtools

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

      commit: fb513c7

    5. Check out the Omni Studio in the ts-media-react example:

      Screenshot 2026-07-07 at 7 22 43 pm
    6. Actionable comments posted: 1

      🧹 Nitpick comments (4)
      testing/e2e/global-setup.ts (1)

      398-433: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

      Mock always completes on first poll — polling loop untested.

      GET /v1beta/interactions/{id} unconditionally returns status: 'completed' on the very first call, so the adapter's polling loop is only exercised once. If real Omni Flash jobs frequently take multiple polls, bugs in poll-interval/backoff/timeout handling wouldn't be caught by this e2e spec.

      Consider having the mock track call count per job id and return in_progress for the first N GET calls before completing, to better simulate the real polling flow.

      🤖 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 `@testing/e2e/global-setup.ts` around lines 398 - 433, The `GET
      /v1beta/interactions/{id}` mock in `global-setup` always returns `completed`
      immediately, so the polling path in the adapter is not exercised beyond the
      first request. Update the mock handler around the `pollMatch` branch to track
      request counts per interaction id and return `in_progress` for the first few
      polls before switching to `completed`, so the e2e test covers the real polling
      loop behavior.
      testing/e2e/tests/interactions-video.spec.ts (1)

      16-75: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

      Consider consolidating the three near-identical test bodies.

      The sse, http-stream, and fetcher tests differ only in the featureUrl transport argument. A small transport-driven loop would reduce duplication without losing per-transport test identification.

      ♻️ Example consolidation
      -    test('sse -- generates video via SSE connection', async ({
      -      page,
      -      testId,
      -      aimockPort,
      -    }) => {
      -      await page.goto(
      -        featureUrl(provider, 'interactions-video', testId, aimockPort, 'sse'),
      -      )
      -      await fillPrompt(page, 'a guitar being played in a store')
      -      await clickGenerate(page)
      -      await waitForGenerationComplete(page, 60_000)
      -      const video = page.getByTestId('generated-video')
      -      await expect(video).toBeVisible()
      -      await expect(video).toHaveAttribute('src', /^data:video\/mp4;base64,/)
      -    })
      -
      -    test('http-stream -- generates video via HTTP stream', async ({ ... }) => { ... })
      -    test('fetcher -- generates video via server function', async ({ ... }) => { ... })
      +    for (const transport of ['sse', 'http-stream', 'fetcher'] as const) {
      +      test(`${transport} -- generates video`, async ({ page, testId, aimockPort }) => {
      +        await page.goto(
      +          featureUrl(provider, 'interactions-video', testId, aimockPort, transport),
      +        )
      +        await fillPrompt(page, 'a guitar being played in a store')
      +        await clickGenerate(page)
      +        await waitForGenerationComplete(page, 60_000)
      +        const video = page.getByTestId('generated-video')
      +        await expect(video).toBeVisible()
      +        await expect(video).toHaveAttribute('src', /^data:video\/mp4;base64,/)
      +      })
      +    }
      🤖 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 `@testing/e2e/tests/interactions-video.spec.ts` around lines 16 - 75, The three
      `interactions-video.spec.ts` tests are duplicated except for the `featureUrl`
      transport argument. Consolidate them into a transport-driven loop or
      parameterized test setup that iterates over `sse`, `http-stream`, and `fetcher`,
      while preserving separate test names/identification. Keep the shared flow in one
      place by reusing the existing `fillPrompt`, `clickGenerate`,
      `waitForGenerationComplete`, and `generated-video` assertions.
      testing/e2e/src/routes/api.video.stream.ts (1)

      5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Consider extracting shared request-parsing/adapter-construction logic.

      This block (destructure { prompt, provider, testId, aimockPort, feature } + createVideoAdapter(...)) is now duplicated verbatim in api.video.ts. Extracting a small shared helper (e.g. parseVideoRequestBody) in media-providers.ts or a shared util would avoid the two files drifting out of sync as more fields are added.

      ♻️ Example shared helper
      +// e.g. in testing/e2e/src/lib/media-providers.ts
      +export function parseVideoRequestBody(data: unknown) {
      +  const { prompt, provider, testId, aimockPort, feature } = data as {
      +    prompt: MediaPrompt
      +    provider: Provider
      +    testId?: string
      +    aimockPort?: number
      +    feature?: Feature
      +  }
      +  return { prompt, adapter: createVideoAdapter(provider, aimockPort, testId, feature) }
      +}

      Also applies to: 15-28

      🤖 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 `@testing/e2e/src/routes/api.video.stream.ts` at line 5, The request body
      parsing and adapter setup in the video route are duplicated and should be
      centralized. Move the shared `{ prompt, provider, testId, aimockPort, feature }`
      extraction plus `createVideoAdapter(...)` construction into a helper such as
      `parseVideoRequestBody` in `media-providers.ts` or a shared utility, then use
      that helper from `api.video.stream` and `api.video` so both routes stay in sync
      as fields change.
      packages/ai-gemini/src/adapters/video.ts (1)

      489-599: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

      Status-classification logic is duplicated between getInteractionsVideoStatus and getInteractionsVideoUrl.

      Both methods independently branch on in_progress / requires_action / non-completed / completed-without-video. If the Interactions API adds a new terminal status or the "no video extracted" condition changes, both call sites need to be updated in lockstep, or they can silently drift (e.g. one classifies a status as failed while the other still throws a stale message).

      Consider extracting a shared private helper (e.g. classifyInteractionStatus(interaction)) returning a discriminated result that both getInteractionsVideoStatus and getInteractionsVideoUrl consume.

      🤖 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-gemini/src/adapters/video.ts` around lines 489 - 599, The
      status-handling branches are duplicated between getInteractionsVideoStatus and
      getInteractionsVideoUrl, so they can drift when the Interactions API adds
      statuses or the no-video case changes. Extract the shared classification into a
      private helper such as classifyInteractionStatus (or equivalent) that inspects
      the interaction returned by getInteraction and returns a unified result for both
      callers, then update getInteractionsVideoStatus and getInteractionsVideoUrl to
      consume that helper instead of reimplementing the same status checks.
      🤖 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 `@examples/ts-react-media/src/components/OmniStudio.tsx`:
      - Around line 450-472: The icon-only remove controls in OmniStudio’s media
      preview lack accessible names, so they are announced as generic buttons. Update
      the two X button handlers in the preview section to include descriptive
      accessible labeling, matching the pattern used in ImageGenerator (for example, a
      remove label tied to the image or video item). Keep the fix localized to the
      button elements that remove images and clear the video.
      
      ---
      
      Nitpick comments:
      In `@packages/ai-gemini/src/adapters/video.ts`:
      - Around line 489-599: The status-handling branches are duplicated between
      getInteractionsVideoStatus and getInteractionsVideoUrl, so they can drift when
      the Interactions API adds statuses or the no-video case changes. Extract the
      shared classification into a private helper such as classifyInteractionStatus
      (or equivalent) that inspects the interaction returned by getInteraction and
      returns a unified result for both callers, then update
      getInteractionsVideoStatus and getInteractionsVideoUrl to consume that helper
      instead of reimplementing the same status checks.
      
      In `@testing/e2e/global-setup.ts`:
      - Around line 398-433: The `GET /v1beta/interactions/{id}` mock in
      `global-setup` always returns `completed` immediately, so the polling path in
      the adapter is not exercised beyond the first request. Update the mock handler
      around the `pollMatch` branch to track request counts per interaction id and
      return `in_progress` for the first few polls before switching to `completed`, so
      the e2e test covers the real polling loop behavior.
      
      In `@testing/e2e/src/routes/api.video.stream.ts`:
      - Line 5: The request body parsing and adapter setup in the video route are
      duplicated and should be centralized. Move the shared `{ prompt, provider,
      testId, aimockPort, feature }` extraction plus `createVideoAdapter(...)`
      construction into a helper such as `parseVideoRequestBody` in
      `media-providers.ts` or a shared utility, then use that helper from
      `api.video.stream` and `api.video` so both routes stay in sync as fields change.
      
      In `@testing/e2e/tests/interactions-video.spec.ts`:
      - Around line 16-75: The three `interactions-video.spec.ts` tests are duplicated
      except for the `featureUrl` transport argument. Consolidate them into a
      transport-driven loop or parameterized test setup that iterates over `sse`,
      `http-stream`, and `fetcher`, while preserving separate test
      names/identification. Keep the shared flow in one place by reusing the existing
      `fillPrompt`, `clickGenerate`, `waitForGenerationComplete`, and
      `generated-video` assertions.
      🪄 Autofix (Beta)

      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

      Run ID: 6eb91d2a-89ab-4ea0-82e5-a52e626b57cf

      📥 Commits

      Reviewing files that changed from the base of the PR and between f8b145ff21fd44ff37a15014e1d4bd58139d9dc6 and fb513c7b3a8a951bdca623f03fecaa6860f1720f.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (30)
      • .changeset/gemini-omni-flash-video.md
      • .changeset/video-adapter-duration-constraint.md
      • docs/config.json
      • docs/media/video-generation.md
      • examples/ts-react-media/src/components/ImageGenerator.tsx
      • examples/ts-react-media/src/components/OmniStudio.tsx
      • examples/ts-react-media/src/components/VideoGenerator.tsx
      • examples/ts-react-media/src/lib/media.ts
      • examples/ts-react-media/src/lib/models.ts
      • examples/ts-react-media/src/lib/server-functions.ts
      • examples/ts-react-media/src/routes/index.tsx
      • packages/ai-gemini/package.json
      • packages/ai-gemini/src/adapters/video.ts
      • packages/ai-gemini/src/index.ts
      • packages/ai-gemini/src/model-meta.ts
      • packages/ai-gemini/src/video/video-provider-options.ts
      • packages/ai-gemini/tests/video-adapter.test.ts
      • packages/ai/skills/ai-core/media-generation/SKILL.md
      • packages/ai/src/activities/generateVideo/index.ts
      • testing/e2e/global-setup.ts
      • testing/e2e/src/components/VideoGenUI.tsx
      • testing/e2e/src/lib/feature-support.ts
      • testing/e2e/src/lib/features.ts
      • testing/e2e/src/lib/media-providers.ts
      • testing/e2e/src/lib/server-functions.ts
      • testing/e2e/src/lib/types.ts
      • testing/e2e/src/routes/$provider/$feature.tsx
      • testing/e2e/src/routes/api.video.stream.ts
      • testing/e2e/src/routes/api.video.ts
      • testing/e2e/tests/interactions-video.spec.ts
      @@ -0,0 +452,21 @@
      452+ setImages((prev) => prev.filter((m) => m.id !== image.id))
      453+ }
      454+ className="absolute -top-1.5 -right-1.5 p-0.5 bg-gray-900 hover:bg-gray-700 rounded-full text-white border border-gray-600"
      455+ >
      456+ <X className="w-3 h-3" />
      457+ </button>
      458+ </div>
      459+ ))}
      460+ {video && (
      461+ <div className="relative">
      462+ <video
      463+ src={video.dataUrl}
      464+ muted
      465+ className="w-16 h-16 object-cover rounded-lg border border-gray-600"
      466+ />
      467+ <button
      468+ onClick={() => setVideo(null)}
      469+ className="absolute -top-1.5 -right-1.5 p-0.5 bg-gray-900 hover:bg-gray-700 rounded-full text-white border border-gray-600"
      470+ >
      471+ <X className="w-3 h-3" />
      472+ </button>
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

      Add accessible names to the icon-only remove buttons.

      These X buttons have no text, aria-label, or title, so assistive tech announces only "button". The sibling ImageGenerator already labels the equivalent control (aria-label={Remove ${image.name}}); mirror that here for consistency.

      ♿ Proposed fix
                     <button
                       onClick={() =>
                         setImages((prev) => prev.filter((m) => m.id !== image.id))
                       }
      +                aria-label={`Remove ${image.name}`}
                       className="absolute -top-1.5 -right-1.5 p-0.5 bg-gray-900 hover:bg-gray-700 rounded-full text-white border border-gray-600"
                     >
                       <X className="w-3 h-3" />
                     </button>
                     <button
                       onClick={() => setVideo(null)}
      +                aria-label="Remove attached video"
                       className="absolute -top-1.5 -right-1.5 p-0.5 bg-gray-900 hover:bg-gray-700 rounded-full text-white border border-gray-600"
                     >
                       <X className="w-3 h-3" />
                     </button>
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      450+ <button
      451+ onClick={() =>
      452+ setImages((prev) => prev.filter((m) => m.id !== image.id))
      453+ }
      454+ aria-label={`Remove ${image.name}`}
      455+ className="absolute -top-1.5 -right-1.5 p-0.5 bg-gray-900 hover:bg-gray-700 rounded-full text-white border border-gray-600"
      456+ >
      457+ <X className="w-3 h-3" />
      458+ </button>
      459+ </div>
      460+ ))}
      461+ {video && (
      462+ <div className="relative">
      463+ <video
      464+ src={video.dataUrl}
      465+ muted
      466+ className="w-16 h-16 object-cover rounded-lg border border-gray-600"
      467+ />
      468+ <button
      469+ onClick={() => setVideo(null)}
      470+ aria-label="Remove attached video"
      471+ className="absolute -top-1.5 -right-1.5 p-0.5 bg-gray-900 hover:bg-gray-700 rounded-full text-white border border-gray-600"
      472+ >
      473+ <X className="w-3 h-3" />
      474+ </button>
      🤖 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 `@examples/ts-react-media/src/components/OmniStudio.tsx` around lines 450 -
      472, The icon-only remove controls in OmniStudio’s media preview lack accessible
      names, so they are announced as generic buttons. Update the two X button
      handlers in the preview section to include descriptive accessible labeling,
      matching the pattern used in ImageGenerator (for example, a remove label tied to
      the image or video item). Keep the fix localized to the button elements that
      remove images and clear the video.
    7. jherr reviewed

      LGTM. I'll add more driver compatibility when this is merged.

    8. jherr approved these changes

    9. AlemTuzlak approved these changes

    10. AlemTuzlak merged thisde5fbb5

    11. AlemTuzlak closed this

Sign in to join this conversation.