Skip to content

The agent that grows with you

fix(desktop): extract wake pause into a callback to satisfy the no-ref-mirror lint rule

teknium14478e76061b8
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
index 0709b3d02ee..0fb5c288751 100644
--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
@@ -166,17 +166,23 @@ export function useComposerVoice({
.catch(() => undefined)
}, [])
+ // The ref is a request token (did WE issue wake.pause?), not an atom mirror —
+ // it guards resumeWakeIfPaused from resuming a detector another surface owns.
+ const pauseWakeForVoice = useCallback(() => {
+ wakePausedRef.current = true
+ void $gateway
+ .get()
+ ?.request('wake.pause', {})
+ .catch(() => undefined)
+ }, [])
+
useEffect(() => {
if (voiceConversationActive) {
- wakePausedRef.current = true
- void $gateway
- .get()
- ?.request('wake.pause', {})
- .catch(() => undefined)
+ pauseWakeForVoice()
} else {
resumeWakeIfPaused()
}
- }, [resumeWakeIfPaused, voiceConversationActive])
+ }, [pauseWakeForVoice, resumeWakeIfPaused, voiceConversationActive])
useEffect(() => resumeWakeIfPaused, [resumeWakeIfPaused])