Skip to content

Commit 5d1fb18

Browse files
committed
Merge remote-tracking branch 'origin/main' into perf/git-config-snapshot
2 parents aaa7275 + 268e581 commit 5d1fb18

254 files changed

Lines changed: 6263 additions & 1653 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/ipc/methods/sshEnvironment.ts‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
} from "@t3tools/contracts";
2727
import { SshHttpBridgeError } from "@t3tools/ssh/errors";
2828
import { resolveLoopbackSshHttpBaseUrl } from "@t3tools/ssh/tunnel";
29-
import * as Data from "effect/Data";
3029
import * as Effect from "effect/Effect";
3130
import * as Schema from "effect/Schema";
3231

@@ -35,10 +34,12 @@ import * as DesktopIpc from "../DesktopIpc.ts";
3534
import * as DesktopSshEnvironment from "../../ssh/DesktopSshEnvironment.ts";
3635
import * as DesktopSshPasswordPrompts from "../../ssh/DesktopSshPasswordPrompts.ts";
3736

38-
type DesktopSshEnvironmentRequestOperation =
39-
| "fetch-environment-descriptor"
40-
| "bootstrap-bearer-session"
41-
| "fetch-session-state";
37+
const DesktopSshEnvironmentRequestOperation = Schema.Literals([
38+
"fetch-environment-descriptor",
39+
"bootstrap-bearer-session",
40+
"fetch-session-state",
41+
]);
42+
type DesktopSshEnvironmentRequestOperation = typeof DesktopSshEnvironmentRequestOperation.Type;
4243

4344
type DesktopSshEnvironmentRequestCause = RemoteEnvironmentAuthError | SshHttpBridgeError;
4445

@@ -47,12 +48,13 @@ const isEnvironmentInternalError = Schema.is(EnvironmentInternalError);
4748
const isEnvironmentOperationForbiddenError = Schema.is(EnvironmentOperationForbiddenError);
4849
const isEnvironmentRequestInvalidError = Schema.is(EnvironmentRequestInvalidError);
4950
const isEnvironmentScopeRequiredError = Schema.is(EnvironmentScopeRequiredError);
51+
const isRemoteEnvironmentAuthUndeclaredStatusError = Schema.is(
52+
RemoteEnvironmentAuthUndeclaredStatusError,
53+
);
54+
const isSshHttpBridgeError = Schema.is(SshHttpBridgeError);
5055

