Skip to content

Conversation

@thomasyuill-livekit
Copy link
Contributor

@thomasyuill-livekit thomasyuill-livekit commented Jan 16, 2026

Summary

  • Replace useMicrophone with useSessionContext across Agent stories
  • Update useInputControls/AgentControlBar to use useSessionContext to retrieve microphoneTrack
  • Tweak Tailwind selector syntax for radial visualizer + track control styles

Summary by CodeRabbit

  • Refactor

    • Microphone input is now sourced from the shared session context across visualizers, controls, and stories, unifying audio data flow.
    • Input-control hook return shape adjusted to reflect the session-based microphone handling (internal API change).
  • Style

    • Audio visualizer styling selectors simplified for more consistent rendering across variants.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2026

⚠️ No Changeset found

Latest commit: 53669a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@thomasyuill-livekit thomasyuill-livekit self-assigned this Jan 16, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Moves microphone sourcing from per-story/useMicrophone to centralized session context (useSessionContext), removes local microphone logic from AgentSessionProvider, and updates stories, hook, and components to consume local.microphoneTrack instead.

Changes

Cohort / File(s) Change Summary
Session Provider
docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx
Removed useMicrophone usage and TrackReference-based return; component now relies solely on SessionProvider and StoryFn.
Stories (Visualizer)
docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx, docs/storybook/stories/agents-ui/AgentAudioVisualizerGrid.stories.tsx, docs/storybook/stories/agents-ui/AgentAudioVisualizerRadial.stories.tsx
Replaced useMicrophone with useSessionContext to obtain local.microphoneTrack and pass it as audioTrack; adjusted imports and story args.
Stories (Controls)
docs/storybook/stories/agents-ui/AgentControlBar.stories.tsx, docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx
Removed direct useMicrophone calls; AgentTrackControl stories now use useTrackToggle for pressed state and useSessionContext for microphoneTrack.
Hook API
packages/shadcn/hooks/agents-ui/use-agent-control-bar.ts
Public API changed: micTrackRef?: TrackReferenceOrPlaceholdermicrophoneTrack?: TrackReference; retrieval moved to useSessionContext; removed useLocalParticipant/useMemo.
Components (internal rename & styling)
packages/shadcn/components/agents-ui/agent-control-bar.tsx, packages/shadcn/components/agents-ui/agent-track-control.tsx
Renamed internal micTrackRefmicrophoneTrack; adjusted Tailwind selector ordering for off-state SVG text color.
Visualizer CSS
packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx
Replaced nested per-item selectors with generalized :data-lk-index attribute selectors across variant classes.

Sequence Diagram(s)

