Skip to content

Commit 1607382

Browse files
committed
chore(mobile): merge main into native glass fix
2 parents 095538b + 220eb73 commit 1607382

1,220 files changed

Lines changed: 63356 additions & 20921 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.

‎.github/workflows/web-preview.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ jobs:
8282
--archive=tgz \
8383
--yes \
8484
--token "$VERCEL_TOKEN" \
85-
--scope "$vercel_scope"
85+
--scope "$vercel_scope" \
86+
--build-env "VITE_RELEASE_CHANNEL=preview"
8687
)"
8788
printf '%s\n' "$deployment_output"
8889
# Vercel can print lockfile warnings to stdout before the deployment URL.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ apps/mobile/.generated/
3636
apps/mobile/.android-cache/
3737
/.generated/
3838
artifacts/app-store/screenshots/
39+
artifacts/mobile-e2e/
3940
.github/pr-assets/
4041
native/**/target/
4142
node_modules/

‎AGENTS.md‎

Lines changed: 3 additions & 2 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): use `cafe` for existing PRs, issues, comments and labels, but push and open PRs on GitHub, where CI runs.
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,6 +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 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>`.
197198
- 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.
198199
- If a rule here fights the task in front of you, say so loudly and get a human sign-off before breaking it.
199200

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,10 @@ export const make = Effect.gen(function* () {
382382
webContents.send(DESKTOP_APP_ACTIVATION_REQUEST_CHANNEL, request);
383383
});
384384
}),
385-
complete: (response) => Effect.sync(() => broker.complete(response)),
385+
// The IPC handler owns the activation-completion span.
386+
complete: Effect.fnUntraced(function* (response) {
387+
return yield* Effect.sync(() => broker.complete(response));
388+
}),
386389
});
387390
});
388391

‎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/DesktopObservability.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,36 @@ describe("DesktopObservability", () => {
342342
Effect.provide(Layer.mergeAll(NodeServices.layer, layerCollector(requests), layerEmptyEnv)),
343343
);
344344
});
345+
346+
it.effect("describes the Node runtime and the desktop mode under semantic or t3code keys", () => {
347+
const requests: Array<ExportedRequest> = [];
348+
return Effect.gen(function* () {
349+
const fileSystem = yield* FileSystem.FileSystem;
350+
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
351+
prefix: "t3-desktop-observability-test-",
352+
});
353+
const layerEnvironment = layerEnvironmentFor(baseDir);
354+
yield* writeObservabilitySettings(layerEnvironment, {
355+
otlpLogsUrl: "https://settings.example.com/v1/logs",
356+
});
357+
358+
yield* Effect.scoped(
359+
Effect.logInfo("desktop resource under test").pipe(
360+
Effect.provide(DesktopObservability.layer.pipe(Layer.provideMerge(layerEnvironment))),
361+
),
362+
);
363+
364+
const body = requests.map((request) => request.body).join("\n");
365+
assert.include(body, '"key":"process.runtime.name","value":{"stringValue":"nodejs"}');
366+
assert.include(
367+
body,
368+
`"key":"process.runtime.version","value":{"stringValue":"${process.versions.node}"}`,
369+
);
370+
assert.include(body, '"key":"t3code.desktop.mode","value":{"stringValue":"development"}');
371+
assert.notInclude(body, "service.mode");
372+
}).pipe(
373+
Effect.scoped,
374+
Effect.provide(Layer.mergeAll(NodeServices.layer, layerCollector(requests), layerEmptyEnv)),
375+
);
376+
});
345377
});

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

Lines changed: 101 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import { PRIMARY_LOCAL_ENVIRONMENT_ID } from "@t3tools/contracts";
22
import {
33
makeLocalFileTracer,
44
makeTraceSink,
5+
nodeProcessRuntimeAttributes,
6+
processServiceInstanceId,
57
type SignalExport,
68
} from "@t3tools/shared/observability";
79
import * as HostProcess from "@t3tools/shared/HostProcess";
810
import * as SharedObservability from "@t3tools/shared/observability";
911
import * as OtelEnvironment from "@t3tools/shared/otelEnvironment";
12+
import { releaseChannelOf, releaseResourceAttributes } from "@t3tools/shared/releaseResource";
1013
import {
1114
parsePersistedServerObservabilitySettings,
1215
type PersistedServerObservabilitySettings,
@@ -456,90 +459,91 @@ const makeBackendOutputLogShape = (
456459
): Effect.Effect<DesktopBackendOutputLogShape> =>
457460
Option.match(sink, {
458461
onNone: () => Effect.succeed(DesktopBackendOutputLogNoop),
459-
onSome: (logFile) =>
460-
Effect.gen(function* () {
461-
const sessionRef = yield* Ref.make(Option.none<BackendOutputSession>());
462-
const writeFailure = Effect.fn("desktop.observability.backendOutput.writeFailure")(
463-
function* (session: BackendOutputSession, details: string) {
464-
yield* writeBackendChildLogRecord(logFile, {
465-
message: "backend child process failure output start",
466-
level: "ERROR",
467-
annotations: {
468-
component: "desktop-backend-child",
469-
runId: session.runId,
470-
instanceId: id,
471-
phase: "START",
472-
details: session.startDetails,
473-
},
474-
});
475-
for (const output of session.chunks) {
476-
yield* writeBackendChildLogRecord(logFile, {
477-
message: "backend child process output",
478-
level: output.streamName === "stderr" ? "ERROR" : "INFO",
479-
annotations: {
480-
component: "desktop-backend-child",
481-
runId: session.runId,
482-
instanceId: id,
483-
stream: output.streamName,
484-
text: textDecoder.decode(output.chunk.subarray(output.offset)),
485-
},
486-
});
487-
}
488-
yield* writeBackendChildLogRecord(logFile, {
489-
message: "backend child process failure output end",
490-
level: "ERROR",
491-
annotations: {
492-
component: "desktop-backend-child",
493-
runId: session.runId,
494-
instanceId: id,
495-
phase: "END",
496-
details: sanitizeLogValue(details),
497-
},
498-
});
462+
// The enclosing operation owns the span for this inline handler.
463+
onSome: Effect.fnUntraced(function* (logFile) {
464+
const sessionRef = yield* Ref.make(Option.none<BackendOutputSession>());
465+
const writeFailure = Effect.fn("desktop.observability.backendOutput.writeFailure")(function* (
466+
session: BackendOutputSession,
467+
details: string,
468+
) {
469+
yield* writeBackendChildLogRecord(logFile, {
470+
message: "backend child process failure output start",
471+
level: "ERROR",
472+
annotations: {
473+
component: "desktop-backend-child",
474+
runId: session.runId,
475+
instanceId: id,
476+
phase: "START",
477+
details: session.startDetails,
499478
},
500-
);
501-
return {
502-
beginSession: Effect.fn("desktop.observability.backendOutput.beginSession")(function* ({
503-
details,
504-
}) {
505-
const runId = yield* currentDesktopRunId;
506-
yield* Ref.set(
507-
sessionRef,
508-
Option.some({
509-
runId,
510-
startDetails: sanitizeLogValue(details),
511-
chunks: [],
512-
byteLength: 0,
513-
}),
514-
);
515-
}),
516-
writeOutputChunk: Effect.fnUntraced(function* (streamName, chunk) {
517-
if (environment.isDevelopment) {
518-
yield* writeDevelopmentConsoleOutput(streamName, chunk);
519-
}
520-
yield* Ref.update(
521-
sessionRef,
522-
Option.map((session) => appendBoundedOutputChunk(session, streamName, chunk)),
523-
);
524-
}),
525-
persistFailureSnapshot: Effect.fn(
526-
"desktop.observability.backendOutput.persistFailureSnapshot",
527-
)(function* ({ details }) {
528-
const session = yield* Ref.get(sessionRef);
529-
if (Option.isSome(session)) {
530-
yield* writeFailure(session.value, details);
531-
}
532-
}),
533-
persistFailure: Effect.fn("desktop.observability.backendOutput.persistFailure")(
534-
function* ({ details }) {
535-
const session = yield* Ref.modify(sessionRef, (current) => [current, Option.none()]);
536-
if (Option.isNone(session)) return;
537-
yield* writeFailure(session.value, details);
479+
});
480+
for (const output of session.chunks) {
481+
yield* writeBackendChildLogRecord(logFile, {
482+
message: "backend child process output",
483+
level: output.streamName === "stderr" ? "ERROR" : "INFO",
484+
annotations: {
485+
component: "desktop-backend-child",
486+
runId: session.runId,
487+
instanceId: id,
488+
stream: output.streamName,
489+
text: textDecoder.decode(output.chunk.subarray(output.offset)),
538490
},
539-
),
540-
discardSession: Ref.set(sessionRef, Option.none()),
541-
} satisfies DesktopBackendOutputLogShape;
542-
}),
491+
});
492+
}
493+
yield* writeBackendChildLogRecord(logFile, {
494+
message: "backend child process failure output end",
495+
level: "ERROR",
496+
annotations: {
497+
component: "desktop-backend-child",
498+
runId: session.runId,
499+
instanceId: id,
500+
phase: "END",
501+
details: sanitizeLogValue(details),
502+
},
503+
});
504+
});
505+
return {
506+
beginSession: Effect.fn("desktop.observability.backendOutput.beginSession")(function* ({
507+
details,
508+
}) {
509+
const runId = yield* currentDesktopRunId;
510+
yield* Ref.set(
511+
sessionRef,
512+
Option.some({
513+
runId,
514+
startDetails: sanitizeLogValue(details),
515+
chunks: [],
516+
byteLength: 0,
517+
}),
518+
);
519+
}),
520+
writeOutputChunk: Effect.fnUntraced(function* (streamName, chunk) {
521+
if (environment.isDevelopment) {
522+
yield* writeDevelopmentConsoleOutput(streamName, chunk);
523+
}
524+
yield* Ref.update(
525+
sessionRef,
526+
Option.map((session) => appendBoundedOutputChunk(session, streamName, chunk)),
527+
);
528+
}),
529+
persistFailureSnapshot: Effect.fn(
530+
"desktop.observability.backendOutput.persistFailureSnapshot",
531+
)(function* ({ details }) {
532+
const session = yield* Ref.get(sessionRef);
533+
if (Option.isSome(session)) {
534+
yield* writeFailure(session.value, details);
535+
}
536+
}),
537+
persistFailure: Effect.fn("desktop.observability.backendOutput.persistFailure")(function* ({
538+
details,
539+
}) {
540+
const session = yield* Ref.modify(sessionRef, (current) => [current, Option.none()]);
541+
if (Option.isNone(session)) return;
542+
yield* writeFailure(session.value, details);
543+
}),
544+
discardSession: Ref.set(sessionRef, Option.none()),
545+
} satisfies DesktopBackendOutputLogShape;
546+
}),
543547
});
544548

545549
const layerBackendOutputLogFactory = Layer.effect(
@@ -586,7 +590,9 @@ const layerBackendOutputLogFactory = Layer.effect(
586590
});
587591

588592
return DesktopBackendOutputLogFactory.of({
589-
forInstance: (id) => makeForId(id),
593+
forInstance: Effect.fn("DesktopBackendOutputLogFactory.forInstance")(function (id) {
594+
return makeForId(id);
595+
}),
590596
});
591597
}),
592598
);
@@ -595,15 +601,24 @@ const layerTelemetry = Layer.unwrap(
595601
Effect.gen(function* () {
596602
const environment = yield* DesktopEnvironment.DesktopEnvironment;
597603
const endpoints = yield* resolveOtlpEndpoints;
604+
// Unpackaged runs launch a script, so Electron reports its own version.
605+
const serviceVersion = environment.isPackaged
606+
? environment.appVersion
607+
: desktopPackageJson.version;
598608
const resource = {
599609
serviceName: "t3code-desktop",
600-
// Unpackaged runs launch a script, so Electron reports its own version.
601-
serviceVersion: environment.isPackaged ? environment.appVersion : desktopPackageJson.version,
610+
serviceVersion,
602611
attributes: {
603612
"service.namespace": "t3code",
604613
"service.runtime": "desktop",
605-
"service.mode": environment.isDevelopment ? "development" : "packaged",
614+
"t3code.desktop.mode": environment.isDevelopment ? "development" : "packaged",
615+
"service.instance.id": processServiceInstanceId(endpoints.resourceAttributes),
616+
...releaseResourceAttributes(
617+
environment.isDevelopment ? "dev" : releaseChannelOf(serviceVersion),
618+
endpoints.resourceAttributes,
619+
),
606620
"host.name": endpoints.resourceAttributes["host.name"] || (yield* HostProcess.Hostname),
621+
...nodeProcessRuntimeAttributes(),
607622
},
608623
};
609624

0 commit comments

Comments
 (0)