@devries-cameron20 / t3code Mirror · read-only / commits / a20c4dba9e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 13:30 UTC

fix(server): voice cleanup pinned to an ACP provider uses the text model (#36912)

Julius Marminge committed Nov 14, 2026 at 12:29 UTC a20c4dba9e8c2952ae24be85e7fca98a095d3bb6
2 files changed +85 -1
apps/server/src/speech/postProcessing.test.ts new
+81
@@ -0,0 +1,81 @@
1 +import * as NodeServices from "@effect/platform-node/NodeServices";
2 +import { assert, it } from "@effect/vitest";
3 +import { ProviderInstanceId, type ModelSelection } from "@t3tools/contracts";
4 +import * as Effect from "effect/Effect";
5 +import * as Layer from "effect/Layer";
6 +import * as Ref from "effect/Ref";
7 +
8 +import * as ProviderRegistry from "../provider/ProviderRegistry.ts";
9 +import * as ServerSettings from "../serverSettings.ts";
10 +import * as TextGeneration from "../textGeneration/TextGeneration.ts";
11 +import * as SpeechPostProcessing from "./postProcessing.ts";
12 +
13 +const textGenerationSelection = {
14 + instanceId: ProviderInstanceId.make("fakeapi"),
15 + model: "fake-model",
16 +};
17 +const acpSelection = { instanceId: ProviderInstanceId.make("acp_local"), model: "default" };
18 +
19 +it.effect("cleanup pinned to a provider that cannot generate text uses the text model", () =>
20 + Effect.gen(function* () {
21 + const used = yield* Ref.make<ModelSelection | null>(null);
22 + const layer = SpeechPostProcessing.layer.pipe(
23 + Layer.provide(
24 + Layer.succeed(TextGeneration.TextGeneration, {
25 + generateTranscriptionPostProcessing: (input: { modelSelection: ModelSelection }) =>
26 + Ref.set(used, input.modelSelection).pipe(Effect.as({ transcription: "Hello, world." })),
27 + } as unknown as TextGeneration.TextGeneration["Service"]),
28 + ),
29 + Layer.provide(
30 + Layer.succeed(ProviderRegistry.ProviderRegistry, {
31 + getProviders: Effect.succeed([
32 + {
33 + instanceId: acpSelection.instanceId,
34 + driver: "acpRegistry",
35 + enabled: true,
36 + installed: true,
37 + supportsTextGeneration: false,
38 + },
39 + ]),
40 + } as unknown as ProviderRegistry.ProviderRegistry["Service"]),
41 + ),
42 + Layer.provide(
43 + ServerSettings.layerTest({
44 + providerInstances: {
45 + [acpSelection.instanceId]: {
46 + driver: "acpRegistry",
47 + enabled: true,
48 + config: { source: "local", commandPath: "acp-agent" },
49 + },
50 + },
51 + textGenerators: {
52 + [textGenerationSelection.instanceId]: {
53 + kind: "openaiCompatible",
54 + baseUrl: "http://127.0.0.1:18999/v1",
55 + enabled: true,
56 + },
57 + },
58 + textGenerationModelSelection: textGenerationSelection,
59 + speechPostProcessingModelSelection: acpSelection,
60 + }),
61 + ),
62 + Layer.provide(NodeServices.layer),
63 + );
64 + yield* Effect.gen(function* () {
65 + const postProcessing = yield* SpeechPostProcessing.SpeechPostProcessing;
66 + yield* postProcessing.process({
67 + options: {
68 + speechCustomWords: [],
69 + speechPostProcessingPrompt: { mode: "default", customInstructions: "" },
70 + },
71 + transcript: "um hello world",
72 + draft: { text: "", selection: { start: 0, end: 0 } },
73 + } as never);
74 + }).pipe(Effect.provide(layer));
75 + const selection = yield* Ref.get(used);
76 + assert.deepStrictEqual(
77 + { instanceId: selection?.instanceId, model: selection?.model },
78 + textGenerationSelection,
79 + );
80 + }),
81 +);
apps/server/src/speech/postProcessing.ts
+4 -1
@@ -8,6 +8,7 @@ import * as FileSystem from "effect/FileSystem";
8 import * as Layer from "effect/Layer";
9 import { resolveSpeechPostProcessingModelSelection } from "@t3tools/shared/serverSettings";
10
11 +import * as ProviderRegistry from "../provider/ProviderRegistry.ts";
12 import * as ServerSettings from "../serverSettings.ts";
13 import * as TextGeneration from "../textGeneration/TextGeneration.ts";
14 import { buildTranscriptionPostProcessingPrompt } from "../textGeneration/TranscriptionPostProcessing.ts";
@@ -27,11 +28,13 @@ const make = Effect.gen(function* () {
28 const settingsService = yield* ServerSettings.ServerSettingsService;
29 const fileSystem = yield* FileSystem.FileSystem;
30 const textGeneration = yield* TextGeneration.TextGeneration;
31 + const providerRegistry = yield* ProviderRegistry.ProviderRegistry;
32 return SpeechPostProcessing.of({
33 process: Effect.fn("SpeechPostProcessing.process")(
34 function* (input) {
35 if (input.transcript.trim().length === 0) return { text: input.transcript };
36 const settings = yield* settingsService.getSettings;
37 + const providers = yield* providerRegistry.getProviders;
38 const { mode, customInstructions } = input.options.speechPostProcessingPrompt;
39 const instructions =
40 (mode === "custom" ? customInstructions.trim() : "") ||
@@ -46,7 +49,7 @@ const make = Effect.gen(function* () {
49 input.draft,
50 input.options.speechCorrectionWord,
51 ),
49 - modelSelection: resolveSpeechPostProcessingModelSelection(settings),
52 + modelSelection: resolveSpeechPostProcessingModelSelection(settings, providers),
53 });
54 const text = generated.transcription.trim();
55 return {