(Skipped — changes are refactors and story/hook updates without introducing a new multi-component control-flow feature.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • lukasIO
  • 1egoman
  • mattherzog

Poem

🐰 Microphone Shuffle

I hopped from hook to center stage,
A session's song begins a new page,
Tracks converge where stories play,
Central rhythm guides the day,
The rabbit twitches, happy sway 🥕🎶

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring microphone track retrieval logic from useMicrophone to useSessionContext throughout the codebase.

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

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx (1)

22-22: Remove duplicate listening duration class.

has-data-[lk-state=listening]:**:data-lk-index:duration-300 appears twice; one instance is sufficient.

♻️ Proposed cleanup
-    'has-data-[lk-state=listening]:**:data-lk-index:duration-300 has-data-[lk-state=listening]:**:data-lk-index:duration-300',
+    'has-data-[lk-state=listening]:**:data-lk-index:duration-300',
docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx (1)

11-24: Storybook pressed control is now overridden

pressed is always derived from microphoneToggle.enabled, so the pressed arg control no longer affects the rendered state. Consider removing that control or wiring args into the toggle for clearer demos.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a78249 and 53669a3.

📒 Files selected for processing (10)
  • docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerGrid.stories.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerRadial.stories.tsx
  • docs/storybook/stories/agents-ui/AgentControlBar.stories.tsx
  • docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx
  • packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx
  • packages/shadcn/components/agents-ui/agent-control-bar.tsx
  • packages/shadcn/components/agents-ui/agent-track-control.tsx
  • packages/shadcn/hooks/agents-ui/use-agent-control-bar.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerGrid.stories.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerRadial.stories.tsx
  • packages/shadcn/components/agents-ui/agent-control-bar.tsx
🧰 Additional context used
🧬 Code graph analysis (2)
docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx (3)
packages/shadcn/components/agents-ui/agent-track-control.tsx (2)
  • AgentTrackControl (259-324)
  • AgentTrackControlProps (199-240)
docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx (1)
  • AgentSessionProvider (10-23)
packages/shadcn/components/agents-ui/agent-session-provider.tsx (1)
  • AgentSessionProvider (50-61)
docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx (2)
packages/shadcn/components/agents-ui/agent-audio-visualizer-bar.tsx (2)
  • AgentAudioVisualizerBar (118-196)
  • AgentAudioVisualizerBarProps (71-100)
docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx (1)
  • AgentSessionProvider (10-23)
🪛 GitHub Actions: Test
docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx

[error] 1-1: Vite build encountered multiple 'Module level directives cause errors when bundled, use client' warnings/errors during Storybook production build. This may indicate incompatible components or client-only code in Storybook preview.

docs/storybook/stories/agents-ui/AgentControlBar.stories.tsx

[error] 1-1: Vite build encountered multiple 'Module level directives cause errors when bundled, use client' warnings/errors during Storybook production build. This may indicate incompatible components or client-only code in Storybook preview.

docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx

[error] 1-1: Vite build encountered multiple 'Module level directives cause errors when bundled, use client' warnings/errors during Storybook production build. This may indicate incompatible components or client-only code in Storybook preview.

docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx

[error] 1-1: Vite build encountered multiple 'Module level directives cause errors when bundled, use client' warnings/errors during Storybook production build. This may indicate incompatible components or client-only code in Storybook preview.

🔇 Additional comments (8)
packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx (1)

17-23: Confirm Tailwind v4 variant syntax for **:data-lk-index chaining.

Please verify that the descendant selector plus data-attribute variant combo is supported in your Tailwind version/config. If not, you may need **:data-[lk-index] or **:[data-lk-index] depending on the supported syntax.

docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx (1)

1-4: Decorator import cleanup looks good

Nice simplification; removing local mic logic keeps the Storybook decorator lightweight.

docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx (2)

54-57: Default story mic track wiring looks good


95-97: Outlined story mic track wiring looks good

docs/storybook/stories/agents-ui/AgentControlBar.stories.tsx (1)

3-3: Storybook build verification needed (use client directive errors in CI)

CI reports Vite/Storybook build errors about module-level use client directives. Please re-verify the Storybook production build after these updates and ensure the build config handles client-only modules.

docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx (1)

3-15: Mic track wiring for visualizer looks good

packages/shadcn/hooks/agents-ui/use-agent-control-bar.ts (1)

58-75: No action required—documented usage pattern ensures provider is present

useInputControls is only called within AgentControlBar, which must be wrapped in AgentSessionProvider (as shown in the README). AgentSessionProvider provides SessionProvider, so useSessionContext() will always be accessible. The type of local.microphoneTrack is correctly TrackReference | undefined per the SessionStateConnected definition.

packages/shadcn/components/agents-ui/agent-track-control.tsx (1)

36-53: No changes needed. The trailing ! modifier (text-destructive!) is the standard and preferred syntax for Tailwind v4, which this package uses (^4). The code is correct.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

size-limit report 📦

Path Size
LiveKitRoom only 6 KB (0%)
LiveKitRoom with VideoConference 32.46 KB (0%)
All exports 43.37 KB (0%)

@thomasyuill-livekit thomasyuill-livekit force-pushed the ty/shadcn-cleanup-microphoneTrack-creation branch from 2dd163e to 0a78249 Compare January 16, 2026 17:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/storybook/stories/agents-ui/AgentAudioVisualizerGrid.stories.tsx (1)

17-24: Typo: default should be size.

Line 18 uses default: 'lg' which is not a valid prop for AgentAudioVisualizerGrid. Based on the argTypes configuration and the component's props interface, this should be size: 'lg'.

   args: {
-    default: 'lg',
+    size: 'lg',
     state: 'connecting',
     radius: 5,
     interval: 100,
     rowCount: 10,
     columnCount: 10,
   },
docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx (1)

101-107: Bug: Microphone control won't receive audioTrack due to incorrect condition.

Line 106 checks args.source === Track.Source.Microphone, but args.source is undefined (no source in the story's args), while line 104 hardcodes source={Track.Source.Microphone}. This means the condition will always be false and audioTrack will be undefined.

This is inconsistent with the Default story (line 65) which correctly passes audioTrack={microphoneTrack} unconditionally for the Microphone control.

         <AgentTrackControl
           {...args}
           kind="audioinput"
           source={Track.Source.Microphone}
           pressed={isMicrophonePressed}
-          audioTrack={args.source === Track.Source.Microphone ? microphoneTrack : undefined}
+          audioTrack={microphoneTrack}
           onPressedChange={(pressed: boolean) => setIsMicrophonePressed(pressed)}
         />
🧹 Nitpick comments (1)
docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx (1)

13-16: Missing session in useEffect dependency array.

The session object is used inside the effect but not listed in the dependency array. This will trigger an ESLint exhaustive-deps warning. If session is guaranteed to be stable across renders (memoized by useSession), the current pattern is functionally correct but consider adding session to the array or suppressing the lint rule with a comment explaining the intentional omission.

   useEffect(() => {
     session.start();
     return () => session.end();
-  }, []);
+  }, [session]);
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dd163e and 0a78249.

