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 now comes from the shared session context across visualizers, controls, and stories, unifying audio data flow.
    • Internal input-control hook return shape adjusted to reflect session-based microphone handling.
  • Style

    • Standardized styling selectors and off-state icon color rules for more consistent visuals.
  • Docs

    • Storybook stories updated to use the session-based microphone source.

✏️ 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: 1861835

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 story-level useMicrophone to centralized LiveKit session context (useSessionContext), removes local microphone logic from AgentSessionProvider, updates stories, hook return shape, and component internals to consume local.microphoneTrack.

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 only 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, docs/storybook/stories/agents-ui/AgentAudioVisualizerAura.stories.tsx, docs/storybook/stories/agents-ui/AgentAudioVisualizerWave.stories.tsx
Replaced useMicrophone with useSessionContext(); pass local.microphoneTrack 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 useMicrophone calls; AgentTrackControl stories now derive pressed state from useTrackToggle and obtain microphoneTrack via useSessionContext.
Hook API
packages/shadcn/hooks/agents-ui/use-agent-control-bar.ts
Public return shape changed: micTrackRef?: TrackReferenceOrPlaceholdermicrophoneTrack?: TrackReference; microphone 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
Internal rename micTrackRefmicrophoneTrack; swapped toggle variant constant names/usages; updated Tailwind/data-state selector syntax and a few className/layout tweaks; minor SVG color selector change.
Visualizer CSS changes
packages/shadcn/components/agents-ui/agent-audio-visualizer-radial.tsx, packages/shadcn/components/agents-ui/agent-audio-visualizer-grid.tsx
Replaced nested per-item selectors with attribute-based selectors (e.g., :data-lk-index, data-[lk-highlighted=true]) across variant styles.
Shader toy & misc
packages/shadcn/components/agents-ui/react-shader-toy.tsx, package.json, manifest updates
Texture API changed to accept TextureParams; WebGL texture unit usage updated; iMouse and pointer handling guarded; Texture type usage introduced; license/comment formatting and minor manifest edits.

Sequence Diagram(s)

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

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • 1egoman
  • lukasIO
  • mattherzog

Poem

🐇 A hop, a switch, a gentle tune,

I swapped the hook beneath the moon,
Sessions sing where tracks align,
Stories hum — the code feels fine,
Carrots for the midnight review! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 'chore(shadcn): cleanup microphoneTrack' accurately describes the main change: replacing useMicrophone hook usage with useSessionContext for microphoneTrack retrieval across components and stories.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 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 a56a8da and 1861835.

📒 Files selected for processing (2)
  • packages/shadcn/components/agents-ui/agent-audio-visualizer-grid.tsx
  • packages/shadcn/components/agents-ui/agent-control-bar.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/shadcn/components/agents-ui/agent-control-bar.tsx
  • packages/shadcn/components/agents-ui/agent-audio-visualizer-grid.tsx
⏰ 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

✏️ 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
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: 1

🤖 Fix all issues with AI agents
In `@packages/shadcn/components/agents-ui/agent-control-bar.tsx`:
- Around line 24-32: The LK_TOGGLE_VARIANT_1 constant contains malformed
Tailwind arbitrary-variant strings (patterns like `data-[state=off]_~_button]`,
`dark:data-[state=off]_~_button]:bg-accent`,
`dark:data-[state=off]_~_button:hover]`) which Tailwind will ignore; fix by
replacing those entries in LK_TOGGLE_VARIANT_1 with valid arbitrary-variant
syntax that targets sibling buttons (for example use `[&_~_button]:bg-accent`,
`[&_~_button]:border-border`, `[&_~_button]:hover:bg-foreground/10` and their
dark/hover/focus variants as needed) so all selectors are balanced and conform
to Tailwind v4 arbitrary-variant rules.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

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

📒 Files selected for processing (5)
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerAura.stories.tsx
  • docs/storybook/stories/agents-ui/AgentAudioVisualizerWave.stories.tsx
  • packages/shadcn/components/agents-ui/agent-audio-visualizer-grid.tsx
  • packages/shadcn/components/agents-ui/agent-control-bar.tsx
  • packages/shadcn/components/agents-ui/react-shader-toy.tsx
🧰 Additional context used
🧬 Code graph analysis (2)
docs/storybook/stories/agents-ui/AgentAudioVisualizerWave.stories.tsx (1)
packages/shadcn/components/agents-ui/agent-audio-visualizer-wave.tsx (2)
  • AgentAudioVisualizerWave (278-329)
  • AgentAudioVisualizerWaveProps (224-258)
