Skip to content

Commit 63dc277

Browse files
author
linzhengyu
committed
style: clean up code formatting and improve docstring consistency in Chatbox and ChatModeMenu components
1 parent 68713f8 commit 63dc277

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

app/components/layout/ChatModeMenu.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ interface ChatModeMenuProps {
1010
/**
1111
* Current chat mode.
1212
*/
13-
chatMode: 'text' | 'voice'
13+
chatMode: 'text' | 'voice'
1414
/**
1515
* Callback function called when a chat mode is selected.
1616
* @param mode The selected chat mode.
1717
*/
18-
onModeSelect: (mode: 'text' | 'voice' ) => void
18+
onModeSelect: (mode: 'text' | 'voice') => void
1919
}
2020

2121
/**
@@ -28,10 +28,7 @@ interface ChatModeMenuProps {
2828
* @param onModeSelect Callback function called when a mode is selected.
2929
* @returns JSX.Element The chat mode menu UI component.
3030
*/
31-
export default function ChatModeMenu({
32-
chatMode,
33-
onModeSelect
34-
}: ChatModeMenuProps) {
31+
export default function ChatModeMenu({ chatMode, onModeSelect }: ChatModeMenuProps) {
3532
const { t } = useTranslation('fronted')
3633
const [showChatModeMenu, setShowChatModeMenu] = useState(false)
3734
const chatModeMenuRef = useRef<HTMLDivElement>(null)
@@ -42,7 +39,7 @@ export default function ChatModeMenu({
4239
useEffect(() => {
4340
/**
4441
* Handle click outside event to close the menu.
45-
*
42+
*
4643
* @param event The mouse event.
4744
* @returns void
4845
*/
@@ -63,7 +60,7 @@ export default function ChatModeMenu({
6360

6461
/**
6562
* Get the display text for the current chat mode.
66-
*
63+
*
6764
* @returns The translated text for the current chat mode.
6865
*/
6966
const getChatModeText = () => {
@@ -79,13 +76,13 @@ export default function ChatModeMenu({
7976

8077
/**
8178
* Handle chat mode selection.
82-
*
79+
*
8380
* Calls the onModeSelect callback and closes the menu.
84-
*
81+
*
8582
* @param mode The selected chat mode.
8683
* @returns void
8784
*/
88-
const handleChatModeSelect = (mode: 'text' | 'voice' ) => {
85+
const handleChatModeSelect = (mode: 'text' | 'voice') => {
8986
onModeSelect(mode)
9087
setShowChatModeMenu(false)
9188
}
@@ -126,4 +123,3 @@ export default function ChatModeMenu({
126123
</div>
127124
)
128125
}
129-

app/components/layout/Chatbox.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export default function Chatbox({ globalState }: ChatboxProps) {
3333

3434
/**
3535
* Handle sending chat message.
36-
*
36+
*
3737
* Sends the current chat message to the state machine. If an animation is currently playing,
3838
* it will interrupt the animation before sending the message.
39-
*
39+
*
4040
* @returns void
4141
*/
4242
const handleSendMessage = () => {
@@ -56,10 +56,10 @@ export default function Chatbox({ globalState }: ChatboxProps) {
5656

5757
/**
5858
* Handle Enter key press in textarea.
59-
*
59+
*
6060
* Sends the message when Enter is pressed without Shift. Prevents default behavior
6161
* to avoid adding a new line.
62-
*
62+
*
6363
* @param e The keyboard event from the textarea.
6464
* @returns void
6565
*/
@@ -76,7 +76,7 @@ export default function Chatbox({ globalState }: ChatboxProps) {
7676
className="chatbox-textarea"
7777
placeholder={t('chat.inputMessagePlaceholder')}
7878
value={chatMessage}
79-
onChange={(e) => setChatMessage(e.target.value)}
79+
onChange={e => setChatMessage(e.target.value)}
8080
onKeyDown={handleTextareaKeyDown}
8181
/>
8282
<button
@@ -89,4 +89,3 @@ export default function Chatbox({ globalState }: ChatboxProps) {
8989
</div>
9090
)
9191
}
92-

app/contexts/BabylonJSContext.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function BabylonJSProvider({
5252
const [globalState, setGlobalState] = useState<GlobalState>()
5353
const webSocketState = useWebSocket()
5454
const [isSceneInitialized, setIsSceneInitialized] = useState(false)
55-
const [chatMode, setChatMode] = useState<'text' | 'voice' >('voice')
55+
const [chatMode, setChatMode] = useState<'text' | 'voice'>('voice')
5656

5757
// Add PCM queue to store audio data when websocket is not ready
5858
const pcmQueue = useRef<ArrayBuffer[]>([])
@@ -281,7 +281,7 @@ function BabylonJSProvider({
281281
* Handle chat mode selection.
282282
* Updates the local state and the record audio button visibility.
283283
*/
284-
const handleChatModeSelect = (mode: 'text' | 'voice' ) => {
284+
const handleChatModeSelect = (mode: 'text' | 'voice') => {
285285
setChatMode(mode)
286286
const isVoiceMode = mode === 'voice'
287287
if (globalState?.gui?.recordAudioButton) {
@@ -294,9 +294,7 @@ function BabylonJSProvider({
294294
{children}
295295
<ChatModeMenu chatMode={chatMode} onModeSelect={handleChatModeSelect} />
296296

297-
{chatMode === 'text' && (
298-
<Chatbox globalState={globalState} />
299-
)}
297+
{chatMode === 'text' && <Chatbox globalState={globalState} />}
300298
</BabylonJSContext.Provider>
301299
)
302300
}

app/library/babylonjs/runtime/gui/gui.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ export class GUI {
273273
recordingStarted = true
274274
if (this._globalState.runtime?.streamedAnimationPlaying()) {
275275
this._globalState.stateMachine?.putConditionedMessage(
276-
new ConditionedMessage(Conditions.USER_AUDIO_INTERRUPT_ANIMATION, null),
276+
new ConditionedMessage(
277+
Conditions.USER_AUDIO_INTERRUPT_ANIMATION,
278+
null,
279+
),
277280
)
278281
} else {
279282
this._globalState.stateMachine?.putConditionedMessage(

0 commit comments

Comments
 (0)