Skip to content

Commit 7828716

Browse files
committed
refactor: run pnpm format
1 parent 96b37e6 commit 7828716

File tree

14 files changed

+89
-113
lines changed

14 files changed

+89
-113
lines changed

components/embed-iframe/agent-client.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { toastAlert } from '@/components/alert-toast';
88
import { Toaster } from '@/components/ui/sonner';
99
import useConnectionDetails from '@/hooks/use-connection-details';
1010
import type { AppConfig } from '@/lib/types';
11-
1211
import { SessionView } from './session-view';
1312
import { WelcomeView } from './welcome-view';
1413

components/embed-iframe/session-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import { toastAlert } from '@/components/alert-toast';
1414
import { DeviceSelect } from '@/components/livekit/device-select';
1515
import { TrackToggle } from '@/components/livekit/track-toggle';
1616
import { Button } from '@/components/ui/button';
17+
import { useAgentControlBar } from '@/hooks/use-agent-control-bar';
1718
import { useDebugMode } from '@/hooks/useDebug';
1819
import type { AppConfig } from '@/lib/types';
1920
import { cn } from '@/lib/utils';
20-
import { useAgentControlBar } from '@/hooks/use-agent-control-bar';
2121

2222
function isAgentAvailable(agentState: AgentState) {
2323
return agentState == 'listening' || agentState == 'thinking' || agentState == 'speaking';

components/embed-popup/agent-client.tsx

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ import { useEffect, useMemo, useState } from 'react';
44
import { Room, RoomEvent } from 'livekit-client';
55
import { motion } from 'motion/react';
66
import { RoomAudioRenderer, RoomContext, StartAudio } from '@livekit/components-react';
7+
import { CaretDownIcon } from '@phosphor-icons/react';
78
import { toastAlert } from '@/components/alert-toast';
89
import { PopupView } from '@/components/embed-popup/popup-view';
9-
import useConnectionDetails from '@/hooks/use-connection-details';
10-
import type { AppConfig } from '@/lib/types';
11-
1210
import { Button } from '@/components/ui/button';
11+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
1312
import { Toaster } from '@/components/ui/sonner';
14-
import {
15-
Popover,
16-
PopoverContent,
17-
PopoverTrigger,
18-
} from "@/components/ui/popover"
19-
import { CaretDownIcon } from '@phosphor-icons/react';
13+
import useConnectionDetails from '@/hooks/use-connection-details';
14+
import type { AppConfig } from '@/lib/types';
2015
import { cn } from '@/lib/utils';
2116

2217
export type EmbedFixedAgentClientProps = {
@@ -27,7 +22,10 @@ export type EmbedFixedAgentClientProps = {
2722
buttonPosition?: 'fixed' | 'static';
2823
};
2924

30-
function EmbedFixedAgentClient({ appConfig, buttonPosition='fixed' }: EmbedFixedAgentClientProps) {
25+
function EmbedFixedAgentClient({
26+
appConfig,
27+
buttonPosition = 'fixed',
28+
}: EmbedFixedAgentClientProps) {
3129
const [popupOpen, setPopupOpen] = useState(false);
3230

3331
const room = useMemo(() => new Room(), []);
@@ -90,12 +88,12 @@ function EmbedFixedAgentClient({ appConfig, buttonPosition='fixed' }: EmbedFixed
9088
<Button
9189
variant="primary"
9290
size="lg"
93-
className={cn("w-12 h-12 p-0", {
94-
"fixed bottom-4 right-4": buttonPosition === 'fixed',
91+
className={cn('h-12 w-12 p-0', {
92+
'fixed right-4 bottom-4': buttonPosition === 'fixed',
9593
})}
96-
onClick={() => popupOpen ? setPopupOpen(false) : setPopupOpen(true)}
94+
onClick={() => (popupOpen ? setPopupOpen(false) : setPopupOpen(true))}
9795
>
98-
<div className="flex items-center justify-center bg-background w-10 h-10 rounded-full">
96+
<div className="bg-background flex h-10 w-10 items-center justify-center rounded-full">
9997
{popupOpen ? (
10098
<CaretDownIcon size={24} className="text-fg1" />
10199
) : (
@@ -130,14 +128,12 @@ function EmbedFixedAgentClient({ appConfig, buttonPosition='fixed' }: EmbedFixed
130128
return (
131129
<>
132130
{/* Backdrop */}
133-
{popupOpen ? (
134-
<div className="fixed inset-0" onClick={() => setPopupOpen(false)} />
135-
) : null}
131+
{popupOpen ? <div className="fixed inset-0" onClick={() => setPopupOpen(false)} /> : null}
136132

137133
{triggerButton}
138134

139135
<motion.div
140-
className="fixed right-4 bottom-20 w-full max-w-[360px] h-[480px] rounded-md bg-bg2"
136+
className="bg-bg2 fixed right-4 bottom-20 h-[480px] w-full max-w-[360px] rounded-md"
141137
initial={false}
142138
animate={{
143139
opacity: popupOpen ? 1 : 0,
@@ -152,15 +148,13 @@ function EmbedFixedAgentClient({ appConfig, buttonPosition='fixed' }: EmbedFixed
152148
case 'static':
153149
return (
154150
<Popover open={popupOpen} onOpenChange={setPopupOpen}>
155-
<PopoverTrigger asChild>
156-
{triggerButton}
157-
</PopoverTrigger>
158-
<PopoverContent className="p-0 bg-bg2 w-[360px] h-[480px]" align="end">
151+
<PopoverTrigger asChild>{triggerButton}</PopoverTrigger>
152+
<PopoverContent className="bg-bg2 h-[480px] w-[360px] p-0" align="end">
159153
{popupContents}
160154
</PopoverContent>
161155
</Popover>
162156
);
163-
}
157+
}
164158
}
165159

166160
export default EmbedFixedAgentClient;

components/embed-popup/popup-view.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
'use client';
22

33
import React, { useEffect } from 'react';
4-
import { AnimatePresence, motion } from 'motion/react';
54
import { Track } from 'livekit-client';
5+
import { AnimatePresence, motion } from 'motion/react';
66
import {
77
type AgentState,
8+
BarVisualizer,
89
useRoomContext,
910
useVoiceAssistant,
10-
BarVisualizer,
1111
} from '@livekit/components-react';
1212
import { PhoneDisconnectIcon } from '@phosphor-icons/react/dist/ssr';
13-
1413
import { toastAlert } from '@/components/alert-toast';
15-
import { Button } from '@/components/ui/button';
16-
import { useAgentControlBar } from '@/hooks/use-agent-control-bar';
14+
import { ChatEntry } from '@/components/livekit/chat/chat-entry';
1715
import { DeviceSelect } from '@/components/livekit/device-select';
1816
import { TrackToggle } from '@/components/livekit/track-toggle';
17+
import { Button } from '@/components/ui/button';
18+
import { useAgentControlBar } from '@/hooks/use-agent-control-bar';
19+
import useChatAndTranscription from '@/hooks/use-chat-and-transcription';
1920
import { useDebugMode } from '@/hooks/useDebug';
2021
import type { AppConfig } from '@/lib/types';
2122
import { cn } from '@/lib/utils';
22-
import useChatAndTranscription from '@/hooks/use-chat-and-transcription';
23-
import { ChatEntry } from '@/components/livekit/chat/chat-entry';
2423
import { ChatInput } from '../livekit/chat/chat-input';
2524

2625
function isAgentAvailable(agentState: AgentState) {
@@ -50,7 +49,7 @@ export const PopupView = ({
5049
handleDisconnect,
5150
} = useAgentControlBar({
5251
controls: { microphone: true },
53-
saveUserChoices: true
52+
saveUserChoices: true,
5453
});
5554
const { messages, send } = useChatAndTranscription();
5655

@@ -102,18 +101,17 @@ export const PopupView = ({
102101
return () => clearTimeout(timeout);
103102
}, [agentState, sessionStarted, room]);
104103

105-
const showAgentListening = (
106-
appConfig.isPreConnectBufferEnabled &&
104+
const showAgentListening =
105+
appConfig.isPreConnectBufferEnabled &&
107106
agentState !== 'disconnected' &&
108107
agentState !== 'connecting' &&
109-
agentState !== 'initializing'
110-
);
108+
agentState !== 'initializing';
111109

112110
return (
113-
<div ref={ref} inert={disabled} className="flex flex-col w-full h-full">
114-
<div className="relative flex flex-col justify-end h-0 p-2 grow-1 shrink-1 overflow-y-auto">
111+
<div ref={ref} inert={disabled} className="flex h-full w-full flex-col">
112+
<div className="relative flex h-0 shrink-1 grow-1 flex-col justify-end overflow-y-auto p-2">
115113
<motion.div
116-
className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col items-center"
114+
className="absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col items-center"
117115
initial={false}
118116
animate={{
119117
opacity: agentState === 'connecting' ? 1 : 0,
@@ -169,15 +167,15 @@ export const PopupView = ({
169167

170168
<div
171169
aria-label="Voice assistant controls"
172-
className="relative flex items-center gap-1 px-2 h-12 grow-0 shrink-0"
170+
className="relative flex h-12 shrink-0 grow-0 items-center gap-1 px-2"
173171
>
174172
<motion.div
175173
initial={false}
176174
animate={{
177175
opacity: showAgentListening ? 1 : 0,
178176
pointerEvents: showAgentListening ? 'auto' : 'none',
179177
}}
180-
className="absolute -top-8 right-2 flex justify-center items-center gap-2 bg-bg2 px-3 py-0.5 rounded-full"
178+
className="bg-bg2 absolute -top-8 right-2 flex items-center justify-center gap-2 rounded-full px-3 py-0.5"
181179
>
182180
<BarVisualizer
183181
barCount={3}
@@ -245,7 +243,7 @@ export const PopupView = ({
245243
{/* FIXME: do I need to handle the other channels here? */}
246244
</div>
247245

248-
<ChatInput className="w-0 grow-1 shrink-1" onSend={onSend} />
246+
<ChatInput className="w-0 shrink-1 grow-1" onSend={onSend} />
249247
</div>
250248
</div>
251249
);

components/embed-popup/standalone-bundle-root.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import ReactDOM from 'react-dom/client';
21
import * as React from 'react';
3-
import EmbedFixedAgentClient, { EmbedFixedAgentClientProps } from './agent-client';
2+
import ReactDOM from 'react-dom/client';
43
import { APP_CONFIG_DEFAULTS } from '@/app-config';
5-
64
import globalCss from '../../app/globals.css';
5+
import EmbedFixedAgentClient, { EmbedFixedAgentClientProps } from './agent-client';
76

8-
const wrapper = document.createElement("div");
9-
wrapper.setAttribute("id", "lk-embed-wrapper");
7+
const wrapper = document.createElement('div');
8+
wrapper.setAttribute('id', 'lk-embed-wrapper');
109
document.body.appendChild(wrapper);
1110

1211
const shadowRoot = wrapper.attachShadow({ mode: 'open' });
1312

14-
const styleTag = document.createElement("style");
13+
const styleTag = document.createElement('style');
1514
styleTag.textContent = globalCss;
1615
shadowRoot.appendChild(styleTag);
1716

18-
const reactRoot = document.createElement("div");
17+
const reactRoot = document.createElement('div');
1918
shadowRoot.appendChild(reactRoot);
2019

2120
const root = ReactDOM.createRoot(reactRoot);

components/livekit/chat/chat-entry.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export const ChatEntry = ({
4747
</span>
4848
)}
4949

50-
<span className={cn('max-w-4/5 rounded-[20px] p-2 text-sm', isUser ? 'bg-muted ml-auto' : 'mr-auto')}>
50+
<span
51+
className={cn(
52+
'max-w-4/5 rounded-[20px] p-2 text-sm',
53+
isUser ? 'bg-muted ml-auto' : 'mr-auto'
54+
)}
55+
>
5156
{message}
5257
</span>
5358
</li>

components/livekit/chat/chat-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function ChatInput({ onSend, className, disabled, ...props }: ChatInputPr
4242
disabled={disabled}
4343
placeholder="Type something..."
4444
onChange={(e) => setMessage(e.target.value)}
45-
className="grow-1 shrink-1 w-0 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
45+
className="w-0 shrink-1 grow-1 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
4646
/>
4747
<Button
4848
size="sm"

components/livekit/chat/hooks/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export const useChatMessage = (entry: ReceivedChatMessage, messageFormatter?: Me
1212
const name = entry.from?.name && entry.from.name !== '' ? entry.from.name : entry.from?.identity;
1313

1414
return { message: formattedMessage, hasBeenEdited, time, locale, name };
15-
};
15+
};

components/theme-toggle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { useEffect, useState } from 'react';
44
import { MonitorIcon, MoonIcon, SunIcon } from '@phosphor-icons/react';
5-
import type { ThemeMode } from '@/lib/types';
65
import { THEME_MEDIA_QUERY, THEME_STORAGE_KEY } from '@/lib/env';
6+
import type { ThemeMode } from '@/lib/types';
77
import { cn } from '@/lib/utils';
88

99
const THEME_SCRIPT = `

components/ui/popover.tsx

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
"use client"
1+
'use client';
22

3-
import * as React from "react"
4-
import * as PopoverPrimitive from "@radix-ui/react-popover"
3+
import * as React from 'react';
4+
import * as PopoverPrimitive from '@radix-ui/react-popover';
5+
import { cn } from '@/lib/utils';
56

6-
import { cn } from "@/lib/utils"
7-
8-
function Popover({
9-
...props
10-
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
11-
return <PopoverPrimitive.Root data-slot="popover" {...props} />
7+
function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
8+
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
129
}
1310

14-
function PopoverTrigger({
15-
...props
16-
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
17-
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
11+
function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
12+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
1813
}
1914

2015
function PopoverContent({
2116
className,
22-
align = "center",
17+
align = 'center',
2318
sideOffset = 4,
2419
...props
2520
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
@@ -30,19 +25,17 @@ function PopoverContent({
3025
align={align}
3126
sideOffset={sideOffset}
3227
className={cn(
33-
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
28+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden',
3429
className
3530
)}
3631
{...props}
3732
/>
3833
</PopoverPrimitive.Portal>
39-
)
34+
);
4035
}
4136

42-
function PopoverAnchor({
43-
...props
44-
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
45-
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
37+
function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
38+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />;
4639
}
4740

48-
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
41+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };

0 commit comments

Comments
 (0)