GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #1 from YassinTM/voice/dictation · YassinTM/t3code@282c907

This repository was archived by the owner on Oct 29, 2026. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • FORK.md
  • apps
    • desktop/src/window
      • DesktopWindow.test.ts
      • DesktopWindow.ts
      • MainWindowPermissions.ts
    • mobile/src/features/voice-input
      • voiceInputSession.test.ts
      • voiceInputSession.ts
    • server/src
      • auth
        • RpcAuthorization.ts
      • dictation
        • Dictation.integration.test.ts
        • Dictation.test.ts
        • Dictation.ts
        • DictationArtifacts.test.ts
        • DictationArtifacts.ts
        • DictationRecognizer.ts
        • audio.test.ts
        • audio.ts
        • integrity.ts
        • layer.ts
        • models.ts
        • rpcAggregates.ts
        • rpcHandlers.ts
        • tar.ts
      • observability
        • RpcInstrumentation.ts
      • server.ts
      • ws.ts
    • web/src
      • components
        • ComposerPromptEditorTiptap.tsx
        • chat
          • ChatComposer.tsx
          • ComposerDictationActivity.tsx
          • ComposerDictationControl.tsx
        • settings
          • ConnectionsSettings.tsx
          • DictationSettings.tsx
          • IntegrationsSettings.tsx
          • KeybindingsSettings.logic.ts
          • dictationSearchItems.ts
          • settingsSearch.ts
      • dictation
        • composerFlash.ts
        • dictation.css
        • dictationLevel.ts
        • dictationWaveform.ts
        • pcmCapture.ts
        • pcmProcessor.worklet.ts
        • streamingDictation.ts
        • useComposerDictation.ts
        • useComposerDictationWiring.ts
        • useDictationHoldShortcut.ts
      • index.css
      • keybindings.ts
      • state
        • dictation.ts
  • docs/user
    • composer.md
    • keybindings.md
  • packages
    • client-runtime
      • package.json
      • src
        • rpc
          • client.ts
        • state
          • dictation.test.ts
          • dictation.ts
        • voice-input
          • controller.test.ts
          • controller.ts
          • index.ts
          • transcription.ts
    • contracts/src
      • clientRpcPermissions.ts
      • dictation.ts
      • dictationRpc.ts
      • index.ts
      • keybindings.ts
      • rpc.ts
      • settings.ts
    • shared
      • package.json
      • src
        • keybindings.ts
        • spokenSkills.test.ts
        • spokenSkills.ts
  • scripts
    • build-desktop-artifact.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎FORK.md‎

Copy file name to clipboardExpand all lines: FORK.md
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ Keep this list short; each one can conflict with upstream.
3939

4040
Put new features in new files where possible and hook them in with small edits.
4141

42+
## Fork features
43+
44+
- **Dictation** (voice/dictation): upstream PR pingdotgg/t3code#19273, restructured so
45+
its code lives in `*/dictation/*`, `contracts/src/dictation*.ts` and
46+
`shared/src/spokenSkills.ts`, with one- or two-line hooks in `rpc.ts`, `ws.ts`,
47+
`server.ts`, `settings.ts`, `RpcAuthorization.ts`, `RpcInstrumentation.ts`,
48+
`clientRpcPermissions.ts` and a single block in `ChatComposer.tsx`. If upstream
49+
merges dictation, drop the fork copy in favour of theirs.
50+
4251
## Setup (once)
4352

4453
- Repository secret `FORK_SYNC_TOKEN`: a fine-grained PAT for this repo only,
Collapse file

‎apps/desktop/src/window/DesktopWindow.test.ts‎