📒 Files selected for processing (10)
  • docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerGrid.stories.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerRadial.stories.tsx
  • docs/storybook/stories/agents-ui/AgentControlBar.stories.tsx
  • docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx
  • packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx
  • packages/shadcn/components/agents-ui/agent-control-bar.tsx
  • packages/shadcn/components/agents-ui/agent-track-control.tsx
  • packages/shadcn/hooks/agents-ui/use-agent-control-bar.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerRadial.stories.tsx
  • packages/shadcn/components/agents-ui/agent-control-bar.tsx
  • packages/shadcn/hooks/agents-ui/use-agent-control-bar.ts
  • packages/shadcn/components/agents-ui/agent-track-control.tsx
  • docs/storybook/stories/agents-ui/AgentControlBar.stories.tsx
🧰 Additional context used
🧬 Code graph analysis (3)
docs/storybook/stories/agents-ui/AgentAudioVisualizerGrid.stories.tsx (2)
packages/shadcn/components/agents-ui/agent-audio-visualizer-grid.tsx (2)
  • AgentAudioVisualizerGrid (239-290)
  • AgentAudioVisualizerGridProps (195-219)
docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx (1)
  • AgentSessionProvider (10-23)
docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx (3)
packages/shadcn/components/agents-ui/agent-track-control.tsx (2)
  • AgentTrackControl (259-324)
  • AgentTrackControlProps (199-240)
docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx (1)
  • AgentSessionProvider (10-23)
packages/shadcn/components/agents-ui/agent-session-provider.tsx (1)
  • AgentSessionProvider (50-61)
docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx (2)
packages/shadcn/components/agents-ui/agent-audio-visualizer-bar.tsx (2)
  • AgentAudioVisualizerBar (118-196)
  • AgentAudioVisualizerBarProps (71-100)
docs/storybook/.storybook/lk-decorators/AgentSessionProvider.tsx (1)
  • AgentSessionProvider (10-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (4)
docs/storybook/stories/agents-ui/AgentAudioVisualizerBar.stories.tsx (1)

10-15: LGTM!

The migration from useMicrophone to useSessionContext is clean. The destructuring of local.microphoneTrack and passing it as audioTrack prop aligns with the PR objectives and matches the expected prop types.

docs/storybook/stories/agents-ui/AgentAudioVisualizerGrid.stories.tsx (1)

10-15: LGTM!

The migration to useSessionContext follows the same clean pattern as the other stories.

docs/storybook/stories/agents-ui/AgentTrackControl.stories.tsx (1)

11-26: LGTM!

The default render function cleanly integrates useSessionContext for microphoneTrack and useTrackToggle for toggle state management. The conditional audioTrack prop based on source type is appropriate here since the source can vary via args.

packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx (1)

17-22: Tailwind v4 natively supports these selectors — no issue.

The project uses Tailwind CSS v4, which has built-in support for both the **: descendant combinator variant and data-*: attribute variants. The selectors **:data-lk-index:... and has-data-[lk-state=...]:**:data-lk-index:... are valid Tailwind v4 syntax and will not be stripped. Other components in the codebase (tooltip, select, alert, etc.) already use data-[...] variants successfully. No custom variant configuration or fallback syntax is needed.

Likely an incorrect or invalid review comment.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@thomasyuill-livekit thomasyuill-livekit force-pushed the ty/shadcn-cleanup-microphoneTrack-creation branch from 0a78249 to 53669a3 Compare January 21, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants