Skip to content

Commit e45c0dc

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-11805
2 parents f640656 + 1a12c4a commit e45c0dc

181 files changed

Lines changed: 8737 additions & 390 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/backend/DesktopBackendConfiguration.test.ts‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,43 @@ describe("DesktopBackendConfiguration", () => {
683683
),
684684
);
685685

686+
it.effect("gives the Windows and WSL backends one host scope that survives a restart", () =>
687+
Effect.gen(function* () {
688+
const fileSystem = yield* FileSystem.FileSystem;
689+
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
690+
prefix: "t3-desktop-backend-config-test-",
691+
});
692+
const launch = Effect.gen(function* () {
693+
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
694+
const primary = yield* configuration.resolvePrimary;
695+
const wsl = yield* configuration.resolveWsl({ port: 5050, distro: null });
696+
assert.equal(wsl.env.T3CODE_DESKTOP_HOST_SCOPE, primary.env.T3CODE_DESKTOP_HOST_SCOPE);
697+
assert.include((wsl.env.WSLENV ?? "").split(":"), "T3CODE_DESKTOP_HOST_SCOPE");
698+
return primary.env.T3CODE_DESKTOP_HOST_SCOPE;
699+
}).pipe(
700+
Effect.provide(
701+
layerBackendConfiguration().pipe(
702+
Layer.provideMerge(layerServerExposure),
703+
Layer.provideMerge(DesktopAppSettings.layerTest()),
704+
Layer.provideMerge(DesktopWslServerTree.layerTest()),
705+
Layer.provideMerge(
706+
DesktopWslEnvironment.layerTest({
707+
isAvailable: true,
708+
windowsToWslPath: () => Option.some("/mnt/c/repo/apps/server/src/index.ts"),
709+
getDistroIp: () => Option.some("172.27.0.99"),
710+
}),
711+
),
712+
Layer.provideMerge(layerEnvironment(baseDir, { platform: "win32" })),
713+
),
714+
),
715+
);
716+
717+
const first = yield* launch;
718+
assert.match(first ?? "", /^[0-9a-f]{32}$/);
719+
assert.equal(yield* launch, first);
720+
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
721+
);
722+
686723
it.effect("resolveWsl carries the kill switch and resource attributes into the distro", () =>
687724
Effect.gen(function* () {
688725
const fileSystem = yield* FileSystem.FileSystem;
@@ -748,7 +785,7 @@ describe("DesktopBackendConfiguration", () => {
748785
assert.equal(config.env.T3CODE_OTLP_PROTOCOL, "http/protobuf");
749786
assert.equal(
750787
config.env.WSLENV,
751-
"GOPATH/p:OPENAI_API_KEY/u:EMPTY::AZURE_DEVOPS_EXT_PAT/u:ANTHROPIC_API_KEY:T3CODE_OTLP_HEADERS:T3CODE_OTLP_PROTOCOL",
788+
"GOPATH/p:OPENAI_API_KEY/u:EMPTY::AZURE_DEVOPS_EXT_PAT/u:T3CODE_DESKTOP_HOST_SCOPE:ANTHROPIC_API_KEY:T3CODE_OTLP_HEADERS:T3CODE_OTLP_PROTOCOL",
752789
);
753790
}).pipe(
754791
Effect.provide(

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,38 @@ interface SharedBootstrapInput {
243243
readonly bootstrapToken: string;
244244
readonly bootstrapSecret: string;
245245
readonly observabilitySettings: BackendObservabilitySettings;
246+
readonly hostScope: string;
246247
}
247248

249+
// Matches the server's DESKTOP_HOST_SCOPE_ENV.
250+
const DESKTOP_HOST_SCOPE_ENV = "T3CODE_DESKTOP_HOST_SCOPE";
251+
const HOST_SCOPE_FILE_NAME = "desktop-host-scope";
252+
const HOST_SCOPE_PATTERN = /^[0-9a-f]{32}$/;
253+
254+
/**
255+
* Not a credential: it only tells this install's Windows and WSL servers that
256+
* they run on one machine, so usage both read from one Windows directory counts
257+
* once. Persisted so summaries from earlier launches still match.
258+
*/
259+
const readOrCreateHostScope = Effect.gen(function* () {
260+
const fileSystem = yield* FileSystem.FileSystem;
261+
const environment = yield* DesktopEnvironment.DesktopEnvironment;
262+
const random = yield* SecureRandom.SecureRandom;
263+
const scopePath = environment.path.join(environment.stateDir, HOST_SCOPE_FILE_NAME);
264+
const existing = (yield* fileSystem
265+
.readFileString(scopePath)
266+
.pipe(Effect.orElseSucceed(() => ""))).trim();
267+
if (HOST_SCOPE_PATTERN.test(existing)) return existing;
268+
const scope = Hex.encode(yield* random.randomBytes(16).pipe(Effect.orDie));
269+
yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true }).pipe(
270+
Effect.andThen(fileSystem.writeFileString(scopePath, scope)),
271+
Effect.catch((cause) =>
272+
Effect.logWarning("Could not persist the desktop host scope.", { cause }),
273+
),
274+
);
275+
return scope;
276+
});
277+
248278
type WslPreflightRuntime =
249279
| {
250280
readonly kind: "executable";
@@ -540,6 +570,7 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
540570
ELECTRON_RUN_AS_NODE: "1",
541571
T3CODE_DESKTOP_SHELL_DISCOVERY_PENDING: "1",
542572
T3CODE_CLI_PATH: Option.getOrUndefined(input.cliPath),
573+
[DESKTOP_HOST_SCOPE_ENV]: input.hostScope,
543574
},
544575
extendEnv: true,
545576
bootstrap,
@@ -636,8 +667,8 @@ const resolveWslStartConfig = Effect.fn("desktop.backendConfiguration.resolveWsl
636667
const httpBaseUrl = new URL(`http://${rendererHost}:${input.port}`);
637668

638669
const distroArgs = distroForConfig ? ["-d", distroForConfig] : [];
639-
const forwardedEnv: Record<string, string> = {};
640-
const forwardedEnvNames: string[] = [];
670+
const forwardedEnv: Record<string, string> = { [DESKTOP_HOST_SCOPE_ENV]: input.hostScope };
671+
const forwardedEnvNames: string[] = [DESKTOP_HOST_SCOPE_ENV];
641672
for (const name of WSL_FORWARDED_ENV_NAMES) {
642673
const value = env[name];
643674
if (value !== undefined && value.length > 0) {
@@ -735,6 +766,13 @@ export const make = Effect.gen(function* () {
735766
const random = yield* SecureRandom.SecureRandom;
736767
// Random generation yields; serialize it so concurrent backends cannot capture distinct bootstrap secrets.
737768
const secretRef = yield* SynchronizedRef.make(Option.none<string>());
769+
const hostScope = yield* Effect.cached(
770+
readOrCreateHostScope.pipe(
771+
Effect.provideService(FileSystem.FileSystem, fileSystem),
772+
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
773+
Effect.provideService(SecureRandom.SecureRandom, random),
774+
),
775+
);
738776
const getOrCreateBootstrapSecret = SynchronizedRef.modifyEffect(secretRef, (current) =>
739777
Option.match(current, {
740778
onSome: (secret) => Effect.succeed([secret, current] as const),
@@ -762,6 +800,7 @@ export const make = Effect.gen(function* () {
762800
bootstrapToken,
763801
bootstrapSecret,
764802
observabilitySettings,
803+
hostScope: yield* hostScope,
765804
} satisfies SharedBootstrapInput;
766805
});
767806

‎apps/desktop/src/preview/Manager.test.ts‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,74 @@ describe("PreviewManager", () => {
746746
),
747747
);
748748

749+
effectIt.effect.each([
750+
"navigate",
751+
"reload",
752+
"goBack",
753+
"goForward",
754+
"refresh",
755+
"hardReload",
756+
] as const)("%s stops a page script that never yields before it navigates", (operation) =>
757+
withManager((manager) =>
758+
Effect.gen(function* () {
759+
const preview = makeFaviconWebContents();
760+
// As in Chromium: the hung renderer answers nothing, and a terminate reaches it only
761+
// while no navigation is pending.
762+
let stopped = false;
763+
const probed = yield* Deferred.make<void>();
764+
const navigatedAfterStop: Array<boolean> = [];
765+
const navigated = () => {
766+
navigatedAfterStop.push(stopped);
767+
};
768+
const sendCommand = async (method: string) => {
769+
if (method === "Runtime.evaluate") {
770+
Deferred.doneUnsafe(probed, Effect.void);
771+
await new Promise(() => {});
772+
}
773+
if (method === "Runtime.terminateExecution") stopped = true;
774+
};
775+
Object.assign(preview.webContents, {
776+
getURL: () => "http://localhost:5173/busy",
777+
reload: navigated,
778+
reloadIgnoringCache: navigated,
779+
loadURL: async () => navigated(),
780+
navigationHistory: {
781+
canGoBack: () => true,
782+
canGoForward: () => true,
783+
goBack: navigated,
784+
goForward: navigated,
785+
},
786+
debugger: {
787+
isAttached: () => false,
788+
attach: vi.fn(),
789+
sendCommand,
790+
on: vi.fn(),
791+
off: vi.fn(),
792+
},
793+
});
794+
fromId.mockReturnValue(preview.webContents);
795+
yield* manager.createTab("tab_busy");
796+
yield* manager.registerWebview("tab_busy", 42);
797+
798+
const leaving = yield* (
799+
operation === "navigate"
800+
? manager.navigate("tab_busy", "http://localhost:5173/next")
801+
: operation === "reload"
802+
? manager.navigate("tab_busy", "http://localhost:5173/busy")
803+
: manager[operation]("tab_busy")
804+
).pipe(Effect.forkChild);
805+
const probing = yield* Effect.raceFirst(
806+
Deferred.await(probed).pipe(Effect.as(true)),
807+
Fiber.await(leaving).pipe(Effect.as(false)),
808+
);
809+
if (probing) yield* TestClock.adjust(1_000);
810+
yield* Fiber.join(leaving);
811+
812+
expect(navigatedAfterStop).toEqual([true]);
813+
}),
814+
),
815+
);
816+
749817
effectIt.effect("keeps mouse back and forward buttons inside the preview tab", () =>
750818
withManager((manager) =>
751819
Effect.gen(function* () {

‎apps/desktop/src/preview/Manager.ts‎

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const PICTURE_IN_PICTURE_JPEG_QUALITY = 80;
136136
const CAPTURE_PAGE_RETRY_ATTEMPTS = 3;
137137
const CAPTURE_PAGE_RETRY_DELAY_MS = 120;
138138
const CAPTURE_PAGE_ATTEMPT_TIMEOUT_MS = 1_000;
139+
const BUSY_PAGE_PROBE_MS = 1_000;
139140
const PICTURE_IN_PICTURE_INITIAL_WIDTH = 480;
140141
const PICTURE_IN_PICTURE_INITIAL_HEIGHT = 320;
141142
const PICTURE_IN_PICTURE_MIN_WIDTH = 240;
@@ -2038,6 +2039,28 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
20382039
);
20392040
});
20402041

2042+
/**
2043+
* A same-site navigation reuses the renderer, so it never commits while a page script holds it.
2044+
* Runs before the navigation starts: Chromium does not deliver a terminate once one is pending.
2045+
*/
2046+
const leaveBusyPage = Effect.fn("PreviewManager.leaveBusyPage")(function* (
2047+
wc: Electron.WebContents,
2048+
) {
2049+
const control = (yield* SynchronizedRef.get(controlSessionsRef)).get(wc.id);
2050+
if (!control) return;
2051+
const answered = yield* Effect.promise(() =>
2052+
control.debugger.sendCommand("Runtime.evaluate", { expression: "0" }).then(
2053+
() => undefined,
2054+
() => undefined,
2055+
),
2056+
).pipe(Effect.timeoutOption(BUSY_PAGE_PROBE_MS));
2057+
if (Option.isSome(answered)) return;
2058+
// Not awaited: a renderer blocked on something other than script may never acknowledge it.
2059+
yield* Effect.sync(() => {
2060+
void control.debugger.sendCommand("Runtime.terminateExecution").catch(() => undefined);
2061+
});
2062+
});
2063+
20412064
const navigate = Effect.fn("PreviewManager.navigate")(function* (tabId: string, rawUrl: string) {
20422065
const url = yield* attempt({ operation: "navigate.normalizeUrl", tabId }, () =>
20432066
normalizePreviewUrl(rawUrl),
@@ -2120,6 +2143,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
21202143
);
21212144
return;
21222145
}
2146+
yield* leaveBusyPage(wc);
21232147
if (wc.getURL() === url) {
21242148
yield* attempt({ operation: "navigate.reload", tabId, webContentsId: wc.id }, () =>
21252149
wc.reload(),
@@ -2155,18 +2179,28 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
21552179
yield* attempt({ operation, tabId, webContentsId: wc.id }, () => use(wc));
21562180
});
21572181

2182+
const leavePage = Effect.fn("PreviewManager.leavePage")(function* (
2183+
operation: string,
2184+
tabId: string,
2185+
use: (wc: Electron.WebContents) => void,
2186+
) {
2187+
const wc = yield* requireWebContents(tabId);
2188+
yield* leaveBusyPage(wc);
2189+
yield* attempt({ operation, tabId, webContentsId: wc.id }, () => use(wc));
2190+
});
2191+
21582192
const goBack = (tabId: string) =>
2159-
withWebContents("goBack", tabId, (wc) => {
2193+
leavePage("goBack", tabId, (wc) => {
21602194
if (wc.navigationHistory.canGoBack()) wc.navigationHistory.goBack();
21612195
});
21622196
const goForward = (tabId: string) =>
2163-
withWebContents("goForward", tabId, (wc) => {
2197+
leavePage("goForward", tabId, (wc) => {
21642198
if (wc.navigationHistory.canGoForward()) wc.navigationHistory.goForward();
21652199
});
2166-
const refresh = (tabId: string) => withWebContents("refresh", tabId, (wc) => wc.reload());
2200+
const refresh = (tabId: string) => leavePage("refresh", tabId, (wc) => wc.reload());
21672201
const stopLoading = (tabId: string) => withWebContents("stopLoading", tabId, (wc) => wc.stop());
21682202
const hardReload = (tabId: string) =>
2169-
withWebContents("hardReload", tabId, (wc) => wc.reloadIgnoringCache());
2203+
leavePage("hardReload", tabId, (wc) => wc.reloadIgnoringCache());
21702204
const findInPage = (
21712205
tabId: string,
21722206
text: string,

‎apps/mobile/deps/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The Enriched Markdown tarball comes from Julius's [`fork/t3-mobile` branch](https://github.com/pingdotgg/enriched-markdown/tree/fork/t3-mobile). Its `t3-fork.json` records the exact source commit and upstream base. React block renderers, signed image sources, the `onLinksChange` link list (`renderers`, `resolveImageSource`, `onLinksChange`) and the iOS streaming memory bounds are upstream. The fork carries only changes with an open upstream PR: clipboard link metadata ([#962](https://github.com/software-mansion/enriched-markdown/pull/962)), development-host autolinks ([#961](https://github.com/software-mansion/enriched-markdown/pull/961)) and hash-route link fragments ([mity/md4c#454](https://github.com/mity/md4c/pull/454), arriving through [md4c#7](https://github.com/software-mansion-labs/md4c/pull/7)), `md4cFlags.preserveWindowsPaths`, which keeps backslashes in Windows drive paths in prose ([#1105](https://github.com/software-mansion/enriched-markdown/pull/1105), after [mity/md4c#477](https://github.com/mity/md4c/pull/477)), GitHub's strikethrough rules for `~` ([md4c#6](https://github.com/software-mansion-labs/md4c/pull/6)), `\(…\)` and `\[…\]` math delimiters ([#1043](https://github.com/software-mansion/enriched-markdown/pull/1043), [md4c#4](https://github.com/software-mansion-labs/md4c/pull/4)), iOS Copy as Markdown keeping bold spans whole ([#1143](https://github.com/software-mansion/enriched-markdown/pull/1143)), line breaks in copied table cells written as `<br>` ([#1144](https://github.com/software-mansion/enriched-markdown/pull/1144)), and Android measuring text in the span order its view draws it, so code blocks nested in list items no longer make a reply overlap the next message ([#1145](https://github.com/software-mansion/enriched-markdown/pull/1145)). It also carries one fork-only change: iOS code blocks too big for one backing store draw through tiles, so a tall block with long lines no longer shows an empty pane ([pingdotgg/enriched-markdown#15](https://github.com/pingdotgg/enriched-markdown/pull/15)).
1+
The Enriched Markdown tarball comes from Julius's [`fork/t3-mobile` branch](https://github.com/pingdotgg/enriched-markdown/tree/fork/t3-mobile). Its `t3-fork.json` records the exact source commit and upstream base. React block renderers, signed image sources, the `onLinksChange` link list (`renderers`, `resolveImageSource`, `onLinksChange`) and the iOS streaming memory bounds are upstream. The fork carries only changes with an open upstream PR: clipboard link metadata ([#962](https://github.com/software-mansion/enriched-markdown/pull/962)), development-host autolinks ([#961](https://github.com/software-mansion/enriched-markdown/pull/961)) and hash-route link fragments ([mity/md4c#454](https://github.com/mity/md4c/pull/454), arriving through [md4c#7](https://github.com/software-mansion-labs/md4c/pull/7)), `md4cFlags.preserveWindowsPaths`, which keeps backslashes in Windows drive paths in prose ([#1105](https://github.com/software-mansion/enriched-markdown/pull/1105), after [mity/md4c#477](https://github.com/mity/md4c/pull/477)), GitHub's strikethrough rules for `~` ([md4c#6](https://github.com/software-mansion-labs/md4c/pull/6)), `\(…\)` and `\[…\]` math delimiters ([#1043](https://github.com/software-mansion/enriched-markdown/pull/1043), [md4c#4](https://github.com/software-mansion-labs/md4c/pull/4)), iOS Copy as Markdown keeping bold spans whole ([#1143](https://github.com/software-mansion/enriched-markdown/pull/1143)), line breaks in copied table cells written as `<br>` ([#1144](https://github.com/software-mansion/enriched-markdown/pull/1144)), and Android measuring text in the span order its view draws it, so code blocks nested in list items no longer make a reply overlap the next message ([#1145](https://github.com/software-mansion/enriched-markdown/pull/1145)). It also carries two fork-only changes: iOS code blocks too big for one backing store draw through tiles, so a tall block with long lines no longer shows an empty pane ([pingdotgg/enriched-markdown#15](https://github.com/pingdotgg/enriched-markdown/pull/15)), and a long-pressed iOS blockquote lifts on the background it sits on instead of drawing its text over the thread.
22

33
To replace it, commit the fork changes, run `yarn install --immutable` and `yarn workspace react-native-enriched-markdown prepare` in the fork checkout, then `node scripts/pack-t3.mjs /path/to/t3code/apps/mobile/deps`. Keep the package version aligned with Julius's `fork/t3-mobile` branch. Rename the archive to include the first eight characters of the source commit, such as `react-native-enriched-markdown-1.2.0-t3.18-4287c5d3.tgz`, so each build has a distinct dependency path without version bumps. Update the tarball path in `apps/mobile/package.json` and `pnpm-workspace.yaml`'s `allowBuilds`, and run `vp i` to update the lockfile. Native clients need rebuilding when this dependency changes.
44

apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.18-0dc7ed81.tgz renamed to apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.18-16db4c75.tgz

1.38 MB
Binary file not shown.

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
"react": "catalog:",
127127
"react-dom": "catalog:",
128128
"react-native": "0.88.1",
129-
"react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-t3.18-0dc7ed81.tgz",
129+
"react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-t3.18-16db4c75.tgz",
130130
"react-native-gesture-handler": "~3.5.0",
131131
"react-native-image-viewing": "^0.2.2",
132132
"react-native-keyboard-controller": "1.23.0",

‎apps/mobile/src/App.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import {
7575
import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
7676
import { installUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
7777
import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
78+
import { ConnectDeviceApprovalCoordinator } from "./features/connection/ConnectDeviceApprovalCoordinator";
7879
import { installSubscriptionUsageRefresh } from "./widgets/useSubscriptionUsage";
7980
import { GlobalVoiceInputControl } from "./features/voice-input/GlobalVoiceInputControl";
8081
import {
@@ -281,6 +282,7 @@ function AppContent() {
281282
<>
282283
<SplashScreenCoordinator />
283284
<SubscriptionUsageCoordinator />
285+
<ConnectDeviceApprovalCoordinator />
284286
<GestureHandlerRootView className="flex-1">
285287
<KeyboardProvider statusBarTranslucent>
286288
<SafeAreaProvider>

‎apps/mobile/src/components/ui/Dialog.android.test.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ it("keeps a dialog raised while the activity is replaced", () => {
9090
expect(current.container.textContent).toContain("Shared content imported");
9191
});
9292

93+
it("tells a replaced alert it was dismissed", () => {
94+
mountHost();
95+
const onDismiss = vi.fn();
96+
act(() => Dialog.alert("Older", undefined, [{ text: "OK" }], { onDismiss }));
97+
act(() => Dialog.alert("Newer", undefined, [{ text: "OK" }]));
98+
99+
expect(onDismiss).toHaveBeenCalledOnce();
100+
});
101+
93102
it("ignores a late action from a dialog that a newer one replaced", () => {
94103
const { container } = mountHost();
95104
const olderAction = vi.fn();

‎apps/mobile/src/components/ui/Dialog.android.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ function setPresented(next: PresentedDialog | null) {
4949
}
5050

5151
function submitRequest(dialog: DialogRequest) {
52+
const replaced = presented;
5253
setPresented({ ...dialog, id: ++nextPresentationId });
54+
// A replaced alert closed without an answer, which its owner hears as a dismissal.
55+
if (replaced?.kind === "alert") replaced.request.options?.onDismiss?.();
5356
}
5457

5558
/** Closes the dialog only if it is still the one the action came from. */

0 commit comments

Comments
 (0)