Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
298cb24
refactor: errors are Schema.TaggedError, not Data.TaggedError or nati…
juliusmarminge Nov 5, 2026
67eebac
fix(server): a stopped run no longer shrinks thread history to one ro…
shivamhwp Nov 5, 2026
01a8db0
fix(server): refresh divergence after a merged branch ref changes (#3…
Yash-Singh1 Nov 5, 2026
8a14762
fix(mobile): one aligned notice for ChatGPT sharing limits (#31277)
shivamhwp Nov 5, 2026
337c585
fix(mobile): composer keeps the keyboard when a queued edit ends (#31…
shivamhwp Nov 5, 2026
8b570d2
fix(mobile): delivered messages no longer reappear at the bottom of r…
saphid Nov 5, 2026
725cfc9
fix(threads): side chats inherit parent permissions by default (#31114)
extoci Nov 5, 2026
02cb2fc
fix(server): threads follow their worktree's branch changes (#31599)
Yash-Singh1 Nov 5, 2026
df0cc36
fix(pi): usage reports include sessions stored in a --session-dir lau…
saphid Nov 5, 2026
6ae0d3f
perf(mobile): skip unchanged terminal toolbar fade updates (#25312)
saphid Nov 5, 2026
b564442
perf(mobile): assemble HTML replacements in one pass (#25278)
saphid Nov 5, 2026
09eb653
perf(mobile): skip canceled SVG parsing (#25314)
saphid Nov 5, 2026
221d8b8
test(server): strengthen v1 cutover proof with event-stream waits and…
saphid Nov 5, 2026
9529ee3
fix(contracts): a stored secret reference is always sensitive (#31403)
yordis Nov 5, 2026
edeea8c
fix(server): a settings save no longer reads an unreadable secret aga…
yordis Nov 5, 2026
e66c316
fix(threads): allow snoozing pending input requests (#20058)
saphid Nov 5, 2026
b18434e
fix(server): repair cutover test crypto import breaking main CI (#31630)
Yash-Singh1 Nov 5, 2026
6a7e7d1
Merge remote-tracking branch 'upstream/main' into yordis/chore-sync-u…
yordis Nov 5, 2026
1bf064f
test(server): fork secret shapes load as sensitive references
yordis Nov 5, 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
33 changes: 18 additions & 15 deletions apps/desktop/src/ipc/methods/sshEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
} from "@t3tools/contracts";
import { SshHttpBridgeError } from "@t3tools/ssh/errors";
import { resolveLoopbackSshHttpBaseUrl } from "@t3tools/ssh/tunnel";
import * as Data from "effect/Data";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";

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

type DesktopSshEnvironmentRequestOperation =
| "fetch-environment-descriptor"
| "bootstrap-bearer-session"
| "fetch-session-state";
const DesktopSshEnvironmentRequestOperation = Schema.Literals([
"fetch-environment-descriptor",
"bootstrap-bearer-session",
"fetch-session-state",
]);
type DesktopSshEnvironmentRequestOperation = typeof DesktopSshEnvironmentRequestOperation.Type;

type DesktopSshEnvironmentRequestCause = RemoteEnvironmentAuthError | SshHttpBridgeError;

Expand All @@ -47,12 +48,13 @@ const isEnvironmentInternalError = Schema.is(EnvironmentInternalError);
const isEnvironmentOperationForbiddenError = Schema.is(EnvironmentOperationForbiddenError);
const isEnvironmentRequestInvalidError = Schema.is(EnvironmentRequestInvalidError);
const isEnvironmentScopeRequiredError = Schema.is(EnvironmentScopeRequiredError);
const isRemoteEnvironmentAuthUndeclaredStatusError = Schema.is(
RemoteEnvironmentAuthUndeclaredStatusError,
);
const isSshHttpBridgeError = Schema.is(SshHttpBridgeError);

function readSshHttpStatus(cause: DesktopSshEnvironmentRequestCause): number | null {
if (
cause instanceof RemoteEnvironmentAuthUndeclaredStatusError ||
cause instanceof SshHttpBridgeError
) {
if (isRemoteEnvironmentAuthUndeclaredStatusError(cause) || isSshHttpBridgeError(cause)) {
return cause.status ?? null;
}
if (isEnvironmentRequestInvalidError(cause)) {
Expand All @@ -73,13 +75,14 @@ function readSshHttpStatus(cause: DesktopSshEnvironmentRequestCause): number | n
return null;
}

export class DesktopSshEnvironmentRequestError extends Data.TaggedError(
export class DesktopSshEnvironmentRequestError extends Schema.TaggedError<DesktopSshEnvironmentRequestError>()(
"DesktopSshEnvironmentRequestError",
)<{
readonly operation: DesktopSshEnvironmentRequestOperation;
readonly cause: DesktopSshEnvironmentRequestCause;
readonly sshHttpStatus: number | null;
}> {
{
operation: DesktopSshEnvironmentRequestOperation,
cause: Schema.Defect(),
sshHttpStatus: Schema.NullOr(Schema.Number),
},
) {
// The web client matches "[ssh_http:500]" to explain version-skewed SSH pairing.
override get message() {
const prefix = this.sshHttpStatus === null ? "" : `[ssh_http:${this.sshHttpStatus}] `;
Expand Down
4 changes: 3 additions & 1 deletion apps/desktop/src/snapShot/DesktopSnapShot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,9 @@ it.effect("capture fails closed while snapshots are disabled", () => {

it.effect("points capture setup failures at SnapShot settings", () => {
vi.stubEnv("XDG_SESSION_TYPE", "wayland");
linuxCaptureMock.mockRejectedValueOnce(new CaptureSetupRequiredError("Install the helper."));
linuxCaptureMock.mockRejectedValueOnce(
new CaptureSetupRequiredError({ state: "Install the helper." }),
);
return Effect.scoped(
Effect.gen(function* () {
const service = yield* DesktopSnapShot.make;
Expand Down
4 changes: 3 additions & 1 deletion apps/desktop/src/snapShot/DesktopSnapShot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ import {
import * as HostProcess from "@t3tools/shared/HostProcess";
import { readImageDimensions } from "@t3tools/shared/imageDimensions";

const isCaptureSetupRequiredError = Schema.is(CaptureSetupRequiredError);

const MAX_CAPTURE_WIDTH = 2_560;
const MAX_CAPTURE_HEIGHT = 1_600;
const SHORTCUT_COOLDOWN_NS = 200_000_000n;
Expand Down Expand Up @@ -180,7 +182,7 @@ const shortcutFailure = (cause: unknown) => new SnapShotShortcutError({ cause })

function captureFailure(cause: unknown, captureId?: string): DesktopSnapShotError {
if (isDesktopSnapShotError(cause)) return cause;
const operation = cause instanceof CaptureSetupRequiredError ? "setup-required" : "capture";
const operation = isCaptureSetupRequiredError(cause) ? "setup-required" : "capture";
return new DesktopSnapShotError({ operation, captureId, cause });
}

Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/snapShot/HyprlandSnapShot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ export async function captureHyprlandWindow(
let state = await setup.state();
if (state.status === "update-required") {
await setup.perform("install-hyprland-helper").catch((cause: unknown) => {
throw new CaptureSetupRequiredError(state.message, { cause });
throw new CaptureSetupRequiredError({ state: state.message, cause });
});
state = await setup.state();
}
if (state.status !== "ready") throw new CaptureSetupRequiredError(state.message);
if (state.status !== "ready") throw new CaptureSetupRequiredError({ state: state.message });
const executable = hyprlandCaptureExecutable(paths);
const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-hyprland-capture-"));
const cleanup = () => NodeFSP.rm(directory, { recursive: true, force: true });
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/snapShot/KdeSnapShot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export async function captureKdeWindow(
options?: { readonly flash: boolean; readonly animate: boolean },
): Promise<LinuxWindowSnapshot> {
const state = await new KdeCaptureSetup(paths).state();
if (state.status !== "ready") throw new CaptureSetupRequiredError(state.message);
if (state.status !== "ready") throw new CaptureSetupRequiredError({ state: state.message });
const { executable } = kdeCapturePaths(paths);
const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-kde-capture-"));
let retained = false;
Expand Down
10 changes: 7 additions & 3 deletions apps/desktop/src/snapShot/linuxCaptureSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
import * as NodeFSP from "node:fs/promises";
import * as NodeURL from "node:url";
import type { SnapShotKeyChord } from "@t3tools/contracts";
import * as Schema from "effect/Schema";
import { nativeImage } from "electron";

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

export const HYPRLAND_CAPTURE_ACTION = "capture-window";

export class CaptureSetupRequiredError extends Error {
constructor(state: string, options?: ErrorOptions) {
super(`${state} Open Settings → SnapShots to continue setup.`, options);
export class CaptureSetupRequiredError extends Schema.TaggedError<CaptureSetupRequiredError>()(
"CaptureSetupRequiredError",
{ state: Schema.String, cause: Schema.optional(Schema.Defect()) },
) {
override get message(): string {
return `${this.state} Open Settings → SnapShots to continue setup.`;
}
}
export const NIRI_CAPTURE_PATH = "/com/t3tools/SnapShot";
Expand Down
5 changes: 4 additions & 1 deletion apps/desktop/src/ssh/DesktopSshEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
import * as Schema from "effect/Schema";
import * as HttpClient from "effect/http/HttpClient";
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";

Expand Down Expand Up @@ -74,11 +75,13 @@ function discoverDesktopSshHostsEffect(input?: { readonly homeDir?: string }) {
return discoverSshHosts(input ?? {});
}

const isSshPasswordPromptError = Schema.is(SshPasswordPromptError);

export function isDesktopSshPasswordPromptCancellation(
error: unknown,
): error is SshPasswordPromptError {
return (
error instanceof SshPasswordPromptError &&
isSshPasswordPromptError(error) &&
DesktopSshPasswordPrompts.isDesktopSshPasswordPromptCancellation(error.cause)
);
}
Expand Down
9 changes: 7 additions & 2 deletions apps/mobile/src/components/ComposerEditor.ios.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const native = vi.hoisted(() => ({
text: "",
eventCount: 0,
resetGeneration: 0,
mounts: 0,
props: null as NativeProps | null,
deliver: null as ((event: NativeEvent) => void) | null,
}));
Expand All @@ -28,6 +29,7 @@ function NativeView(props: NativeProps) {
const propsRef = useRef(props);
useLayoutEffect(() => {
Object.assign(native, { text: "", eventCount: 0, resetGeneration: 0 });
native.mounts += 1;
}, []);
useLayoutEffect(() => {
propsRef.current = props;
Expand Down Expand Up @@ -173,13 +175,16 @@ it("keeps a pending event from the previous native editor out of the selected dr
);
await act(async () => renderDraft(first));
const deliverPendingEvent = native.deliver!;
const pending = { eventCount: native.eventCount + 1, resetGeneration: native.resetGeneration };
const mounts = native.mounts;
await act(async () => renderDraft(second));
// Remounting the native view would drop the keyboard mid-edit.
expect(native.mounts).toBe(mounts);
await act(async () =>
deliverPendingEvent({
value: "Draft A corrected",
selection: { start: 17, end: 17 },
eventCount: 1,
resetGeneration: 0,
...pending,
}),
);
expect(getComposerDraftSnapshot(second).text).toBe("Draft B");
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/ComposerEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function ComposerEditor({
<>
{/* Reset revision history with the recreated iOS view without aborting context imports. */}
<NativeComposerEditor
key={`${hidden ? "hidden" : "visible"}:${draftKey ?? "no-draft"}`}
key={hidden ? "hidden" : "visible"}
{...props}
enterBehavior={props.enterBehavior ?? preferredEnterBehavior}
onChangeText={changeText}
Expand Down
70 changes: 46 additions & 24 deletions apps/mobile/src/components/ComposerToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComponentProps, ReactNode } from "react";
import { useState } from "react";
import { useCallback, useRef, useState } from "react";
import {
Pressable,
ScrollView,
Expand Down Expand Up @@ -149,37 +149,59 @@ export function ComposerToolbarScroller(props: {
readonly fadeSurface?: "card" | "sheet";
readonly contentPaddingRight?: number;
}) {
const [metrics, setMetrics] = useState({
const metricsRef = useRef({
contentWidth: 0,
offsetX: 0,
viewportWidth: 0,
showLeftFade: false,
showRightFade: false,
});
const [scrollEdges, setScrollEdges] = useState({
showLeftFade: false,
showRightFade: false,
});

const maxOffset = Math.max(0, metrics.contentWidth - metrics.viewportWidth);
const scrollEdges = {
showLeftFade: metrics.offsetX > COMPOSER_TOOLBAR_SCROLL_EPSILON,
showRightFade: metrics.offsetX < maxOffset - COMPOSER_TOOLBAR_SCROLL_EPSILON,
};
const updateScrollEdges = useCallback(() => {
const metrics = metricsRef.current;
const maxOffset = Math.max(0, metrics.contentWidth - metrics.viewportWidth);
const showLeftFade = metrics.offsetX > COMPOSER_TOOLBAR_SCROLL_EPSILON;
const showRightFade = metrics.offsetX < maxOffset - COMPOSER_TOOLBAR_SCROLL_EPSILON;
if (metrics.showLeftFade === showLeftFade && metrics.showRightFade === showRightFade) {
return;
}
metrics.showLeftFade = showLeftFade;
metrics.showRightFade = showRightFade;
setScrollEdges({ showLeftFade, showRightFade });
}, []);

const handleLayout = (event: LayoutChangeEvent) => {
const viewportWidth = event.nativeEvent.layout.width;
setMetrics((current) =>
current.viewportWidth === viewportWidth ? current : { ...current, viewportWidth },
);
};
const handleLayout = useCallback(
(event: LayoutChangeEvent) => {
const viewportWidth = event.nativeEvent.layout.width;
if (metricsRef.current.viewportWidth === viewportWidth) return;
metricsRef.current.viewportWidth = viewportWidth;
updateScrollEdges();
},
[updateScrollEdges],
);

const handleContentSizeChange = (contentWidth: number) => {
setMetrics((current) =>
current.contentWidth === contentWidth ? current : { ...current, contentWidth },
);
};
const handleContentSizeChange = useCallback(
(contentWidth: number) => {
if (metricsRef.current.contentWidth === contentWidth) return;
metricsRef.current.contentWidth = contentWidth;
updateScrollEdges();
},
[updateScrollEdges],
);

const handleScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
const offsetX = event.nativeEvent.contentOffset.x;
setMetrics((current) =>
Math.abs(current.offsetX - offsetX) < 1 ? current : { ...current, offsetX },
);
};
const handleScroll = useCallback(
(event: NativeSyntheticEvent<NativeScrollEvent>) => {
const offsetX = event.nativeEvent.contentOffset.x;
if (Math.abs(metricsRef.current.offsetX - offsetX) < 1) return;
metricsRef.current.offsetX = offsetX;
updateScrollEdges();
},
[updateScrollEdges],
);

return (
<View className="relative min-w-0 flex-1">
Expand Down
33 changes: 20 additions & 13 deletions apps/mobile/src/components/FilePreviewModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Schema from "effect/Schema";
import * as Dialog from "./ui/Dialog";
import { useContext, useEffect, useEffectEvent, useState } from "react";
import { Platform } from "react-native";
Expand All @@ -21,15 +22,17 @@ export type {
ResolvedFilePreviewSource,
} from "./FilePreviewModal.types";

class PreviewResolutionError extends Error {
constructor(
override readonly cause: unknown,
readonly fallbackMessage: string,
) {
super(fallbackMessage, { cause });
class PreviewResolutionError extends Schema.TaggedError<PreviewResolutionError>()(
"PreviewResolutionError",
{ cause: Schema.Defect(), fallbackMessage: Schema.String },
) {
override get message(): string {
return this.fallbackMessage;
}
}

const isPreviewResolutionError = Schema.is(PreviewResolutionError);

interface ResolvedPreviewUri {
readonly uri: string;
readonly dispose?: () => void;
Expand All @@ -42,7 +45,10 @@ async function resolvePreviewUri(
if ("uri" in item) return { uri: item.uri };
if ("attachment" in item) {
return loadLocalAttachmentPreview(item.attachment, signal).catch((error: unknown) => {
throw new PreviewResolutionError(error, "Attach the file again and retry.");
throw new PreviewResolutionError({
cause: error,
fallbackMessage: "Attach the file again and retry.",
});
});
}
// Refresh expired URLs before handing them to Quick Look or ACTION_VIEW, which retain them.
Expand All @@ -52,10 +58,11 @@ async function resolvePreviewUri(
return value;
})
.catch((error: unknown) => {
throw new PreviewResolutionError(
error,
"Reconnect to this environment and try again. The file may have been moved or deleted.",
);
throw new PreviewResolutionError({
cause: error,
fallbackMessage:
"Reconnect to this environment and try again. The file may have been moved or deleted.",
});
});
return { uri: url + (item.srcFragment ?? "") };
}
Expand Down Expand Up @@ -99,9 +106,9 @@ function ResolvedFilePreview(props: {
if (progressiveGallery && index !== selectedIndex) return settle(index, null);
controller.abort();
onResolutionError(
error instanceof PreviewResolutionError
isPreviewResolutionError(error)
? error
: new PreviewResolutionError(error, "Try again."),
: new PreviewResolutionError({ cause: error, fallbackMessage: "Try again." }),
);
},
);
Expand Down
9 changes: 4 additions & 5 deletions apps/mobile/src/features/cloud/dpop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Digest from "effect/crypto/Digest";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Data from "effect/Data";
import * as Effect from "effect/Effect";
import * as Base64Url from "effect/encoding/Base64Url";
import * as Hex from "effect/encoding/Hex";
Expand All @@ -13,10 +12,10 @@ import { DpopProof } from "@t3tools/client-runtime/relay";
import { DpopPublicJwk } from "@t3tools/shared/dpopCommon";
import * as Layer from "effect/Layer";

export class CloudDpopError extends Data.TaggedError("CloudDpopError")<{
readonly message: string;
readonly cause?: unknown;
}> {}
export class CloudDpopError extends Schema.TaggedError<CloudDpopError>()("CloudDpopError", {
message: Schema.String,
cause: Schema.optional(Schema.Defect()),
}) {}

function cloudDpopError(message: string) {
return (cause: unknown) => new CloudDpopError({ message, cause });
Expand Down
Loading
Loading