From 502dd2d2e27de0c358f0b70b77ea7dcd07e1f1dd Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Fri, 13 Mar 2026 21:07:18 +0700 Subject: [PATCH] refactor(app): remove debug logging from voice and UI components --- packages/app/src/app/_layout.tsx | 23 -- .../app/src/components/agent-input-area.tsx | 30 --- .../app/src/components/artifact-drawer.tsx | 11 - .../app/src/components/explorer-sidebar.tsx | 8 +- packages/app/src/components/left-sidebar.tsx | 78 ------ packages/app/src/components/message-input.tsx | 77 ------ .../src/components/realtime-voice-overlay.tsx | 16 -- .../src/components/sidebar-workspace-list.tsx | 58 +---- .../components/ui/dropdown-menu-floating.ts | 21 -- .../components/voice-compact-indicator.tsx | 17 -- packages/app/src/components/voice-panel.tsx | 16 -- .../explorer-sidebar-animation-context.tsx | 26 -- packages/app/src/contexts/session-context.tsx | 123 --------- packages/app/src/contexts/voice-context.tsx | 47 +--- .../src/hooks/use-audio-recorder.native.ts | 46 ---- .../app/src/hooks/use-audio-recorder.web.ts | 10 - .../use-dictation-audio-source.native.ts | 73 +----- .../hooks/use-dictation-audio-source.web.ts | 9 - .../src/hooks/use-explorer-open-gesture.ts | 22 -- .../src/hooks/use-sidebar-workspaces-list.ts | 37 --- packages/app/src/runtime/host-runtime.ts | 50 +--- .../src/screens/agent/agent-ready-screen.tsx | 13 - packages/app/src/stores/panel-store.ts | 147 +++-------- packages/app/src/styles/unistyles.ts | 7 - packages/app/src/utils/os-notifications.ts | 9 +- packages/app/src/voice/audio-engine.native.ts | 240 +----------------- packages/app/src/voice/speech-segmenter.ts | 22 -- packages/app/src/voice/voice-runtime.ts | 108 -------- 28 files changed, 56 insertions(+), 1288 deletions(-) diff --git a/packages/app/src/app/_layout.tsx b/packages/app/src/app/_layout.tsx index a300f6c59..974a34469 100644 --- a/packages/app/src/app/_layout.tsx +++ b/packages/app/src/app/_layout.tsx @@ -71,18 +71,6 @@ polyfillCrypto(); attachConsole(); const HostRuntimeBootstrapContext = createContext(false); -const IS_DEV = Boolean((globalThis as { __DEV__?: boolean }).__DEV__); - -function logLeftSidebarOpenGesture( - event: string, - details: Record -): void { - if (!IS_DEV) { - return; - } - console.log(`[LeftSidebarOpenGesture] ${event}`, details); -} - function PushNotificationRouter() { const router = useRouter(); const lastHandledIdRef = useRef(null); @@ -339,10 +327,6 @@ function AppContainer({ }) .onStart(() => { isGesturing.value = true; - runOnJS(logLeftSidebarOpenGesture)("start", { - mobileView, - openGestureEnabled, - }); }) .onUpdate((event) => { // Start from closed position (-windowWidth) and move towards 0 @@ -359,13 +343,6 @@ function AppContainer({ isGesturing.value = false; // Open if dragged more than 1/3 of sidebar or fast swipe const shouldOpen = event.translationX > windowWidth / 3 || event.velocityX > 500; - runOnJS(logLeftSidebarOpenGesture)("end", { - translationX: event.translationX, - velocityX: event.velocityX, - shouldOpen, - mobileView, - openGestureEnabled, - }); if (shouldOpen) { animateToOpen(); runOnJS(openAgentList)(); diff --git a/packages/app/src/components/agent-input-area.tsx b/packages/app/src/components/agent-input-area.tsx index 55153a952..abec6dd01 100644 --- a/packages/app/src/components/agent-input-area.tsx +++ b/packages/app/src/components/agent-input-area.tsx @@ -103,23 +103,6 @@ export function AgentInputArea({ const { client, isConnected, snapshot } = useHostRuntimeSession(serverId) const toast = useToast() const voice = useVoiceOptional() - console.log("[AgentInputArea] render", { - serverId, - agentId, - isConnected, - isVoiceMode: voice?.isVoiceMode ?? false, - isVoiceSwitching: voice?.isVoiceSwitching ?? false, - isMuted: voice?.isMuted ?? false, - }) - console.log("[AgentInputArea] voice_snapshot", { - serverId, - agentId, - isVoiceMode: voice?.isVoiceMode ?? false, - isVoiceSwitching: voice?.isVoiceSwitching ?? false, - isMuted: voice?.isMuted ?? false, - activeServerId: voice?.activeServerId ?? null, - activeAgentId: voice?.activeAgentId ?? null, - }) const isDictationReady = isConnected && (snapshot?.agentDirectoryStatus === 'ready' || @@ -168,19 +151,6 @@ export function AgentInputArea({ `message-input:${serverId}:${agentId}:${Math.random().toString(36).slice(2)}` ) - useEffect(() => { - console.log("[AgentInputArea] mount", { - serverId, - agentId, - }) - return () => { - console.log("[AgentInputArea] unmount", { - serverId, - agentId, - }) - } - }, [agentId, serverId]) - const autocomplete = useAgentAutocomplete({ userInput, cursorIndex, diff --git a/packages/app/src/components/artifact-drawer.tsx b/packages/app/src/components/artifact-drawer.tsx index 51fc81302..c0ec709db 100644 --- a/packages/app/src/components/artifact-drawer.tsx +++ b/packages/app/src/components/artifact-drawer.tsx @@ -6,7 +6,6 @@ import { Modal, } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; -import { useEffect } from "react"; import { StyleSheet } from "react-native-unistyles"; import { Fonts } from "@/constants/theme"; @@ -154,16 +153,6 @@ const styles = StyleSheet.create((theme) => ({ })); export function ArtifactDrawer({ artifact, onClose }: ArtifactDrawerProps) { - useEffect(() => { - if (!artifact) return; - console.log( - "[ArtifactDrawer] Showing artifact:", - artifact.id, - artifact.type, - artifact.title - ); - }, [artifact]); - if (!artifact) { return null; } diff --git a/packages/app/src/components/explorer-sidebar.tsx b/packages/app/src/components/explorer-sidebar.tsx index 0516b9a45..96d96d3a7 100644 --- a/packages/app/src/components/explorer-sidebar.tsx +++ b/packages/app/src/components/explorer-sidebar.tsx @@ -23,13 +23,7 @@ import { FileExplorerPane } from "./file-explorer-pane"; import { useKeyboardShiftStyle } from "@/hooks/use-keyboard-shift-style"; const MIN_CHAT_WIDTH = 400; -const IS_DEV = Boolean((globalThis as { __DEV__?: boolean }).__DEV__); - -function logExplorerSidebar(event: string, details: Record): void { - if (!IS_DEV) { - return; - } - console.log(`[ExplorerSidebar] ${event}`, details); +function logExplorerSidebar(_event: string, _details: Record): void { } interface ExplorerSidebarProps { diff --git a/packages/app/src/components/left-sidebar.tsx b/packages/app/src/components/left-sidebar.tsx index 9add6a26f..c91ac29fd 100644 --- a/packages/app/src/components/left-sidebar.tsx +++ b/packages/app/src/components/left-sidebar.tsx @@ -32,14 +32,6 @@ import { import { useKeyboardShortcutsStore } from '@/stores/keyboard-shortcuts-store' const DESKTOP_SIDEBAR_WIDTH = 320 -const IS_DEV = Boolean((globalThis as { __DEV__?: boolean }).__DEV__) - -function logLeftSidebarCloseGesture(event: string, details: Record): void { - if (!IS_DEV) { - return - } - console.log(`[LeftSidebarCloseGesture] ${event}`, details) -} interface LeftSidebarProps { selectedAgentId?: string @@ -144,70 +136,6 @@ export function LeftSidebar({ selectedAgentId: _selectedAgentId }: LeftSidebarPr // Track user-initiated refresh to avoid showing spinner on background revalidation const [isManualRefresh, setIsManualRefresh] = useState(false) - useEffect(() => { - console.log('[LeftSidebar] isOpen_changed', { - isOpen, - isMobile, - mobileView, - desktopAgentListOpen, - }) - }, [desktopAgentListOpen, isMobile, isOpen, mobileView]) - - useEffect(() => { - console.log('[LeftSidebar] pathname_changed', { - pathname, - activeServerIdFromPath, - activeServerId, - }) - }, [activeServerId, activeServerIdFromPath, pathname]) - - useEffect(() => { - console.log('[LeftSidebar] hosts_changed', { - hostCount: daemons.length, - serverIds: daemons.map((daemon) => daemon.serverId), - runtimeConnectionStatusSignature, - }) - }, [daemons, runtimeConnectionStatusSignature]) - - useEffect(() => { - console.log('[LeftSidebar] active_host_changed', { - activeServerId, - activeHostLabel, - activeHostStatus, - }) - }, [activeHostLabel, activeHostStatus, activeServerId]) - - useEffect(() => { - console.log('[LeftSidebar] projects_changed', { - activeServerId, - projectCount: projects.length, - projectKeys: projects.map((project) => project.projectKey), - workspaceCounts: projects.map((project) => ({ - projectKey: project.projectKey, - workspaceCount: project.workspaces.length, - })), - isInitialLoad, - isRevalidating, - }) - }, [activeServerId, isInitialLoad, isRevalidating, projects]) - - useEffect(() => { - console.log('[LeftSidebar] collapsed_or_shortcuts_changed', { - collapsedProjectKeys: Array.from(collapsedProjectKeys), - shortcutCount: shortcutIndexByWorkspaceKey.size, - }) - }, [collapsedProjectKeys, shortcutIndexByWorkspaceKey]) - - useEffect(() => { - console.log('[LeftSidebar] animation_context_changed', { - windowWidth, - translateXValue: translateX.value, - backdropOpacityValue: backdropOpacity.value, - isGesturing: isGesturing.value, - hasCloseGestureRef: Boolean(closeGestureRef.current), - }) - }, [backdropOpacity, closeGestureRef, isGesturing, translateX, windowWidth]) - const handleRefresh = useCallback(() => { setIsManualRefresh(true) refreshAll() @@ -320,7 +248,6 @@ export function LeftSidebar({ selectedAgentId: _selectedAgentId }: LeftSidebarPr }) .onStart(() => { isGesturing.value = true - runOnJS(logLeftSidebarCloseGesture)('start', { isOpen, isMobile }) }) .onUpdate((event) => { if (!isMobile) return @@ -338,11 +265,6 @@ export function LeftSidebar({ selectedAgentId: _selectedAgentId }: LeftSidebarPr isGesturing.value = false if (!isMobile) return const shouldClose = event.translationX < -windowWidth / 3 || event.velocityX < -500 - runOnJS(logLeftSidebarCloseGesture)('end', { - translationX: event.translationX, - velocityX: event.velocityX, - shouldClose, - }) if (shouldClose) { animateToClose() runOnJS(handleClose)() diff --git a/packages/app/src/components/message-input.tsx b/packages/app/src/components/message-input.tsx index 0fe71d5ae..d7d5cfff9 100644 --- a/packages/app/src/components/message-input.tsx +++ b/packages/app/src/components/message-input.tsx @@ -216,18 +216,6 @@ export const MessageInput = forwardRef(funct markScrollInvestigationRender(investigationComponentId) const toast = useToast() const voice = useVoiceOptional() - console.log("[MessageInput] render", { - voiceServerId: voiceServerId ?? null, - voiceAgentId: voiceAgentId ?? null, - hasVoice: Boolean(voice), - isVoiceMode: voice?.isVoiceMode ?? false, - isVoiceSwitching: voice?.isVoiceSwitching ?? false, - isMuted: voice?.isMuted ?? false, - disabled, - isSubmitLoading, - valueLength: value.length, - imageCount: images.length, - }) const [inputHeight, setInputHeight] = useState(MIN_INPUT_HEIGHT) const rootRef = useRef(null) const inputWrapperRef = useRef(null) @@ -301,19 +289,6 @@ export const MessageInput = forwardRef(funct ) ) - useEffect(() => { - console.log("[MessageInput] mount", { - voiceServerId: voiceServerId ?? null, - voiceAgentId: voiceAgentId ?? null, - }) - return () => { - console.log("[MessageInput] unmount", { - voiceServerId: voiceServerId ?? null, - voiceAgentId: voiceAgentId ?? null, - }) - } - }, [voiceAgentId, voiceServerId]) - useEffect(() => { valueRef.current = value }, [value]) @@ -428,25 +403,6 @@ export const MessageInput = forwardRef(funct const showRealtimeOverlay = isRealtimeVoiceForCurrentAgent const showOverlay = showDictationOverlay || showRealtimeOverlay - useEffect(() => { - console.log("[MessageInput] overlay_state", { - showDictationOverlay, - showRealtimeOverlay, - showOverlay, - isDictating, - isDictationProcessing, - dictationStatus, - isRealtimeVoiceForCurrentAgent, - }) - }, [ - dictationStatus, - isDictating, - isDictationProcessing, - isRealtimeVoiceForCurrentAgent, - showDictationOverlay, - showOverlay, - showRealtimeOverlay, - ]) useEffect(() => { if (isDictating || isDictationProcessing) { @@ -484,11 +440,6 @@ export const MessageInput = forwardRef(funct })) const handleVoicePress = useCallback(async () => { - console.log("[MessageInput] handleVoicePress", { - isRealtimeVoiceForCurrentAgent, - isDictating, - hasVoice: Boolean(voice), - }) if (isRealtimeVoiceForCurrentAgent && voice) { voice.toggleMute() return @@ -508,39 +459,28 @@ export const MessageInput = forwardRef(funct ]) const handleCancelRecording = useCallback(async () => { - console.log("[MessageInput] handleCancelRecording") await cancelDictation() }, [cancelDictation]) const handleAcceptRecording = useCallback(async () => { - console.log("[MessageInput] handleAcceptRecording") sendAfterTranscriptRef.current = false await confirmDictation() }, [confirmDictation]) const handleAcceptAndSendRecording = useCallback(async () => { - console.log("[MessageInput] handleAcceptAndSendRecording") sendAfterTranscriptRef.current = true await confirmDictation() }, [confirmDictation]) const handleRetryFailedRecording = useCallback(() => { - console.log("[MessageInput] handleRetryFailedRecording") void retryFailedDictation() }, [retryFailedDictation]) const handleDiscardFailedRecording = useCallback(() => { - console.log("[MessageInput] handleDiscardFailedRecording") discardFailedDictation() }, [discardFailedDictation]) const handleStopRealtimeVoice = useCallback(async () => { - console.log("[MessageInput] handleStopRealtimeVoice", { - hasVoice: Boolean(voice), - isRealtimeVoiceForCurrentAgent, - isAgentRunning, - voiceAgentId: voiceAgentId ?? null, - }) if (!voice || !isRealtimeVoiceForCurrentAgent) { return } @@ -560,18 +500,6 @@ export const MessageInput = forwardRef(funct }, [client, isAgentRunning, isRealtimeVoiceForCurrentAgent, voice, voiceAgentId]) const handleToggleRealtimeVoiceShortcut = useCallback(() => { - console.log("[MessageInput] handleToggleRealtimeVoiceShortcut", { - hasVoice: Boolean(voice), - voiceServerId: voiceServerId ?? null, - voiceAgentId: voiceAgentId ?? null, - isConnected, - disabled, - isVoiceSwitching: voice?.isVoiceSwitching ?? false, - isVoiceModeForAgent: - voice && voiceServerId && voiceAgentId - ? voice.isVoiceModeForAgent(voiceServerId, voiceAgentId) - : false, - }) if (!voice || !voiceServerId || !voiceAgentId || !isConnected || disabled) { return } @@ -593,11 +521,6 @@ export const MessageInput = forwardRef(funct }, [disabled, handleStopRealtimeVoice, isConnected, toast, voice, voiceAgentId, voiceServerId]) const handleSendMessage = useCallback(() => { - console.log("[MessageInput] handleSendMessage", { - valueLength: value.length, - imageCount: images.length, - isAgentRunning, - }) const trimmed = value.trim() if (!trimmed && images.length === 0) return const payload = { diff --git a/packages/app/src/components/realtime-voice-overlay.tsx b/packages/app/src/components/realtime-voice-overlay.tsx index 2901caf31..b85cc622b 100644 --- a/packages/app/src/components/realtime-voice-overlay.tsx +++ b/packages/app/src/components/realtime-voice-overlay.tsx @@ -1,5 +1,4 @@ import { ActivityIndicator, Pressable, View } from "react-native"; -import { useEffect } from "react"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { Mic, MicOff, Square } from "lucide-react-native"; import { FOOTER_HEIGHT } from "@/constants/layout"; @@ -24,21 +23,6 @@ export function RealtimeVoiceOverlay({ }: RealtimeVoiceOverlayProps) { const { theme } = useUnistyles(); const { volume, isDetecting, isSpeaking } = useVoiceTelemetry(); - console.log("[RealtimeVoiceOverlay] render", { - isMuted, - isSwitching, - volume, - isDetecting, - isSpeaking, - }); - - useEffect(() => { - console.log("[RealtimeVoiceOverlay] mount"); - return () => { - console.log("[RealtimeVoiceOverlay] unmount"); - }; - }, []); - return ( diff --git a/packages/app/src/components/sidebar-workspace-list.tsx b/packages/app/src/components/sidebar-workspace-list.tsx index 8aeb78624..8cb6d9c46 100644 --- a/packages/app/src/components/sidebar-workspace-list.tsx +++ b/packages/app/src/components/sidebar-workspace-list.tsx @@ -257,7 +257,6 @@ function NewWorktreeButton({ function useLongPressDragInteraction(input: { drag: () => void menuController: ReturnType | null - debugId: string }) { const didLongPressRef = useRef(false) const dragArmedRef = useRef(false) @@ -295,15 +294,11 @@ function useLongPressDragInteraction(input: { input.menuController.setOpen(true) menuOpenedRef.current = true didLongPressRef.current = true - console.log('[sidebar-dnd-debug] context menu opened', { id: input.debugId }) - }, [input.debugId, input.menuController]) + }, [input.menuController]) const handleLongPress = useCallback(() => { // Manual timers own long-press behavior on mobile. - console.log('[sidebar-dnd-debug] native onLongPress ignored (manual state machine active)', { - id: input.debugId, - }) - }, [input.debugId]) + }, []) useEffect(() => { return () => { @@ -332,16 +327,11 @@ function useLongPressDragInteraction(input: { const dy = current.y - start.y const distance = Math.sqrt(dx * dx + dy * dy) if (distance > DRAG_ARM_STATIONARY_SLOP_PX) { - console.log('[sidebar-dnd-debug] drag arm cancelled (movement)', { - id: input.debugId, - distance, - }) return } dragArmedRef.current = true dragActivatedRef.current = true didLongPressRef.current = true - console.log('[sidebar-dnd-debug] drag armed', { id: input.debugId }) void Haptics.selectionAsync().catch(() => {}) input.drag() }, DRAG_ARM_DELAY_MS) @@ -363,17 +353,12 @@ function useLongPressDragInteraction(input: { const dy = current.y - start.y const distance = Math.sqrt(dx * dx + dy * dy) if (distance > CONTEXT_MENU_STATIONARY_SLOP_PX) { - console.log('[sidebar-dnd-debug] context menu cancelled (movement)', { - id: input.debugId, - distance, - }) return } - console.log('[sidebar-dnd-debug] long-press armed', { id: input.debugId }) void Haptics.selectionAsync().catch(() => {}) openContextMenuAtStartPoint() }, CONTEXT_MENU_DELAY_MS) - }, [clearTimers, input.debugId, input.menuController, openContextMenuAtStartPoint]) + }, [clearTimers, input.menuController, openContextMenuAtStartPoint]) const handleDragIntent = useCallback( (details: { dx: number; dy: number; distance: number }) => { @@ -383,10 +368,9 @@ function useLongPressDragInteraction(input: { didStartDragRef.current = true didLongPressRef.current = true clearTimers() - console.log('[sidebar-dnd-debug] drag movement detected', { id: input.debugId, ...details }) void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium).catch(() => {}) }, - [clearTimers, input.debugId] + [clearTimers] ) const handleScrollIntent = useCallback( @@ -394,18 +378,16 @@ function useLongPressDragInteraction(input: { scrollIntentRef.current = true didLongPressRef.current = true clearTimers() - console.log('[sidebar-dnd-debug] scroll intent detected', { id: input.debugId, ...details }) }, - [clearTimers, input.debugId] + [clearTimers] ) const handleSwipeIntent = useCallback( (details: { dx: number; dy: number; distance: number }) => { didLongPressRef.current = true clearTimers() - console.log('[sidebar-dnd-debug] swipe intent detected', { id: input.debugId, ...details }) }, - [clearTimers, input.debugId] + [clearTimers] ) const handlePressIn = useCallback((event: GestureResponderEvent) => { @@ -423,13 +405,8 @@ function useLongPressDragInteraction(input: { x: event.nativeEvent.pageX, y: event.nativeEvent.pageY, } - console.log('[sidebar-dnd-debug] press-in', { - id: input.debugId, - x: event.nativeEvent.pageX, - y: event.nativeEvent.pageY, - }) armTimers() - }, [armTimers, input.debugId]) + }, [armTimers]) const handleTouchMove = useCallback( (event: any) => { @@ -476,20 +453,11 @@ function useLongPressDragInteraction(input: { const handlePressOut = useCallback(() => { clearTimers() - console.log('[sidebar-dnd-debug] press-out no context-menu', { - id: input.debugId, - didLongPress: didLongPressRef.current, - didStartDrag: didStartDragRef.current, - dragActivated: dragActivatedRef.current, - scrollIntent: scrollIntentRef.current, - dragArmed: dragArmedRef.current, - menuOpened: menuOpenedRef.current, - }) dragArmedRef.current = false dragActivatedRef.current = false touchStartRef.current = null touchCurrentRef.current = null - }, [clearTimers, input.debugId]) + }, [clearTimers]) return { didLongPressRef, @@ -518,7 +486,6 @@ function ProjectHeaderRow({ const interaction = useLongPressDragInteraction({ drag, menuController, - debugId: `project:${project.projectKey}`, }) const handlePress = useCallback(() => { @@ -626,7 +593,6 @@ function WorkspaceRowInner({ const interaction = useLongPressDragInteraction({ drag, menuController, - debugId: `workspace:${workspace.workspaceKey}`, }) const handlePress = useCallback(() => { @@ -1474,9 +1440,7 @@ export function SidebarWorkspaceList({ style={styles.list} contentContainerStyle={styles.listContent} showsVerticalScrollIndicator={false} - onScrollBeginDrag={() => - console.log('[sidebar-dnd-debug] outer scroll begin') - } + testID="sidebar-project-workspace-list-scroll" > {content} @@ -1486,9 +1450,7 @@ export function SidebarWorkspaceList({ style={styles.list} contentContainerStyle={styles.listContent} showsVerticalScrollIndicator={false} - onScrollBeginDrag={() => - console.log('[sidebar-dnd-debug] outer scroll begin') - } + testID="sidebar-project-workspace-list-scroll" > {content} diff --git a/packages/app/src/components/ui/dropdown-menu-floating.ts b/packages/app/src/components/ui/dropdown-menu-floating.ts index 0e3676804..6eefd1f1d 100644 --- a/packages/app/src/components/ui/dropdown-menu-floating.ts +++ b/packages/app/src/components/ui/dropdown-menu-floating.ts @@ -170,10 +170,6 @@ export function useDropdownFloating({ }, []); const update = useCallback(async () => { - console.log("[useDropdownFloating] update called", { - hasReferenceEl: !!referenceEl, - hasFloatingEl: !!floatingElRef.current, - }); if (!referenceEl || !floatingElRef.current) { return; @@ -185,12 +181,6 @@ export function useDropdownFloating({ measureElement(floatingElRef.current), ]); - console.log("[useDropdownFloating] measured", { - fromRect, - contentRect, - displayArea, - }); - const result = computeGeometry({ fromRect, contentSize: { width: contentRect.width, height: contentRect.height }, @@ -201,8 +191,6 @@ export function useDropdownFloating({ padding, }); - console.log("[useDropdownFloating] geometry result", result); - setGeometry(result); } catch (e) { console.warn("[useDropdownFloating] measure failed:", e); @@ -210,7 +198,6 @@ export function useDropdownFloating({ }, [referenceEl, displayArea, placement, alignment, offset, padding]); const floatingRef = useCallback((el: View | null) => { - console.log("[useDropdownFloating] floatingRef called", { hasEl: !!el }); floatingElRef.current = el; }, []); @@ -218,17 +205,10 @@ export function useDropdownFloating({ const [floatingReady, setFloatingReady] = useState(false); const handleFloatingLayout = useCallback(() => { - console.log("[useDropdownFloating] handleFloatingLayout called"); setFloatingReady(true); }, []); useEffect(() => { - console.log("[useDropdownFloating] useEffect", { - open, - floatingReady, - hasReferenceEl: !!referenceEl, - hasFloatingEl: !!floatingElRef.current, - }); if (!open) { setGeometry(null); @@ -237,7 +217,6 @@ export function useDropdownFloating({ } if (floatingReady && referenceEl && floatingElRef.current) { - console.log("[useDropdownFloating] calling update from useEffect"); update(); } }, [open, floatingReady, referenceEl, update]); diff --git a/packages/app/src/components/voice-compact-indicator.tsx b/packages/app/src/components/voice-compact-indicator.tsx index c4bd2f0fb..fc14cb72e 100644 --- a/packages/app/src/components/voice-compact-indicator.tsx +++ b/packages/app/src/components/voice-compact-indicator.tsx @@ -1,5 +1,4 @@ import { ActivityIndicator, Alert, Pressable, View } from "react-native"; -import { useEffect } from "react"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { Mic, MicOff, Square } from "lucide-react-native"; import { VolumeMeter } from "@/components/volume-meter"; @@ -15,22 +14,6 @@ export function VoiceCompactIndicator() { toggleMute, stopVoice, } = useVoice(); - console.log("[VoiceCompactIndicator] render", { - isVoiceMode, - isVoiceSwitching, - isMuted, - volume, - isDetecting, - isSpeaking, - }); - - useEffect(() => { - console.log("[VoiceCompactIndicator] mount"); - return () => { - console.log("[VoiceCompactIndicator] unmount"); - }; - }, []); - if (!isVoiceMode) { return null; } diff --git a/packages/app/src/components/voice-panel.tsx b/packages/app/src/components/voice-panel.tsx index d5b8e2645..0b4079ed0 100644 --- a/packages/app/src/components/voice-panel.tsx +++ b/packages/app/src/components/voice-panel.tsx @@ -1,5 +1,4 @@ import { View, Pressable } from "react-native"; -import { useEffect } from "react"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { MicOff, Square } from "lucide-react-native"; import { VolumeMeter } from "./volume-meter"; @@ -16,21 +15,6 @@ export function VoicePanel() { toggleMute, activeServerId, } = useVoice(); - console.log("[VoicePanel] render", { - activeServerId, - isMuted, - volume, - isDetecting, - isSpeaking, - }); - - useEffect(() => { - console.log("[VoicePanel] mount"); - return () => { - console.log("[VoicePanel] unmount"); - }; - }, []); - const hostLabel = activeServerId ? daemons.find((daemon) => daemon.serverId === activeServerId)?.label ?? null : null; diff --git a/packages/app/src/contexts/explorer-sidebar-animation-context.tsx b/packages/app/src/contexts/explorer-sidebar-animation-context.tsx index 81e843343..9bd103306 100644 --- a/packages/app/src/contexts/explorer-sidebar-animation-context.tsx +++ b/packages/app/src/contexts/explorer-sidebar-animation-context.tsx @@ -12,18 +12,6 @@ import { usePanelStore } from "@/stores/panel-store"; const ANIMATION_DURATION = 220; const ANIMATION_EASING = Easing.bezier(0.25, 0.1, 0.25, 1); -const IS_DEV = Boolean((globalThis as { __DEV__?: boolean }).__DEV__); - -function logExplorerAnimation( - event: string, - details: Record -): void { - if (!IS_DEV) { - return; - } - console.log(`[ExplorerAnimation] ${event}`, details); -} - interface ExplorerSidebarAnimationContextValue { translateX: SharedValue; backdropOpacity: SharedValue; @@ -66,23 +54,9 @@ export function ExplorerSidebarAnimationProvider({ children }: { children: React // Don't animate if we're in the middle of a gesture - the gesture handler will handle it if (isGesturing.value) { - logExplorerAnimation("sync-skipped-during-gesture", { - previousIsOpen, - nextIsOpen: isOpen, - mobileView, - desktopFileExplorerOpen, - }); return; } - logExplorerAnimation("sync-state-change", { - previousIsOpen, - nextIsOpen: isOpen, - mobileView, - desktopFileExplorerOpen, - windowWidth, - }); - if (isOpen) { translateX.value = withTiming(0, { duration: ANIMATION_DURATION, diff --git a/packages/app/src/contexts/session-context.tsx b/packages/app/src/contexts/session-context.tsx index b2d3aac6a..a167496cc 100644 --- a/packages/app/src/contexts/session-context.tsx +++ b/packages/app/src/contexts/session-context.tsx @@ -127,17 +127,6 @@ function buildAudioPlaybackSource( }; } -function logVoiceSession( - event: string, - details?: Record -): void { - if (details) { - console.log(`[VoiceSession] ${event}`, details); - return; - } - console.log(`[VoiceSession] ${event}`); -} - const findLatestAssistantMessageText = (items: StreamItem[]): string | null => { for (let i = items.length - 1; i >= 0; i -= 1) { const item = items[i]; @@ -273,11 +262,6 @@ function SessionProviderInternal({ }: SessionProviderClientProps) { const voiceRuntime = useVoiceRuntimeOptional(); const voiceAudioEngine = useVoiceAudioEngineOptional(); - console.log("[SessionProvider] render", { - serverId, - hasVoiceRuntime: Boolean(voiceRuntime), - hasVoiceAudioEngine: Boolean(voiceAudioEngine), - }); const queryClient = useQueryClient(); const isConnected = useHostRuntimeIsConnected(serverId); @@ -519,11 +503,6 @@ function SessionProviderInternal({ const queue = session?.queuedMessages.get(agent.id); if (queue && queue.length > 0) { const [next, ...rest] = queue; - console.log( - "[Session] Flushing queued message for agent:", - agent.id, - next.text - ); if (sendAgentMessageRef.current) { void sendAgentMessageRef.current(agent.id, next.text, next.images); } @@ -684,13 +663,6 @@ function SessionProviderInternal({ ); // Initialize session in store - useEffect(() => { - console.log("[SessionProvider] mount", { serverId }); - return () => { - console.log("[SessionProvider] unmount", { serverId }); - }; - }, [serverId]); - useEffect(() => { initializeSession(serverId, client); }, [serverId, client, initializeSession]); @@ -704,44 +676,27 @@ function SessionProviderInternal({ return; } - console.log("[SessionProvider] register_voice_session", { serverId }); return voiceRuntime.registerSession({ serverId, setVoiceMode: async (enabled, agentId) => { - console.log("[SessionProvider] setVoiceMode", { - serverId, - enabled, - agentId: agentId ?? null, - }); if (!client) { throw new Error("Daemon unavailable"); } await client.setVoiceMode(enabled, agentId); }, sendVoiceAudioChunk: async (audioData, mimeType, isLast) => { - console.log("[SessionProvider] sendVoiceAudioChunk", { - serverId, - audioDataLength: audioData.length, - mimeType, - isLast, - }); if (!client) { throw new Error("Daemon unavailable"); } await client.sendVoiceAudioChunk(audioData, mimeType, isLast); }, abortRequest: async () => { - console.log("[SessionProvider] abortRequest", { serverId }); if (!client) { throw new Error("Daemon unavailable"); } await client.abortRequest(); }, setAssistantAudioPlaying: (isPlaying) => { - console.log("[SessionProvider] setAssistantAudioPlaying", { - serverId, - isPlaying, - }); setIsPlayingAudio(serverId, isPlaying); }, }); @@ -753,10 +708,6 @@ function SessionProviderInternal({ ]); useEffect(() => { - console.log("[SessionProvider] updateSessionConnection", { - serverId, - isConnected, - }); voiceRuntime?.updateSessionConnection(serverId, isConnected); }, [isConnected, serverId, voiceRuntime]); @@ -1244,13 +1195,6 @@ function SessionProviderInternal({ if (message.type !== "agent_permission_request") return; const { agentId, request } = message.payload; - console.log( - "[Session] Permission request:", - request.id, - "for agent:", - agentId - ); - setPendingPermissions(serverId, (prev) => { const next = new Map(prev); const key = derivePendingPermissionKey(agentId, request); @@ -1266,13 +1210,6 @@ function SessionProviderInternal({ if (message.type !== "agent_permission_resolved") return; const { requestId, agentId } = message.payload; - console.log( - "[Session] Permission resolved:", - requestId, - "for agent:", - agentId - ); - setPendingPermissions(serverId, (prev) => { const next = new Map(prev); const derivedKey = `${agentId}:${requestId}`; @@ -1299,16 +1236,6 @@ function SessionProviderInternal({ } const payload: AudioOutputPayload = message.payload; - console.log("[SessionProvider] audio_output", { - serverId, - id: payload.id, - groupId: payload.groupId ?? null, - chunkIndex: payload.chunkIndex ?? 0, - isLastChunk: payload.isLastChunk ?? true, - format: payload.format, - isVoiceMode: payload.isVoiceMode ?? false, - audioLength: payload.audio.length, - }); const playbackGroupId = payload.groupId ?? payload.id; const chunkIndex = payload.chunkIndex ?? 0; const isFinalChunk = payload.isLastChunk ?? true; @@ -1338,16 +1265,6 @@ function SessionProviderInternal({ !payload.isVoiceMode || (voiceRuntime?.shouldPlayVoiceAudio(serverId) ?? false); const audioBlob = buildAudioPlaybackSource(bufferedChunks); - if (payload.isVoiceMode) { - logVoiceSession("audio_output_ready", { - serverId, - playbackGroupId, - chunkCount: bufferedChunks.length, - format: payload.format, - blobBytes: audioBlob.size, - shouldPlay, - }); - } const confirmAudioPlayed = async () => { await Promise.all( chunkIds.map((chunkId) => @@ -1366,18 +1283,6 @@ function SessionProviderInternal({ voiceRuntime?.onAssistantAudioStarted(serverId); } await voiceAudioEngine.play(audioBlob); - if (payload.isVoiceMode) { - logVoiceSession("audio_output_played", { - serverId, - playbackGroupId, - chunkCount: bufferedChunks.length, - }); - } - } else if (payload.isVoiceMode) { - logVoiceSession("audio_output_suppressed", { - serverId, - playbackGroupId, - }); } await confirmAudioPlayed(); } catch (error) { @@ -1397,13 +1302,6 @@ function SessionProviderInternal({ const unsubActivity = client.on("activity_log", (message) => { if (message.type !== "activity_log") return; const data = message.payload; - console.log("[SessionProvider] activity_log", { - serverId, - type: data.type, - contentPreview: - typeof data.content === "string" ? data.content.slice(0, 80) : null, - }); - if (data.type === "system" && data.content.includes("Transcribing")) { return; } @@ -1523,12 +1421,6 @@ function SessionProviderInternal({ if (message.type !== "transcription_result") return; const transcriptText = message.payload.text.trim(); - console.log("[SessionProvider] transcription_result", { - serverId, - textLength: transcriptText.length, - textPreview: transcriptText.slice(0, 80), - }); - if (!transcriptText) { voiceRuntime?.onTranscriptionResult(serverId, transcriptText); return; @@ -1542,7 +1434,6 @@ function SessionProviderInternal({ return; } const { agentId } = message.payload; - console.log("[Session] Agent deleted:", agentId); deletePendingAgentUpdate(serverId, agentId); clearArchiveAgentPending({ queryClient, serverId, agentId }); @@ -1618,7 +1509,6 @@ function SessionProviderInternal({ return; } const { agentId, archivedAt } = message.payload; - console.log("[Session] Agent archived:", agentId); clearArchiveAgentPending({ queryClient, serverId, agentId }); setAgents(serverId, (prev) => { @@ -1802,11 +1692,6 @@ function SessionProviderInternal({ worktreeName?: string; requestId?: string; }) => { - console.log( - "[Session] createAgent called with images:", - images?.length ?? 0, - images - ); if (!client) { console.warn("[Session] createAgent skipped: daemon unavailable"); return; @@ -1815,14 +1700,6 @@ function SessionProviderInternal({ let imagesData: Array<{ data: string; mimeType: string }> | undefined; try { imagesData = await encodeImages(images); - console.log( - "[Session] encodeImages result:", - imagesData?.length ?? 0, - imagesData?.map((img) => ({ - dataLength: img.data?.length ?? 0, - mimeType: img.mimeType, - })) - ); } catch (error) { console.error( "[Session] Failed to prepare images for agent creation:", diff --git a/packages/app/src/contexts/voice-context.tsx b/packages/app/src/contexts/voice-context.tsx index 748b78358..4461125cf 100644 --- a/packages/app/src/contexts/voice-context.tsx +++ b/packages/app/src/contexts/voice-context.tsx @@ -46,19 +46,6 @@ const VoiceAudioEngineContext = createContext(null); const noopSubscribe = () => () => {}; const getEmptySnapshot = () => EMPTY_SNAPSHOT; const getEmptyTelemetry = () => EMPTY_TELEMETRY; -let nextVoiceProviderInstanceId = 1; - -function getProviderTraceStack(): string | undefined { - const stack = new Error().stack; - if (!stack) { - return undefined; - } - return stack - .split("\n") - .slice(2, 7) - .map((line) => line.trim()) - .join(" | "); -} export function useVoice() { const value = useVoiceOptional(); @@ -121,47 +108,21 @@ interface VoiceProviderProps { } export function VoiceProvider({ children }: VoiceProviderProps) { - const providerIdRef = useRef(null); - if (providerIdRef.current === null) { - providerIdRef.current = nextVoiceProviderInstanceId++; - console.log("[VoiceProvider] instance_created", { - providerId: providerIdRef.current, - stack: getProviderTraceStack(), - }); - } - - const providerId = providerIdRef.current; const engineRef = useRef(null); const runtimeRef = useRef(null); - console.log("[VoiceProvider] render", { - providerId, - hasEngine: Boolean(engineRef.current), - hasRuntime: Boolean(runtimeRef.current), - }); if (!engineRef.current) { let runtime: VoiceRuntime | null = null; - console.log("[VoiceProvider] create_engine_and_runtime"); const engine = createAudioEngine({ onCaptureData: (pcm) => { - console.log("[VoiceProvider] onCaptureData", { - providerId, - bytes: pcm.byteLength, - }); runtime?.handleCapturePcm(pcm); }, onVolumeLevel: (level) => { - console.log("[VoiceProvider] onVolumeLevel", { - providerId, - level, - }); runtime?.handleCaptureVolume(level); }, onError: (error) => { console.error("[VoiceEngine] Capture error:", error); }, - }, { - traceLabel: `voice-provider:${providerId}`, }); runtime = createVoiceRuntime({ @@ -184,18 +145,12 @@ export function VoiceProvider({ children }: VoiceProviderProps) { const runtime = runtimeRef.current!; useEffect(() => { - console.log("[VoiceProvider] mount", { - providerId, - }); return () => { - console.log("[VoiceProvider] unmount", { - providerId, - }); void runtime.destroy().catch((error) => { console.error("[VoiceProvider] Failed to destroy voice runtime", error); }); }; - }, [providerId, runtime]); + }, [runtime]); return ( diff --git a/packages/app/src/hooks/use-audio-recorder.native.ts b/packages/app/src/hooks/use-audio-recorder.native.ts index 14b7bd4c8..17201edf1 100644 --- a/packages/app/src/hooks/use-audio-recorder.native.ts +++ b/packages/app/src/hooks/use-audio-recorder.native.ts @@ -18,41 +18,27 @@ export interface AudioCaptureConfig { */ async function getActualRecordingUri(createdAt: Date): Promise { try { - console.log('[AudioRecorder] Searching for recording file created at:', createdAt.toISOString()); const audioDir = new Directory(Paths.cache, 'Audio'); - console.log('[AudioRecorder] Audio cache directory URI:', audioDir.uri); - console.log('[AudioRecorder] Directory exists:', audioDir.exists); if (!audioDir.exists) { - console.log('[AudioRecorder] Audio cache directory does not exist'); return null; } const files = audioDir.list(); - console.log('[AudioRecorder] Found files in Audio cache:', files.length); if (!files.length) { - console.log('[AudioRecorder] No files found in Audio cache directory'); return null; } const validFiles = files .map(file => { const info = file.info(); - console.log('[AudioRecorder] File info:', { - uri: info.uri, - size: info.size, - creationTime: info.creationTime ? new Date(info.creationTime).toISOString() : null, - }); return info; }) .filter(f => f.size && f.size > 0); - console.log('[AudioRecorder] Valid files (size > 0):', validFiles.length); - if (validFiles.length === 0) { - console.log('[AudioRecorder] No valid files found (all are zero-byte)'); return null; } @@ -62,10 +48,6 @@ async function getActualRecordingUri(createdAt: Date): Promise { for (const file of validFiles) { if (!file.creationTime || !file.uri) continue; const diff = Math.abs(file.creationTime - createdAt.getTime()); - console.log('[AudioRecorder] Time diff for file:', { - uri: file.uri, - diffMs: diff, - }); if (diff < minDiff) { closest = file; minDiff = diff; @@ -74,15 +56,9 @@ async function getActualRecordingUri(createdAt: Date): Promise { if (closest) { const resultUri = closest.uri?.slice(0, -1) ?? null; - console.log('[AudioRecorder] Found closest file:', { - uri: resultUri, - size: closest.size, - timeDiffMs: minDiff, - }); return resultUri; } - console.log('[AudioRecorder] No closest file found'); return null; } catch (e) { console.error('[AudioRecorder] Error finding actual recording file:', e); @@ -208,7 +184,6 @@ export function useAudioRecorder(config?: AudioCaptureConfig) { attemptGuardRef.current.assertCurrent(attemptId); // Request microphone permissions - console.log('[AudioRecorder] Requesting recording permissions...'); const permissionResponse = await requestRecordingPermissionsAsync(); attemptGuardRef.current.assertCurrent(attemptId); @@ -217,38 +192,26 @@ export function useAudioRecorder(config?: AudioCaptureConfig) { } // Configure audio mode for recording - console.log('[AudioRecorder] Configuring audio mode...'); await setAudioModeAsync({ playsInSilentMode: true, allowsRecording: true, }); attemptGuardRef.current.assertCurrent(attemptId); - console.log('[AudioRecorder] Starting recording with options:', { - sampleRate: recordingOptions.sampleRate, - numberOfChannels: recordingOptions.numberOfChannels, - bitRate: recordingOptions.bitRate, - }); - const startTime = new Date(); setRecordingStartTime(startTime); attemptGuardRef.current.assertCurrent(attemptId); // Prepare the recorder before recording (required step) - console.log('[AudioRecorder] Preparing recorder...'); await recorder.prepareToRecordAsync(); attemptGuardRef.current.assertCurrent(attemptId); - console.log('[AudioRecorder] Starting recording...'); await recorder.record(); attemptGuardRef.current.assertCurrent(attemptId); - console.log('[AudioRecorder] Recording started at:', startTime.toISOString()); - console.log('[AudioRecorder] Recorder isRecording:', recorder.isRecording); } catch (error: any) { setRecordingStartTime(null); if (error instanceof AttemptCancelledError) { - console.log('[AudioRecorder] Recording start cancelled.'); return; } if (error?.message !== 'Recording cancelled') { @@ -278,15 +241,12 @@ export function useAudioRecorder(config?: AudioCaptureConfig) { // Get URI from recorder let uri = recorder.uri; - console.log('[AudioRecorder] Initial URI from recorder:', uri); // Workaround for Expo SDK 54 Android bug - find actual recording file if (recordingStartTime && (!uri || uri === '')) { - console.log('[AudioRecorder] Using workaround to find actual recording file...'); const actualUri = await getActualRecordingUri(recordingStartTime); if (actualUri) { uri = actualUri; - console.log('[AudioRecorder] Found actual recording URI:', uri); } } @@ -299,7 +259,6 @@ export function useAudioRecorder(config?: AudioCaptureConfig) { // Get file info const file = new File(uri); const exists = file.exists; - console.log('[AudioRecorder] File exists:', exists); if (!exists) { setRecordingStartTime(null); @@ -309,11 +268,6 @@ export function useAudioRecorder(config?: AudioCaptureConfig) { // Convert URI to Blob const audioBlob = await uriToBlob(uri); - console.log('[AudioRecorder] Recording converted to blob:', { - size: audioBlob.size, - type: audioBlob.type, - }); - // Clean up the temporary file file.delete(); diff --git a/packages/app/src/hooks/use-audio-recorder.web.ts b/packages/app/src/hooks/use-audio-recorder.web.ts index bc9fe5bc7..353bbd830 100644 --- a/packages/app/src/hooks/use-audio-recorder.web.ts +++ b/packages/app/src/hooks/use-audio-recorder.web.ts @@ -163,16 +163,6 @@ export function useAudioRecorder(config?: AudioCaptureConfig) { throw new Error("Microphone capture is not supported in this environment"); } - console.log("[AudioRecorder][Web] Microphone preflight", { - secureContext, - currentOrigin, - isTauri, - hasMediaDevices: - typeof navigator !== "undefined" && - !!navigator.mediaDevices && - typeof navigator.mediaDevices.getUserMedia === "function", - }); - if (!secureContext && !isTauri) { throw new Error( `Microphone access requires HTTPS or localhost. Current origin: ${currentOrigin}` diff --git a/packages/app/src/hooks/use-dictation-audio-source.native.ts b/packages/app/src/hooks/use-dictation-audio-source.native.ts index 895020704..446030944 100644 --- a/packages/app/src/hooks/use-dictation-audio-source.native.ts +++ b/packages/app/src/hooks/use-dictation-audio-source.native.ts @@ -6,53 +6,18 @@ import { createAudioEngine } from "@/voice/audio-engine"; import type { DictationAudioSource, DictationAudioSourceConfig } from "./use-dictation-audio-source.types"; -let nextDictationAudioSourceInstanceId = 1; - -function getDictationTraceStack(): string | undefined { - const stack = new Error().stack; - if (!stack) { - return undefined; - } - return stack - .split("\n") - .slice(2, 7) - .map((line) => line.trim()) - .join(" | "); -} - export function useDictationAudioSource(config: DictationAudioSourceConfig): DictationAudioSource { const onPcmSegmentRef = useRef(config.onPcmSegment); const onErrorRef = useRef(config.onError); const [volume, setVolume] = useState(0); - const sourceIdRef = useRef(null); const engineRef = useRef | null>(null); - if (sourceIdRef.current === null) { - sourceIdRef.current = nextDictationAudioSourceInstanceId++; - console.log("[DictationAudioSource] instance_created", { - sourceId: sourceIdRef.current, - stack: getDictationTraceStack(), - }); - } - - const sourceId = sourceIdRef.current; - - console.log("[DictationAudioSource] render", { - sourceId, - hasEngine: Boolean(engineRef.current), - }); - const getOrCreateEngine = useCallback(() => { if (engineRef.current) { return engineRef.current; } - console.log("[DictationAudioSource] create_engine", { - sourceId, - stack: getDictationTraceStack(), - }); - engineRef.current = createAudioEngine( - { + engineRef.current = createAudioEngine({ onCaptureData: (pcm) => { onPcmSegmentRef.current(Buffer.from(pcm).toString("base64")); }, @@ -62,59 +27,33 @@ export function useDictationAudioSource(config: DictationAudioSourceConfig): Dic onError: (error) => { onErrorRef.current?.(error); }, - }, - { - traceLabel: `dictation:${sourceId}`, - } - ); + }); return engineRef.current; - }, [sourceId]); + }, []); useEffect(() => { onPcmSegmentRef.current = config.onPcmSegment; onErrorRef.current = config.onError; }, [config.onPcmSegment, config.onError]); - useEffect(() => { - console.log("[DictationAudioSource] mount", { - sourceId, - }); - return () => { - console.log("[DictationAudioSource] unmount", { - sourceId, - }); - }; - }, [sourceId]); - const start = useCallback(async () => { - console.log("[DictationAudioSource] start", { - sourceId, - }); const engine = getOrCreateEngine(); await engine.initialize(); await engine.startCapture(); - }, [getOrCreateEngine, sourceId]); + }, [getOrCreateEngine]); const stop = useCallback(async () => { - console.log("[DictationAudioSource] stop", { - sourceId, - hasEngine: Boolean(engineRef.current), - }); await engineRef.current?.stopCapture(); setVolume(0); - }, [sourceId]); + }, []); useEffect(() => { return () => { const engine = engineRef.current; engineRef.current = null; - console.log("[DictationAudioSource] destroy_engine", { - sourceId, - hadEngine: Boolean(engine), - }); void engine?.destroy().catch(() => undefined); }; - }, [sourceId]); + }, []); return { start, diff --git a/packages/app/src/hooks/use-dictation-audio-source.web.ts b/packages/app/src/hooks/use-dictation-audio-source.web.ts index 3a3e275eb..64c2b99b2 100644 --- a/packages/app/src/hooks/use-dictation-audio-source.web.ts +++ b/packages/app/src/hooks/use-dictation-audio-source.web.ts @@ -163,15 +163,6 @@ export function useDictationAudioSource(config: DictationAudioSourceConfig): Dic if (missingNavigator) { throw new Error("Microphone capture is not supported in this environment"); } - console.log("[DictationAudio][Web] Microphone preflight", { - secureContext, - currentOrigin, - isTauri, - hasMediaDevices: - typeof navigator !== "undefined" && - !!navigator.mediaDevices && - typeof navigator.mediaDevices.getUserMedia === "function", - }); if (!secureContext && !isTauri) { throw new Error(`Microphone access requires HTTPS or localhost. Current origin: ${currentOrigin}`); } diff --git a/packages/app/src/hooks/use-explorer-open-gesture.ts b/packages/app/src/hooks/use-explorer-open-gesture.ts index 621f192ca..002f810cd 100644 --- a/packages/app/src/hooks/use-explorer-open-gesture.ts +++ b/packages/app/src/hooks/use-explorer-open-gesture.ts @@ -13,18 +13,6 @@ interface UseExplorerOpenGestureParams { onOpen: () => void; } -const IS_DEV = Boolean((globalThis as { __DEV__?: boolean }).__DEV__); - -function logExplorerOpenGesture( - event: string, - details: Record -): void { - if (!IS_DEV) { - return; - } - console.log(`[ExplorerOpenGesture] ${event}`, details); -} - export function useExplorerOpenGesture({ enabled, onOpen, @@ -82,7 +70,6 @@ export function useExplorerOpenGesture({ }) .onStart(() => { isGesturing.value = true; - runOnJS(logExplorerOpenGesture)("start", { enabled }); }) .onUpdate((event) => { // Right sidebar: start from closed position (+windowWidth) and move towards 0. @@ -103,15 +90,6 @@ export function useExplorerOpenGesture({ const shouldOpenByPosition = translateX.value < (windowWidth * 2) / 3; const shouldOpenByVelocity = event.velocityX < -500; const shouldOpen = shouldOpenByPosition || shouldOpenByVelocity; - runOnJS(logExplorerOpenGesture)("end", { - translationX: event.translationX, - velocityX: event.velocityX, - panelTranslateX: translateX.value, - windowWidth, - shouldOpenByPosition, - shouldOpenByVelocity, - shouldOpen, - }); if (shouldOpen) { animateToOpen(); runOnJS(onOpen)(); diff --git a/packages/app/src/hooks/use-sidebar-workspaces-list.ts b/packages/app/src/hooks/use-sidebar-workspaces-list.ts index e4e4a45ff..258982bca 100644 --- a/packages/app/src/hooks/use-sidebar-workspaces-list.ts +++ b/packages/app/src/hooks/use-sidebar-workspaces-list.ts @@ -302,13 +302,6 @@ export function useSidebarWorkspacesList(options?: { ) const projects = useMemo(() => { - console.log('[useSidebarWorkspacesList] build_projects', { - serverId, - hasSessionWorkspaces: Boolean(sessionWorkspaces), - workspaceCount: sessionWorkspaces?.size ?? 0, - projectOrderLength: persistedProjectOrder.length, - workspaceOrderScopeCount: Object.keys(persistedWorkspaceOrderByScope).length, - }) if (!sessionWorkspaces || sessionWorkspaces.size === 0 || !serverId) { return EMPTY_PROJECTS } @@ -320,36 +313,6 @@ export function useSidebarWorkspacesList(options?: { }) }, [persistedProjectOrder, persistedWorkspaceOrderByScope, serverId, sessionWorkspaces]) - useEffect(() => { - console.log('[useSidebarWorkspacesList] inputs_changed', { - serverId, - connectionStatus, - hasHydratedWorkspaces, - workspaceCount: sessionWorkspaces?.size ?? 0, - projectOrderLength: persistedProjectOrder.length, - workspaceOrderScopeCount: Object.keys(persistedWorkspaceOrderByScope).length, - }) - }, [ - connectionStatus, - hasHydratedWorkspaces, - persistedProjectOrder, - persistedWorkspaceOrderByScope, - serverId, - sessionWorkspaces, - ]) - - useEffect(() => { - console.log('[useSidebarWorkspacesList] projects_changed', { - serverId, - projectCount: projects.length, - projectKeys: projects.map((project) => project.projectKey), - workspaceCounts: projects.map((project) => ({ - projectKey: project.projectKey, - workspaceCount: project.workspaces.length, - })), - }) - }, [projects, serverId]) - useEffect(() => { if (!serverId || projects.length === 0) { return diff --git a/packages/app/src/runtime/host-runtime.ts b/packages/app/src/runtime/host-runtime.ts index f1babb070..914cb57d4 100644 --- a/packages/app/src/runtime/host-runtime.ts +++ b/packages/app/src/runtime/host-runtime.ts @@ -103,29 +103,6 @@ function toErrorMessage(error: unknown): string { return error instanceof Error ? error.message : String(error); } -function toReasonCode(reason: string | null): string | null { - if (!reason) { - return null; - } - const normalized = reason.toLowerCase(); - if (normalized.includes("timed out")) { - return "connect_timeout"; - } - if (normalized.includes("disposed")) { - return "disposed"; - } - if (normalized.includes("client closed") || normalized.includes("client_closed")) { - return "client_closed"; - } - if (normalized.includes("transport")) { - return "transport_error"; - } - if (normalized.includes("failed to connect")) { - return "connect_failed"; - } - return "unknown"; -} - function hashForLog(value: string): string { let hash = 0; for (let index = 0; index < value.length; index += 1) { @@ -915,35 +892,12 @@ export class HostRuntimeController { }); } - private logConnectionTransition(input: { + private logConnectionTransition(_input: { from: HostRuntimeConnectionMachineState["tag"]; to: HostRuntimeConnectionMachineState["tag"]; event: HostRuntimeConnectionMachineEvent; }): void { - const { event } = input; - const reason = - event.type === "connect_failed" - ? event.message - : event.type === "client_state" - ? event.state.status === "disconnected" - ? event.state.reason ?? event.lastError ?? null - : null - : null; - const reasonCode = - event.type === "connect_failed" - ? "connect_failed" - : toReasonCode(reason); - console.info("[HostRuntimeTransition]", { - serverId: this.host.serverId, - clientIdHash: this.clientIdHash, - from: input.from, - to: input.to, - event: event.type, - connectionPath: this.snapshot.activeConnection?.type ?? null, - generation: this.snapshot.clientGeneration, - reasonCode, - reason, - }); + // Intentionally empty - logging removed. } private trackConnectionFirstSeen(): void { diff --git a/packages/app/src/screens/agent/agent-ready-screen.tsx b/packages/app/src/screens/agent/agent-ready-screen.tsx index c2492704d..cc3e1d572 100644 --- a/packages/app/src/screens/agent/agent-ready-screen.tsx +++ b/packages/app/src/screens/agent/agent-ready-screen.tsx @@ -60,15 +60,6 @@ import { } from "./agent-ready-screen-bottom-anchor"; const EMPTY_STREAM_ITEMS: StreamItem[] = []; -const IS_DEV = Boolean((globalThis as { __DEV__?: boolean }).__DEV__); - -function logAgentExplorer(event: string, details: Record): void { - if (!IS_DEV) { - return; - } - console.log(`[AgentExplorer] ${event}`, details); -} - function logWebStickyBottom( _event: string, _details: Record @@ -264,10 +255,6 @@ function AgentScreenContent({ }, [resolveCachedCheckoutIsGit, resolvedAgentId, checkout?.isGit, serverId]); const openExplorerForActiveCheckout = useCallback(() => { const checkoutContext = resolveCurrentExplorerCheckout(); - logAgentExplorer("openExplorerForActiveCheckout", { - hasCheckoutContext: Boolean(checkoutContext), - checkoutContext, - }); if (checkoutContext) { activateExplorerTabForCheckout(checkoutContext); } diff --git a/packages/app/src/stores/panel-store.ts b/packages/app/src/stores/panel-store.ts index 58011fffb..f39b35570 100644 --- a/packages/app/src/stores/panel-store.ts +++ b/packages/app/src/stores/panel-store.ts @@ -51,23 +51,6 @@ export const DEFAULT_EXPLORER_FILES_SPLIT_RATIO = 0.38; export const MIN_EXPLORER_FILES_SPLIT_RATIO = 0.2; export const MAX_EXPLORER_FILES_SPLIT_RATIO = 0.8; -const IS_DEV = Boolean((globalThis as { __DEV__?: boolean }).__DEV__); - -function logPanelTransition( - action: string, - details: Record -): void { - if (!IS_DEV) { - return; - } - const stack = - new Error().stack - ?.split("\n") - .slice(2, 8) - .join("\n") ?? "stack unavailable"; - console.log(`[PanelStore] ${action}`, details, stack); -} - interface PanelState { // Mobile: which panel is currently shown mobileView: MobilePanelView; @@ -151,103 +134,52 @@ export const usePanelStore = create()( explorerFilesSplitRatio: DEFAULT_EXPLORER_FILES_SPLIT_RATIO, openAgentList: () => - set((state) => { - const nextState = { - mobileView: "agent-list" as const, - desktop: { ...state.desktop, agentListOpen: true }, - }; - logPanelTransition("openAgentList", { - fromMobileView: state.mobileView, - toMobileView: nextState.mobileView, - fromDesktopAgentListOpen: state.desktop.agentListOpen, - toDesktopAgentListOpen: nextState.desktop.agentListOpen, - }); - return nextState; - }), + set((state) => ({ + mobileView: "agent-list" as const, + desktop: { ...state.desktop, agentListOpen: true }, + })), openFileExplorer: () => set((state) => { const resolvedTab = resolveExplorerTabFromActiveCheckout(state); - const nextMobileView: MobilePanelView = "file-explorer"; - const nextDesktop = { ...state.desktop, fileExplorerOpen: true }; - const nextState = { - mobileView: nextMobileView, - desktop: nextDesktop, + return { + mobileView: "file-explorer" as MobilePanelView, + desktop: { ...state.desktop, fileExplorerOpen: true }, ...(resolvedTab ? { explorerTab: resolvedTab } : {}), }; - logPanelTransition("openFileExplorer", { - fromMobileView: state.mobileView, - toMobileView: nextMobileView, - fromDesktopFileExplorerOpen: state.desktop.fileExplorerOpen, - toDesktopFileExplorerOpen: nextDesktop.fileExplorerOpen, - resolvedTab: resolvedTab ?? null, - activeCheckout: state.activeExplorerCheckout, - }); - return nextState; }), closeFileExplorer: () => - set((state) => { - const nextState = { - mobileView: - state.mobileView === "file-explorer" ? ("agent" as const) : state.mobileView, - desktop: { - ...state.desktop, - fileExplorerOpen: false, - }, - }; - logPanelTransition("closeFileExplorer", { - fromMobileView: state.mobileView, - toMobileView: nextState.mobileView, - fromDesktopFileExplorerOpen: state.desktop.fileExplorerOpen, - toDesktopFileExplorerOpen: nextState.desktop.fileExplorerOpen, - }); - return nextState; - }), + set((state) => ({ + mobileView: + state.mobileView === "file-explorer" ? ("agent" as const) : state.mobileView, + desktop: { + ...state.desktop, + fileExplorerOpen: false, + }, + })), closeToAgent: () => - set((state) => { - const nextState = { - mobileView: "agent" as const, - // On desktop, closing depends on which panel triggered it - // This is called when closing via gesture/backdrop, so we close the currently active mobile panel - desktop: { - agentListOpen: - state.mobileView === "agent-list" ? false : state.desktop.agentListOpen, - fileExplorerOpen: - state.mobileView === "file-explorer" ? false : state.desktop.fileExplorerOpen, - }, - }; - logPanelTransition("closeToAgent", { - fromMobileView: state.mobileView, - toMobileView: nextState.mobileView, - fromDesktopAgentListOpen: state.desktop.agentListOpen, - toDesktopAgentListOpen: nextState.desktop.agentListOpen, - fromDesktopFileExplorerOpen: state.desktop.fileExplorerOpen, - toDesktopFileExplorerOpen: nextState.desktop.fileExplorerOpen, - }); - return nextState; - }), + set((state) => ({ + mobileView: "agent" as const, + // On desktop, closing depends on which panel triggered it + // This is called when closing via gesture/backdrop, so we close the currently active mobile panel + desktop: { + agentListOpen: + state.mobileView === "agent-list" ? false : state.desktop.agentListOpen, + fileExplorerOpen: + state.mobileView === "file-explorer" ? false : state.desktop.fileExplorerOpen, + }, + })), toggleAgentList: () => - set((state) => { + set((state) => ({ // Mobile: toggle between agent and agent-list - const newMobileView: MobilePanelView = - state.mobileView === "agent-list" ? "agent" : "agent-list"; - const nextState = { - mobileView: newMobileView, - desktop: { - ...state.desktop, - agentListOpen: !state.desktop.agentListOpen, - }, - }; - logPanelTransition("toggleAgentList", { - fromMobileView: state.mobileView, - toMobileView: nextState.mobileView, - fromDesktopAgentListOpen: state.desktop.agentListOpen, - toDesktopAgentListOpen: nextState.desktop.agentListOpen, - }); - return nextState; - }), + mobileView: (state.mobileView === "agent-list" ? "agent" : "agent-list") as MobilePanelView, + desktop: { + ...state.desktop, + agentListOpen: !state.desktop.agentListOpen, + }, + })), toggleFileExplorer: () => set((state) => { @@ -266,23 +198,12 @@ export const usePanelStore = create()( mobileView: nextMobileView, desktop: nextDesktop, }; - let resolvedTab: ExplorerTab | null = null; if (willOpenMobile || willOpenDesktop) { - resolvedTab = resolveExplorerTabFromActiveCheckout(state); + const resolvedTab = resolveExplorerTabFromActiveCheckout(state); if (resolvedTab) { nextState.explorerTab = resolvedTab; } } - logPanelTransition("toggleFileExplorer", { - fromMobileView: state.mobileView, - toMobileView: nextMobileView, - fromDesktopFileExplorerOpen: state.desktop.fileExplorerOpen, - toDesktopFileExplorerOpen: nextDesktop.fileExplorerOpen, - willOpenMobile, - willOpenDesktop, - resolvedTab: resolvedTab ?? null, - activeCheckout: state.activeExplorerCheckout, - }); return nextState; }), diff --git a/packages/app/src/styles/unistyles.ts b/packages/app/src/styles/unistyles.ts index c8595ad2d..4bcb6e072 100644 --- a/packages/app/src/styles/unistyles.ts +++ b/packages/app/src/styles/unistyles.ts @@ -2,9 +2,6 @@ import { StyleSheet } from "react-native-unistyles"; // import { UnistylesRuntime } from "react-native-unistyles"; import { lightTheme, darkTheme } from "./theme"; -console.log("[Unistyles] Configuring..."); - -// // Configure Unistyles with adaptive themes StyleSheet.configure({ themes: { light: lightTheme, @@ -22,8 +19,6 @@ StyleSheet.configure({ }, }); -console.log("[Unistyles] Configuration complete!"); - // Type augmentation for TypeScript type AppThemes = { light: typeof lightTheme; @@ -43,6 +38,4 @@ declare module "react-native-unistyles" { export interface UnistylesBreakpoints extends AppBreakpoints {} } -console.log(lightTheme.colors.background); - // UnistylesRuntime.setRootViewBackgroundColor(lightTheme.colors.background); diff --git a/packages/app/src/utils/os-notifications.ts b/packages/app/src/utils/os-notifications.ts index e05b6d804..6697bc83e 100644 --- a/packages/app/src/utils/os-notifications.ts +++ b/packages/app/src/utils/os-notifications.ts @@ -86,7 +86,6 @@ async function ensureTauriNotificationPermission( try { const granted = await notificationModule.isPermissionGranted(); if (granted) { - console.log("[OSNotifications][Tauri] Permission already granted"); return true; } } catch (error) { @@ -106,7 +105,6 @@ async function ensureTauriNotificationPermission( try { const result = await notificationModule.requestPermission(); - console.log("[OSNotifications][Tauri] requestPermission result:", result); return result === "granted"; } catch (error) { console.warn( @@ -210,12 +208,7 @@ export async function sendOsNotification( const NotificationConstructor = getWebNotificationConstructor(); if (NotificationConstructor) { const granted = await ensureNotificationPermission(); - if (!granted) { - console.log( - "[OSNotifications][Web] Permission not granted:", - NotificationConstructor.permission - ); - } else { + if (granted) { const notification = new NotificationConstructor(payload.title, { body: payload.body, data: payload.data, diff --git a/packages/app/src/voice/audio-engine.native.ts b/packages/app/src/voice/audio-engine.native.ts index 7a87c719d..f3d9e8812 100644 --- a/packages/app/src/voice/audio-engine.native.ts +++ b/packages/app/src/voice/audio-engine.native.ts @@ -34,34 +34,10 @@ interface CuePcm { durationMs: number; } -interface StreamDebugState { - count: number; - totalValue: number; - maxValue: number; - startedAtMs: number; - lastAtMs: number; - maxGapMs: number; - nextLogAtMs: number; -} - interface AudioEngineTraceOptions { traceLabel?: string; } -let nextAudioEngineInstanceId = 1; - -function getTraceStack(): string | undefined { - const stack = new Error().stack; - if (!stack) { - return undefined; - } - return stack - .split("\n") - .slice(2, 7) - .map((line) => line.trim()) - .join(" | "); -} - function resamplePcm16( pcm: Uint8Array, fromRate: number, @@ -118,33 +94,10 @@ function parsePcmSampleRate(mimeType: string): number | null { return Number.isFinite(rate) && rate > 0 ? rate : null; } -function logVoiceNative(event: string, details?: Record): void { - if (details) { - console.log(`[VoiceNative] ${event}`, details); - return; - } - console.log(`[VoiceNative] ${event}`); -} - -function createStreamDebugState(nowMs: number): StreamDebugState { - return { - count: 0, - totalValue: 0, - maxValue: 0, - startedAtMs: nowMs, - lastAtMs: nowMs, - maxGapMs: 0, - nextLogAtMs: nowMs + 1000, - }; -} - export function createAudioEngine( callbacks: AudioEngineCallbacks, - options?: AudioEngineTraceOptions + _options?: AudioEngineTraceOptions ): AudioEngine { - const engineId = nextAudioEngineInstanceId++; - const traceLabel = options?.traceLabel ?? "unknown"; - const traceStack = getTraceStack(); const refs: { initialized: boolean; captureActive: boolean; @@ -163,8 +116,6 @@ export function createAudioEngine( timeout: ReturnType | null; }; thinkingTone: CuePcm | null; - captureDebug: StreamDebugState | null; - volumeDebug: StreamDebugState | null; destroyed: boolean; } = { initialized: false, @@ -180,135 +131,36 @@ export function createAudioEngine( timeout: null, }, thinkingTone: null, - captureDebug: null, - volumeDebug: null, destroyed: false, }; - logVoiceNative("engine_created", { - engineId, - traceLabel, - stack: traceStack, - }); - - function resetCaptureDebug(): void { - refs.captureDebug = null; - } - - function resetVolumeDebug(): void { - refs.volumeDebug = null; - } - - function recordCaptureChunk(byteLength: number): void { - const nowMs = Date.now(); - const debug = refs.captureDebug ?? createStreamDebugState(nowMs); - const gapMs = debug.count === 0 ? 0 : nowMs - debug.lastAtMs; - debug.count += 1; - debug.totalValue += byteLength; - debug.maxValue = Math.max(debug.maxValue, byteLength); - debug.maxGapMs = Math.max(debug.maxGapMs, gapMs); - debug.lastAtMs = nowMs; - - if (nowMs >= debug.nextLogAtMs) { - const elapsedMs = Math.max(1, nowMs - debug.startedAtMs); - logVoiceNative("capture_summary", { - chunks: debug.count, - totalBytes: debug.totalValue, - averageChunkBytes: Math.round(debug.totalValue / debug.count), - maxChunkBytes: debug.maxValue, - chunksPerSecond: Number(((debug.count * 1000) / elapsedMs).toFixed(1)), - maxGapMs: debug.maxGapMs, - muted: refs.muted, - }); - refs.captureDebug = createStreamDebugState(nowMs); - return; - } - - refs.captureDebug = debug; - } - - function recordVolumeLevel(level: number): void { - const nowMs = Date.now(); - const debug = refs.volumeDebug ?? createStreamDebugState(nowMs); - const gapMs = debug.count === 0 ? 0 : nowMs - debug.lastAtMs; - debug.count += 1; - debug.totalValue += level; - debug.maxValue = Math.max(debug.maxValue, level); - debug.maxGapMs = Math.max(debug.maxGapMs, gapMs); - debug.lastAtMs = nowMs; - - if (nowMs >= debug.nextLogAtMs) { - const elapsedMs = Math.max(1, nowMs - debug.startedAtMs); - logVoiceNative("volume_summary", { - samples: debug.count, - averageLevel: Number((debug.totalValue / debug.count).toFixed(3)), - peakLevel: Number(debug.maxValue.toFixed(3)), - samplesPerSecond: Number(((debug.count * 1000) / elapsedMs).toFixed(1)), - maxGapMs: debug.maxGapMs, - muted: refs.muted, - }); - refs.volumeDebug = createStreamDebugState(nowMs); - return; - } - - refs.volumeDebug = debug; - } - const microphoneSubscription = addExpoTwoWayAudioEventListener( "onMicrophoneData", (event) => { - console.log("[VoiceNative] onMicrophoneData", { - engineId, - traceLabel, - captureActive: refs.captureActive, - muted: refs.muted, - bytes: event.data.byteLength, - }); if (!refs.captureActive || refs.muted) { return; } - recordCaptureChunk(event.data.byteLength); callbacks.onCaptureData(event.data); } ); - logVoiceNative("listener_added", { - engineId, - traceLabel, - event: "onMicrophoneData", - }); const volumeSubscription = addExpoTwoWayAudioEventListener( "onInputVolumeLevelData", (event) => { - console.log("[VoiceNative] onInputVolumeLevelData", { - engineId, - traceLabel, - captureActive: refs.captureActive, - muted: refs.muted, - level: event.data, - }); if (!refs.captureActive) { return; } const level = refs.muted ? 0 : event.data; - recordVolumeLevel(level); callbacks.onVolumeLevel(level); } ); - logVoiceNative("listener_added", { - engineId, - traceLabel, - event: "onInputVolumeLevelData", - }); async function ensureInitialized(): Promise { if (refs.initialized) { return; } - logVoiceNative("initialize_start"); await initialize(); refs.initialized = true; - logVoiceNative("initialize_complete"); } async function ensureMicrophonePermission(): Promise { @@ -330,10 +182,6 @@ export function createAudioEngine( const pcm16k = Buffer.from(THINKING_TONE_NATIVE_PCM_BASE64, "base64"); const durationMs = THINKING_TONE_NATIVE_PCM_DURATION_MS; refs.thinkingTone = { pcm16k, durationMs }; - logVoiceNative("thinking_tone_loaded", { - bytes: pcm16k.byteLength, - durationMs, - }); return refs.thinkingTone; } @@ -357,13 +205,6 @@ export function createAudioEngine( const inputRate = parsePcmSampleRate(audio.type || "") ?? 24000; const pcm16k = resamplePcm16(pcm, inputRate, 16000); const durationSec = pcm16k.length / 2 / 16000; - logVoiceNative("playback_start", { - inputBytes: pcm.byteLength, - outputBytes: pcm16k.byteLength, - inputRate, - durationMs: Math.round(durationSec * 1000), - queueLength: refs.queue.length, - }); playPCMData(pcm16k); clearPlaybackTimeout(); @@ -375,9 +216,6 @@ export function createAudioEngine( } active.settled = true; refs.activePlayback = null; - logVoiceNative("playback_complete", { - durationMs: Math.round(durationSec * 1000), - }); resolve(durationSec); }, durationSec * 1000); } catch (error) { @@ -386,9 +224,6 @@ export function createAudioEngine( if (active && !active.settled) { active.settled = true; refs.activePlayback = null; - logVoiceNative("playback_failed", { - error: error instanceof Error ? error.message : String(error), - }); reject(error instanceof Error ? error : new Error(String(error))); } } @@ -401,9 +236,6 @@ export function createAudioEngine( } refs.processingQueue = true; - logVoiceNative("queue_drain_start", { - queueLength: refs.queue.length, - }); while (refs.queue.length > 0) { const item = refs.queue.shift()!; try { @@ -414,13 +246,9 @@ export function createAudioEngine( } } refs.processingQueue = false; - logVoiceNative("queue_drain_complete"); } function stopLooping(): void { - if (refs.looping.active) { - logVoiceNative("thinking_tone_stop"); - } refs.looping.active = false; refs.looping.token += 1; if (refs.looping.timeout) { @@ -438,17 +266,9 @@ export function createAudioEngine( async destroy() { if (refs.destroyed) { - logVoiceNative("engine_destroy_skipped", { - engineId, - traceLabel, - }); return; } refs.destroyed = true; - logVoiceNative("engine_destroy_start", { - engineId, - traceLabel, - }); stopLooping(); this.stop(); this.clearQueue(); @@ -458,29 +278,13 @@ export function createAudioEngine( } clearPlaybackTimeout(); refs.muted = false; - resetCaptureDebug(); - resetVolumeDebug(); callbacks.onVolumeLevel(0); if (refs.initialized) { tearDown(); refs.initialized = false; } microphoneSubscription.remove(); - logVoiceNative("listener_removed", { - engineId, - traceLabel, - event: "onMicrophoneData", - }); volumeSubscription.remove(); - logVoiceNative("listener_removed", { - engineId, - traceLabel, - event: "onInputVolumeLevelData", - }); - logVoiceNative("engine_destroy_complete", { - engineId, - traceLabel, - }); }, async startCapture() { @@ -489,23 +293,12 @@ export function createAudioEngine( } try { - logVoiceNative("capture_start_requested"); - logVoiceNative("capture_trace", { - engineId, - traceLabel, - }); await ensureMicrophonePermission(); await ensureInitialized(); toggleRecording(true); refs.captureActive = true; - resetCaptureDebug(); - resetVolumeDebug(); - logVoiceNative("capture_started"); } catch (error) { const wrapped = error instanceof Error ? error : new Error(String(error)); - logVoiceNative("capture_start_failed", { - error: wrapped.message, - }); callbacks.onError?.(wrapped); throw wrapped; } @@ -517,21 +310,11 @@ export function createAudioEngine( } refs.captureActive = false; refs.muted = false; - resetCaptureDebug(); - resetVolumeDebug(); - logVoiceNative("capture_stopped"); - logVoiceNative("capture_trace", { - engineId, - traceLabel, - }); callbacks.onVolumeLevel(0); }, toggleMute() { refs.muted = !refs.muted; - logVoiceNative("mute_toggled", { - muted: refs.muted, - }); if (refs.muted) { callbacks.onVolumeLevel(0); } @@ -545,11 +328,6 @@ export function createAudioEngine( async play(audio: AudioPlaybackSource) { return await new Promise((resolve, reject) => { refs.queue.push({ audio, resolve, reject }); - logVoiceNative("queue_enqueue", { - queueLength: refs.queue.length, - blobBytes: audio.size, - mimeType: audio.type || null, - }); if (!refs.processingQueue) { void processQueue(); } @@ -557,9 +335,6 @@ export function createAudioEngine( }, stop() { - if (refs.activePlayback) { - logVoiceNative("playback_stopped"); - } stopPlayback(); clearPlaybackTimeout(); const active = refs.activePlayback; @@ -571,11 +346,6 @@ export function createAudioEngine( }, clearQueue() { - if (refs.queue.length > 0) { - logVoiceNative("queue_cleared", { - queueLength: refs.queue.length, - }); - } while (refs.queue.length > 0) { refs.queue.shift()!.reject(new Error("Playback stopped")); } @@ -605,11 +375,6 @@ export function createAudioEngine( durationMs: (audio.byteLength / 2 / 16000) * 1000, } : await ensureThinkingTone(); - logVoiceNative("thinking_tone_start", { - bytes: cue.pcm16k.byteLength, - durationMs: Math.round(cue.durationMs), - gapMs: gapMs || THINKING_TONE_REPEAT_GAP_MS, - }); const loop = () => { if (!refs.looping.active || refs.looping.token !== token) { @@ -617,9 +382,6 @@ export function createAudioEngine( } resumePlayback(); playPCMData(cue.pcm16k); - logVoiceNative("thinking_tone_tick", { - durationMs: Math.round(cue.durationMs), - }); refs.looping.timeout = setTimeout( loop, cue.durationMs + (gapMs || THINKING_TONE_REPEAT_GAP_MS) diff --git a/packages/app/src/voice/speech-segmenter.ts b/packages/app/src/voice/speech-segmenter.ts index a3315a4df..6beae1343 100644 --- a/packages/app/src/voice/speech-segmenter.ts +++ b/packages/app/src/voice/speech-segmenter.ts @@ -139,11 +139,6 @@ export class SpeechSegmenter { } flush(isLast: boolean): void { - console.log("[SpeechSegmenter] flush", { - isLast, - audioBufferLength: this.audioBuffer.length, - bufferedBytes: this.bufferedBytes, - }); if (this.audioBuffer.length === 0) { this.bufferedBytes = 0; return; @@ -162,13 +157,6 @@ export class SpeechSegmenter { * In non-continuous mode, chunk buffering is gated by the VAD state. */ pushPcmChunk(chunk: Uint8Array): void { - console.log("[SpeechSegmenter] pushPcmChunk", { - bytes: chunk.length, - speechDetectionStartMs: this.speechDetectionStartMs, - isSpeaking: this.isSpeaking, - speechConfirmed: this.speechConfirmed, - bufferedBytes: this.bufferedBytes, - }); if (chunk.length === 0) { return; } @@ -198,16 +186,6 @@ export class SpeechSegmenter { * Called with a normalized volume level (0..1). Drives VAD transitions. */ pushVolumeLevel(volume: number, nowMs: number): void { - console.log("[SpeechSegmenter] pushVolumeLevel", { - volume, - nowMs, - speechDetectionStartMs: this.speechDetectionStartMs, - isSpeaking: this.isSpeaking, - isDetecting: this.isDetecting, - speechConfirmed: this.speechConfirmed, - silenceStartMs: this.silenceStartMs, - confirmedDropStartMs: this.confirmedDropStartMs, - }); if (this.config.enableContinuousStreaming) { return; } diff --git a/packages/app/src/voice/voice-runtime.ts b/packages/app/src/voice/voice-runtime.ts index d012231b7..37c577ad3 100644 --- a/packages/app/src/voice/voice-runtime.ts +++ b/packages/app/src/voice/voice-runtime.ts @@ -96,17 +96,6 @@ const INITIAL_TELEMETRY: VoiceRuntimeTelemetrySnapshot = { segmentDuration: 0, }; -function logVoiceRuntime( - event: string, - details?: Record -): void { - if (details) { - console.log(`[VoiceRuntime] ${event}`, details); - return; - } - console.log(`[VoiceRuntime] ${event}`); -} - function snapshotsEqual( left: VoiceRuntimeSnapshot, right: VoiceRuntimeSnapshot @@ -196,15 +185,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { } const previous = state.snapshot; state.snapshot = next; - logVoiceRuntime("snapshot_changed", { - previousPhase: previous.phase, - phase: next.phase, - isVoiceMode: next.isVoiceMode, - isVoiceSwitching: next.isVoiceSwitching, - isMuted: next.isMuted, - activeServerId: next.activeServerId, - activeAgentId: next.activeAgentId, - }); emit(); } @@ -294,11 +274,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { stopCue(); return; } - logVoiceRuntime("thinking_tone_requested", { - phase: state.snapshot.phase, - isDetecting: state.telemetry.isDetecting, - isSpeaking: state.telemetry.isSpeaking, - }); deps.engine.playLooping(new Uint8Array(0), THINKING_TONE_REPEAT_GAP_MS); } @@ -346,12 +321,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { if (isLast) { state.turnInProgress = true; } - logVoiceRuntime("audio_segment_ready", { - isLast, - base64Bytes: audioData.length, - phase: state.snapshot.phase, - serverId: activeSession.adapter.serverId, - }); void activeSession.adapter .sendVoiceAudioChunk(audioData, PCM_MIME_TYPE, isLast) @@ -365,10 +334,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { ) { return; } - logVoiceRuntime("audio_segment_sent", { - isLast, - serverId: activeSession.adapter.serverId, - }); patchSnapshot((prev) => ({ ...prev, phase: "waiting" })); reconcileCue(); }) @@ -377,11 +342,9 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { }); }, onSpeechStart: () => { - logVoiceRuntime("speech_started"); stopCue(); }, onSpeechEnd: () => { - logVoiceRuntime("speech_ended"); clearSpeechInterruptTimer(); state.speechInterruptSent = false; reconcileCue(); @@ -390,10 +353,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { const previous = state.telemetry; patchTelemetry((prev) => ({ ...prev, isDetecting })); if (previous.isDetecting !== isDetecting) { - logVoiceRuntime("detecting_changed", { - isDetecting, - volume: Number(state.telemetry.volume.toFixed(3)), - }); } if (!previous.isDetecting && isDetecting) { stopCue(); @@ -405,11 +364,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { const previous = state.telemetry; patchTelemetry((prev) => ({ ...prev, isSpeaking })); if (previous.isSpeaking !== isSpeaking) { - logVoiceRuntime("speaking_changed", { - isSpeaking, - phase: state.snapshot.phase, - volume: Number(state.telemetry.volume.toFixed(3)), - }); } if (!previous.isSpeaking && isSpeaking) { @@ -429,15 +383,8 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { return; } state.speechInterruptSent = true; - logVoiceRuntime("barge_in_interrupt_triggered", { - phase: state.snapshot.phase, - }); void interruptActiveTurn(); }, REALTIME_VOICE_VAD_CONFIG.interruptGracePeriodMs); - logVoiceRuntime("barge_in_interrupt_scheduled", { - gracePeriodMs: REALTIME_VOICE_VAD_CONFIG.interruptGracePeriodMs, - phase: state.snapshot.phase, - }); } } @@ -543,9 +490,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { }, registerSession(adapter) { - logVoiceRuntime("session_registered", { - serverId: adapter.serverId, - }); sessions.set(adapter.serverId, { adapter, connected: true, @@ -566,10 +510,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { return; } session.connected = connected; - logVoiceRuntime("session_connection_changed", { - serverId, - connected, - }); if (state.snapshot.activeServerId !== serverId) { return; } @@ -581,12 +521,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { }, handleCapturePcm(chunk) { - console.log("[VoiceRuntime] handleCapturePcm", { - bytes: chunk.byteLength, - isVoiceMode: state.snapshot.isVoiceMode, - isMuted: state.snapshot.isMuted, - phase: state.snapshot.phase, - }); if (!state.snapshot.isVoiceMode || state.snapshot.isMuted) { return; } @@ -595,12 +529,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { handleCaptureVolume(level) { const nowMs = Date.now(); - console.log("[VoiceRuntime] handleCaptureVolume", { - level, - isVoiceMode: state.snapshot.isVoiceMode, - isMuted: state.snapshot.isMuted, - phase: state.snapshot.phase, - }); const displayLevel = state.snapshot.isMuted ? 0 : level; publishDisplayVolume(displayLevel, nowMs); if (!state.snapshot.isVoiceMode || state.snapshot.isMuted) { @@ -610,10 +538,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { }, async startVoice(serverId, agentId) { - logVoiceRuntime("start_requested", { - serverId, - agentId, - }); const session = sessions.get(serverId); if (!session) { throw new Error(`Voice runtime is not ready for host ${serverId}`); @@ -678,26 +602,13 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { phase: "listening", isMuted: deps.engine.isMuted(), })); - logVoiceRuntime("start_completed", { - serverId, - agentId, - }); } catch (error) { - logVoiceRuntime("start_failed", { - serverId, - agentId, - error: error instanceof Error ? error.message : String(error), - }); await performLocalStop(); throw error; } }, async stopVoice() { - logVoiceRuntime("stop_requested", { - activeServerId: state.snapshot.activeServerId, - activeAgentId: state.snapshot.activeAgentId, - }); const activeSession = getActiveSession(); const generation = state.generation + 1; state.generation = generation; @@ -722,7 +633,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { if (state.generation === generation) { resetToDisabledState(); } - logVoiceRuntime("stop_completed"); } }, @@ -736,9 +646,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { toggleMute() { const nextMuted = deps.engine.toggleMute(); - logVoiceRuntime("mute_toggled", { - muted: nextMuted, - }); if (nextMuted) { resetSegmenter(segmenter); patchSnapshot((prev) => ({ @@ -778,9 +685,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { ) { return; } - logVoiceRuntime("assistant_audio_started", { - serverId, - }); stopCue(); getActiveSession()?.adapter.setAssistantAudioPlaying(true); patchSnapshot((prev) => ({ ...prev, phase: "playing" })); @@ -791,10 +695,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { return; } - logVoiceRuntime("assistant_audio_finished", { - serverId, - turnInProgress: state.turnInProgress, - }); getActiveSession()?.adapter.setAssistantAudioPlaying(false); if (!state.snapshot.isVoiceMode) { return; @@ -822,9 +722,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { return; } - logVoiceRuntime("empty_transcription_result", { - serverId, - }); state.turnInProgress = false; patchSnapshot((prev) => ({ ...prev, phase: "listening" })); stopCue(); @@ -838,11 +735,6 @@ export function createVoiceRuntime(deps: VoiceRuntimeDeps): VoiceRuntime { ) { return; } - logVoiceRuntime("turn_event", { - serverId, - agentId, - eventType, - }); if (eventType === "turn_started") { state.turnInProgress = true;