Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6494a4a
feat(contracts): voice transcription settings, upload RPC, and dictat…
Oct 21, 2026
debc567
feat(server): store the voice transcription API key in the secret store
Oct 21, 2026
90cb31d
feat(server): transcribe voice recordings through a signed upload route
Oct 21, 2026
7fe49cf
feat(server): serve voice.createTranscriptionUrl over the WebSocket RPC
Oct 21, 2026
d66d268
feat(client-runtime): environment-backed voice transcriber
Oct 21, 2026
cfc1ff2
feat(contracts): add an xAI provider to voice transcription settings
Oct 21, 2026
9a03a81
feat(web): MediaRecorder voice recorder and environment transcriber b…
Oct 21, 2026
2d20002
Merge branch 'feat/voice-input-web' into feat/voice-input-client
Oct 21, 2026
204191e
feat(server): transcribe voice recordings through xAI speech-to-text
Oct 21, 2026
de220b4
feat(web): voice input in the composer
Oct 21, 2026
ebbc00b
feat(desktop): microphone privacy pane and usage description for voic…
Oct 21, 2026
8414137
feat(contracts): add the apple-on-device voice transcription provider
Oct 21, 2026
dc791ed
Merge branch 'feat/voice-input-web' into feat/voice-input-client
Oct 21, 2026
121ad2f
fix(web): voice input survives cancelled prompts, unplugged microphon…
Oct 21, 2026
542791a
feat(web): voice input settings
Oct 21, 2026
86cd109
docs: voice input on desktop and web
Oct 21, 2026
a4c08d8
feat(native): add the Apple speech helper for on-device transcription
Oct 21, 2026
31e60e9
feat(server): transcribe voice recordings with Apple on-device speech
Oct 21, 2026
48d5049
feat(desktop): bundle the Apple speech helper in mac builds
Oct 21, 2026
d1d9608
Merge branch 'feat/voice-input-client' into feat/voice-input-web
Oct 21, 2026
8c80aea
feat(desktop): open the macOS microphone privacy pane from voice input
Oct 21, 2026
f47b8be
fix(native): Apple speech helper answers empty recordings instead of …
Oct 21, 2026
eefa01f
fix(native): write the universal Apple speech helper atomically
Oct 21, 2026
469b912
fix(desktop): build mac apps on an older SDK without the Apple speech…
Oct 21, 2026
e218545
chore(cli): stop plumbing the Apple speech helper into CLI archives
Oct 21, 2026
c81b920
fix(server): read Apple speech availability without waiting for the p…
Oct 21, 2026
6997ff5
fix(server): structured voice transcription errors with an internal f…
Oct 21, 2026
7e0efe9
fix(server): accept each voice upload link once and keep it out of tr…
Oct 21, 2026
ee75ec2
fix(server): refuse to send the voice transcription key over public http
Oct 21, 2026
347a6af
fix(server): cap voice transcription upstream responses at 1 MiB
Oct 21, 2026
4525b05
fix(voice): keep a failed recording for retry and report refused commits
Oct 21, 2026
59833be
fix(voice): preflight transcription settings and keep the server's re…
Oct 21, 2026
efa94ad
fix(server): accept voice uploads without a Content-Length header
Oct 21, 2026
bec6409
fix(server): drop the saved voice transcription key when the endpoint…
Oct 21, 2026
0f6942a
fix(web): name the microphone failure and the place to unblock it
Oct 21, 2026
0a1fa2a
style(server): fit the untraced path comment on one line
Oct 21, 2026
09ba807
perf(web): write WAV samples through an Int16Array and skip the mono …
Oct 21, 2026
f2701e0
fix(web): leave Escape to other editables and expose retry from the v…
Oct 21, 2026
181a490
fix(web): show voice input errors as a composer banner and keep the f…
Oct 21, 2026
c1a9a7f
fix(web): voice settings name the shortcut, not the command id
Oct 21, 2026
8574eff
fix(desktop): skip the drag-in helper for the microphone privacy pane
Oct 21, 2026
e9d7cef
docs: voice input scope, probe timing, retry, and the shortcut
Oct 21, 2026
1a0d362
chore(voice): drop an unused re-export knip flagged
Oct 21, 2026
e93c466
Merge branch 'feat/voice-input-web' into feat/voice-input-client
Oct 21, 2026
a236050
fix(voice): read the not-configured reason through the decoded error …
Oct 21, 2026
542c056
fix(voice): send the transcription upload as bytes so a 401 cannot ex…
Oct 21, 2026
a609fb3
test(server): pin that a config subscriber learns of Apple transcript…
Oct 21, 2026
7a068c2
docs(server): restore why the descriptor reads runtime capabilities p…
Oct 21, 2026
38a5336
fix(server): re-send the config snapshot when the Apple speech probe …
Oct 21, 2026
6d0c346
fix(voice): leave Apple availability to the server's mint check
Oct 21, 2026
ed569a0
fix(voice): keep failed recordings only on clients that can resend them
Oct 21, 2026
17a717f
fix(voice): offer retry only for failures that sending the audio agai…
Oct 21, 2026
b7b906a
fix(server): give up on the Apple speech probe after five tries
Oct 21, 2026
9778650
test(server): check that transcribe gives up on a helper that never a…
Oct 21, 2026
70f0bee
fix(web): keep composer focus when the voice banner opens settings
Oct 21, 2026
3d12e77
test(web): keep voice input browser test state inside setup
Oct 21, 2026
f768f01
test(server): say why the undici fetch test still waits after transcribe
Oct 21, 2026
58d4118
chore(voice): drop comments that restate the code
Oct 21, 2026
b9395d8
fix(voice): keep the recording when its upload arrives damaged
Oct 21, 2026
ca8df18
Merge remote-tracking branch 'origin/main' into feat/voice-input-web
Oct 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions apps/desktop/src/backend/DesktopBackendConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,42 @@ describe("DesktopBackendConfiguration", () => {
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);

it.effect("hands the packaged Apple speech helper only to a macOS backend", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-desktop-backend-config-test-",
});
const resourcesPath = path.join(baseDir, "resources");
const helperPath = path.join(resourcesPath, "apple-speech/t3-apple-speech");
yield* fileSystem.makeDirectory(path.dirname(helperPath), { recursive: true });
yield* fileSystem.writeFileString(helperPath, "binary");
yield* fileSystem.chmod(helperPath, 0o755);

