Skip to content

Commit 9f9b203

Browse files
Merge remote-tracking branch 'gh/main' into takeover/mobile-file-link-24620
# Conflicts: # apps/mobile/src/features/files/SourceFileSurface.tsx
2 parents 8900def + 572cf74 commit 9f9b203

770 files changed

Lines changed: 36376 additions & 11552 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.

‎.agents/skills/test-t3-mobile/SKILL.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ names). The device id may be omitted when exactly one device is booted. It
4141
prints one JSON line; on failure it names the next command. Authorized mobile
4242
verification includes that step unless the user prohibits it.
4343

44+
For a device you opened in an agent-device session elsewhere (a device pool,
45+
cloud, or remote host), run `vp run mobile:install <ios|android> --session <s>`
46+
from the directory you opened the session in. It installs the cached build into
47+
that session (`--abi arm64-v8a` for an ARM Android device; `--metro <url>` also
48+
opens it against Metro) and never builds.
49+
4450
Start `vp run dev:client` from `apps/mobile`, or reuse a healthy Metro belonging
4551
to this checkout. Open its printed development-client URL with AgentDevice
4652
`open com.t3tools.t3code.dev <url>` and all returned target arguments.

‎AGENTS.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The most common defect in this repo is a change that works on the path you teste
9090

9191
An empty database is a bad test. Seed your worktree's `.t3` with a copy of real data instead of pointing at live state:
9292

93-
- The first `vp run dev` in a worktree does this for you when its database is missing. `--no-seed` or `T3CODE_DEV_SEED=0` skips it.
93+
- The first `vp run dev` in a worktree does this for you when its database is missing and the source is at most 500 MiB. Larger sources warn and dev starts with an empty database. `--no-seed` or `T3CODE_DEV_SEED=0` skips seeding. Manual migration still accepts larger sources and may use substantial disk space before pruning.
9494
- Run `vp run migrate-dev-db` with your dev server stopped to refresh. It rebuilds `<worktree>/.t3/userdata/statev2.sqlite` from a read-only snapshot of `~/.t3/userdata/statev2.sqlite`, the developer's real data. It keeps recent projects and their stopped threads, and drops scheduled tasks, pending work, and auth sessions, so your dev server never runs the developer's agents. Raise `--projects` and `--threads-per-project` for more data.
9595
- Refresh `statev2.sqlite`, not `state.sqlite`. The server copies the V1 `state.sqlite` only when `statev2.sqlite` is missing.
9696
- Bring `secrets` and `settings.json` only if the flow under test needs them.
@@ -139,7 +139,7 @@ For authorized mobile verification, a missing or outdated native client is an in
139139
## Pull requests
140140

