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 — local: take PR #19273 head b8d5c37c onto main 01a93e7b51 · FOX-cOSMIC/FOX-cOSMIC-t3@1aea39c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • 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
        • models.ts
        • tar.ts
      • observability
        • RpcInstrumentation.ts
      • server.ts
      • ws.test.ts
      • ws.ts
    • web/src
      • components
        • ChatView.tsx
        • ComposerPromptEditorTiptap.tsx
        • chat
          • ChatComposer.tsx
          • ComposerDictationActivity.tsx
          • ComposerDictationControl.tsx
        • settings
          • ConnectionsSettings.tsx
          • DictationSettings.tsx
          • IntegrationsSettings.tsx
          • KeybindingsSettings.logic.ts
          • settingsSearch.ts
      • dictation
        • dictationLevel.ts
        • dictationWaveform.ts
        • pcmCapture.ts
        • pcmProcessor.worklet.ts
        • streamingDictation.ts
        • useComposerDictation.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
      • index.ts
      • keybindings.ts
      • rpc.ts
      • settings.ts
    • shared/src
      • inlineSkills.test.ts
      • inlineSkills.ts
      • keybindings.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

‎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
@@ -93,6 +93,7 @@ function makeFakeBrowserWindow() {
9393
reloadIgnoringCache: vi.fn(),
9494
replaceMisspelling: vi.fn(),
9595
send: vi.fn(),
96+
session: { setPermissionRequestHandler: vi.fn() },
9697
setBackgroundThrottling: vi.fn(),
9798
setWindowOpenHandler: vi.fn(),
9899
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
@@ -37,6 +37,7 @@ import * as ElectronApp from "../electron/ElectronApp.ts";
3737
import * as DesktopRendererHistory from "../telemetry/DesktopRendererHistory.ts";
3838
import { makeQuitShortcutHandler } from "./QuitHold.ts";
3939
import { copyContextMenuImage } from "./ContextMenuImage.ts";
40+
import { installMainWindowPermissions } from "./MainWindowPermissions.ts";
4041

4142
const TITLEBAR_HEIGHT = 40;
4243
// Match --workspace-topbar-height in apps/web/src/index.css; native macOS buttons stay 14 points at any zoom.
@@ -417,6 +418,7 @@ export const make = Effect.gen(function* () {
417418

418419
pendingMainReveals.set(window, Effect.void);
419420
yield* rendererHistory.register(window.webContents, { surface: "main" });
421+
installMainWindowPermissions(window.webContents, environment.platform);
420422
if (environment.platform === "darwin") {
421423
window.setAutoHideCursor(false);
422424
}
Collapse file

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

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as Electron from "electron";
2+
3+
// Ask macOS for microphone consent before granting main-window capture; preserve other grants.
4+
export function installMainWindowPermissions(
5+
webContents: Electron.WebContents,
6+
platform: NodeJS.Platform,
7+
): void {
8+
webContents.session.setPermissionRequestHandler((requester, permission, callback, details) => {
9+
const wantsMicrophone =
10+
platform === "darwin" &&
11+
permission === "media" &&
12+
requester === webContents &&
13+
"mediaTypes" in details &&
14+
details.mediaTypes?.includes("audio") === true;
15+
if (!wantsMicrophone) {
16+
callback(true);
17+
return;
18+
}
19+
void Electron.systemPreferences
20+
.askForMediaAccess("microphone")
21+
.then(callback, () => callback(false));
22+
});
23+
}
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
@@ -159,10 +159,11 @@ describe("global voice input", () => {
159159
createTarget("second", () => "other prompt", vi.fn(), { start: 12, end: 12 }),
160160
);
161161
await session.controller.stop();
162-
expect(commit).toHaveBeenCalledWith(expected, {
163-
start: cursor,
164-
end: cursor,
165-
});
162+
expect(commit).toHaveBeenCalledWith(
163+
expected,
164+
{ start: cursor, end: cursor },
165+
expect.anything(),
166+
);
166167
},
167168
);
168169

@@ -236,7 +237,11 @@ describe("global voice input", () => {
236237
transcription.resolve("spoken text");
237238
await (stopping ?? session.controller.stop());
238239
expect(recorder.record).toHaveBeenCalledTimes(1);
239-
expect(firstCommit).toHaveBeenCalledWith("first spoken text", { start: 17, end: 17 });
240+
expect(firstCommit).toHaveBeenCalledWith(
241+
"first spoken text",
242+
{ start: 17, end: 17 },
243+
expect.anything(),
244+
);
240245
expect(secondCommit).not.toHaveBeenCalled();
241246
},
242247
);
@@ -265,7 +270,11 @@ describe("global voice input", () => {
265270
error: null,
266271
url: recorder.uri,
267272
});
268-
expect(commit).toHaveBeenCalledWith("first spoken text", { start: 17, end: 17 });
273+
expect(commit).toHaveBeenCalledWith(
274+
"first spoken text",
275+
{ start: 17, end: 17 },
276+
expect.anything(),
277+
);
269278
expect(session.controller.currentState.phase).toBe("idle");
270279
});
271280