5156
function readSshHttpStatus(cause: DesktopSshEnvironmentRequestCause): number | null {
52-
if (
53-
cause instanceof RemoteEnvironmentAuthUndeclaredStatusError ||
54-
cause instanceof SshHttpBridgeError
55-
) {
57+
if (isRemoteEnvironmentAuthUndeclaredStatusError(cause) || isSshHttpBridgeError(cause)) {
5658
return cause.status ?? null;
5759
}
5860
if (isEnvironmentRequestInvalidError(cause)) {
@@ -73,13 +75,14 @@ function readSshHttpStatus(cause: DesktopSshEnvironmentRequestCause): number | n
7375
return null;
7476
}
7577

76-
export class DesktopSshEnvironmentRequestError extends Data.TaggedError(
78+
export class DesktopSshEnvironmentRequestError extends Schema.TaggedError<DesktopSshEnvironmentRequestError>()(
7779
"DesktopSshEnvironmentRequestError",
78-
)<{
79-
readonly operation: DesktopSshEnvironmentRequestOperation;
80-
readonly cause: DesktopSshEnvironmentRequestCause;
81-
readonly sshHttpStatus: number | null;
82-
}> {
80+
{
81+
operation: DesktopSshEnvironmentRequestOperation,
82+
cause: Schema.Defect(),
83+
sshHttpStatus: Schema.NullOr(Schema.Number),
84+
},
85+
) {
8386
// The web client matches "[ssh_http:500]" to explain version-skewed SSH pairing.
8487
override get message() {
8588
const prefix = this.sshHttpStatus === null ? "" : `[ssh_http:${this.sshHttpStatus}] `;

‎apps/desktop/src/snapShot/DesktopSnapShot.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,9 @@ it.effect("capture fails closed while snapshots are disabled", () => {
18721872

18731873
it.effect("points capture setup failures at SnapShot settings", () => {
18741874
vi.stubEnv("XDG_SESSION_TYPE", "wayland");
1875-
linuxCaptureMock.mockRejectedValueOnce(new CaptureSetupRequiredError("Install the helper."));
1875+
linuxCaptureMock.mockRejectedValueOnce(
1876+
new CaptureSetupRequiredError({ state: "Install the helper." }),
1877+
);
18761878
return Effect.scoped(
18771879
Effect.gen(function* () {
18781880
const service = yield* DesktopSnapShot.make;

‎apps/desktop/src/snapShot/DesktopSnapShot.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ import {
9494
import * as HostProcess from "@t3tools/shared/HostProcess";
9595
import { readImageDimensions } from "@t3tools/shared/imageDimensions";
9696

97+
const isCaptureSetupRequiredError = Schema.is(CaptureSetupRequiredError);
98+
9799
const MAX_CAPTURE_WIDTH = 2_560;
98100
const MAX_CAPTURE_HEIGHT = 1_600;
99101
const SHORTCUT_COOLDOWN_NS = 200_000_000n;
@@ -180,7 +182,7 @@ const shortcutFailure = (cause: unknown) => new SnapShotShortcutError({ cause })
180182

181183
function captureFailure(cause: unknown, captureId?: string): DesktopSnapShotError {
182184
if (isDesktopSnapShotError(cause)) return cause;
183-
const operation = cause instanceof CaptureSetupRequiredError ? "setup-required" : "capture";
185+
const operation = isCaptureSetupRequiredError(cause) ? "setup-required" : "capture";
184186
return new DesktopSnapShotError({ operation, captureId, cause });
185187
}
186188

‎apps/desktop/src/snapShot/HyprlandSnapShot.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ export async function captureHyprlandWindow(
171171
let state = await setup.state();
172172
if (state.status === "update-required") {
173173
await setup.perform("install-hyprland-helper").catch((cause: unknown) => {
174-
throw new CaptureSetupRequiredError(state.message, { cause });
174+
throw new CaptureSetupRequiredError({ state: state.message, cause });
175175
});
176176
state = await setup.state();
177177
}
178-
if (state.status !== "ready") throw new CaptureSetupRequiredError(state.message);
178+
if (state.status !== "ready") throw new CaptureSetupRequiredError({ state: state.message });
179179
const executable = hyprlandCaptureExecutable(paths);
180180
const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-hyprland-capture-"));
181181
const cleanup = () => NodeFSP.rm(directory, { recursive: true, force: true });

‎apps/desktop/src/snapShot/KdeSnapShot.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export async function captureKdeWindow(
215215
options?: { readonly flash: boolean; readonly animate: boolean },
216216
): Promise<LinuxWindowSnapshot> {
217217
const state = await new KdeCaptureSetup(paths).state();
218-
if (state.status !== "ready") throw new CaptureSetupRequiredError(state.message);
218+
if (state.status !== "ready") throw new CaptureSetupRequiredError({ state: state.message });
219219
const { executable } = kdeCapturePaths(paths);
220220
const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-kde-capture-"));
221221
let retained = false;

‎apps/desktop/src/snapShot/linuxCaptureSession.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
import * as NodeFSP from "node:fs/promises";
33
import * as NodeURL from "node:url";
44
import type { SnapShotKeyChord } from "@t3tools/contracts";
5+
import * as Schema from "effect/Schema";
56
import { nativeImage } from "electron";
67

78
// Keep dbus-next out of desktop detection and PNG reads in the main process.
89

910
export const HYPRLAND_CAPTURE_ACTION = "capture-window";
1011

11-
export class CaptureSetupRequiredError extends Error {
12-
constructor(state: string, options?: ErrorOptions) {
13-
super(`${state} Open Settings → SnapShots to continue setup.`, options);
12+
export class CaptureSetupRequiredError extends Schema.TaggedError<CaptureSetupRequiredError>()(
13+
"CaptureSetupRequiredError",
14+
{ state: Schema.String, cause: Schema.optional(Schema.Defect()) },
15+
) {
16+
override get message(): string {
17+
return `${this.state} Open Settings → SnapShots to continue setup.`;
1418
}
1519
}
1620
export const NIRI_CAPTURE_PATH = "/com/t3tools/SnapShot";

‎apps/desktop/src/ssh/DesktopSshEnvironment.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import * as Effect from "effect/Effect";
2323
import * as FileSystem from "effect/FileSystem";
2424
import * as Layer from "effect/Layer";
2525
import * as Path from "effect/Path";
26+
import * as Schema from "effect/Schema";
2627
import * as HttpClient from "effect/http/HttpClient";
2728
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
2829

@@ -74,11 +75,13 @@ function discoverDesktopSshHostsEffect(input?: { readonly homeDir?: string }) {
7475
return discoverSshHosts(input ?? {});
7576
}
7677

78+
const isSshPasswordPromptError = Schema.is(SshPasswordPromptError);
79+
7780
export function isDesktopSshPasswordPromptCancellation(
7881
error: unknown,
7982
): error is SshPasswordPromptError {
8083
return (
81-
error instanceof SshPasswordPromptError &&
84+
isSshPasswordPromptError(error) &&
8285
DesktopSshPasswordPrompts.isDesktopSshPasswordPromptCancellation(error.cause)
8386
);
8487
}

‎apps/mobile/modules/t3-voice-transcription/android/build.gradle‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ android {
1616

1717
dependencies {
1818
implementation project(':expo-modules-core')
19+
implementation project(':expo-audio')
1920
implementation 'androidx.media3:media3-common:1.9.1'
2021
implementation 'com.google.mlkit:genai-speech-recognition:1.0.0-alpha2'
2122
testImplementation 'junit:junit:4.13.2'
23+
testImplementation 'com.facebook.react:react-android'
2224
testImplementation 'org.robolectric:robolectric:4.16.1'
2325
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2'
2426
}

‎apps/mobile/modules/t3-voice-transcription/android/src/main/java/expo/modules/t3voicetranscription/GoogleVoiceTranscriber.kt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,16 @@ internal class MlKitSpeechClient(context: Context, locale: Locale, mode: Int) :
158158
}
159159
}
160160

161+
suspend fun transcribeLive(capture: LivePcmCapture, pipe: PcmPipe): String = pipe.use {
162+
val request = speechRecognizerRequest { audioSource = pipe.source }
163+
try {
164+
collectGoogleVoiceTranscript(
165+
livePcmResponses(capture, pipe) { recognizer.startRecognition(request) }
166+
)
167+
} finally {
168+
withContext(NonCancellable) { runCatching { recognizer.stopRecognition() } }
169+
}
170+
}
171+
161172
override fun close() = recognizer.close()
162173
}

0 commit comments

Comments
 (0)