Copy file name to clipboardExpand all lines: apps/desktop/src/window/DesktopWindow.test.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function makeFakeBrowserWindow() {
9494
reloadIgnoringCache: vi.fn(),
9595
replaceMisspelling: vi.fn(),
9696
send: vi.fn(),
97+
session: { setPermissionRequestHandler: vi.fn() },
9798
setBackgroundThrottling: vi.fn(),
9899
setWindowOpenHandler: vi.fn(),
99100
toggleDevTools: vi.fn(),
Collapse file

‎apps/desktop/src/window/DesktopWindow.ts‎

Copy file name to clipboardExpand all lines: apps/desktop/src/window/DesktopWindow.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import * as ElectronApp from "../electron/ElectronApp.ts";
3434
import * as DesktopRendererHistory from "../telemetry/DesktopRendererHistory.ts";
3535
import { makeQuitShortcutHandler } from "./QuitHold.ts";
3636
import { copyContextMenuImage } from "./ContextMenuImage.ts";
37+
import { installMainWindowPermissions } from "./MainWindowPermissions.ts";
3738

3839
const TITLEBAR_HEIGHT = 40;
3940
// Matches --workspace-topbar-height in apps/web/src/index.css. Native macOS
@@ -391,6 +392,7 @@ export const make = Effect.gen(function* () {
391392
});
392393

393394
yield* rendererHistory.register(window.webContents, { surface: "main" });
395+
installMainWindowPermissions(window.webContents, environment.platform);
394396
if (environment.platform === "darwin") {
395397
window.setAutoHideCursor(false);
396398
}
Collapse file

‎apps/desktop/src/window/MainWindowPermissions.ts‎

Copy file name to clipboard
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as Electron from "electron";
2+
3+
/**
4+
* Permission policy for the main window's session. A session without a
5+
* handler grants every request, and this keeps that. The one addition is
6+
* microphone capture from the main window on macOS: it asks the OS for
7+
* consent first, so dictation gets the system prompt instead of silence
8+
* when the app has not been allowed to record yet.
9+
*/
10+
export function installMainWindowPermissions(
11+
webContents: Electron.WebContents,
12+
platform: NodeJS.Platform,
13+
): void {
14+
webContents.session.setPermissionRequestHandler((requester, permission, callback, details) => {
15+
const wantsMicrophone =
16+
platform === "darwin" &&
17+
permission === "media" &&
18+
requester === webContents &&
19+
"mediaTypes" in details &&
20+
details.mediaTypes?.includes("audio") === true;
21+
if (!wantsMicrophone) {
22+
callback(true);
23+
return;
24+
}
25+
void Electron.systemPreferences
26+
.askForMediaAccess("microphone")
27+
.then(callback, () => callback(false));
28+
});
29+
}
Collapse file

‎apps/mobile/src/features/voice-input/voiceInputSession.test.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/voice-input/voiceInputSession.test.ts
+25-8Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ describe("global voice input", () => {
5757
createTarget("second", () => "other prompt", vi.fn(), { start: 12, end: 12 }),
5858
);
5959
await session.controller.stop();
60-
expect(commit).toHaveBeenCalledWith(expected, {
61-
start: cursor,
62-
end: cursor,
63-
});
60+
expect(commit).toHaveBeenCalledWith(
61+
expected,
62+
{ start: cursor, end: cursor },
63+
expect.anything(),
64+
);
6465
},
6566
);
6667

@@ -134,7 +135,11 @@ describe("global voice input", () => {
134135
transcription.resolve("spoken text");
135136
await (stopping ?? session.controller.stop());
136137
expect(recorder.record).toHaveBeenCalledTimes(1);
137-
expect(firstCommit).toHaveBeenCalledWith("first spoken text", { start: 17, end: 17 });
138+
expect(firstCommit).toHaveBeenCalledWith(
139+
"first spoken text",
140+
{ start: 17, end: 17 },
141+
expect.anything(),
142+
);
138143
expect(secondCommit).not.toHaveBeenCalled();
139144
},
140145
);
@@ -163,7 +168,11 @@ describe("global voice input", () => {
163168
error: null,
164169
url: recorder.uri,
165170
});
166-
expect(commit).toHaveBeenCalledWith("first spoken text", { start: 17, end: 17 });
171+
expect(commit).toHaveBeenCalledWith(
172+
"first spoken text",
173+
{ start: 17, end: 17 },
174+
expect.anything(),
175+
);
167176
expect(session.controller.currentState.phase).toBe("idle");
168177
});
169178

@@ -238,7 +247,11 @@ describe("global voice input", () => {
238247
expect(recorder.stop).not.toHaveBeenCalled();
239248
expect(session.controller.currentState.phase).toBe("recording");
240249
await session.controller.stop();
241-
expect(commit).toHaveBeenCalledWith("hello spoken text", { start: 17, end: 17 });
250+
expect(commit).toHaveBeenCalledWith(
251+
"hello spoken text",
252+
{ start: 17, end: 17 },
253+
expect.anything(),
254+
);
242255
});
243256

244257
it("waits for canceled native work before starting a recording for another draft", async () => {
@@ -267,6 +280,10 @@ describe("global voice input", () => {
267280
await session.controller.stop();
268281
expect(recorder.record).toHaveBeenCalledTimes(1);
269282
expect(oldCommit).not.toHaveBeenCalled();
270-
expect(nextCommit).toHaveBeenCalledWith("second spoken text", { start: 18, end: 18 });
283+
expect(nextCommit).toHaveBeenCalledWith(
284+
"second spoken text",
285+
{ start: 18, end: 18 },
286+
expect.anything(),
287+
);
271288
});
272289
});
Collapse file

‎apps/mobile/src/features/voice-input/voiceInputSession.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/voice-input/voiceInputSession.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export class VoiceInputSession {
5858
dependencies.onStateChange(state);
5959
},
6060
readDraft: () => this.target?.readDraft() ?? null,
61-
commitDraft: (text, selection) => this.target?.commitDraft(text, selection),
61+
commitDraft: (text, selection, inserted) =>
62+
this.target?.commitDraft(text, selection, inserted),
6263
});
6364
}
6465