@@ -324,7 +333,11 @@ describe("global voice input", () => {
324333
expect(recorder.stop).not.toHaveBeenCalled();
325334
expect(session.controller.currentState.phase).toBe("recording");
326335
await session.controller.stop();
327-
expect(commit).toHaveBeenCalledWith("hello spoken text", { start: 17, end: 17 });
336+
expect(commit).toHaveBeenCalledWith(
337+
"hello spoken text",
338+
{ start: 17, end: 17 },
339+
expect.anything(),
340+
);
328341
});
329342

330343
it("waits for canceled native work before starting a recording for another draft", async () => {
@@ -353,7 +366,11 @@ describe("global voice input", () => {
353366
await session.controller.stop();
354367
expect(recorder.record).toHaveBeenCalledTimes(1);
355368
expect(oldCommit).not.toHaveBeenCalled();
356-
expect(nextCommit).toHaveBeenCalledWith("second spoken text", { start: 18, end: 18 });
369+
expect(nextCommit).toHaveBeenCalledWith(
370+
"second spoken text",
371+
{ start: 18, end: 18 },
372+
expect.anything(),
373+
);
357374
});
358375

359376
it("holds the screen awake and meters only while recording", async () => {
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
@@ -103,7 +103,8 @@ export class VoiceInputSession {
103103
...dependencies,
104104
onStateChange: (state) => this.handleStateChange(state),
105105
readDraft: () => this.target?.readDraft() ?? null,
106-
commitDraft: (text, selection) => this.target?.commitDraft(text, selection),
106+
commitDraft: (text, selection, inserted) =>
107+
this.target?.commitDraft(text, selection, inserted),
107108
});
108109
}
109110

Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/auth/RpcAuthorization.ts
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ export const RPC_REQUIRED_SCOPES = {
205205
[WS_METHODS.deviceDetail]: AuthOrchestrationReadScope,
206206
[WS_METHODS.deviceAction]: AuthOrchestrationOperateScope,
207207
[WS_METHODS.subscribeDeviceState]: AuthOrchestrationReadScope,
208+
[WS_METHODS.dictationInstall]: AuthOrchestrationOperateScope,
209+
[WS_METHODS.dictationRemove]: AuthOrchestrationOperateScope,
210+
[WS_METHODS.dictationStart]: AuthOrchestrationOperateScope,
211+
[WS_METHODS.dictationWarm]: AuthOrchestrationOperateScope,
212+
[WS_METHODS.dictationAppend]: AuthOrchestrationOperateScope,
213+
[WS_METHODS.dictationFinish]: AuthOrchestrationOperateScope,
214+
[WS_METHODS.dictationCancel]: AuthOrchestrationOperateScope,
215+
[WS_METHODS.subscribeDictationState]: AuthOrchestrationReadScope,
208216
[WS_METHODS.subscribeServerConfig]: AuthOrchestrationReadScope,
209217
[WS_METHODS.subscribeServerLifecycle]: AuthOrchestrationReadScope,
210218
[WS_METHODS.subscribeAuthAccess]: AuthAccessReadScope,
Collapse file

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

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

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.