packages/shadcn/components/agents-ui/agent-control-bar.tsx (1)
packages/shadcn/lib/utils.ts (1)
  • cn (4-6)
⏰ 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 (19)
docs/storybook/stories/agents-ui/AgentAudioVisualizerAura.stories.tsx (2)

3-6: LGTM!

The import changes correctly replace useMicrophone with useSessionContext from @livekit/components-react, aligning with the PR objective to centralize microphone track retrieval via session context.


12-19: LGTM!

The migration from useMicrophone to useSessionContext is correctly implemented. The nested destructuring to extract microphoneTrack from local works well here since the AgentSessionProvider decorator ensures the session context is properly initialized before the render function executes.

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

10-15: Guard against missing local in session context.

If useSessionContext() can ever return local as undefined (e.g., before connection or if a provider is missing), the destructuring on Line 11 will throw. Consider a null-safe access unless the hook explicitly guarantees local is always defined.

✅ Suggested safe access
-    const {
-      local: { microphoneTrack },
-    } = useSessionContext();
+    const { local } = useSessionContext();
+    const microphoneTrack = local?.microphoneTrack;
packages/shadcn/components/agents-ui/react-shader-toy.tsx (9)

1-25: LGTM!

License block reformatted cleanly with updated copyright year.


260-262: LGTM!

Good API simplification—load now accepts configuration params directly rather than requiring a pre-constructed object.


364-370: LGTM!

Clean normalization of pointer coordinates with proper null safety for touch events.


492-492: LGTM!

Correct type—the ref stores Texture instances, not raw WebGLTexture handles.


511-522: LGTM!

Good use of type discrimination via 'width' in texture to differentiate between TextureParams (pre-load, no dimensions) and Texture (post-load, has dimensions). The early return guard on line 515 is a nice defensive addition.


561-567: LGTM!

Good defensive guard—prevents potential runtime errors when iMouse uniform isn't configured.


700-702: LGTM!

Proper two-phase dimension setup: initial call with placeholder dimensions, then post-load call with actual texture dimensions.


820-820: LGTM!

gl.TEXTURE0 + index is the correct and idiomatic WebGL pattern for computing texture unit constants, replacing the fragile dynamic property lookup.


840-844: LGTM!

Consistent defensive guard pattern for the mouse lerp operation, matching the other iMouse handlers.

packages/shadcn/components/agents-ui/agent-control-bar.tsx (6)

3-17: LGTM!

Imports are well-organized and the motion/react import path is correct for motion v12+.


111-122: LGTM!

The className composition using cn() is appropriate, and the field-sizing-content utility for intrinsic textarea sizing is a nice modern CSS approach.


138-242: LGTM!

The JSDoc documentation improvements are clear and well-structured. The @defaultValue annotations provide useful guidance for consumers of this component.


258-267: LGTM!

The microphoneTrack destructuring aligns with the PR objective of retrieving the microphone track via useSessionContext. The rename from micTrackRef to microphoneTrack improves clarity and consistency with the session context API.


314-332: LGTM on the microphone control wiring.

The audioTrack={microphoneTrack} prop correctly passes the track from the session context to AgentTrackControl, consistent with the centralized microphone sourcing approach described in the PR objectives.


291-295: Verify Tailwind v4 opacity modifier syntax.

The drop-shadow-md/3 syntax uses Tailwind v4's opacity modifier format. Ensure the project is configured for Tailwind v4, as this syntax would be invalid in Tailwind v3.

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

52-55: The code is using valid Tailwind CSS 4.x syntax. The *: modifier is fully supported as a composable variant in Tailwind v4 and can be stacked with arbitrary data-[...] selectors. No compatibility issues or fallbacks are 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.

Copy link
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

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

lgtm

@thomasyuill-livekit thomasyuill-livekit force-pushed the ty/shadcn-cleanup-microphoneTrack-creation branch from a56a8da to 1861835 Compare January 23, 2026 16:52
@thomasyuill-livekit thomasyuill-livekit merged commit 6ee1daf into main Jan 23, 2026
7 checks passed
@thomasyuill-livekit thomasyuill-livekit deleted the ty/shadcn-cleanup-microphoneTrack-creation branch January 23, 2026 16:57
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.

3 participants