const resolveBootstrap = (platform: NodeJS.Platform) =>
Effect.gen(function* () {
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
return (yield* configuration.resolvePrimary).bootstrap;
}).pipe(
Effect.provide(
layerBackendConfiguration().pipe(
Layer.provideMerge(layerServerExposure),
Layer.provideMerge(DesktopAppSettings.layerTest()),
Layer.provideMerge(DesktopWslServerTree.layerTest()),
Layer.provideMerge(DesktopWslEnvironment.layerTest()),
Layer.provideMerge(
layerEnvironment(baseDir, { platform, isPackaged: true, resourcesPath }),
),
),
),
);

assert.equal((yield* resolveBootstrap("darwin")).appleSpeechHelperPath, helperPath);
assert.notProperty(yield* resolveBootstrap("linux"), "appleSpeechHelperPath");
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);

it("resolvePrimaryLabel is runSync-safe against the real WSL availability probe", async () => {
// oxlint-disable-next-line t3code/no-manual-effect-runtime-in-tests -- This test intentionally replicates the sync IPC handler's runSync path to catch a regression to async-only resolution; it.effect would mask it.
const runtime = ManagedRuntime.make(
Expand Down
84 changes: 58 additions & 26 deletions apps/desktop/src/backend/DesktopBackendConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,38 +170,60 @@ function resourceMonitorBinaryName(platform: NodeJS.Platform): string {
return platform === "win32" ? "t3-resource-monitor.exe" : "t3-resource-monitor";
}

const resolveBundledHelperPath = Effect.fn("desktop.backendConfiguration.resolveBundledHelperPath")(
function* (input: {
readonly directory: string;
readonly binaryName: string;
readonly devBuildDirectories: ReadonlyArray<string>;
}) {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
const candidates = environment.isDevelopment
? input.devBuildDirectories.map((directory) =>
environment.path.join(environment.rootDir, directory, input.binaryName),
)
: environment.isPackaged
? [environment.path.join(environment.resourcesPath, input.directory, input.binaryName)]
: environment.resolveResourcePathCandidates(
environment.path.join(input.directory, input.binaryName),
);

for (const candidate of candidates) {
if (yield* fileSystem.exists(candidate).pipe(Effect.orElseSucceed(() => false))) {
return Option.some(candidate);
}
}

return Option.none<string>();
},
);

const resolveResourceMonitorPath = Effect.fn(
"desktop.backendConfiguration.resolveResourceMonitorPath",
)(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
const binaryName = resourceMonitorBinaryName(environment.platform);
const candidates = environment.isDevelopment
? [
environment.path.join(
environment.rootDir,
"native/resource-monitor/target/release",
binaryName,
),
environment.path.join(
environment.rootDir,
"native/resource-monitor/target/debug",
binaryName,
),
]
: environment.isPackaged
? [environment.path.join(environment.resourcesPath, "resource-monitor", binaryName)]
: environment.resolveResourcePathCandidates(
environment.path.join("resource-monitor", binaryName),
);
return yield* resolveBundledHelperPath({
directory: "resource-monitor",
binaryName: resourceMonitorBinaryName(environment.platform),
devBuildDirectories: [
"native/resource-monitor/target/release",
"native/resource-monitor/target/debug",
],
});
});

for (const candidate of candidates) {
if (yield* fileSystem.exists(candidate).pipe(Effect.orElseSucceed(() => false))) {
return Option.some(candidate);
}
const resolveAppleSpeechHelperPath = Effect.fn(
"desktop.backendConfiguration.resolveAppleSpeechHelperPath",
)(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
if (environment.platform !== "darwin") {
return Option.none<string>();
}

return Option.none<string>();
return yield* resolveBundledHelperPath({
directory: "apple-speech",
binaryName: "t3-apple-speech",
devBuildDirectories: ["native/apple-speech/build"],
});
});

const readPersistedBackendObservabilitySettings = Effect.gen(function* () {
Expand Down Expand Up @@ -500,6 +522,7 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
function* (
input: SharedBootstrapInput & {
readonly resourceMonitorPath: Option.Option<string>;
readonly appleSpeechHelperPath: Option.Option<string>;
readonly cliPath: Option.Option<string>;
readonly shellEnvironmentPrepared: boolean;
},
Expand Down Expand Up @@ -532,6 +555,10 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
onNone: () => ({}),
onSome: (resourceMonitorPath) => ({ resourceMonitorPath }),
}),
...Option.match(input.appleSpeechHelperPath, {
onNone: () => ({}),
onSome: (appleSpeechHelperPath) => ({ appleSpeechHelperPath }),
}),
...buildObservabilityFragment(input.observabilitySettings),
};

Expand Down Expand Up @@ -817,6 +844,10 @@ export const make = Effect.gen(function* () {
Effect.provideService(FileSystem.FileSystem, fileSystem),
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
);
const appleSpeechHelperPath = yield* resolveAppleSpeechHelperPath().pipe(
Effect.provideService(FileSystem.FileSystem, fileSystem),
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
);
const cliPath = yield* DesktopCliShim.install.pipe(
Effect.provideService(FileSystem.FileSystem, fileSystem),
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
Expand All @@ -825,6 +856,7 @@ export const make = Effect.gen(function* () {
return yield* resolvePrimaryStartConfig({
...shared,
resourceMonitorPath,
appleSpeechHelperPath,
cliPath,
shellEnvironmentPrepared,
}).pipe(
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/ipc/methods/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ export const openSystemSettings = DesktopIpc.makeIpcMethod({
if (environment.platform !== "darwin") return false;
const owner = Electron.BrowserWindow.getFocusedWindow();
const opened = yield* shell.openSystemSettings(pane);
if (opened && environment.isPackaged) {
// The helper explains dragging T3 Code into the list; the microphone pane has no add button.
if (opened && environment.isPackaged && pane === "full-disk-access") {
const permissions = yield* MacPermissions.MacPermissions;
const isGranted = yield* safariPermissionCheck;
yield* permissions.showHelper(pane, owner, isGranted);
yield* permissions.showHelper(pane, owner, yield* safariPermissionCheck);
}
return opened;
}),
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/src/permissions/MacPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const MAC_PERMISSION_SETTINGS_URLS = {
accessibility: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility",
"full-disk-access":
"x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_AllFiles",
microphone: "x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone",
};

export type MacPermission = keyof typeof MAC_PERMISSION_SETTINGS_URLS;
Expand All @@ -12,4 +13,5 @@ export const MAC_PERMISSION_TITLES: Record<MacPermission, string> = {
"screen-recording": "Screen Recording",
accessibility: "Accessibility",
"full-disk-access": "Full Disk Access",
microphone: "Microphone",
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { AppText as Text } from "../../components/ui/AppText";
import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
import { cn } from "../../lib/cn";
import { VOICE_WAVEFORM_SAMPLE_COUNT } from "@t3tools/client-runtime/voice-input";
import type { VoiceComposerPresentation } from "./voiceInputPresentation";
import { VOICE_WAVEFORM_SAMPLE_COUNT } from "./voiceInputMetering";

const DICTATION_TIMING = {
duration: 220,
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/features/voice-input/VoiceInputProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import { getLocalVoiceTranscriber } from "../../native/voiceTranscription";
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import { getNativeShowcaseScene } from "../showcase/nativeShowcaseScene";
import {
normalizeVoiceInputDecibels,
VOICE_RECORDING_LIMIT_SECONDS,
VOICE_WAVEFORM_SAMPLE_COUNT,
voiceInputBlocksSubmission,
type VoiceInputState,
} from "@t3tools/client-runtime/voice-input";
import { createLazyVoiceRecorder, type LazyVoiceRecorder } from "./lazyVoiceRecorder";
import { normalizeVoiceInputDecibels, VOICE_WAVEFORM_SAMPLE_COUNT } from "./voiceInputMetering";
import { VoiceInputSession } from "./voiceInputSession";

const INITIAL_STATE: VoiceInputState = { phase: "idle", error: null, errorAction: null };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ describe("createLazyVoiceRecorder", () => {
configureRecording: async () => undefined,
releaseRecording: async () => undefined,
deleteRecording: (uri) => deleted.push(uri),
retainFailedRecordings: false,
readDraft: () => ({
ownerKey: "thread",
text: "",
selection: { start: 0, end: 0 },
revision: 0,
}),
commitDraft: () => undefined,
commitDraft: () => true,
onStateChange: () => undefined,
});
return { ...harness, controller, deleted };
Expand Down
13 changes: 0 additions & 13 deletions apps/mobile/src/features/voice-input/voiceInputMetering.ts

This file was deleted.

28 changes: 25 additions & 3 deletions apps/mobile/src/features/voice-input/voiceInputSession.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
import type { PreparedVoiceTranscription } from "@t3tools/client-runtime/voice-input";
import {
VoiceTranscriptionError,
type PreparedVoiceTranscription,
} from "@t3tools/client-runtime/voice-input";
import { Atom, AtomRegistry } from "effect/reactivity";
import { resetVoiceInputGlobalsForTests } from "../../../../../packages/client-runtime/src/voice-input/controller";

Expand Down Expand Up @@ -29,16 +32,17 @@ function createSession() {
locale: "en-US",
transcribe: async () => "spoken text",
}));
const deleteRecording = vi.fn();
const session = new VoiceInputSession({
recorder,
getTranscriber: () => ({ prepare }),
requestPermission: async () => ({ granted: true, canAskAgain: true }),
configureRecording: async () => {},
releaseRecording: vi.fn(async () => {}),
deleteRecording: vi.fn(),
deleteRecording,
onStateChange: vi.fn(),
});
return { session, recorder, prepare };
return { session, recorder, prepare, deleteRecording };
}

describe("global voice input", () => {
Expand Down Expand Up @@ -153,6 +157,24 @@ describe("global voice input", () => {
},
);

it("deletes a recording whose transcription failed, since retry records anew", async () => {
const { session, recorder, prepare, deleteRecording } = createSession();
prepare.mockResolvedValueOnce({
locale: "en-US",
transcribe: async () => {
throw new VoiceTranscriptionError("transcription-failed", "Upload failed", {
retryable: true,
});
},
});
await session.start(createTarget("first", () => "hello", vi.fn(), { start: 5, end: 5 }));
await session.controller.stop();

expect(session.controller.currentState.phase).toBe("error");
expect(session.controller.currentState.errorAction).not.toBe("retry-transcription");
expect(deleteRecording).toHaveBeenCalledWith(recorder.uri);
});

it("finishes the original draft at the recording limit while it is off screen", async () => {
const { session, recorder } = createSession();
const commit = vi.fn();
Expand Down
16 changes: 13 additions & 3 deletions apps/mobile/src/features/voice-input/voiceInputSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type VoiceInputTarget = {
readonly ownerKey: string;
readonly label?: string;
readonly readDraft: () => VoiceDraftSnapshot | null;
readonly commitDraft: VoiceInputControllerDependencies["commitDraft"];
readonly commitDraft: (text: string, selection: VoiceDraftSnapshot["selection"]) => void;
readonly subscribe: () => () => void;
};

Expand Down Expand Up @@ -47,9 +47,15 @@ export class VoiceInputSession {
private target: VoiceInputTarget | null = null;
private unsubscribe: (() => void) | null = null;

constructor(dependencies: Omit<VoiceInputControllerDependencies, "readDraft" | "commitDraft">) {
constructor(
dependencies: Omit<
VoiceInputControllerDependencies,
"readDraft" | "commitDraft" | "retainFailedRecordings"
>,
) {
this.controller = new VoiceInputController({
...dependencies,
retainFailedRecordings: false,
onStateChange: (state) => {
if (!voiceInputBlocksSubmission(state)) {
this.unsubscribe?.();
Expand All @@ -58,7 +64,11 @@ export class VoiceInputSession {
dependencies.onStateChange(state);
},
readDraft: () => this.target?.readDraft() ?? null,
commitDraft: (text, selection) => this.target?.commitDraft(text, selection),
commitDraft: (text, selection) => {
if (!this.target) return false;
this.target.commitDraft(text, selection);
return true;
},
});
}

Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/assets/AttachmentUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ function decodeClaims(encodedPayload: string): AttachmentUploadClaims | null {
}
}

const loadSigningSecret = Effect.gen(function* () {
export const loadUploadSigningSecret = Effect.gen(function* () {
const secretStore = yield* ServerSecretStore.ServerSecretStore;
return yield* secretStore.getOrCreateRandom(SIGNING_SECRET_NAME, 32);
});

export const issueAttachmentUploadUrl = Effect.fn("AttachmentUpload.issueUrl")(function* (
input: AttachmentCreateUploadUrlInput,
) {
const secret = yield* loadSigningSecret.pipe(
const secret = yield* loadUploadSigningSecret.pipe(
Effect.mapError((cause) => new AttachmentUploadSigningKeyError({ cause })),
);
const config = yield* ServerConfig.ServerConfig;
Expand Down Expand Up @@ -125,7 +125,7 @@ export const validateAttachmentUploadToken = Effect.fn("AttachmentUpload.validat
return null;
}

const secret = yield* loadSigningSecret.pipe(
const secret = yield* loadUploadSigningSecret.pipe(
Effect.tapError((cause) =>
Effect.logError("Failed to load the attachment upload signing key.", { cause }),
),
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/cli/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export const resolveServerConfig = Effect.fn("config.resolveServerConfig")(funct
const desktopBrowserFd = bootstrap?.desktopBrowserFd;
const desktopBrowserControlFd = bootstrap?.desktopBrowserControlFd;
const resourceMonitorPath = bootstrap?.resourceMonitorPath;
const appleSpeechHelperPath = bootstrap?.appleSpeechHelperPath;
const autoBootstrapProjectFromCwd = Option.getOrElse(
resolveOptionPrecedence(
Option.fromUndefinedOr(options?.forceAutoBootstrapProjectFromCwd),
Expand Down Expand Up @@ -477,6 +478,7 @@ export const resolveServerConfig = Effect.fn("config.resolveServerConfig")(funct
desktopBrowserFd,
desktopBrowserControlFd,
resourceMonitorPath,
appleSpeechHelperPath,
autoBootstrapProjectFromCwd,
logWebSocketEvents,
tailscaleServeEnabled,
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/cloud/CloudLink.lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ describe("releaseManagedTunnelOnShutdown", () => {
ServerEnvironment.ServerEnvironment.of({
getEnvironmentId: Effect.succeed(EnvironmentId.make("env_123")),
getDescriptor: Effect.die("unused"),
streamDescriptorChanges: Stream.die("unused"),
}),
),
Effect.provideService(
Expand Down
Loading
Loading