Collapse file

‎apps/server/src/auth/RpcAuthorization.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/auth/RpcAuthorization.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
CLIENT_GUARDED_RPC_SCOPES,
3+
DICTATION_RPC_REQUIRED_SCOPES,
34
type DeviceListInput,
45
clientRpcRequiredScopes,
56
authScopeRequiredResponse,
@@ -201,6 +202,7 @@ export const RPC_REQUIRED_SCOPES = {
201202
[WS_METHODS.deviceDetail]: AuthOrchestrationReadScope,
202203
[WS_METHODS.deviceAction]: AuthOrchestrationOperateScope,
203204
[WS_METHODS.subscribeDeviceState]: AuthOrchestrationReadScope,
205+
...DICTATION_RPC_REQUIRED_SCOPES,
204206
[WS_METHODS.subscribeServerConfig]: AuthOrchestrationReadScope,
205207
[WS_METHODS.subscribeServerLifecycle]: AuthOrchestrationReadScope,
206208
[WS_METHODS.subscribeAuthAccess]: AuthAccessReadScope,
Collapse file

‎apps/server/src/dictation/Dictation.integration.test.ts‎

Copy file name to clipboard
+178Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
import * as NodeServices from "@effect/platform-node/NodeServices";
2+
import { assert, it } from "@effect/vitest";
3+
import { DictationModelId } from "@t3tools/contracts";
4+
import * as Schema from "effect/Schema";
5+
import * as Clock from "effect/Clock";
6+
import * as Effect from "effect/Effect";
7+
import * as FileSystem from "effect/FileSystem";
8+
import * as NodeOS from "node:os";
9+
import * as Layer from "effect/Layer";
10+
import * as Path from "effect/Path";
11+
import * as Stream from "effect/Stream";
12+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
13+
import * as HttpClient from "effect/http/HttpClient";
14+
import * as HttpClientResponse from "effect/http/HttpClientResponse";
15+
import * as ServerConfig from "../config.ts";
16+
import * as ServerSettings from "../serverSettings.ts";
17+
import * as Dictation from "./Dictation.ts";
18+
import * as DictationArtifacts from "./DictationArtifacts.ts";
19+
import * as DictationRecognizer from "./DictationRecognizer.ts";
20+
import { models } from "./models.ts";
21+
22+
const fixture = process.env.T3_DICTATION_E2E_FIXTURE;
23+
const candidate = process.env.T3_DICTATION_E2E_MODEL ?? "parakeet-v3";
24+
if (!Schema.is(DictationModelId)(candidate))
25+
throw new Error("Unknown dictation verification model.");
26+
const model = candidate;
27+
const home = process.env.T3_DICTATION_E2E_HOME;
28+
29+
/** Run explicitly with the spike model directory. Runtime + tokens use real HTTP; ONNX bytes stream from the verified cache. */
30+
it.live.skipIf(!fixture)(
31+
"installs and transcribes through the real native runtime",
32+
() =>
33+
Effect.gen(function* () {
34+
const fs = yield* FileSystem.FileSystem;
35+
const path = yield* Path.Path;
36+
const network = yield* HttpClient.HttpClient;
37+
const http = HttpClient.make((request) => {
38+
const name = request.url.split("/").at(-1)!;
39+
const file =
40+
model === "parakeet-v3"
41+
? models[model].files.find(
42+
(candidate) => candidate.name === name && name.endsWith(".onnx"),
43+
)
44+
: undefined;
45+
if (!file) return network.execute(request);
46+
return Stream.toReadableStreamEffect(fs.stream(path.join(fixture!, name))).pipe(
47+
Effect.map((stream) =>
48+
HttpClientResponse.fromWeb(
49+
request,
50+
new Response(stream, { headers: { "content-length": String(file.bytes) } }),
51+
),
52+
),
53+
Effect.orDie,
54+
);
55+
});
56+
const artifactsLayer = DictationArtifacts.layer.pipe(
57+
Layer.provide(Layer.succeed(HttpClient.HttpClient, http)),
58+
);
59+
const layer = Dictation.layer.pipe(
60+
Layer.provide(DictationRecognizer.layer.pipe(Layer.provide(artifactsLayer))),
61+
Layer.provideMerge(artifactsLayer),
62+
Layer.provideMerge(
63+
ServerSettings.layerTest({ dictation: { engine: "local", localModel: model } }),
64+
),
65+
Layer.provide(
66+
ServerConfig.layerTest(process.cwd(), home ?? { prefix: "t3-dictation-e2e-" }),
67+
),
68+
);
69+
yield* Effect.gen(function* () {
70+
const service = yield* Dictation.Dictation;
71+
const settings = yield* ServerSettings.ServerSettingsService;
72+
yield* service.stateStream.pipe(
73+
Stream.filter((state) => state.ready),
74+
Stream.take(1),
75+
Stream.runDrain,
76+
);
77+
yield* service.install({ model });
78+
assert.strictEqual((yield* service.state).ready, true);
79+
const wav = Buffer.from(yield* fs.readFile(path.join(fixture!, "test_wavs", "en.wav")));
80+
assert.strictEqual(wav.toString("ascii", 0, 4), "RIFF");
81+
let sampleRate = 0;
82+
let channels = 0;
83+
let bits = 0;
84+
let audio = Buffer.alloc(0);
85+
for (let offset = 12; offset + 8 <= wav.length;) {
86+
const name = wav.toString("ascii", offset, offset + 4);
87+
const size = wav.readUInt32LE(offset + 4);
88+
if (name === "fmt ") {
89+
assert.strictEqual(wav.readUInt16LE(offset + 8), 1);
90+
channels = wav.readUInt16LE(offset + 10);
91+
sampleRate = wav.readUInt32LE(offset + 12);
92+
bits = wav.readUInt16LE(offset + 22);
93+
}
94+
if (name === "data") audio = wav.subarray(offset + 8, offset + 8 + size);
95+
offset += 8 + size + (size % 2);
96+
}
97+
assert.strictEqual(channels, 1);
98+
assert.strictEqual(bits, 16);
99+
if (sampleRate !== 16000) {
100+
const converted = Buffer.alloc(Math.floor(((audio.length / 2) * 16000) / sampleRate) * 2);
101+
for (let i = 0; i < converted.length / 2; i++) {
102+
const position = (i * sampleRate) / 16000;
103+
const left = Math.floor(position);
104+
const right = Math.min(left + 1, audio.length / 2 - 1);
105+
converted.writeInt16LE(
106+
Math.round(
107+
audio.readInt16LE(left * 2) * (1 - (position - left)) +
108+
audio.readInt16LE(right * 2) * (position - left),
109+
),
110+
i * 2,
111+
);
112+
}
113+
audio = converted;
114+
}
115+
const runs: {
116+
text: string;
117+
locale: string;
118+
finishMs: number;
119+
recordingSeconds: number;
120+
startMs: number;
121+
}[] = [];
122+
for (let run = 0; run < (model === "whisper-turbo" ? 4 : 3); run++) {
123+
if (model === "whisper-turbo" && run === 1)
124+
yield* settings.updateSettings({ dictation: { language: "en" } });
125+
if (model === "whisper-turbo" && run === 3)
126+
yield* settings.updateSettings({ dictation: { language: "nl" } });
127+
const recording =
128+
run !== 2
129+
? audio
130+
: Buffer.concat(
131+
Array.from({ length: 4 }, () => Buffer.concat([audio, Buffer.alloc(12800)])),
132+
);
133+
const beforeStart = yield* Clock.currentTimeMillis;
134+
const { sessionId } = yield* service.start;
135+
const startMs = (yield* Clock.currentTimeMillis) - beforeStart;
136+
let chunkCount = 0;
137+
for (let offset = 0; offset < recording.length; offset += 3200) {
138+
yield* service.append({
139+
sessionId,
140+
seq: chunkCount++,
141+
pcm: recording.subarray(offset, offset + 3200).toString("base64"),
142+
});
143+
// Pace the recording as a microphone would, so background decoding overlaps speech.
144+
yield* Effect.sleep("100 millis");
145+
}
146+
const beforeFinish = yield* Clock.currentTimeMillis;
147+
const result = yield* service.finish({ sessionId, chunkCount });
148+
runs.push({
149+
text: result.text,
150+
locale: result.locale,
151+
finishMs: (yield* Clock.currentTimeMillis) - beforeFinish,
152+
recordingSeconds: recording.length / 32000,
153+
startMs,
154+
});
155+
assert.isTrue(result.text.length > 0);
156+
if (model === "whisper-turbo" && run === 3) assert.strictEqual(result.locale, "nl");
157+
}
158+
// This opt-in test reports the public fixture transcript; the product service never logs recordings.
159+
process.stdout.write(
160+
JSON.stringify(
161+
{
162+
model,
163+
availableParallelism: NodeOS.availableParallelism(),
164+
numThreads: Math.min(8, Math.max(1, NodeOS.availableParallelism())),
165+
runs,
166+
rssMB: Math.round(process.memoryUsage().rss / 1e6),
167+
},
168+
null,
169+
2,
170+
) + "\n",
171+
);
172+
}).pipe(Effect.provide(layer), Effect.scoped);
173+
}).pipe(
174+
Effect.provide(Layer.mergeAll(NodeServices.layer, FetchHttpClient.layer)),
175+
Effect.scoped,
176+
),
177+
{ timeout: 900_000 },
178+
);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.