diff --git a/apps/desktop/src/app/DesktopState.ts b/apps/desktop/src/app/DesktopState.ts index 3452fd13c0807..bb2a46ff635da 100644 --- a/apps/desktop/src/app/DesktopState.ts +++ b/apps/desktop/src/app/DesktopState.ts @@ -18,6 +18,11 @@ export class DesktopState extends Context.Service< readonly backendReady: Ref.Ref; readonly quitting: Ref.Ref; readonly primaryBackendStartup: SubscriptionRef.SubscriptionRef; + /** + * While Home is on, the renderer relays its calls to other environments. + * On macOS, closing the window then hides it so the relay keeps running. + */ + readonly keepAliveOnClose: Ref.Ref; } >()("@t3tools/desktop/app/DesktopState") {} @@ -25,6 +30,7 @@ const make = Effect.all({ backendReady: Ref.make(false), quitting: Ref.make(false), primaryBackendStartup: SubscriptionRef.make({ _tag: "Starting" }), + keepAliveOnClose: Ref.make(false), }); export const layer = Layer.effect(DesktopState, make); diff --git a/apps/desktop/src/backend/DesktopBackendConfiguration.ts b/apps/desktop/src/backend/DesktopBackendConfiguration.ts index 69a70b68a4b3d..13de36a01dda7 100644 --- a/apps/desktop/src/backend/DesktopBackendConfiguration.ts +++ b/apps/desktop/src/backend/DesktopBackendConfiguration.ts @@ -534,6 +534,11 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv ELECTRON_RUN_AS_NODE: "1", T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING: "1", T3CODE_CLI_PATH: Option.getOrUndefined(input.cliPath), + // Packaged Macs ship the dictation helper prebuilt; a checkout's server builds it from source. + T3CODE_APPLE_SPEECH_PATH: + environment.isPackaged && environment.platform === "darwin" + ? environment.path.join(environment.resourcesPath, "apple-speech", "ctrl-apple-speech") + : undefined, }, extendEnv: true, bootstrap, diff --git a/apps/desktop/src/ipc/DesktopIpcHandlers.ts b/apps/desktop/src/ipc/DesktopIpcHandlers.ts index a46dbafab0f41..f2bd6bd65b7b3 100644 --- a/apps/desktop/src/ipc/DesktopIpcHandlers.ts +++ b/apps/desktop/src/ipc/DesktopIpcHandlers.ts @@ -69,6 +69,7 @@ import { import * as PreviewIpc from "./methods/preview.ts"; import * as AppActivationIpc from "./methods/appActivation.ts"; import * as WebLinksIpc from "./methods/webLinks.ts"; +import { setKeepAliveOnClose } from "./methods/keepAliveOnClose.ts"; import { completeLegacyLocalStorage, takeLegacyLocalStorage, @@ -88,6 +89,7 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers" yield* ipc.handle(AppActivationIpc.setReady); yield* ipc.handle(AppActivationIpc.complete); yield* ipc.handle(WebLinksIpc.setReady); + yield* ipc.handle(setKeepAliveOnClose); yield* ipc.handleSync(takeLegacyLocalStorage); yield* ipc.handle(completeLegacyLocalStorage); diff --git a/apps/desktop/src/ipc/channels.ts b/apps/desktop/src/ipc/channels.ts index 0f125c05de307..9d8714ccedeb7 100644 --- a/apps/desktop/src/ipc/channels.ts +++ b/apps/desktop/src/ipc/channels.ts @@ -1,5 +1,6 @@ export const PICK_FOLDER_CHANNEL = "desktop:pick-folder"; export const SET_NOTIFICATION_BADGE_CHANNEL = "desktop:set-notification-badge"; +export const SET_KEEP_ALIVE_ON_CLOSE_CHANNEL = "desktop:set-keep-alive-on-close"; export const PICK_PROJECT_FAVICON_CHANNEL = "desktop:pick-project-favicon"; export const PICK_THEME_FILES_CHANNEL = "desktop:pick-theme-files"; export const SET_THEME_CHANNEL = "desktop:set-theme"; diff --git a/apps/desktop/src/ipc/methods/keepAliveOnClose.ts b/apps/desktop/src/ipc/methods/keepAliveOnClose.ts new file mode 100644 index 0000000000000..60bebe688de18 --- /dev/null +++ b/apps/desktop/src/ipc/methods/keepAliveOnClose.ts @@ -0,0 +1,18 @@ +import * as Effect from "effect/Effect"; +import * as Ref from "effect/Ref"; +import * as Schema from "effect/Schema"; + +import * as DesktopState from "../../app/DesktopState.ts"; +import * as IpcChannels from "../channels.ts"; +import * as DesktopIpc from "../DesktopIpc.ts"; + +/** The renderer turns this on while Home is on, so its relay survives a closed window. */ +export const setKeepAliveOnClose = DesktopIpc.makeIpcMethod({ + channel: IpcChannels.SET_KEEP_ALIVE_ON_CLOSE_CHANNEL, + payload: Schema.Boolean, + result: Schema.Void, + handler: Effect.fn("desktop.ipc.setKeepAliveOnClose")(function* (keepAlive) { + const state = yield* DesktopState.DesktopState; + yield* Ref.set(state.keepAliveOnClose, keepAlive); + }), +}); diff --git a/apps/desktop/src/preload.ts b/apps/desktop/src/preload.ts index da56807186ac5..f031d955c32b2 100644 --- a/apps/desktop/src/preload.ts +++ b/apps/desktop/src/preload.ts @@ -86,6 +86,8 @@ contextBridge.exposeInMainWorld("desktopBridge", { getClientPlatform: () => clientPlatform, setNotificationBadge: (badge) => ipcRenderer.invoke(IpcChannels.SET_NOTIFICATION_BADGE_CHANNEL, badge), + setKeepAliveOnClose: (keepAlive) => + ipcRenderer.invoke(IpcChannels.SET_KEEP_ALIVE_ON_CLOSE_CHANNEL, keepAlive), onNotificationBadgeClear: (listener) => { const handler = () => listener(); ipcRenderer.on(IpcChannels.SET_NOTIFICATION_BADGE_CHANNEL, handler); diff --git a/apps/desktop/src/window/DesktopWindow.test.ts b/apps/desktop/src/window/DesktopWindow.test.ts index b7b1dc2b28c1b..b268320566d38 100644 --- a/apps/desktop/src/window/DesktopWindow.test.ts +++ b/apps/desktop/src/window/DesktopWindow.test.ts @@ -93,6 +93,10 @@ function makeFakeBrowserWindow() { reloadIgnoringCache: vi.fn(), replaceMisspelling: vi.fn(), send: vi.fn(), + session: { + setPermissionCheckHandler: vi.fn(), + setPermissionRequestHandler: vi.fn(), + }, setBackgroundThrottling: vi.fn(), setWindowOpenHandler: vi.fn(), toggleDevTools: vi.fn(), @@ -425,6 +429,7 @@ const makeSplashScenario = (createOutcomes: readonly (Electron.BrowserWindow | n recordMetrics: () => Effect.void, shutdown: Effect.void, }), + DesktopState.layer, layerDesktopEnvironment, DesktopAppSettings.layerTest(), layerDesktopClientSettings, diff --git a/apps/desktop/src/window/DesktopWindow.ts b/apps/desktop/src/window/DesktopWindow.ts index df1edfccfb8e1..e8aff157a84b8 100644 --- a/apps/desktop/src/window/DesktopWindow.ts +++ b/apps/desktop/src/window/DesktopWindow.ts @@ -14,8 +14,8 @@ import { type DesktopSnapShotEvent, DEFAULT_CLIENT_SETTINGS } from "@t3tools/con import * as DesktopAppIcon from "../app/DesktopAppIcon.ts"; import type * as DesktopAssets from "../app/DesktopAssets.ts"; import * as DesktopEnvironment from "../app/DesktopEnvironment.ts"; -import { makeComponentLogger } from "../app/DesktopObservability.ts"; import * as DesktopState from "../app/DesktopState.ts"; +import { makeComponentLogger } from "../app/DesktopObservability.ts"; import * as ElectronMenu from "../electron/ElectronMenu.ts"; import { getDesktopUrl } from "../electron/ElectronProtocol.ts"; import * as ElectronShell from "../electron/ElectronShell.ts"; @@ -36,6 +36,7 @@ import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts"; import * as DesktopClientSettings from "../settings/DesktopClientSettings.ts"; import * as ElectronApp from "../electron/ElectronApp.ts"; import * as DesktopRendererHistory from "../telemetry/DesktopRendererHistory.ts"; +import { installMainWindowPermissionHandlers } from "./MainWindowPermissions.ts"; import { makeQuitShortcutHandler } from "./QuitHold.ts"; import { copyContextMenuImage } from "./ContextMenuImage.ts"; @@ -421,6 +422,10 @@ export const make = Effect.gen(function* () { if (environment.platform === "darwin") { window.setAutoHideCursor(false); } + installMainWindowPermissionHandlers(window.webContents.session, { + appUrl: applicationUrl, + platform: environment.platform, + }); let boundsPersistFiber: Fiber.Fiber | undefined; let pendingBoundsPersistFiber: Fiber.Fiber | undefined; let boundsPersistenceEnabled = persistedBounds === null || restoredPersistedBounds; @@ -690,8 +695,17 @@ export const make = Effect.gen(function* () { window.on("move", scheduleBoundsPersist); window.on("maximize", scheduleBoundsPersist); window.on("unmaximize", scheduleBoundsPersist); - window.on("close", () => { + window.on("close", (event) => { runFork(flushBoundsPersist); + // Hiding keeps the renderer, and with it Home's relay, alive until quit. + if ( + environment.platform === "darwin" && + Ref.getUnsafe(desktopState.keepAliveOnClose) && + !Ref.getUnsafe(desktopState.quitting) + ) { + event.preventDefault(); + window.hide(); + } }); if (environment.platform === "darwin") { diff --git a/apps/desktop/src/window/MainWindowPermissions.test.ts b/apps/desktop/src/window/MainWindowPermissions.test.ts new file mode 100644 index 0000000000000..f091d052eb1b8 --- /dev/null +++ b/apps/desktop/src/window/MainWindowPermissions.test.ts @@ -0,0 +1,72 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { + decideMainWindowMediaRequest, + isAppUrl, + isMainWindowPermissionAllowed, +} from "./MainWindowPermissions.ts"; + +const APP_URL = "t3code://app/"; + +function decide(overrides: Partial[0]> = {}) { + return decideMainWindowMediaRequest({ + requestingUrl: "t3code://app/threads/abc", + appUrl: APP_URL, + mediaTypes: ["audio"], + platform: "darwin", + microphoneStatus: () => "granted", + ...overrides, + }); +} + +describe("isAppUrl", () => { + it("matches the app shell and nothing that merely shares its prefix", () => { + expect(isAppUrl("t3code://app", APP_URL)).toBe(true); + expect(isAppUrl("t3code://app/settings", APP_URL)).toBe(true); + expect(isAppUrl("t3code://application/", APP_URL)).toBe(false); + expect(isAppUrl("https://example.com/", APP_URL)).toBe(false); + expect(isAppUrl(undefined, APP_URL)).toBe(false); + }); +}); + +describe("decideMainWindowMediaRequest", () => { + it("denies media to frames outside the app shell", () => { + expect(decide({ requestingUrl: "https://example.com/embed" })).toBe("deny"); + }); + + it("asks macOS for the microphone until the user has granted it", () => { + expect(decide({ microphoneStatus: () => "not-determined" })).toBe("ask-microphone"); + expect(decide({ microphoneStatus: () => "denied" })).toBe("ask-microphone"); + expect(decide()).toBe("grant"); + expect( + isMainWindowPermissionAllowed("media", APP_URL, APP_URL, { + platform: "darwin", + microphoneStatus: () => "not-determined", + }), + ).toBe(false); + expect( + isMainWindowPermissionAllowed("media", APP_URL, APP_URL, { + platform: "darwin", + microphoneStatus: () => "granted", + }), + ).toBe(true); + }); + + it("grants the microphone directly off macOS", () => { + expect(decide({ platform: "win32", microphoneStatus: () => "unknown" })).toBe("grant"); + }); + + it("keeps granting video-only capture such as preview tab recording", () => { + expect(decide({ mediaTypes: ["video"], microphoneStatus: () => "denied" })).toBe("grant"); + }); +}); + +it("denies synchronous clipboard reads for embedded origins and the app shell", () => { + for (const origin of ["https://example.com/frame", APP_URL]) { + expect(isMainWindowPermissionAllowed("deprecated-sync-clipboard-read", origin, APP_URL)).toBe( + false, + ); + } + expect(isMainWindowPermissionAllowed("media", "https://example.com/frame", APP_URL)).toBe(false); + expect(isMainWindowPermissionAllowed("media", APP_URL, APP_URL)).toBe(true); +}); diff --git a/apps/desktop/src/window/MainWindowPermissions.ts b/apps/desktop/src/window/MainWindowPermissions.ts new file mode 100644 index 0000000000000..ec926731257b3 --- /dev/null +++ b/apps/desktop/src/window/MainWindowPermissions.ts @@ -0,0 +1,77 @@ +import * as Electron from "electron"; + +export type MediaPermissionDecision = "grant" | "deny" | "ask-microphone"; + +/** Whether `url` belongs to the app shell served from `appUrl` (e.g. `t3code://app/`). */ +export function isAppUrl(url: string | undefined, appUrl: string): boolean { + if (!url) return false; + // Custom schemes have an opaque WHATWG origin, so compare the serialized prefix. + const appOrigin = appUrl.endsWith("/") ? appUrl.slice(0, -1) : appUrl; + return url === appOrigin || url.startsWith(`${appOrigin}/`); +} + +/** + * Media requests come from the app shell (voice conversations use the + * microphone; preview tab recording routes `getDisplayMedia` through the same + * permission). Frames from any other origin never get media. On macOS the + * microphone also needs the system's consent, asked for on first use. + */ +export function decideMainWindowMediaRequest(input: { + readonly requestingUrl: string; + readonly appUrl: string; + readonly mediaTypes: ReadonlyArray<"audio" | "video">; + readonly platform: NodeJS.Platform; + readonly microphoneStatus: () => string; +}): MediaPermissionDecision { + if (!isAppUrl(input.requestingUrl, input.appUrl)) return "deny"; + if (!input.mediaTypes.includes("audio") || input.platform !== "darwin") return "grant"; + return input.microphoneStatus() === "granted" ? "grant" : "ask-microphone"; +} + +export function isMainWindowPermissionAllowed( + permission: string, + origin: string | undefined, + appUrl: string, + media?: { readonly platform: NodeJS.Platform; readonly microphoneStatus: () => string }, +): boolean { + return permission === "media" + ? isAppUrl(origin, appUrl) && + (media?.platform !== "darwin" || media.microphoneStatus() !== "not-determined") + : permission !== "deprecated-sync-clipboard-read"; +} + +/** + * Installs the main window session's permission handlers. Only `media` is + * decided here. Synchronous clipboard reads keep Electron's default denial. + */ +export function installMainWindowPermissionHandlers( + session: Electron.Session, + options: { readonly appUrl: string; readonly platform: NodeJS.Platform }, +): void { + session.setPermissionRequestHandler((_webContents, permission, callback, details) => { + if (permission !== "media") { + callback(isMainWindowPermissionAllowed(permission, details.requestingUrl, options.appUrl)); + return; + } + const decision = decideMainWindowMediaRequest({ + requestingUrl: details.requestingUrl, + appUrl: options.appUrl, + mediaTypes: "mediaTypes" in details ? (details.mediaTypes ?? []) : [], + platform: options.platform, + microphoneStatus: () => Electron.systemPreferences.getMediaAccessStatus("microphone"), + }); + if (decision !== "ask-microphone") { + callback(decision === "grant"); + return; + } + Electron.systemPreferences.askForMediaAccess("microphone").then(callback, () => { + callback(false); + }); + }); + session.setPermissionCheckHandler((_webContents, permission, requestingOrigin) => + isMainWindowPermissionAllowed(permission, requestingOrigin, options.appUrl, { + platform: options.platform, + microphoneStatus: () => Electron.systemPreferences.getMediaAccessStatus("microphone"), + }), + ); +} diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts index 60723c9e74694..4b25c2711f5a2 100644 --- a/apps/mobile/app.config.ts +++ b/apps/mobile/app.config.ts @@ -255,6 +255,10 @@ const sharingPlugin: NonNullable[number] = [ }, ]; +const MICROPHONE_PERMISSION = + "Allow Ctrl to use your microphone for voice input and voice conversations."; +const CAMERA_PERMISSION = "Allow Ctrl to access your camera so you can scan pairing QR codes."; + // Match iOS PostScript names on Android so RN and the native composer share fonts before runtime loading. const config: ExpoConfig = { @@ -346,8 +350,11 @@ const config: ExpoConfig = { }, // JS back dispatch needs RN's Android 16 shim and withAndroidPredictiveBackCompat on Android 13-15. predictiveBackGestureEnabled: true, - // expo-sensors declares this for its pedometer, which the app does not use. - blockedPermissions: ["android.permission.ACTIVITY_RECOGNITION"], + // The app uses neither expo-sensors' pedometer nor WebRTC screen sharing. + blockedPermissions: [ + "android.permission.ACTIVITY_RECOGNITION", + "android.permission.SYSTEM_ALERT_WINDOW", + ], }, web: { favicon: variant.assets.appIcon, @@ -412,22 +419,30 @@ const config: ExpoConfig = { [ "expo-audio", { - microphonePermission: "Allow Ctrl to use your microphone for voice input.", - recordAudioAndroid: false, + microphonePermission: MICROPHONE_PERMISSION, + recordAudioAndroid: true, enableBackgroundPlayback: false, enableBackgroundRecording: false, }, ], + // Voice conversations run over WebRTC. Pass both usage strings so its + // plugin cannot fall back to generic ones. + [ + "@config-plugins/react-native-webrtc", + { cameraPermission: CAMERA_PERMISSION, microphonePermission: MICROPHONE_PERMISSION }, + ], [ "expo-camera", { - cameraPermission: "Allow Ctrl to access your camera so you can scan pairing QR codes.", + cameraPermission: CAMERA_PERMISSION, microphonePermission: false, barcodeScannerEnabled: true, recordAudioAndroid: false, }, ], - ["expo-image-picker", { photosPermission: false, microphonePermission: false }], + // `microphonePermission: false` would block RECORD_AUDIO on Android for every + // package, including voice conversations, so share the app's usage string. + ["expo-image-picker", { photosPermission: false, microphonePermission: MICROPHONE_PERMISSION }], [ "expo-splash-screen", { diff --git a/apps/mobile/package.json b/apps/mobile/package.json index a49c3856864f1..cca018d013373 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -131,6 +131,7 @@ "react-native-safe-area-context": "~5.10.1", "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.48.tgz", "react-native-svg": "15.16.0", + "react-native-webrtc": "124.0.8", "react-native-webview": "14.0.1", "react-native-worklets": "0.13.0", "remark-gfm": "catalog:", @@ -141,6 +142,7 @@ }, "devDependencies": { "@babel/core": "^7.29.7", + "@config-plugins/react-native-webrtc": "15.0.2", "@effect/platform-node": "catalog:", "@effect/vitest": "catalog:", "@pierre/trees": "1.0.0-beta.6", diff --git a/apps/mobile/src/components/ui/AppSymbol.tsx b/apps/mobile/src/components/ui/AppSymbol.tsx index 4b17bddd3c324..63ecde90c5bc0 100644 --- a/apps/mobile/src/components/ui/AppSymbol.tsx +++ b/apps/mobile/src/components/ui/AppSymbol.tsx @@ -84,6 +84,7 @@ import IconLayoutSidebar from "@tabler/icons-react-native/IconLayoutSidebar"; import IconLayoutSidebarRight from "@tabler/icons-react-native/IconLayoutSidebarRight"; import IconLetterSpacing from "@tabler/icons-react-native/IconLetterSpacing"; import IconMicrophone from "@tabler/icons-react-native/IconMicrophone"; +import IconMicrophoneOff from "@tabler/icons-react-native/IconMicrophoneOff"; import IconLink from "@tabler/icons-react-native/IconLink"; import IconListNumbers from "@tabler/icons-react-native/IconListNumbers"; import IconMenu2 from "@tabler/icons-react-native/IconMenu2"; @@ -131,6 +132,7 @@ import IconUserQuestion from "@tabler/icons-react-native/IconUserQuestion"; import IconUserPlus from "@tabler/icons-react-native/IconUserPlus"; import IconUsers from "@tabler/icons-react-native/IconUsers"; import IconWifi from "@tabler/icons-react-native/IconWifi"; +import IconWaveSine from "@tabler/icons-react-native/IconWaveSine"; import IconWifiOff from "@tabler/icons-react-native/IconWifiOff"; import IconWorld from "@tabler/icons-react-native/IconWorld"; import IconX from "@tabler/icons-react-native/IconX"; @@ -229,6 +231,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = { macstudio: IconDeviceDesktop, magnifyingglass: IconSearch, mic: IconMicrophone, + "mic.slash": IconMicrophoneOff, paintbrush: IconPalette, pencil: IconPencil, "person.crop.circle": IconUserCircle, @@ -280,6 +283,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = { "tray.and.arrow.up": IconUpload, trash: IconTrash, wifi: IconWifi, + waveform: IconWaveSine, "wifi.slash": IconWifiOff, xmark: IconX, "xmark.circle.fill": IconCircleXFilled, diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx index ea2928f531374..8ed80966f4798 100644 --- a/apps/mobile/src/features/threads/ThreadComposer.tsx +++ b/apps/mobile/src/features/threads/ThreadComposer.tsx @@ -115,6 +115,9 @@ import { import { useVoiceInputController } from "../voice-input/useVoiceInputController"; import { resolveVoiceComposerPresentation } from "../voice-input/voiceInputPresentation"; import type { ExistingThreadSettingsRouteParams } from "./ThreadSettingsSheet"; +import { ComposerVoiceModeButton, ComposerVoiceStrip } from "../voice-mode/ComposerVoiceMode"; +import { useVoiceModePhase, useVoiceModeThreadLifecycle } from "../voice-mode/useVoiceMode"; +import { voiceMode, voiceModeSupported } from "../voice-mode/voiceMode"; import { useThreadSettingsSheetPresentation, type NavigationWithFinishTransitioning, @@ -561,17 +564,37 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps onUsageLimits: usageLimitsOffered && draftAttachments.length === 0 ? openUsageLimits : undefined, }); + const voiceTarget = { environmentId: props.environmentId, threadId: props.selectedThread.id }; + const voicePhase = useVoiceModePhase(voiceTarget); + useVoiceModeThreadLifecycle(voiceTarget); + // Dictation and a voice conversation both need the microphone. + const voiceConversationLive = voicePhase !== "idle"; const voiceInput = useVoiceInputController({ ownerKey: composerDraftKey, label: props.selectedThread.title || "Untitled thread", readDraftMessage: () => getComposerDraftSnapshot(composerDraftKey).text, subscribeToDraftChanges: (onChange) => appAtomRegistry.subscribe(composerDraftsAtom, onChange), selection: composerMenu.selection, + disabled: voiceConversationLive, onChangeDraftMessage: (text) => setComposerDraftText(composerDraftKey, text), onChangeSelection: composerMenu.onSelectionChange, }); const isSubmissionLocked = props.interactionLocked === true || queuedEdit?.saving === true || voiceInput.blocksSubmission; + const offersVoiceConversation = + voiceModeSupported && + props.serverConfig?.providers.find( + (provider) => provider.instanceId === props.selectedThread.providerInstanceId, + )?.supportsVoice === true; + // The server attaches voice to the thread's provider thread, which the first + // run creates. An optimistic pending thread already has a message timestamp. + const canToggleVoiceConversation = + voiceConversationLive || + (props.connectionState === "connected" && + props.canOperateThread && + props.selectedThread.activeProviderThreadId !== null && + !voiceInput.isGloballyBusy); + const toggleVoiceConversation = () => voiceMode.toggle(voiceTarget); const voicePresentation = resolveVoiceComposerPresentation( voiceInput.state, voiceInput.elapsedSeconds, @@ -583,6 +606,14 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps const usesLargeControls = useSidebarWorkspaceTabs() === "picker" || (Platform.OS === "ios" && Platform.isPad); const surfacePaddingVertical = usesLargeControls ? 9 : floatingSidebarComposer ? 6 : 2; + const voiceModeButton = offersVoiceConversation ? ( + + ) : null; const [compactRowWidth, setCompactRowWidth] = useState(0); const compactAttachmentLimit = compactRowWidth >= 500 ? 3 : 1; const compactEditor = useCompactComposerEditor(bodyText, draftMessage); @@ -864,6 +895,9 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps {selectedProviderStatus.compatibilityAdvisory.message} ) : null} + + {voiceConversationLive ? : null} + {modelUnavailable ? (