141141
- Never make a PR unless the developer explicitly asks you to do so.
142-
- If `origin` is git.cafe, follow [GitCafe mirror](docs/operations/development.md#gitcafe-mirror-optional): push to `origin`, open and track PRs with `cafe` and their git.cafe URLs, and keep `gh` for CI logs and merging.
142+
- If `origin` is git.cafe, follow [GitCafe mirror](docs/operations/development.md#gitcafe-mirror-optional): push to `origin`, open and track PRs with `cafe` and their git.cafe URLs, and keep `gh` for merging.
143143
- Conventional commit titles, plain language: `fix(web): new threads no longer spike CPU`.
144144
- Body: the problem in a sentence or two, then how you fixed it. End with the model and harness that did the work.
145145
- UI changes need before/after images. Motion or timing needs a short video.
@@ -194,7 +194,7 @@ Architecture and its constraints: `docs/internals/overview.md`. Glossary: `docs/
194194
options, and pass combinators as additional function-builder arguments.
195195
- Inferred types over annotations. `any` is the enemy.
196196
- Default to no comment. Write one only for a constraint, an external quirk, or an invariant the code can't show, in one line where you can and four at most. Don't restate names or signatures, narrate steps, record history, or explain the fix you just made; the PR carries that. `t3code/no-low-value-comments` enforces the length cap and the mechanical cases.
197-
- React effects are a last resort: derive in render, act in handlers, reset with `key`, or use a ref callback or store. The `t3code/react-effect-budget` lint rule holds each file to its entry in `scripts/effect-budget.json`; raise an entry only in the PR that needs the effect, and lower it when you remove one.
197+
- React effects are for synchronizing with something outside React. Derive in render and act in handlers instead of syncing state, but don't hide real lifecycle work in refs or stores to dodge one. The `t3code/react-effect-budget` lint rule holds each file to its count in `scripts/effect-budget.json`; a new effect states its reason with `// oxlint-disable-next-line t3code/react-effect-budget -- <why>`.
198198
- Our users drive agents all day and notice a dropped frame, a lying spinner, and a stale label. No continuously repainting animations; they peg the GPU on high-refresh displays.
199199
- If a rule here fights the task in front of you, say so loudly and get a human sign-off before breaking it.
200200

‎apps/desktop/src/app/DesktopClerk.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ vi.mock("@clerk/electron", () => ({
2828
vi.mock("@clerk/electron/storage", () => ({
2929
storage: storageMock,
3030
}));
31-
32-
import * as Option from "effect/Option";
3331
import * as Exit from "effect/Exit";
3432
import * as FileSystem from "effect/FileSystem";
3533
import * as ElectronApp from "../electron/ElectronApp.ts";
@@ -297,7 +295,7 @@ it.effect(
297295
}),
298296
} as unknown as ElectronApp.ElectronApp["Service"];
299297
const electronWindow = {
300-
currentMainOrFirst: Effect.succeed(Option.some(window)),
298+
currentMainOrFirst: Effect.succeedSome(window),
301299
reveal: () => Effect.sync(() => revealed.resolve()),
302300
} as unknown as ElectronWindow.ElectronWindow["Service"];
303301
return Effect.gen(function* () {

‎apps/desktop/src/app/DesktopCliCommand.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,15 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
100100
const command = yield* commandIn({ home });
101101
const link = path.join(home, ".local", "bin", "t3");
102102

103-
expect(yield* command.state).toEqual({ supported: true, installedPath: null, onPath: false });
103+
expect(yield* command.state).toEqual({
104+
supported: true,
105+
installedPath: null,
106+
onPath: false,
107+
launcherPath: null,
108+
});
104109
const installed = yield* command.install;
105110
expect(installed.installedPath).toBe(link);
111+
expect(installed.launcherPath).toBe(path.join(home, ".t3", "bin", "t3"));
106112
expect(yield* fs.readLink(link)).toBe(path.join(home, ".t3", "bin", "t3"));
107113
expect((yield* command.install).installedPath).toBe(link);
108114

‎apps/desktop/src/app/DesktopCliCommand.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,26 @@ export const make = Effect.gen(function* () {
150150

151151
const state: DesktopCliCommand["Service"]["state"] = Effect.gen(function* () {
152152
if (!environment.isPackaged) {
153-
return { supported: false, installedPath: null, onPath: false } as const;
153+
return { supported: false, installedPath: null, onPath: false, launcherPath: null } as const;
154154
}
155+
const launcherPath = (yield* exists(launcher)) ? launcher : null;
155156
const installed = yield* installedAt;
156157
const shadowedBy = yield* foreignFirstOnPath;
157158
const shadow = Option.isSome(shadowedBy) ? { shadowedBy: shadowedBy.value } : {};
158159
if (Option.isNone(installed)) {
159-
return { supported: true, installedPath: null, onPath: false, ...shadow };
160+
return { supported: true, installedPath: null, onPath: false, launcherPath, ...shadow };
160161
}
161162
const first = yield* firstOnPath;
162163
const onPath = windows || (Option.isSome(first) && (yield* isOurLink(first.value)));
163-
return { supported: true, installedPath: installed.value, onPath, ...shadow };
164-
}).pipe(Effect.orElseSucceed(() => ({ supported: false, installedPath: null, onPath: false })));
164+
return { supported: true, installedPath: installed.value, onPath, launcherPath, ...shadow };
165+
}).pipe(
166+
Effect.orElseSucceed(() => ({
167+
supported: false,
168+
installedPath: null,
169+
onPath: false,
170+
launcherPath: null,
171+
})),
172+
);
165173

166174
const ensureLauncher = DesktopCliShim.install.pipe(
167175
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),

‎apps/desktop/src/app/DesktopWebLinks.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { assert, describe, it } from "@effect/vitest";
33
import * as NodeEvents from "node:events";
44
import * as Effect from "effect/Effect";
55
import * as Layer from "effect/Layer";
6-
import * as Option from "effect/Option";
76

87
import * as ElectronWindow from "../electron/ElectronWindow.ts";
98
import { WEB_LINK_OPEN_CHANNEL } from "../ipc/channels.ts";
@@ -26,7 +25,7 @@ const makeWindow = () => {
2625
Layer.succeed(
2726
ElectronWindow.ElectronWindow,
2827
ElectronWindow.ElectronWindow.of({
29-
currentMainOrFirst: Effect.succeed(Option.some(window)),
28+
currentMainOrFirst: Effect.succeedSome(window),
3029
reveal: (target: Electron.BrowserWindow) => Effect.sync(() => void revealed.push(target)),
3130
} as unknown as ElectronWindow.ElectronWindow["Service"]),
3231
),

‎apps/desktop/src/ipc/methods/window.test.ts‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ vi.mock("electron", () => ({
2020
import * as DesktopBackendConfiguration from "../../backend/DesktopBackendConfiguration.ts";
2121
import * as DesktopBackendManager from "../../backend/DesktopBackendManager.ts";
2222
import * as DesktopBackendPool from "../../backend/DesktopBackendPool.ts";
23+
import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts";
24+
import * as ElectronDialog from "../../electron/ElectronDialog.ts";
25+
import * as ElectronWindow from "../../electron/ElectronWindow.ts";
2326
import {
2427
getLocalEnvironmentBootstraps,
2528
getRelayTelemetryEnabled,
29+
pickProjectFavicon,
2630
probeRemoteEditors,
2731
} from "./window.ts";
2832

@@ -192,6 +196,78 @@ describe("getRelayTelemetryEnabled", () => {
192196
);
193197
});
194198

199+
describe("pickProjectFavicon", () => {
200+
const pickerLayer = (
201+
pickFiles: () => Effect.Effect<Array<string>>,
202+
settings?: DesktopAppSettings.DesktopSettings,
203+
) =>
204+
Layer.mergeAll(
205+
Layer.mock(ElectronDialog.ElectronDialog)({ pickFiles }),
206+
Layer.mock(ElectronWindow.ElectronWindow)({
207+
focusedMainOrFirst: Effect.succeedNone,
208+
}),
209+
DesktopAppSettings.layerTest(settings),
210+
);
211+
212+
it.effect("opens a single-image picker from the project directory", () =>
213+
Effect.gen(function* () {
214+
const pickFiles = vi.fn(() => Effect.succeed(["/pictures/icon.png"]));
215+
const result = yield* pickProjectFavicon
216+
.handler("/project")
217+
.pipe(Effect.provide(pickerLayer(pickFiles)));
218+
219+
assert.strictEqual(result, "/pictures/icon.png");
220+
assert.deepEqual(pickFiles.mock.calls, [
221+
[
222+
{
223+
owner: Option.none(),
224+
defaultPath: Option.some("/project"),
225+
multiple: false,
226+
filters: [
227+
{
228+
name: "Images",
229+
extensions: [
230+
"avif",
231+
"bmp",
232+
"gif",
233+
"ico",
234+
"heic",
235+
"heif",
236+
"jpeg",
237+
"jpg",
238+
"png",
239+
"svg",
240+
"tif",
241+
"tiff",
242+
"webp",
243+
"icns",
244+
],
245+
},
246+
],
247+
},
248+
],
249+
]);
250+
}),
251+
);
252+
253+
it.effect("does not open a picker while the local environment is off", () =>
254+
Effect.gen(function* () {
255+
const pickFiles = vi.fn(() => Effect.succeed(["/pictures/icon.png"]));
256+
const result = yield* pickProjectFavicon.handler("/project").pipe(
257+
Effect.provide(
258+
pickerLayer(pickFiles, {
259+
...DesktopAppSettings.DEFAULT_DESKTOP_SETTINGS,
260+
localEnvironmentEnabled: false,
261+
}),
262+
),
263+
);
264+
265+
assert.strictEqual(result, null);
266+
assert.strictEqual(pickFiles.mock.calls.length, 0);
267+
}),
268+
);
269+
});
270+
195271
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
196272
"finds remote editors installed without PATH launchers",
197273
() =>

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ describe("CDP relay", () => {
6565
]);
6666
pending[0]!();
6767
await settle();
68-
expect(send).toHaveBeenNthCalledWith(1, "Page.captureScreenshot", {}, undefined);
69-
expect(send).toHaveBeenNthCalledWith(2, "DOM.enable", {}, "iframe-session");
68+
expect(send).toHaveBeenNthCalledWith(1, "Page.captureScreenshot", {}, undefined, undefined);
69+
expect(send).toHaveBeenNthCalledWith(2, "DOM.enable", {}, "iframe-session", undefined);
7070
expect(written.at(-1)).toEqual({
7171
id: 5,
7272
result: { method: "Page.captureScreenshot" },
@@ -92,7 +92,30 @@ describe("CDP relay", () => {
9292
}),
9393
);
9494
await settle();
95-
expect(send.mock.calls).toEqual([["Runtime.runIfWaitingForDebugger", {}, "iframe-session"]]);
95+
expect(send.mock.calls).toEqual([
96+
["Runtime.runIfWaitingForDebugger", {}, "iframe-session", undefined],
97+
]);
98+
});
99+
100+
// Playwright enables focus emulation on every page it connects to, and Chromium then
101+
// counts the guest as captured: a preview the panel hides keeps its timers unthrottled.
102+
it("acknowledges Playwright's focus emulation without forcing it onto the guest", async () => {
103+
const send = vi.fn(async () => ({}));
104+
const written: Array<Record<string, unknown>> = [];
105+
const relay = createCdpRelayConnection(makeTarget(send), (raw) =>
106+
written.push(JSON.parse(raw)),
107+
);
108+
relay.receive(
109+
JSON.stringify({
110+
id: 1,
111+
method: "Emulation.setFocusEmulationEnabled",
112+
params: { enabled: true },
113+
sessionId: "t3-preview-page",
114+
}),
115+
);
116+
await settle();
117+
expect(written).toEqual([{ id: 1, result: {}, sessionId: "t3-preview-page" }]);
118+
expect(send).not.toHaveBeenCalled();
96119
});
97120

98121
it("routes tab events to the page session once the page is announced", async () => {
@@ -147,7 +170,7 @@ describe("CDP relay extra sessions", () => {
147170
expect(written.find((m) => m["id"] === 4)).toHaveProperty("error");
148171
relay.receive(JSON.stringify({ id: 5, method: "Page.startScreencast", sessionId: extra }));
149172
await settle();
150-
expect(send).toHaveBeenLastCalledWith("Page.startScreencast", {}, undefined);
173+
expect(send).toHaveBeenLastCalledWith("Page.startScreencast", {}, undefined, extra);
151174
written.length = 0;
152175
relay.event("Page.screencastFrame", { data: "x" }, undefined);
153176
expect(written.map((m) => m["sessionId"])).toEqual(["t3-preview-page", extra]);

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ export interface CdpRelayTarget {
55
method: string,
66
params: Record<string, unknown>,
77
sessionId: string | undefined,
8+
/** The extra session that sent it, such as a viewer's; the main connection has none. */
9+
owner?: string,
810
) => Promise<unknown>;
11+
readonly sessionDetached?: (owner: string) => void;
912
/** The page's own CDP target id; Playwright keys the main frame by it. */
1013
readonly targetId: () => Promise<string>;
1114
readonly url: () => string;
@@ -111,8 +114,10 @@ export function createCdpRelayConnection(
111114
}
112115
case "Target.detachFromTarget": {
113116
const sessionId = command.params?.["sessionId"];
114-
if (typeof sessionId === "string" && sessionId !== PAGE_SESSION_ID)
117+
if (typeof sessionId === "string" && sessionId !== PAGE_SESSION_ID) {
115118
sessions.delete(sessionId);
119+
target.sessionDetached?.(sessionId);
120+
}
116121
return {};
117122
}
118123
case "Target.setAutoAttach": {
@@ -133,11 +138,15 @@ export function createCdpRelayConnection(
133138

134139
const pageCommand = (command: CdpCommand): Promise<unknown> => {
135140
const child = sessions.get(command.sessionId!) === "page" ? undefined : command.sessionId;
141+
const owner =
142+
child === undefined && command.sessionId !== PAGE_SESSION_ID ? command.sessionId : undefined;
136143
// Child frames/workers pause on auto-attach until resumed; only the main page can skip this command.
137144
if (command.method === "Runtime.runIfWaitingForDebugger" && child === undefined) {
138145
return Promise.resolve({});
139146
}
140-
return target.send(command.method, command.params ?? {}, child);
147+
// Playwright asks for this on every page; the host emulates focus only while it is in use.
148+
if (command.method === "Emulation.setFocusEmulationEnabled") return Promise.resolve({});
149+
return target.send(command.method, command.params ?? {}, child, owner);
141150
};
142151

143152
return {

0 commit comments

Comments
 (0)