The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 17:00 UTC
fix: restore files reverted by 5f1f604
5f1f604 was committed from a tree based on an older main, so it reverted upstream changes outside the e2e runner (including #23973, #22907, #22849). This restores every file to e3592ef and keeps only the runner's own changes (scripts/mobile-e2e.ts, scripts/mobile-showcase.ts, package and lockfile entries, .gitignore). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 25, 2026 at 15:01 UTC
2ed92618e60f5ee6ecc694eb834c28105a502d09
59 files changed
+1666
-66
.github/workflows/web-preview.yml
+2
-1
@@ -82,7 +82,8 @@ jobs:
82
--archive=tgz \
83
--yes \
84
--token "$VERCEL_TOKEN" \
85
- --scope "$vercel_scope"
85
+ --scope "$vercel_scope" \
86
+ --build-env "VITE_RELEASE_CHANNEL=preview"
87
)"
88
printf '%s\n' "$deployment_output"
89
# Vercel can print lockfile warnings to stdout before the deployment URL.
AGENTS.md
+1
@@ -194,6 +194,7 @@ Architecture and its constraints: `docs/internals/overview.md`. Glossary: `docs/
194
options, and pass combinators as additional function-builder arguments.
195
- Inferred types over annotations. `any` is the enemy.
196
- 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.
198
- 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.
199
- If a rule here fights the task in front of you, say so loudly and get a human sign-off before breaking it.
200
apps/desktop/src/app/DesktopObservability.ts
+12
-2
@@ -2,11 +2,13 @@ import { PRIMARY_LOCAL_ENVIRONMENT_ID } from "@t3tools/contracts";
2
import {
3
makeLocalFileTracer,
4
makeTraceSink,
5
+ processServiceInstanceId,
6
type SignalExport,
7
} from "@t3tools/shared/observability";
8
import * as HostProcess from "@t3tools/shared/HostProcess";
9
import * as SharedObservability from "@t3tools/shared/observability";
10
import * as OtelEnvironment from "@t3tools/shared/otelEnvironment";
11
+import { releaseChannelOf, releaseResourceAttributes } from "@t3tools/shared/releaseResource";
12
import {
13
parsePersistedServerObservabilitySettings,
14
type PersistedServerObservabilitySettings,
@@ -595,14 +597,22 @@ const layerTelemetry = Layer.unwrap(
597
Effect.gen(function* () {
598
const environment = yield* DesktopEnvironment.DesktopEnvironment;
599
const endpoints = yield* resolveOtlpEndpoints;
600
+ // Unpackaged runs launch a script, so Electron reports its own version.
601
+ const serviceVersion = environment.isPackaged
602
+ ? environment.appVersion
603
+ : desktopPackageJson.version;
604
const resource = {
605
serviceName: "t3code-desktop",
600
- // Unpackaged runs launch a script, so Electron reports its own version.
601
- serviceVersion: environment.isPackaged ? environment.appVersion : desktopPackageJson.version,
606
+ serviceVersion,
607
attributes: {
608
"service.namespace": "t3code",
609
"service.runtime": "desktop",
610
"service.mode": environment.isDevelopment ? "development" : "packaged",
611
+ "service.instance.id": processServiceInstanceId(endpoints.resourceAttributes),
612
+ ...releaseResourceAttributes(
613
+ environment.isDevelopment ? "dev" : releaseChannelOf(serviceVersion),
614
+ endpoints.resourceAttributes,
615
+ ),
616
"host.name": endpoints.resourceAttributes["host.name"] || (yield* HostProcess.Hostname),
617
},
618
};
apps/desktop/src/backend/DesktopBackendConfiguration.test.ts
+6
-1
@@ -678,7 +678,7 @@ describe("DesktopBackendConfiguration", () => {
678
),
679
);
680
681
- it.effect("resolveWsl carries the kill switch into the distro", () =>
681
+ it.effect("resolveWsl carries the kill switch and resource attributes into the distro", () =>
682
Effect.gen(function* () {
683
const fileSystem = yield* FileSystem.FileSystem;
684
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
@@ -688,10 +688,12 @@ describe("DesktopBackendConfiguration", () => {
688
const previousWslEnv = process.env.WSLENV;
689
const previousDisabled = process.env.OTEL_SDK_DISABLED;
690
const previousTelemetry = process.env.T3CODE_TELEMETRY_ENABLED;
691
+ const previousResourceAttributes = process.env.OTEL_RESOURCE_ATTRIBUTES;
692
try {
693
delete process.env.WSLENV;
694
process.env.OTEL_SDK_DISABLED = "true";
695
process.env.T3CODE_TELEMETRY_ENABLED = "false";
696
+ process.env.OTEL_RESOURCE_ATTRIBUTES = "deployment.environment.name=staging";
697
698
yield* Effect.gen(function* () {
699
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
@@ -701,6 +703,8 @@ describe("DesktopBackendConfiguration", () => {
703
assert.include((config.env.WSLENV ?? "").split(":"), "OTEL_SDK_DISABLED");
704
assert.equal(config.env.T3CODE_TELEMETRY_ENABLED, "false");
705
assert.include((config.env.WSLENV ?? "").split(":"), "T3CODE_TELEMETRY_ENABLED");
706
+ assert.equal(config.env.OTEL_RESOURCE_ATTRIBUTES, "deployment.environment.name=staging");
707
+ assert.include((config.env.WSLENV ?? "").split(":"), "OTEL_RESOURCE_ATTRIBUTES");
708
}).pipe(
709
Effect.provide(
710
layerBackendConfiguration().pipe(
@@ -722,6 +726,7 @@ describe("DesktopBackendConfiguration", () => {
726
restoreEnv("WSLENV", previousWslEnv);
727
restoreEnv("OTEL_SDK_DISABLED", previousDisabled);
728
restoreEnv("T3CODE_TELEMETRY_ENABLED", previousTelemetry);
729
+ restoreEnv("OTEL_RESOURCE_ATTRIBUTES", previousResourceAttributes);
730
}
731
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
732
);
apps/desktop/src/backend/DesktopBackendConfiguration.ts
+1
@@ -110,6 +110,7 @@ const WSL_FORWARDED_ENV_NAMES = [
110
"OTEL_TRACES_EXPORTER",
111
"OTEL_METRICS_EXPORTER",
112
"OTEL_LOGS_EXPORTER",
113
+ "OTEL_RESOURCE_ATTRIBUTES",
114
] as const;
115
116
const WSL_SERVER_SYSTEM_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
apps/mobile/src/features/observability/tracing.test.ts
+1
@@ -27,6 +27,7 @@ it.effect("does not let OTLP serialization failures alter application effects",
27
},
28
{
29
appVariant: "test",
30
+ serviceInstanceId: "test-instance",
31
serviceVersion: "1.2.3",
32
},
33
).pipe(Layer.provide(layerRemoteHttpClient(fetchFn)));
apps/mobile/src/features/observability/tracing.ts
+15
@@ -1,4 +1,5 @@
1
import Constants from "expo-constants";
2
+import { type ReleaseChannel, releaseResourceAttributes } from "@t3tools/shared/releaseResource";
3
import * as RelayTracing from "@t3tools/shared/relayTracing";
4
5
import { hasTracingPublicConfig, resolveCloudPublicConfig } from "../cloud/publicConfig";
@@ -11,9 +12,16 @@ export interface TracingConfig {
12
13
export interface TracingResource {
14
readonly serviceVersion?: string;
15
+ readonly serviceInstanceId: string;
16
readonly appVariant: string;
17
}
18
19
+const RELEASE_CHANNEL_BY_VARIANT: Readonly<Record<string, ReleaseChannel | undefined>> = {
20
+ development: "dev",
21
+ preview: "preview",
22
+ production: "stable",
23
+};
24
+
25
export function resolveTracingConfig(): TracingConfig | null {
26
const config = resolveCloudPublicConfig();
27
if (!hasTracingPublicConfig(config)) {
@@ -24,16 +32,23 @@ export function resolveTracingConfig(): TracingConfig | null {
32
}
33
34
export function layerFromConfig(config: TracingConfig | null, resource: TracingResource) {
35
+ const channel =
36
+ typeof __DEV__ !== "undefined" && __DEV__
37
+ ? "dev"
38
+ : RELEASE_CHANNEL_BY_VARIANT[resource.appVariant];
39
return RelayTracing.layer(config, {
40
serviceName: "t3code-mobile",
41
serviceVersion: resource.serviceVersion,
42
runtime: "react-native",
43
+ serviceInstanceId: resource.serviceInstanceId,
44
client: `mobile-${resource.appVariant}`,
45
+ attributes: channel && releaseResourceAttributes(channel),
46
});
47
}
48
49
export const layer = layerFromConfig(resolveTracingConfig(), {
50
serviceVersion: Constants.expoConfig?.version,
51
+ serviceInstanceId: Constants.sessionId,
52
appVariant:
53
typeof Constants.expoConfig?.extra?.appVariant === "string"
54
? Constants.expoConfig.extra.appVariant
apps/mobile/src/features/threads/use-composer-command-menu.ts
+9
@@ -59,6 +59,8 @@ import type { ComposerCommandItem } from "./ComposerCommandPopover";
59
import { matchesSlashSkillQuery } from "./composerSlashSkillSearch";
60
61
const WORKSPACE_SNAPSHOT_RETRY_COOLDOWN_MS = 10_000;
62
+// A cwd that never scans, such as a deleted worktree, would otherwise retry forever.
63
+const WORKSPACE_SNAPSHOT_MAX_ATTEMPTS = 3;
64
65
function composerSelectionAtEnd(draftMessage: string): ComposerEditorSelection {
66
return { start: draftMessage.length, end: draftMessage.length };
@@ -252,6 +254,7 @@ export function useComposerCommandMenu({
254
);
255
// Record client request time to enforce TTL even when the client clock runs ahead of the server.
256
const workspaceRefreshKeyRef = useRef<{ key: string; requestedAt: number } | null>(null);
257
+ const failedRefreshesRef = useRef<{ key: string; count: number } | null>(null);
258
const [workspaceRefreshRetry, setWorkspaceRefreshRetry] = useState<{
259
key: string;
260
notBefore: number;
@@ -307,6 +310,11 @@ export function useComposerCommandMenu({
310
workspaceRefreshKeyRef.current = request;
311
const retryLater = () => {
312
if (workspaceRefreshKeyRef.current !== request) return;
313
+ const failed = failedRefreshesRef.current;
314
+ const count = failed?.key === key ? failed.count + 1 : 1;
315
+ failedRefreshesRef.current = { key, count };
316
+ // Keeping the request marker lets the TTL hold off the next scan.
317
+ if (count >= WORKSPACE_SNAPSHOT_MAX_ATTEMPTS) return;
318
workspaceRefreshKeyRef.current = null;
319
setWorkspaceRefreshRetry({
320
key,
@@ -326,6 +334,7 @@ export function useComposerCommandMenu({
334
projectCwd,
335
);
336
if (!refreshed) retryLater();
337
+ else failedRefreshesRef.current = null;
338
}, retryLater);
339
}, [
340
draftMessage,
apps/server/scripts/acp-mock-agent.ts
+2
-1
@@ -52,6 +52,7 @@ const emitGrokMonitorPostTurnPoll = process.env.T3_ACP_EMIT_GROK_MONITOR_POST_TU
52
const emitGrokBackgroundTaskStarted = process.env.T3_ACP_EMIT_GROK_BACKGROUND_TASK_STARTED === "1";
53
const emitGrokBackgroundTaskPoll = process.env.T3_ACP_GROK_BACKGROUND_TASK_COMPLETION === "poll";
54
const emitForeignSessionUpdates = process.env.T3_ACP_EMIT_FOREIGN_SESSION_UPDATES === "1";
55
+const omitInitializeModelState = process.env.T3_ACP_OMIT_INITIALIZE_MODEL_STATE === "1";
56
const waitForResumeRelease = process.env.T3_ACP_WAIT_FOR_RESUME_RELEASE === "1";
57
const completeFirstPromptOnCancel = process.env.T3_ACP_COMPLETE_FIRST_PROMPT_ON_CANCEL === "1";
58
const floodStderr = process.env.T3_ACP_FLOOD_STDERR === "1";
@@ -575,7 +576,7 @@ const program = Effect.gen(function* () {
576
return {
577
protocolVersion: 2,
578
info: { name: "t3-acp-mock-agent", version: "0.0.0" },
578
- _meta: { modelState: modelState() },
579
+ ...(omitInitializeModelState ? {} : { _meta: { modelState: modelState() } }),
580
capabilities: {
581
session: {
582
...(supportsSessionLifecycle ? { fork: {}, additionalDirectories: {} } : {}),
apps/server/src/cloud/pinnedRuntime.test.ts
+3
-2
@@ -487,14 +487,15 @@ it.layer(NodeServices.layer)("prunePinnedRuntimes", (it) => {
487
const path = yield* Path.Path;
488
const { baseDir, versionsDir } = yield* setup(["1.0.0", "1.1.0"]);
489
const entry = path.join(versionsDir, "1.0.0", "t3");
490
- yield* fs.copyFile("/bin/sleep", entry);
490
+ // Multicall coreutils (Ubuntu's uutils) refuse to run renamed, so copy Node instead.
491
+ yield* fs.copyFile(process.execPath, entry);
492
yield* fs.chmod(entry, 0o755);
493
const link = path.join(baseDir, "t3");
494
yield* fs.symlink(entry, link);
495
// Its argv names only the link, as with `t3 serve` run from PATH. Removing the link after
496
// spawning leaves the process's executable as the only reference.
497
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
497
- yield* spawner.spawn(ChildProcess.make(link, ["30"]));
498
+ yield* spawner.spawn(ChildProcess.make(link, ["-e", "setTimeout(() => {}, 30_000)"]));
499
yield* fs.remove(link);
500
501
const removed = yield* prunePinnedRuntimes({ baseDir, keep: ["2.0.0"] }).pipe(
apps/server/src/cloud/relayTracing.ts
+16
-2
@@ -1,16 +1,30 @@
1
+import { processServiceInstanceId } from "@t3tools/shared/observability";
2
import * as RelayTracing from "@t3tools/shared/relayTracing";
3
+import * as Effect from "effect/Effect";
4
+import * as Layer from "effect/Layer";
5
6
+import * as ServerConfig from "../config.ts";
7
import { resolveRelayClientTracingConfig } from "./publicConfig.ts";
8
9
const relayClientTracingConfig = resolveRelayClientTracingConfig();
10
7
-export const layerHeadlessRelayClient = RelayTracing.layer(relayClientTracingConfig, {
11
+const relayLayer = (resource: Omit<RelayTracing.RelayClientTracingResource, "serviceInstanceId">) =>
12
+ Layer.unwrap(
13
+ Effect.map(ServerConfig.ServerConfig, (config) =>
14
+ RelayTracing.layer(relayClientTracingConfig, {
15
+ ...resource,
16
+ serviceInstanceId: processServiceInstanceId(config.otelEnvironment.resourceAttributes),
17
+ }),
18
+ ),
19
+ );
20
+
21
+export const layerHeadlessRelayClient = relayLayer({
22
serviceName: "t3code-server",
23
runtime: "node",
24
client: "headless-cli",
25
});
26
13
-export const layerServerRelayBroker = RelayTracing.layer(relayClientTracingConfig, {
27
+export const layerServerRelayBroker = relayLayer({
28
serviceName: "t3code-server",
29
runtime: "node",
30
client: "environment-server",
apps/server/src/config.ts
+14
-1
@@ -10,10 +10,21 @@ import * as Schema from "effect/Schema";
10
11
import type { OtlpEndpointSource } from "@t3tools/contracts";
12
import { sweepStalePendingAttachments } from "./attachmentStore.ts";
13
-import { DEFAULT_SIGNAL_EXPORT, type SignalExport } from "@t3tools/shared/observability";
13
+import {
14
+ DEFAULT_SIGNAL_EXPORT,
15
+ processServiceInstanceId,
16
+ type SignalExport,
17
+} from "@t3tools/shared/observability";
18
import * as OtelEnvironment from "@t3tools/shared/otelEnvironment";
19
+import { type ReleaseChannel, releaseResourceAttributes } from "@t3tools/shared/releaseResource";
20
import packageJson from "../package.json" with { type: "json" };
21
22
+// Official release workflows set this telemetry channel; other builds report dev.
23
+// Unlike __T3CODE_BUILD_CHANNEL__, this is not the sign-in page's latest/nightly channel.
24
+declare const __T3CODE_TELEMETRY_CHANNEL__: ReleaseChannel | undefined;
25
+export const telemetryChannel: ReleaseChannel =
26
+ typeof __T3CODE_TELEMETRY_CHANNEL__ === "undefined" ? "dev" : __T3CODE_TELEMETRY_CHANNEL__;
27
+
28
export const DEFAULT_PORT = 3773;
29
30
export const RuntimeMode = Schema.Literals(["web", "desktop"]);
@@ -114,6 +125,8 @@ export const otlpResource = (
125
"service.namespace": "t3code",
126
"service.runtime": "t3-server",
127
"t3code.server.managed_by": config.mode === "desktop" ? "desktop" : "standalone",
128
+ "service.instance.id": processServiceInstanceId(config.otelEnvironment.resourceAttributes),
129
+ ...releaseResourceAttributes(telemetryChannel, config.otelEnvironment.resourceAttributes),
130
"host.name": config.otelEnvironment.resourceAttributes["host.name"] || hostName,
131
},
132
});
apps/server/src/environment/ServerEnvironment.ts
+1
@@ -239,6 +239,7 @@ export const make = Effect.gen(function* () {
239
threadSnooze: true,
240
environmentThemes: true,
241
usageLimitSources: true,
242
+ providerWorkspaceSnapshotsOnDemand: true,
243
usagePriceOverrides: true,
244
usageModelAliases: true,
245
threadPinning: true,
apps/server/src/observability/Metrics.ts
+19
@@ -15,6 +15,14 @@ export const rpcRequestDuration = Metric.timer("t3_rpc_request_duration", {
15
description: "RPC request handling duration.",
16
});
17
18
+export const orchestrationCommandsTotal = Metric.counter("t3_orchestration_commands_total", {
19
+ description: "Total orchestration commands dispatched, by outcome.",
20
+});
21
+
22
+export const orchestrationCommandDuration = Metric.timer("t3_orchestration_command_duration", {
23
+ description: "Orchestration command handling duration, excluding thread dispatch lock wait.",
24
+});
25
+
26
export const orchestrationEffectClaimsTotal = Metric.counter(
27
"t3_orchestration_effect_claims_total",
28
{
@@ -186,3 +194,14 @@ export const withMetrics: {
194
): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
195
<A, E, R>(effect: Effect.Effect<A, E, R>, options: WithMetricsOptions): Effect.Effect<A, E, R>;
196
} = dual(2, withMetricsImpl);
197
+
198
+// Shaped as an `Effect.fn` combinator: the command is the instrumented function's argument.
199
+export const withCommandMetrics = <A, E, R>(
200
+ effect: Effect.Effect<A, E, R>,
201
+ command: { readonly type: string },
202
+): Effect.Effect<A, E, R> =>
203
+ withMetrics(effect, {
204
+ counter: orchestrationCommandsTotal,
205
+ timer: orchestrationCommandDuration,
206
+ attributes: { commandType: command.type },
207
+ });
apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts
+40
@@ -21,10 +21,15 @@ import {
21
import * as DateTime from "effect/DateTime";
22
import * as Effect from "effect/Effect";
23
import * as Layer from "effect/Layer";
24
+import * as Metric from "effect/Metric";
25
import * as Result from "effect/Result";
26
import * as Stream from "effect/Stream";
27
import * as TestClock from "effect/testing/TestClock";
28
import * as SqlClient from "effect/sql/SqlClient";
29
+import {
30
+ orchestrationCommandDuration,
31
+ orchestrationCommandsTotal,
32
+} from "../observability/Metrics.ts";
33
import * as SqlitePersistence from "../persistence/Sqlite.ts";
34
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
35
import * as DelegatedTaskQuestionReactor from "./DelegatedTaskQuestionReactor.ts";
@@ -1368,3 +1373,38 @@ it.effect("explicit settle clears snooze atomically and stays idempotent after r
1373
assert.deepInclude((yield* projections.getThreadProjection(threadId)).thread, active);
1374
}).pipe(Effect.provide(layerTest)),
1375
);
1376
+
1377
+it.effect("dispatch records the command outcome and its duration", () =>
1378
+ Effect.gen(function* () {
1379
+ const orchestrator = yield* Orchestrator.OrchestratorV2;
1380
+ const successes = Metric.value(
1381
+ Metric.withAttributes(orchestrationCommandsTotal, {
1382
+ commandType: "thread.create",
1383
+ outcome: "success",
1384
+ }),
1385
+ );
1386
+ const durations = Metric.value(
1387
+ Metric.withAttributes(orchestrationCommandDuration, { commandType: "thread.create" }),
1388
+ );
1389
+ const successesBefore = (yield* successes).count;
1390
+ const durationsBefore = (yield* durations).count;
1391
+
1392
+ yield* orchestrator.dispatch({
1393
+ type: "thread.create",
1394
+ commandId: CommandId.make("create-dispatch-metrics"),
1395
+ threadId: ThreadId.make("thread:dispatch-metrics"),
1396
+ projectId: ProjectId.make("project:dispatch-metrics"),
1397
+ title: "Dispatch metrics",
1398
+ modelSelection,
1399
+ runtimeMode: "full-access",
1400
+ interactionMode: "default",
1401
+ branch: null,
1402
+ worktreePath: null,
1403
+ createdBy: "user",
1404
+ creationSource: "web",
1405
+ });
1406
+
1407
+ assert.strictEqual((yield* successes).count - successesBefore, 1);
1408
+ assert.strictEqual((yield* durations).count - durationsBefore, 1);
1409
+ }).pipe(Effect.provide(layerTest)),
1410
+);
apps/server/src/orchestration-v2/Orchestrator.ts
+2
-1
@@ -118,6 +118,7 @@ import {
118
type GuestShareCommand,
119
} from "./GuestShareDecider.ts";
120
import * as EffectOutbox from "./EffectOutbox.ts";
121
+import { withCommandMetrics } from "../observability/Metrics.ts";
122
import type { OrchestrationEffectRequestV2, PendingOrchestrationEffectV2 } from "./EffectOutbox.ts";
123
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
124
import * as ThreadCommandExecutor from "./ThreadCommandExecutor.ts";
@@ -12116,7 +12117,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
12117
storedEvents: committed.storedEvents,
12118
...(committed.committed ? {} : { replayed: true as const }),
12119
} satisfies OrchestratorV2DispatchResult;
12119
- });
12120
+ }, withCommandMetrics);
12121
12122
// dispatchWithReceiptEffect owns the dispatch span; this wrapper selects the thread locks.
12123
const dispatchWithReceipt = Effect.fnUntraced(function* (command: OrchestrationV2ServerCommand) {
apps/server/src/project/ProjectService.test.ts
+32
@@ -5,12 +5,17 @@ import * as Deferred from "effect/Deferred";
5
import * as Effect from "effect/Effect";
6
import * as Fiber from "effect/Fiber";
7
import * as Layer from "effect/Layer";
8
+import * as Metric from "effect/Metric";
9
import * as Option from "effect/Option";
10
import * as Ref from "effect/Ref";
11
import { TestClock } from "effect/testing";
12
import * as SqlClient from "effect/sql/SqlClient";
13
14
import * as ServerConfig from "../config.ts";
15
+import {
16
+ orchestrationCommandDuration,
17
+ orchestrationCommandsTotal,
18
+} from "../observability/Metrics.ts";
19
import * as EventSink from "../orchestration-v2/EventSink.ts";
20
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
21
import * as LegacyV1ThreadImporter from "../orchestration-v2/legacy/LegacyV1ThreadImporter.ts";
@@ -203,6 +208,33 @@ it.layer(layerTest)("ProjectService", (it) => {
208
}),
209
);
210
211
+ it.effect("records the outcome and duration of a committed project command", () =>
212
+ Effect.gen(function* () {
213
+ const service = yield* ProjectService.ProjectService;
214
+ const successes = Metric.value(
215
+ Metric.withAttributes(orchestrationCommandsTotal, {
216
+ commandType: "project.create",
217
+ outcome: "success",
218
+ }),
219
+ );
220
+ const durations = Metric.value(
221
+ Metric.withAttributes(orchestrationCommandDuration, { commandType: "project.create" }),
222
+ );
223
+ const successesBefore = (yield* successes).count;
224
+ const durationsBefore = (yield* durations).count;
225
+
226
+ yield* service.create({
227
+ commandId: CommandId.make("command:metrics:create"),
228
+ projectId: ProjectId.make("project:metrics"),
229
+ title: "Metrics",
230
+ workspaceRoot: "/work/metrics",
231
+ });
232
+
233
+ assert.strictEqual((yield* successes).count - successesBefore, 1);
234
+ assert.strictEqual((yield* durations).count - durationsBefore, 1);
235
+ }),
236
+ );
237
+
238
it.effect("auto-bootstraps a workspace exactly once", () =>
239
Effect.gen(function* () {
240
const service = yield* ProjectService.ProjectService;
apps/server/src/project/ProjectService.ts
+2
-1
@@ -17,6 +17,7 @@ import * as Option from "effect/Option";
17
import * as Result from "effect/Result";
18
import * as Schema from "effect/Schema";
19
20
+import { withCommandMetrics } from "../observability/Metrics.ts";
21
import * as EventSink from "../orchestration-v2/EventSink.ts";
22
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
23
import * as LegacyV1ThreadImporter from "../orchestration-v2/legacy/LegacyV1ThreadImporter.ts";
@@ -283,7 +284,7 @@ export const make = Effect.gen(function* () {
284
rejection ?? receipt.error ?? "The command was previously rejected.",
285
);
286
}
286
- });
287
+ }, withCommandMetrics);
288
289
const readCommitted = Effect.fn("ProjectService.readCommitted")(function* (projectId: ProjectId) {
290
const row = yield* readRow(projectId, { includeDeleted: true });
apps/server/src/provider/ClaudeCapabilitiesProbe.test.ts
+20
-1
@@ -1,8 +1,15 @@
1
// @effect-diagnostics nodeBuiltinImport:off - cleanup uses Node's retrying rm, which the FileSystem service does not expose.
2
+import * as NodeServices from "@effect/platform-node/NodeServices";
3
+import { ClaudeSettings, type ServerProvider } from "@t3tools/contracts";
4
import { vi } from "vite-plus/test";
5
import { assert, it } from "@effect/vitest";
6
+import * as Effect from "effect/Effect";
7
+import * as Schema from "effect/Schema";
8
5
-import { buildClaudeCapabilitiesProbeQueryOptions } from "./ClaudeProvider.ts";
9
+import {
10
+ buildClaudeCapabilitiesProbeQueryOptions,
11
+ probeClaudeWorkspaceSnapshot,
12
+} from "./ClaudeProvider.ts";
13
14
vi.mock("@anthropic-ai/claude-agent-sdk", { spy: true });
15
@@ -20,3 +27,15 @@ it("drops strict MCP mode, and only that, next to an administrator's managed-mcp
27
assert.deepEqual(options.mcpServers, {});
28
assert.equal(options.env?.ENABLE_CLAUDEAI_MCP_SERVERS, "false");
29
});
30
+
31
+it.effect("reports a deleted worktree's scan as finished, not pending", () =>
32
+ Effect.gen(function* () {
33
+ const snapshot = yield* probeClaudeWorkspaceSnapshot(
34
+ yield* Schema.decodeEffect(ClaudeSettings)({}),
35
+ { skills: [], slashCommands: [] } as unknown as ServerProvider,
36
+ "/nonexistent/t3-deleted-worktree",
37
+ { HOME: "/nonexistent/t3-home" },
38
+ );
39
+ assert.strictEqual(snapshot.slashCommandsPending, false);
40
+ }).pipe(Effect.provide(NodeServices.layer)),
41
+);
apps/server/src/provider/ClaudeProvider.ts
+9
-5
@@ -431,10 +431,14 @@ export const probeClaudeWorkspaceSnapshot = Effect.fn("probeClaudeWorkspaceSnaps
431
): Effect.fn.Return<ProviderWorkspaceSnapshot, never, FileSystem.FileSystem | Path.Path> {
432
if (!claudeSettings.enabled) return machineSnapshot;
433
const skills = yield* discoverClaudeSkills(claudeSettings, cwd, environment);
434
- const probeResult = yield* probeClaudeCapabilities(claudeSettings, environment, cwd, false).pipe(
435
- Effect.result,
436
- );
437
- const capabilities = Result.isSuccess(probeResult) ? probeResult.success : undefined;
434
+ const fileSystem = yield* FileSystem.FileSystem;
435
+ // A deleted worktree can never answer the probe. Pending would make clients rescan it forever.
436
+ const cwdExists = yield* fileSystem.exists(cwd).pipe(Effect.orElseSucceed(() => true));
437
+ const probeResult = cwdExists
438
+ ? yield* probeClaudeCapabilities(claudeSettings, environment, cwd, false).pipe(Effect.result)
439
+ : undefined;
440
+ const capabilities =
441
+ probeResult && Result.isSuccess(probeResult) ? probeResult.success : undefined;
442
return {
443
...machineSnapshot,
444
skills,
@@ -442,7 +446,7 @@ export const probeClaudeWorkspaceSnapshot = Effect.fn("probeClaudeWorkspaceSnaps
446
COMPACT_SLASH_COMMAND,
447
...(capabilities?.slashCommands ?? []),
448
]),
445
- slashCommandsPending: !capabilities,
449
+ slashCommandsPending: cwdExists && !capabilities,
450
};
451
});
452
apps/server/src/provider/GrokProvider.test.ts
+21
@@ -352,6 +352,27 @@ it.layer(NodeServices.layer)("checkGrokProviderStatus", (it) => {
352
}),
353
);
354
355
+ it.effect("warns instead of reporting ready when no models are discovered", () =>
356
+ Effect.gen(function* () {
357
+ const snapshot = yield* Effect.scoped(
358
+ Effect.gen(function* () {
359
+ const grokPath = yield* writeFakeGrokCli({
360
+ modelsOutput: "You are logged in with grok.com.\n",
361
+ acp: true,
362
+ });
363
+ return yield* checkGrokProviderStatus(
364
+ decodeGrokSettings({ enabled: true, binaryPath: grokPath }),
365
+ { ...process.env, XAI_API_KEY: "", T3_ACP_OMIT_INITIALIZE_MODEL_STATE: "1" },
366
+ );
367
+ }),
368
+ );
369
+
370
+ expect(snapshot.status).toBe("warning");
371
+ expect(snapshot.message).toContain("did not list any models");
372
+ expect(snapshot.models.map((model) => model.slug)).toEqual(["grok-build"]);
373
+ }),
374
+ );
375
+
376
it.effect("treats XAI_API_KEY as authenticated regardless of CLI login state", () =>
377
Effect.gen(function* () {
378
const snapshot = yield* Effect.scoped(
apps/server/src/provider/ProviderRegistry.test.ts
+130
@@ -693,6 +693,44 @@ it.layer(
693
);
694
});
695
696
+ it("drops Grok models a completed probe no longer advertises", () => {
697
+ const previousProvider = {
698
+ instanceId: ProviderInstanceId.make("grok"),
699
+ driver: ProviderDriverKind.make("grok"),
700
+ status: "ready",
701
+ enabled: true,
702
+ installed: true,
703
+ auth: { status: "authenticated" },
704
+ checkedAt: "2026-09-30T00:00:00.000Z",
705
+ version: "1.0.44",
706
+ models: [
707
+ { slug: "grok-4.7", name: "Grok 4.7", isCustom: false, capabilities: null },
708
+ { slug: "codexhub-removed", name: "Removed", isCustom: false, capabilities: null },
709
+ ],
710
+ slashCommands: [],
711
+ skills: [],
712
+ } as const satisfies ServerProvider;
713
+ const refreshedProvider = {
714
+ ...previousProvider,
715
+ checkedAt: "2026-09-30T00:01:00.000Z",
716
+ models: [previousProvider.models[0]],
717
+ } satisfies ServerProvider;
718
+ const acpFailedProvider = {
719
+ ...refreshedProvider,
720
+ status: "warning",
721
+ message: "Grok CLI is installed but ACP initialize failed.",
722
+ } satisfies ServerProvider;
723
+
724
+ assert.deepStrictEqual(
725
+ ProviderRegistry.mergeProviderSnapshot(previousProvider, refreshedProvider).models,
726
+ [previousProvider.models[0]],
727
+ );
728
+ assert.deepStrictEqual(
729
+ ProviderRegistry.mergeProviderSnapshot(previousProvider, acpFailedProvider).models,
730
+ [...previousProvider.models],
731
+ );
732
+ });
733
+
734
it("retains stale OpenCode models when a refresh fails", () => {
735
const previousProvider = {
736
instanceId: ProviderInstanceId.make("opencode"),
@@ -1246,6 +1284,98 @@ it.layer(
1284
);
1285
});
1286
1287
+ it.effect(
1288
+ "a second request for a cwd being scanned gets its result, even if the first leaves",
1289
+ () =>
1290
+ Effect.gen(function* () {
1291
+ const driver = ProviderDriverKind.make("codex");
1292
+ const instanceId = ProviderInstanceId.make("codex");
1293
+ const provider = {
1294
+ instanceId,
1295
+ driver,
1296
+ status: "ready",
1297
+ enabled: true,
1298
+ installed: true,
1299
+ auth: { status: "authenticated" },
1300
+ checkedAt: "2026-06-10T00:00:00.000Z",
1301
+ version: "1.0.0",
1302
+ models: [],
1303
+ slashCommands: [],
1304
+ skills: [],
1305
+ } as const satisfies ServerProvider;
1306
+ const scanStarted = yield* Deferred.make<void>();
1307
+ const releaseScan = yield* Deferred.make<void>();
1308
+ const scans = yield* Ref.make(0);
1309
+ const instance: ProviderInstance = {
1310
+ instanceId,
1311
+ driverKind: driver,
1312
+ continuationIdentity: { driverKind: driver, continuationKey: "codex:instance:codex" },
1313
+ displayName: undefined,
1314
+ enabled: true,
1315
+ snapshot: {
1316
+ resolveMaintenance: () =>
1317
+ Effect.succeed(
1318
+ makeManualOnlyProviderMaintenanceCapabilities({
1319
+ provider: driver,
1320
+ packageName: null,
1321
+ }),
1322
+ ),
1323
+ getSnapshot: Effect.succeed(provider),
1324
+ refresh: Effect.succeed(provider),
1325
+ streamChanges: Stream.empty,
1326
+ applyUsageLimits: () => Effect.void,
1327
+ },
1328
+ snapshotForCwd: () =>
1329
+ Ref.update(scans, (count) => count + 1).pipe(
1330
+ Effect.andThen(Deferred.succeed(scanStarted, undefined)),
1331
+ Effect.andThen(Deferred.await(releaseScan)),
1332
+ Effect.as(provider),
1333
+ ),
1334
+ orchestrationAdapter: {} as ProviderInstance["orchestrationAdapter"],
1335
+ textGeneration: {} as ProviderInstance["textGeneration"],
1336
+ };
1337
+ const layerInstanceRegistry = Layer.succeed(
1338
+ ProviderInstanceRegistry.ProviderInstanceRegistry,
1339
+ {
1340
+ getInstance: (requestedId) =>
1341
+ Effect.succeed(requestedId === instanceId ? instance : undefined),
1342
+ listInstances: Effect.succeed([instance]),
1343
+ listUnavailable: Effect.succeed([]),
1344
+ streamChanges: Stream.empty,
1345
+ subscribeChanges: Effect.flatMap(PubSub.unbounded<void>(), PubSub.subscribe),
1346
+ },
1347
+ );
1348
+ const scope = yield* Scope.make();
1349
+ yield* Effect.addFinalizer(() => Scope.close(scope, Exit.void));
1350
+ const runtimeServices = yield* Layer.build(
1351
+ ProviderRegistry.layer.pipe(
1352
+ Layer.provideMerge(layerInstanceRegistry),
1353
+ Layer.provideMerge(
1354
+ ServerConfig.layerTest(process.cwd(), {
1355
+ prefix: "t3-provider-registry-shared-workspace-scan-",
1356
+ }),
1357
+ ),
1358
+ Layer.provideMerge(NodeServices.layer),
1359
+ ),
1360
+ ).pipe(Scope.provide(scope));
1361
+
1362
+ yield* Effect.gen(function* () {
1363
+ const registry = yield* ProviderRegistry.ProviderRegistry;
1364
+ const refresh = registry.refreshWorkspaceSnapshot({ instanceId, cwd: "/workspace" });
1365
+ const first = yield* Effect.forkChild(refresh);
1366
+ yield* Deferred.await(scanStarted);
1367
+ const second = yield* Effect.forkChild(refresh, { startImmediately: true });
1368
+ yield* Fiber.interrupt(first);
1369
+ yield* Deferred.succeed(releaseScan, undefined);
1370
+ assert.deepStrictEqual(
1371
+ (yield* Fiber.join(second))[0]?.workspaceSnapshots?.map((snapshot) => snapshot.cwd),
1372
+ ["/workspace"],
1373
+ );
1374
+ assert.strictEqual(yield* Ref.get(scans), 1);
1375
+ }).pipe(Effect.provide(runtimeServices));
1376
+ }),
1377
+ );
1378
+
1379
it.effect("publishes workspace skills while machine health is in error", () =>
1380
Effect.gen(function* () {
1381
const driver = ProviderDriverKind.make("codex");
apps/server/src/provider/ProviderRegistry.ts
+35
-12
@@ -12,6 +12,7 @@ import * as DateTime from "effect/DateTime";
12
import * as Deferred from "effect/Deferred";
13
import * as Effect from "effect/Effect";
14
import * as Equal from "effect/Equal";
15
+import * as Fiber from "effect/Fiber";
16
import * as FileSystem from "effect/FileSystem";
17
import * as Layer from "effect/Layer";
18
import * as Option from "effect/Option";
@@ -167,6 +168,12 @@ const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean =>
168
);
169
}
170
171
+ if (provider.driver === ProviderDriverKind.make("grok")) {
172
+ // Grok reports ready only after it discovers a model list; the pending,
173
+ // ACP-failed, empty-inventory, and logged-out probes are warning/error.
174
+ return !(provider.installed && provider.status === "ready");
175
+ }
176
+
177
const isAntigravity = provider.driver === ProviderDriverKind.make("antigravity");
178
const isCodex = provider.driver === ProviderDriverKind.make("codex");
179
if (!isAntigravity && !isCodex && provider.driver !== ProviderDriverKind.make("opencode")) {
@@ -405,7 +412,7 @@ export const layer = Layer.effect(
412
cachedProviders.map((provider) => classifyCompatibility(provider, initialManifest)),
413
);
414
const workspaceRefreshesRef = yield* Ref.make<
408
- ReadonlyMap<ProviderInstance, ReadonlyMap<string, symbol>>
415
+ ReadonlyMap<ProviderInstance, ReadonlyMap<string, Deferred.Deferred<void>>>
416
>(new Map());
417
const maintenanceActionStatesRef = yield* Ref.make<
418
ReadonlyMap<ProviderInstanceId, { readonly update?: ServerProviderUpdateState | undefined }>
@@ -922,21 +929,13 @@ export const layer = Layer.effect(
929
const scannedAt = DateTime.formatIso(now);
930
const instance = yield* instanceRegistry.getInstance(input.instanceId);
931
if (!instance?.snapshotForCwd) return providers;
925
- const token = Symbol();
926
- const claimed = yield* Ref.modify(workspaceRefreshesRef, (refreshes) => {
927
- const current = refreshes.get(instance);
928
- if (!input.fresh && current?.has(input.cwd)) return [false, refreshes] as const;
929
- const next = new Map(refreshes);
930
- next.set(instance, new Map(current).set(input.cwd, token));
931
- return [true, next] as const;
932
- });
933
- if (!claimed) return yield* Ref.get(providersRef);
932
+ const token = yield* Deferred.make<void>();
933
const refreshMachineSnapshot = input.fresh
934
? (instance.invalidateCaches ?? Effect.void).pipe(
935
Effect.andThen(refreshInstance(input.instanceId)),
936
)
937
: Effect.void;
939
- return yield* refreshMachineSnapshot.pipe(
938
+ const runScan = refreshMachineSnapshot.pipe(
939
Effect.andThen(instance.snapshotForCwd(input.cwd)),
940
// Scans fail on error; returned inventory remains valid even when provider health reports an error.
941
Effect.flatMap((scopedSnapshot) =>
@@ -974,9 +973,33 @@ export const layer = Layer.effect(
973
if (nextCwds.size) next.set(instance, nextCwds);
974
else next.delete(instance);
975
return next;
977
- }),
976
+ }).pipe(Effect.andThen(Deferred.succeed(token, undefined))),
977
),
978
);
979
+ // The claim and the fork happen together, so the token is always completed. The scan is
980
+ // detached so a disconnecting owner cannot cancel the result its waiters depend on.
981
+ const claim = yield* Effect.uninterruptible(
982
+ Effect.gen(function* () {
983
+ const inFlight = yield* Ref.modify(workspaceRefreshesRef, (refreshes) => {
984
+ const current = refreshes.get(instance);
985
+ const running = current?.get(input.cwd);
986
+ if (!input.fresh && running) return [running, refreshes] as const;
987
+ const next = new Map(refreshes);
988
+ next.set(instance, new Map(current).set(input.cwd, token));
989
+ return [undefined, next] as const;
990
+ });
991
+ if (inFlight) return { inFlight } as const;
992
+ return {
993
+ // Starting now attaches the scan's `ensuring` before anything can close the scope.
994
+ scan: yield* Effect.forkIn(runScan, serviceScope, { startImmediately: true }),
995
+ } as const;
996
+ }),
997
+ );
998
+ // Wait for the running scan: on-demand clients get its result only in this reply.
999
+ if ("inFlight" in claim) {
1000
+ return yield* Deferred.await(claim.inFlight).pipe(Effect.andThen(Ref.get(providersRef)));
1001
+ }
1002
+ return yield* Fiber.join(claim.scan);
1003
});
1004
1005
return {
apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts
+1
-1
@@ -165,7 +165,7 @@ describe("terminatePosixOwnedProcessTree", () => {
165
AcpSessionRuntime.resolveLinuxCgroupTargetCommand("grok", scratch, { PATH: undefined }),
166
).toBeUndefined();
167
expect(
168
- AcpSessionRuntime.resolveLinuxCgroupTargetCommand("node", scratch, { PATH: undefined }),
168
+ AcpSessionRuntime.resolveLinuxCgroupTargetCommand("sh", scratch, { PATH: undefined }),
169
).toBeDefined();
170
expect(
171
AcpSessionRuntime.resolveLinuxCgroupTargetCommand("grok", scratch, {
apps/server/src/serverLogger.test.ts
+15
@@ -151,6 +151,21 @@ const printThroughConsole = (fields: object) =>
151
});
152
153
describe("ServerLoggerLive", () => {
154
+ it.effect("exports the operator's service instance id instead of a generated one", () =>
155
+ Effect.gen(function* () {
156
+ const { requests } = yield* logInSpanThrough({
157
+ otlpLogsUrl: "https://collector.example.com/v1/logs",
158
+ otelEnvironment: {
159
+ ...OtelEnvironment.none,
160
+ resourceAttributes: { "service.instance.id": "pod-7" },
161
+ },
162
+ });
163
+
164
+ const body = requests.map((request) => request.body).join("\n");
165
+ assert.include(body, '"key":"service.instance.id","value":{"stringValue":"pod-7"}');
166
+ }),
167
+ );
168
+
169
it.effect("exports a resource that names whether the desktop app launched the server", () =>
170
Effect.gen(function* () {
171
const { requests } = yield* logInSpanThrough({
apps/server/src/telemetry/AnalyticsService.ts
+1
-7
@@ -50,10 +50,6 @@ const RETRY_MAX_DELAY_MS = 300_000;
50
// These statuses reject the batch itself; unlike 408/429, retrying cannot help.
51
const REJECTED_BATCH_STATUSES = new Set([400, 401, 413]);
52
53
-// Official release workflows set this telemetry channel; other builds report dev.
54
-// Unlike __T3CODE_BUILD_CHANNEL__, this is not the sign-in page's latest/nightly channel.
55
-declare const __T3CODE_TELEMETRY_CHANNEL__: "stable" | "nightly" | "preview" | "dev" | undefined;
56
-
53
/** `random` is in [0, 1). */
54
function retryDelayMs(failures: number, random: number): number {
55
const ceiling = Math.min(RETRY_MAX_DELAY_MS, RETRY_BASE_DELAY_MS * 2 ** (failures - 1));
@@ -142,8 +138,6 @@ export const make = Effect.gen(function* () {
138
// The background flush and the shutdown flush must not send the same batch at once.
139
const flushLock = yield* Semaphore.make(1);
140
const clientType = serverConfig.mode === "desktop" ? "desktop-app" : "cli-web-client";
145
- const telemetryChannel =
146
- typeof __T3CODE_TELEMETRY_CHANNEL__ === "undefined" ? "dev" : __T3CODE_TELEMETRY_CHANNEL__;
141
const hostPlatform = yield* HostProcess.Platform;
142
const hostArchitecture = yield* HostProcess.Architecture;
143
@@ -198,7 +192,7 @@ export const make = Effect.gen(function* () {
192
wsl: Option.getOrUndefined(telemetryConfig.wslDistroName),
193
arch: hostArchitecture,
194
t3CodeVersion: packageJson.version,
201
- telemetryChannel,
195
+ telemetryChannel: ServerConfig.telemetryChannel,
196
clientType,
197
serverOs: serverOsFromNodePlatform(hostPlatform),
198
serverArch: hostArchitecture,
apps/server/src/testUtils/managedServiceEnv.setup.ts
new
+6
@@ -0,0 +1,6 @@
1
+import { SERVICE_LAUNCHER_CONTEXT_ENV } from "../cloud/serviceProtocol.ts";
2
+
3
+// Agents inside a managed T3 service inherit its home and launcher context; CI has neither.
4
+for (const name of ["T3CODE_HOME", "T3_BOOT_SERVICE_UNIT", SERVICE_LAUNCHER_CONTEXT_ENV]) {
5
+ delete process.env[name];
6
+}
apps/server/src/ws.test.ts
+161
@@ -5,13 +5,17 @@ import {
5
EnvironmentId,
6
ProjectId,
7
ThreadId,
8
+ ProviderDriverKind,
9
+ ProviderInstanceId,
10
WS_METHODS,
11
+ WsServerRefreshProvidersRpc,
12
WsSubscribeServerConfigRpc,
13
type OrchestrationV2StoredEvent,
14
type OrchestrationV2ThreadShell,
15
type OrchestrationProjectShell,
16
type ServerConfig,
17
type ServerConfigStreamEvent,
18
+ type ServerProvider,
19
} from "@t3tools/contracts";
20
import * as Deferred from "effect/Deferred";
21
import * as DateTime from "effect/DateTime";
@@ -20,6 +24,7 @@ import * as Layer from "effect/Layer";
24
import * as PubSub from "effect/PubSub";
25
import * as Queue from "effect/Queue";
26
import * as Stream from "effect/Stream";
27
+import * as TestClock from "effect/testing/TestClock";
28
import { Headers } from "effect/http";
29
import { RpcGroup, RpcMessage, RpcServer } from "effect/rpc";
30
import * as SqlClient from "effect/sql/SqlClient";
@@ -632,6 +637,162 @@ it.effect(
637
),
638
);
639
640
+it.effect("on-demand clients get provider config without workspace snapshots", () =>
641
+ Effect.gen(function* () {
642
+ const instanceId = ProviderInstanceId.make("claudeAgent");
643
+ const snapshotFor = (cwd: string, checkedAt: string) => ({
644
+ cwd,
645
+ checkedAt,
646
+ slashCommands: [{ name: `${cwd.slice(1)}-command` }],
647
+ skills: [],
648
+ });
649
+ const provider: ServerProvider = {
650
+ instanceId,
651
+ driver: ProviderDriverKind.make("claudeAgent"),
652
+ enabled: true,
653
+ installed: true,
654
+ version: "1.0.0",
655
+ status: "ready",
656
+ auth: { status: "authenticated" },
657
+ checkedAt: "2026-10-25T00:00:00.000Z",
658
+ models: [],
659
+ slashCommands: [{ name: "machine-command" }],
660
+ skills: [],
661
+ workspaceSnapshots: [
662
+ snapshotFor("/a", "2026-10-25T00:00:00.000Z"),
663
+ snapshotFor("/b", "2026-10-25T00:00:00.000Z"),
664
+ ],
665
+ };
666
+ const providerChanges = yield* Queue.unbounded<ReadonlyArray<ServerProvider>>();
667
+ const pulled = yield* Queue.unbounded<void>();
668
+ const responses = yield* Queue.unbounded<unknown>();
669
+ const configRpcServices = Layer.mergeAll(
670
+ layerUnusedConfigRpcServices,
671
+ Layer.mock(ExternalLauncher.ExternalLauncher)({
672
+ resolveAvailableEditors: () => Effect.succeed([]),
673
+ resolveFileManagerRevealKind: () => Effect.succeed(undefined),
674
+ }),
675
+ Layer.mock(ProviderRegistry.ProviderRegistry)({
676
+ getProviders: Effect.succeed([provider]),
677
+ streamChanges: Stream.fromQueue(providerChanges).pipe(
678
+ Stream.tap(() => Queue.offer(pulled, undefined)),
679
+ ),
680
+ refreshWorkspaceSnapshot: () => Effect.succeed([provider]),
681
+ }),
682
+ Layer.mock(UsageLimitSources.UsageLimitSources)({
683
+ current: Effect.succeed([]),
684
+ streamChanges: Stream.make([]),
685
+ }),
686
+ Layer.mock(RemoteOpenTargets.RemoteOpenTargets)({
687
+ resolveTargets: () => Effect.succeed([]),
688
+ }),
689
+ Layer.mock(DirectEndpoints.DirectEndpoints)({ resolve: () => Effect.succeed([]) }),
690
+ Layer.mock(ManagedProjectFolders.ManagedProjectFolders)({
691
+ scratchRoot: Effect.succeedNone,
692
+ namedProjectsRoot: process.cwd(),
693
+ }),
694
+ Layer.mock(ServerEnvironment.ServerEnvironment)({
695
+ getDescriptor: Effect.succeed({
696
+ environmentId: EnvironmentId.make("config-test"),
697
+ label: "Config test",
698
+ platform: { os: "linux", arch: "x64" },
699
+ serverVersion: "0.0.0",
700
+ capabilities: { repositoryIdentity: false },
701
+ }),
702
+ }),
703
+ Layer.mock(EnvironmentAuth.EnvironmentAuth)({
704
+ getDescriptor: () =>
705
+ Effect.succeed({
706
+ policy: "loopback-browser",
707
+ bootstrapMethods: [],
708
+ sessionMethods: ["browser-session-cookie"],
709
+ sessionCookieName: "config-test-session",
710
+ }),
711
+ }),
712
+ );
713
+ const server = yield* RpcServer.makeNoSerialization(
714
+ RpcGroup.make(WsSubscribeServerConfigRpc, WsServerRefreshProvidersRpc),
715
+ {
716
+ ...WS_RPC_SERVER_OPTIONS,
717
+ onFromServer: (response) =>
718
+ response._tag === "Chunk"
719
+ ? Effect.forEach(response.values, (value) => Queue.offer(responses, value), {
720
+ discard: true,
721
+ })
722
+ : response._tag === "Exit" && response.exit._tag === "Success"
723
+ ? Queue.offer(responses, response.exit.value)
724
+ : Effect.void,
725
+ },
726
+ ).pipe(
727
+ Effect.provide(
728
+ layerWsRpc(
729
+ {
730
+ sessionId: AuthSessionId.make("config-test"),
731
+ subject: "config-test",
732
+ method: "browser-session-cookie",
733
+ scopes: [],
734
+ },
735
+ {},
736
+ {},
737
+ yield* PreviewAutomationBroker.PreviewAutomationBroker,
738
+ yield* ServerBrowser.ServerBrowser,
739
+ ).pipe(Layer.provide(configRpcServices)),
740
+ ),
741
+ );
742
+ const configRequest = RpcMessage.RequestId("config");
743
+ yield* server.write(0, {
744
+ _tag: "Request",
745
+ id: configRequest,
746
+ tag: WS_METHODS.subscribeServerConfig,
747
+ payload: { workspaceSnapshotsOnDemand: true },
748
+ headers: Headers.empty,
749
+ });
750
+ const snapshot = (yield* Queue.take(responses)) as ServerConfigStreamEvent;
751
+ if (snapshot.type !== "snapshot") return yield* Effect.die("Missing initial snapshot");
752
+ assert.isUndefined(snapshot.config.providers[0]?.workspaceSnapshots);
753
+ yield* server.write(0, { _tag: "Ack", requestId: configRequest });
754
+
755
+ // A rescan that only touches a snapshot sends nothing; the next real change does.
756
+ yield* Queue.offer(providerChanges, [
757
+ { ...provider, workspaceSnapshots: [snapshotFor("/a", "2026-10-25T00:05:00.000Z")] },
758
+ ]);
759
+ yield* Queue.take(pulled);
760
+ yield* TestClock.adjust("1 second");
761
+ yield* Queue.offer(providerChanges, [{ ...provider, status: "warning" }]);
762
+ yield* Queue.take(pulled);
763
+ yield* TestClock.adjust("1 second");
764
+ const update = (yield* Queue.take(responses)) as ServerConfigStreamEvent;
765
+ if (update.type !== "providerStatuses") return yield* Effect.die("Expected provider update");
766
+ assert.equal(update.payload.providers[0]?.status, "warning");
767
+ assert.isUndefined(update.payload.providers[0]?.workspaceSnapshots);
768
+
769
+ yield* server.write(0, {
770
+ _tag: "Request",
771
+ id: RpcMessage.RequestId("refresh"),
772
+ tag: WS_METHODS.serverRefreshProviders,
773
+ payload: { instanceId, cwd: "/b", workspaceSnapshotsOnDemand: true },
774
+ headers: Headers.empty,
775
+ });
776
+ const refreshed = (yield* Queue.take(responses)) as {
777
+ readonly providers: ReadonlyArray<ServerProvider>;
778
+ };
779
+ assert.deepEqual(
780
+ refreshed.providers.map((entry) => [entry.workspaceSnapshots, entry.slashCommands]),
781
+ [[[snapshotFor("/b", "2026-10-25T00:00:00.000Z")], []]],
782
+ );
783
+ yield* server.write(0, { _tag: "Interrupt", requestId: configRequest, interruptors: [] });
784
+ }).pipe(
785
+ Effect.provide(
786
+ Layer.mergeAll(
787
+ Layer.fresh(layerConfigSources),
788
+ Layer.mock(PreviewAutomationBroker.PreviewAutomationBroker)({}),
789
+ Layer.mock(ServerBrowser.ServerBrowser)({}),
790
+ ),
791
+ ),
792
+ Effect.scoped,
793
+ ),
794
+);
795
+
796
// Compaction keeps the oldest and newest event per message, so a cursor older
797
// than the deleted rows still replays each message where the client would
798
// first have seen it (reducers append on first sight) and reaches the same
apps/server/src/ws.ts
+49
-6
@@ -82,6 +82,7 @@ import {
82
type ServerConfig as ClientServerConfig,
83
type ServerConfigStreamEvent,
84
type ServerLifecycleStreamEvent,
85
+ type ServerProvider,
86
type FilesystemBrowseFailure,
87
FilesystemBrowseError,
88
AssetWorkspaceContextNotFoundError,
@@ -363,6 +364,10 @@ export const withLateEditorConfig = <E, R>(
364
);
365
};
366
367
+function withoutWorkspaceSnapshots(providers: ReadonlyArray<ServerProvider>): ServerProvider[] {
368
+ return providers.map(({ workspaceSnapshots: _workspaceSnapshots, ...provider }) => provider);
369
+}
370
+
371
function unexpectedCompatibilityError(error: never): never {
372
throw new Error(`Unhandled compatibility error: ${String(error)}`);
373
}
@@ -1721,12 +1726,16 @@ export const layerWsRpc = (
1726
1727
const loadServerConfig = Effect.fn("ws.loadServerConfig")(function* (options: {
1728
readonly usageLimitsCommand: boolean;
1729
+ readonly workspaceSnapshotsOnDemand: boolean;
1730
}) {
1731
const keybindingsConfig = yield* keybindings.loadConfigState;
1732
const currentProviders = yield* providerRegistry.getProviders;
1727
- const providers = options.usageLimitsCommand
1733
+ const commandProviders = options.usageLimitsCommand
1734
? withUsageLimitsCommands(currentProviders, yield* usageLimitSources.current)
1735
: currentProviders;
1736
+ const providers = options.workspaceSnapshotsOnDemand
1737
+ ? withoutWorkspaceSnapshots(commandProviders)
1738
+ : commandProviders;
1739
const settings = ServerSettings.redactServerSettingsForClient(
1740
yield* serverSettings.getSettings,
1741
);
@@ -2207,7 +2216,8 @@ export const layerWsRpc = (
2216
Effect.andThen(scheduledTasks.getWebhookDelivery(input)),
2217
),
2218
[WS_METHODS.serverProbe]: (_input) => Effect.succeed({}),
2210
- [WS_METHODS.serverGetConfig]: (_input) => loadServerConfig({ usageLimitsCommand: false }),
2219
+ [WS_METHODS.serverGetConfig]: (_input) =>
2220
+ loadServerConfig({ usageLimitsCommand: false, workspaceSnapshotsOnDemand: false }),
2221
[WS_METHODS.serverSearchAcpRegistry]: (input) =>
2222
acpRegistryCatalog
2223
.search(input)
@@ -2376,7 +2386,29 @@ export const layerWsRpc = (
2386
providers = yield* providerRegistry.refreshInstance(instance.instanceId);
2387
}
2388
}
2379
- return { providers };
2389
+ if (input.workspaceSnapshotsOnDemand !== true) return { providers };
2390
+ const commandProviders =
2391
+ input.usageLimitsCommand === true
2392
+ ? withUsageLimitsCommands(providers, yield* usageLimitSources.current)
2393
+ : providers;
2394
+ const { instanceId, cwd } = input;
2395
+ if (instanceId === undefined || cwd === undefined) {
2396
+ return { providers: withoutWorkspaceSnapshots(commandProviders) };
2397
+ }
2398
+ return {
2399
+ providers: commandProviders
2400
+ .filter((provider) => provider.instanceId === instanceId)
2401
+ .map((provider) => ({
2402
+ ...provider,
2403
+ // Callers read only the cwd snapshot; the config stream carries the rest.
2404
+ models: [],
2405
+ slashCommands: [],
2406
+ skills: [],
2407
+ workspaceSnapshots: (provider.workspaceSnapshots ?? []).filter(
2408
+ (snapshot) => snapshot.cwd === cwd,
2409
+ ),
2410
+ })),
2411
+ };
2412
}),
2413
[WS_METHODS.mcpAppsCallTool]: (input) => mcpAppRequests.callTool(input),
2414
[WS_METHODS.mcpAppsToolInfo]: (input) => mcpAppRequests.toolInfo(input),
@@ -3093,10 +3125,14 @@ export const layerWsRpc = (
3125
Stream.unwrap(
3126
Effect.gen(function* () {
3127
const usageLimitsCommand = input.usageLimitsCommand === true;
3128
+ const workspaceSnapshotsOnDemand = input.workspaceSnapshotsOnDemand === true;
3129
// Buffer changes through discovery and the initial snapshot's RPC ACK wait.
3130
const keybindingsChanges = yield* keybindings.subscribeChanges;
3131
const settingsChanges = yield* serverSettings.subscribeChanges;
3099
- const config = yield* loadServerConfig({ usageLimitsCommand });
3132
+ const config = yield* loadServerConfig({
3133
+ usageLimitsCommand,
3134
+ workspaceSnapshotsOnDemand,
3135
+ });
3136
const keybindingsUpdates = keybindingsChanges.pipe(
3137
Stream.map((event) => ({
3138
version: 1 as const,
@@ -3118,8 +3154,15 @@ export const layerWsRpc = (
3154
usageLimitsCommand ? sameUsageLimitCommandCoverage : () => true,
3155
),
3156
),
3121
- (providers, sources) =>
3122
- usageLimitsCommand ? withUsageLimitsCommands(providers, sources) : providers,
3157
+ (providers, sources) => {
3158
+ const commandProviders = usageLimitsCommand
3159
+ ? withUsageLimitsCommands(providers, sources)
3160
+ : providers;
3161
+ // Stripped before the de-dupe below, so snapshot-only changes send nothing.
3162
+ return workspaceSnapshotsOnDemand
3163
+ ? withoutWorkspaceSnapshots(commandProviders)
3164
+ : commandProviders;
3165
+ },
3166
).pipe(
3167
// Compare initial paired values with the snapshot; blindly dropping them loses changes between snapshot and subscription.
3168
(updates) => Stream.concat(rpcInitialItems([config.providers]), updates),
apps/server/vite.config.ts
+4
-1
@@ -128,7 +128,10 @@ export default mergeConfig(
128
// Parallel sqlite/git/worktree/orchestration tests introduce load-sensitive flakes.
129
fileParallelism: false,
130
sequence: { sequencer: WeightedShardSequencer },
131
- setupFiles: ["./src/testUtils/gitConfig.setup.ts"],
131
+ setupFiles: [
132
+ "./src/testUtils/gitConfig.setup.ts",
133
+ "./src/testUtils/managedServiceEnv.setup.ts",
134
+ ],
135
hookTimeout: 120_000,
136
testTimeout: 120_000,
137
},
apps/web/src/components/chat/ChatMarkdownMedia.tsx
+2
@@ -207,6 +207,7 @@ export function ChatMarkdownImage(props: {
207
alt={props.alt}
208
data-markdown-copy={props.copyMarkdown}
209
decoding="async"
210
+ loading="lazy"
211
draggable={false}
212
className={cn(
213
CHAT_MARKDOWN_IMAGE_SIZE_CLASS_NAME,
@@ -263,6 +264,7 @@ export function ChatMarkdownImage(props: {
264
src={src}
265
alt={props.alt}
266
decoding="async"
267
+ loading="lazy"
268
draggable={false}
269
className="invisible absolute inset-0 size-full"
270
{...imageEvents(src)}
apps/web/src/components/chat/TimelineUserMessageRow.tsx
+1
@@ -508,6 +508,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
508
src={image.previewUrl}
509
alt={image.name}
510
decoding="async"
511
+ loading="lazy"
512
className="block size-full object-cover"
513
/>
514
</button>
apps/web/src/components/chat/useProviderWorkspaceSnapshotRefresh.ts
+9
@@ -14,6 +14,8 @@ import { useEffect, useEffectEvent, useRef, useState } from "react";
14
import { useStableCallback } from "../../hooks/useStableCallback";
15
16
const WORKSPACE_SNAPSHOT_RETRY_COOLDOWN_MS = 10_000;
17
+// A cwd that never scans, such as a deleted worktree, would otherwise retry forever.
18
+const WORKSPACE_SNAPSHOT_MAX_ATTEMPTS = 3;
19
20
/**
21
* Keeps the selected provider's workspace snapshot fresh for the composer's
@@ -32,6 +34,7 @@ export function useProviderWorkspaceSnapshotRefresh(input: {
34
// The last scan this composer asked for. A request inside the TTL is not
35
// repeated, so a client clock ahead of the server's cannot loop rescans.
36
const workspaceRefreshKeyRef = useRef<{ key: string; requestedAt: number } | null>(null);
37
+ const failedRefreshesRef = useRef<{ key: string; count: number } | null>(null);
38
const [workspaceRefreshRetry, setWorkspaceRefreshRetry] = useState<{
39
key: string;
40
notBefore: number;
@@ -96,6 +99,11 @@ export function useProviderWorkspaceSnapshotRefresh(input: {
99
workspaceRefreshKeyRef.current = request;
100
const retryLater = () => {
101
if (workspaceRefreshKeyRef.current !== request) return;
102
+ const failed = failedRefreshesRef.current;
103
+ const count = failed?.key === key ? failed.count + 1 : 1;
104
+ failedRefreshesRef.current = { key, count };
105
+ // Keeping the request marker lets the TTL hold off the next scan.
106
+ if (count >= WORKSPACE_SNAPSHOT_MAX_ATTEMPTS) return;
107
workspaceRefreshKeyRef.current = null;
108
setWorkspaceRefreshRetry({
109
key,
@@ -115,6 +123,7 @@ export function useProviderWorkspaceSnapshotRefresh(input: {
123
gitCwd,
124
);
125
if (!refreshedSnapshot) retryLater();
126
+ else failedRefreshesRef.current = null;
127
}, retryLater);
128
};
129
const refreshWorkspaceSnapshotOnChange = useEffectEvent(refreshWorkspaceSnapshotIfStale);
apps/web/src/lib/runtime.ts
+1
@@ -22,6 +22,7 @@ const layerRelayTracing = RelayTracing.layer(resolveRelayTracingConfig(), {
22
serviceName: "t3code-web",
23
serviceVersion: import.meta.env.APP_VERSION,
24
runtime: "browser",
25
+ serviceInstanceId: ClientTracer.serviceInstanceId,
26
client: typeof window !== "undefined" && window.desktopBridge ? "desktop" : "web",
27
}).pipe(Layer.provide(layerHttpClient));
28
apps/web/src/observability/clientTracer.ts
+5
@@ -1,6 +1,11 @@
1
import * as Layer from "effect/Layer";
2
import * as Tracer from "effect/Tracer";
3
4
+import { randomUUID } from "../lib/utils";
5
+
6
+/** `service.instance.id` for this page load, shared by every resource the UI exports. */
7
+export const serviceInstanceId = randomUUID();
8
+
9
let delegate: Tracer.Tracer | null = null;
10
11
export function setDelegate(next: Tracer.Tracer | null): void {
apps/web/src/observability/clientTracing.ts
+10
-1
@@ -8,17 +8,26 @@ import { OtlpExporter, OtlpSerialization, OtlpTracer } from "effect/observabilit
8
import { settleAsyncResult, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
9
import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
10
import { resolvePrimaryEnvironmentHttpUrl } from "../environments/primary";
11
+import { releaseChannelOf, releaseResourceAttributes } from "@t3tools/shared/releaseResource";
12
import * as ClientTracer from "./clientTracer";
13
import * as PrimaryEnvironmentHttpLayer from "../environments/primary/httpLayer";
14
import { isElectron } from "../env";
15
import { APP_VERSION } from "~/branding";
16
17
const DEFAULT_EXPORT_INTERVAL_MS = 1_000;
18
+// PR previews can't mark themselves in APP_VERSION without breaking the version-skew check against the server.
19
+const RELEASE_CHANNEL =
20
+ import.meta.env.DEV || import.meta.env.VITE_RELEASE_CHANNEL === "dev"
21
+ ? "dev"
22
+ : import.meta.env.VITE_RELEASE_CHANNEL === "preview"
23
+ ? "preview"
24
+ : releaseChannelOf(APP_VERSION);
25
const CLIENT_TRACING_RESOURCE = {
26
serviceName: "t3code-web",
27
attributes: {
28
"service.namespace": "t3code",
21
- "deployment.environment.name": import.meta.env.DEV ? "development" : "production",
29
+ "service.instance.id": ClientTracer.serviceInstanceId,
30
+ ...releaseResourceAttributes(RELEASE_CHANNEL),
31
"service.runtime": "t3-web",
32
"t3code.client.surface": isElectron ? "desktop" : "web",
33
"service.version": APP_VERSION,
apps/web/src/vite-env.d.ts
+1
@@ -7,6 +7,7 @@ interface ImportMetaEnv {
7
readonly VITE_WS_URL: string;
8
readonly VITE_HOSTED_APP_URL: string;
9
readonly VITE_HOSTED_APP_CHANNEL: string;
10
+ readonly VITE_RELEASE_CHANNEL: string;
11
readonly VITE_CLERK_PUBLISHABLE_KEY: string;
12
readonly VITE_CLERK_JWT_TEMPLATE: string;
13
readonly VITE_CLERK_CLI_OAUTH_CLIENT_ID: string;
apps/web/vite.config.ts
+3
@@ -39,6 +39,8 @@ const configuredRelayTracingUrl = repoEnv.VITE_RELAY_OTLP_TRACES_URL?.trim() ||
39
const configuredRelayTracingDataset = repoEnv.VITE_RELAY_OTLP_TRACES_DATASET?.trim() || "";
40
const configuredRelayTracingToken = repoEnv.VITE_RELAY_OTLP_TRACES_TOKEN?.trim() || "";
41
const configuredHostedAppChannel = process.env.VITE_HOSTED_APP_CHANNEL?.trim() || "";
42
+const configuredReleaseChannel =
43
+ process.env.T3CODE_BUILT_DEV === "1" ? "dev" : process.env.VITE_RELEASE_CHANNEL?.trim() || "";
44
const configuredAppVersion = process.env.APP_VERSION?.trim() || pkg.version;
45
const configuredDesktopUpdateRepository =
46
process.env.T3CODE_DESKTOP_UPDATE_REPOSITORY?.trim() ||
@@ -237,6 +239,7 @@ export default defineConfig(() => {
239
"import.meta.env.T3CODE_DESKTOP_UPDATE_REPOSITORY": JSON.stringify(
240
configuredDesktopUpdateRepository,
241
),
242
+ "import.meta.env.VITE_RELEASE_CHANNEL": JSON.stringify(configuredReleaseChannel),
243
"import.meta.env.APP_VERSION": JSON.stringify(configuredAppVersion),
244
},
245
resolve: {
docs/operations/observability.md
+17
-3
@@ -393,12 +393,14 @@ Traces are best for one request. Metrics are best for trends.
393
Good metric families to watch:
394
395
- `t3_rpc_request_duration`
396
+- `t3_orchestration_command_duration`
397
- `t3_provider_turn_duration` (how long the provider adapter takes to start a turn, not the turn's run time)
398
- `t3_git_command_duration`
399
400
Counters tell you volume and failure rate:
401
402
- `t3_rpc_requests_total`
403
+- `t3_orchestration_commands_total`
404
- `t3_provider_turns_total`
405
- `t3_git_commands_total`
406
@@ -625,15 +627,27 @@ with a startup warning, rather than sending it to the Settings endpoint.
627
Service names are fixed: `t3code-server` for the backend and `t3code-desktop` for the desktop main
628
process, both in `service.namespace` `t3code`. `OTEL_SERVICE_NAME` and a `service.name` or
629
`service.namespace` in `OTEL_RESOURCE_ATTRIBUTES` are ignored. Tell installations apart with other
628
-resource attributes, such as `OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=development`.
629
-The UI reports `deployment.environment.name` from its build: `development` under the Vite dev server
630
-and `production` otherwise.
630
+resource attributes, such as `OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=staging`.
631
+
632
+Each process reports its own build, not the one it talks to: the server, the desktop main process,
633
+the UI, and the mobile app each carry `t3code.release.channel` (`dev`, `stable`, `nightly`, or
634
+`preview`, from their own version; desktop PR builds count as `preview`, and a server not built by a
635
+release workflow reports `dev`) and `deployment.environment.name` (`development`, `production`, or
636
+`staging` for `preview`). On the server and the desktop main process either key in
637
+`OTEL_RESOURCE_ATTRIBUTES` wins. The UI and mobile app never read that variable: Vercel PR previews
638
+set `VITE_RELEASE_CHANNEL=preview` because their `APP_VERSION` must stay comparable with the
639
+server's, and the mobile app maps its build variant (`development`, `preview`, `production`), or
640
+reports `dev` from a development bundle.
641
642
Attributes specific to T3 Code use the `t3code.` prefix. The UI runs as `t3code-web` in both a
643
browser and the desktop window, since it is the same code, and `t3code.client.surface` is `desktop`
644
or `web`. The server's `t3code.server.managed_by` is `desktop` when the desktop app launched it and
645
`standalone` otherwise.
646
647
+Every resource also carries a `service.instance.id`: random per process for the server and desktop,
648
+per page load for the UI, and the Expo session on mobile. A `service.instance.id` in
649
+`OTEL_RESOURCE_ATTRIBUTES` replaces the generated one on the server and desktop.
650
+
651
If the OTLP URLs are unset, local tracing still works, metrics stay in-process only, and logs stay
652
on stdout only.
653
oxlint-plugin-t3code/index.ts
+2
@@ -15,6 +15,7 @@ import noMobileUniwindThemeEscapeHatches from "./rules/no-mobile-uniwind-theme-e
15
import noAmbiguousDetailNavigation from "./rules/no-ambiguous-detail-navigation.ts";
16
import noMobilePullRequestGlyphLiterals from "./rules/no-mobile-pull-request-glyph-literals.ts";
17
import noNativeTitleTooltip from "./rules/no-native-title-tooltip.ts";
18
+import reactEffectBudget from "./rules/react-effect-budget.ts";
19
import requireRegisteredListScroll from "./rules/require-registered-list-scroll.ts";
20
import noOutsetStateIndicators from "./rules/no-outset-state-indicators.ts";
21
import noPollingLoopInTests from "./rules/no-polling-loop-in-tests.ts";
@@ -52,6 +53,7 @@ export default definePlugin({
53
"no-ambiguous-detail-navigation": noAmbiguousDetailNavigation,
54
"no-mobile-pull-request-glyph-literals": noMobilePullRequestGlyphLiterals,
55
"no-native-title-tooltip": noNativeTitleTooltip,
56
+ "react-effect-budget": reactEffectBudget,
57
"require-registered-list-scroll": requireRegisteredListScroll,
58
"no-outset-state-indicators": noOutsetStateIndicators,
59
"no-polling-loop-in-tests": noPollingLoopInTests,
oxlint-plugin-t3code/rules/react-effect-budget.test.ts
new
+50
@@ -0,0 +1,50 @@
1
+import { assert, describe } from "@effect/vitest";
2
+
3
+import budget from "../../scripts/effect-budget.json" with { type: "json" };
4
+import { createOxlintRuleHarness } from "../test/utils.ts";
5
+
6
+const [budgetedFile, allowed] = Object.entries(budget)[0]!;
7
+
8
+const component = (effects: number) => `import React, { useEffect } from "react";
9
+export function Panel() {
10
+${Array.from({ length: effects }, (_, index) => (index % 2 === 0 ? " useEffect(() => {}, []);" : " React.useLayoutEffect(() => {});")).join("\n")}
11
+ return null;
12
+}
13
+`;
14
+
15
+const reports = (output: string) => output.match(/t3code\(react-effect-budget\)/g)?.length ?? 0;
16
+const lint = (filename: string) =>
17
+ createOxlintRuleHarness("t3code/react-effect-budget", { filename });
18
+
19
+const budgeted = lint(budgetedFile);
20
+const unbudgeted = lint("apps/web/src/NotInTheBudget.tsx");
21
+
22
+describe("t3code/react-effect-budget", () => {
23
+ budgeted.valid("passes a file at its budget", component(allowed));
24
+
25
+ budgeted.invalid("reports only the calls past the budget", component(allowed + 2), (output) => {
26
+ assert.strictEqual(reports(output), 2);
27
+ assert.include(output, `has ${allowed + 2} React effects against a budget of ${allowed}`);
28
+ });
29
+
30
+ unbudgeted.invalid(
31
+ "gives a file without an entry a budget of 0, counting member calls",
32
+ `export function New() { React.useEffect(() => {}); return null; }`,
33
+ (output) => {
34
+ assert.strictEqual(reports(output), 1);
35
+ assert.include(output, "has 1 React effect against a budget of 0");
36
+ },
37
+ );
38
+
39
+ unbudgeted.valid(
40
+ "ignores comments, strings and lookalike names",
41
+ `// useEffect(() => {}) in a comment
42
+/* React.useLayoutEffect(() => {}) */
43
+const label = "useEffect(() => {})";
44
+const pipeline = Effect.matchCauseEffect(effect, {});
45
+const alias = useEffect;
46
+`,
47
+ );
48
+
49
+ lint("apps/web/src/Panel.test.tsx").valid("skips test files", component(3));
50
+});
oxlint-plugin-t3code/rules/react-effect-budget.ts
new
+58
@@ -0,0 +1,58 @@
1
+import { defineRule, type ESTree } from "@oxlint/plugins";
2
+import * as Option from "effect/Option";
3
+
4
+import budget from "../../scripts/effect-budget.json" with { type: "json" };
5
+import { getPropertyName, unwrapExpression } from "../utils.ts";
6
+
7
+const BUDGET_FILE = "scripts/effect-budget.json";
8
+const EFFECT_HOOKS = new Set(["useEffect", "useLayoutEffect", "useInsertionEffect"]);
9
+const EFFECT_HOOK_TEXT = /use(?:Layout|Insertion)?Effect/;
10
+const UNBUDGETED_FILE = /\.test\.[cm]?[jt]sx?$|[\\/](?:test|__tests__)[\\/]/;
11
+const budgets: Readonly<Record<string, number>> = budget;
12
+
13
+const isEffectHookCall = (node: ESTree.CallExpression): boolean => {
14
+ const callee = unwrapExpression(node.callee);
15
+ if (Option.isNone(callee)) return false;
16
+ const expression = callee.value;
17
+ if (expression.type === "Identifier") return EFFECT_HOOKS.has(expression.name);
18
+ if (expression.type === "MemberExpression" && !expression.computed) {
19
+ return Option.exists(getPropertyName(expression.property), (name) => EFFECT_HOOKS.has(name));
20
+ }
21
+ return false;
22
+};
23
+
24
+// Budget keys are repo-relative; matching on the path's end also works for files linted elsewhere.
25
+const budgetFor = (filename: string): number => {
26
+ const normalized = filename.replaceAll("\\", "/");
27
+ const key = Object.keys(budgets).find((file) => normalized.endsWith(`/${file}`));
28
+ return key === undefined ? 0 : budgets[key]!;
29
+};
30
+
31
+export default defineRule({
32
+ meta: {
33
+ type: "suggestion",
34
+ docs: {
35
+ description: `Hold each file to the React effect hooks it is allowed in ${BUDGET_FILE}; a missing entry allows none.`,
36
+ },
37
+ },
38
+ create(context) {
39
+ if (UNBUDGETED_FILE.test(context.filename) || !EFFECT_HOOK_TEXT.test(context.sourceCode.text)) {
40
+ return {};
41
+ }
42
+ const calls: Array<ESTree.CallExpression> = [];
43
+ return {
44
+ CallExpression(node) {
45
+ if (isEffectHookCall(node)) calls.push(node);
46
+ },
47
+ "Program:exit"() {
48
+ const allowed = budgetFor(context.filename);
49
+ if (calls.length <= allowed) return;
50
+ const message =
51
+ `This file has ${calls.length} React ${calls.length === 1 ? "effect" : "effects"} against a budget of ${allowed}. ` +
52
+ "Prefer deriving in render, event handlers, a `key` reset, an element-owned ref callback, or a store. " +
53
+ `If an effect is genuinely right, raise this file's entry in ${BUDGET_FILE} in the same PR.`;
54
+ for (const node of calls.slice(allowed)) context.report({ node, message });
55
+ },
56
+ };
57
+ },
58
+});
packages/client-runtime/src/rpc/session.ts
+7
-2
@@ -170,6 +170,11 @@ export const make = Effect.fn("RpcSessionFactory.make")(function* (
170
...(options.usageLimitSources === true ? { usageLimitSources: true } : {}),
171
...(options.usageLimitsCommand === true ? { usageLimitsCommand: true } : {}),
172
};
173
+ // Config state merges the snapshots it fetches back in, so no subscriber needs them broadcast.
174
+ const onDemandSnapshots = (input: ServerConfigSubscriptionInput) => ({
175
+ ...input,
176
+ workspaceSnapshotsOnDemand: true,
177
+ });
178
179
const connect = Effect.fnUntraced(function* (connection: PreparedConnection) {
180
const via = connection.target._tag === "RelayConnectionTarget" ? "relay" : "direct";
@@ -248,7 +253,7 @@ export const make = Effect.fn("RpcSessionFactory.make")(function* (
253
detail: `${connection.label} config subscription ended.`,
254
});
255
const serverConfigSource = protocolClient[WS_METHODS.subscribeServerConfig](
251
- serverConfigInput,
256
+ onDemandSnapshots(serverConfigInput),
257
).pipe(
258
Stream.runForEach((event) =>
259
Effect.gen(function* () {
@@ -387,7 +392,7 @@ export const make = Effect.fn("RpcSessionFactory.make")(function* (
392
Effect.as(
393
Equal.equals(input, serverConfigInput)
394
? serverConfigEvents
390
- : protocolClient[WS_METHODS.subscribeServerConfig](input),
395
+ : protocolClient[WS_METHODS.subscribeServerConfig](onDemandSnapshots(input)),
396
),
397
),
398
);
packages/client-runtime/src/state/server.test.ts
+84
@@ -1,5 +1,6 @@
1
import {
2
EnvironmentId,
3
+ ProviderInstanceId,
4
ServerObservability,
5
EnvironmentThemeId,
6
UsageLimitSourceId,
@@ -39,6 +40,8 @@ import {
40
makeEnvironmentServerWelcomeState,
41
makeEnvironmentServerConfigState,
42
isLegacyUpdateHandoffLoss,
43
+ recordFetchedWorkspaceSnapshot,
44
+ withFetchedWorkspaceSnapshots,
45
matchesServerUpdateReadyEvent,
46
matchesServerUpdateResumeEvent,
47
nudgeReconnectDuringUpdateRestart,
@@ -937,6 +940,87 @@ describe("server state projection", () => {
940
).toBe(live);
941
});
942
943
+ it("merges fetched workspace snapshots only from servers that omit them", () => {
944
+ const claude = ProviderInstanceId.make("claudeAgent");
945
+ const codex = ProviderInstanceId.make("codex");
946
+ const snapshot = (cwd: string, command: string) => ({
947
+ cwd,
948
+ checkedAt: "2026-10-25T00:00:00.000Z",
949
+ slashCommands: [{ name: command }],
950
+ skills: [],
951
+ });
952
+ const provider = (
953
+ instanceId: ProviderInstanceId,
954
+ workspaceSnapshots?: ReadonlyArray<ReturnType<typeof snapshot>>,
955
+ slashCommands: ReadonlyArray<{ readonly name: string }> = [],
956
+ ) =>
957
+ ({
958
+ instanceId,
959
+ enabled: true,
960
+ slashCommands,
961
+ skills: [],
962
+ ...(workspaceSnapshots ? { workspaceSnapshots } : {}),
963
+ }) as unknown as ServerConfig["providers"][number];
964
+ const configWith = (onDemand: boolean, providers: ServerConfig["providers"]) =>
965
+ ({
966
+ ...CONFIG,
967
+ environment: { capabilities: { providerWorkspaceSnapshotsOnDemand: onDemand } },
968
+ providers,
969
+ }) as unknown as ServerConfig;
970
+ const claudeA = snapshot("/a", "claude");
971
+ const record = (
972
+ current: Parameters<typeof recordFetchedWorkspaceSnapshot>[0],
973
+ instanceId: ProviderInstanceId,
974
+ fresh: boolean,
975
+ reply: ServerConfig["providers"],
976
+ ) =>
977
+ recordFetchedWorkspaceSnapshot(
978
+ current,
979
+ { instanceId, cwd: "/a", fresh },
980
+ reply,
981
+ provider(instanceId),
982
+ );
983
+
984
+ let fetched = record([], claude, false, [provider(claude, [claudeA])]);
985
+ fetched = record(fetched, codex, false, [provider(codex, [snapshot("/a", "codex")])]);
986
+ const merged = withFetchedWorkspaceSnapshots(
987
+ configWith(true, [provider(claude), provider(codex)]),
988
+ fetched,
989
+ );
990
+ expect(merged.providers[0]?.workspaceSnapshots).toEqual([claudeA]);
991
+ // An unchanged answer keeps the cache, so config readers do not re-render.
992
+ expect(
993
+ record(fetched, claude, false, [
994
+ provider(claude, [JSON.parse(JSON.stringify(claudeA)) as typeof claudeA]),
995
+ ]),
996
+ ).toBe(fetched);
997
+
998
+ // Health checks and usage updates leave the snapshot in place.
999
+ expect(
1000
+ withFetchedWorkspaceSnapshots(
1001
+ configWith(true, [
1002
+ { ...provider(claude), checkedAt: "2026-10-25T00:09:00.000Z", usageLimits: {} },
1003
+ ] as unknown as ServerConfig["providers"]),
1004
+ fetched,
1005
+ ).providers[0]?.workspaceSnapshots,
1006
+ ).toEqual([claudeA]);
1007
+
1008
+ // New provider-wide commands, such as a live session's, retire the old snapshot.
1009
+ expect(
1010
+ withFetchedWorkspaceSnapshots(
1011
+ configWith(true, [provider(claude, undefined, [{ name: "live" }])]),
1012
+ fetched,
1013
+ ).providers[0]?.workspaceSnapshots,
1014
+ ).toBeUndefined();
1015
+
1016
+ // Older servers send every snapshot and every drop; their config stands.
1017
+ const legacy = configWith(false, [provider(claude)]);
1018
+ expect(withFetchedWorkspaceSnapshots(legacy, fetched)).toBe(legacy);
1019
+
1020
+ // A fresh scan drops the cwd's other provider snapshots, as the server does.
1021
+ expect(record(fetched, claude, true, [])).toEqual([]);
1022
+ });
1023
+
1024
it.effect("starts from cached configuration and persists the live projection", () =>
1025
Effect.gen(function* () {
1026
const events = yield* Queue.unbounded<ServerConfigStreamEvent>();
packages/client-runtime/src/state/server.ts
+129
-1
@@ -1,9 +1,11 @@
1
import {
2
type EnvironmentId,
3
+ type ProviderInstanceId,
4
type ServerConfig,
5
type ServerConfigStreamEvent,
6
type ServerLifecycleWelcomePayload,
7
type ServerLifecycleStreamReadyEvent,
8
+ type ServerProviderWorkspaceSnapshot,
9
type ServerSelfUpdateProgressEvent,
10
type ServerSelfUpdateResult,
11
shouldRecommendDatabaseCompaction,
@@ -11,6 +13,7 @@ import {
13
} from "@t3tools/contracts";
14
import * as Cause from "effect/Cause";
15
import * as Duration from "effect/Duration";
16
+import * as Equal from "effect/Equal";
17
import * as Deferred from "effect/Deferred";
18
import * as Effect from "effect/Effect";
19
import * as Exit from "effect/Exit";
@@ -42,6 +45,7 @@ import { runCachePersistence } from "./cachePersistence.ts";
45
import {
46
isRpcClientError,
47
request,
48
+ requestGuarded,
49
runStream,
50
subscribe,
51
subscribeDynamicWithSession,
@@ -51,6 +55,7 @@ import type { RpcSession } from "../rpc/session.ts";
55
import { followStreamInEnvironment } from "./runtime.ts";
56
import {
57
applyServerConfigProjection,
58
+ reuseUnchanged,
59
type ServerConfigProjection,
60
withoutEnvironmentThemes,
61
} from "./serverConfigProjection.ts";
@@ -648,6 +653,92 @@ export function resolveServerConfigValue(
653
return initialConfig ?? projection?.config ?? null;
654
}
655
656
+type ServerProviderEntry = ServerConfig["providers"][number];
657
+
658
+/**
659
+ * The provider-wide fields a workspace snapshot builds on. A live session, a sign-out, or a
660
+ * /usage-limits change shows up here, so a snapshot fetched before it no longer applies.
661
+ */
662
+const snapshotBasis = (provider: ServerProviderEntry | undefined) =>
663
+ provider && {
664
+ enabled: provider.enabled,
665
+ slashCommands: provider.slashCommands,
666
+ skills: provider.skills,
667
+ };
668
+
669
+interface FetchedWorkspaceSnapshot {
670
+ readonly instanceId: ProviderInstanceId;
671
+ readonly snapshot: ServerProviderWorkspaceSnapshot;
672
+ readonly basis: ReturnType<typeof snapshotBasis>;
673
+}
674
+
675
+const MAX_FETCHED_WORKSPACE_SNAPSHOTS = 32;
676
+
677
+/**
678
+ * Servers with `providerWorkspaceSnapshotsOnDemand` leave per-cwd snapshots out of the config,
679
+ * so the ones this client fetched are merged back in. Older servers send every snapshot and
680
+ * their drops, so their config is used as is.
681
+ */
682
+export function withFetchedWorkspaceSnapshots(
683
+ config: ServerConfig,
684
+ fetched: ReadonlyArray<FetchedWorkspaceSnapshot>,
685
+): ServerConfig {
686
+ if (
687
+ fetched.length === 0 ||
688
+ config.environment.capabilities.providerWorkspaceSnapshotsOnDemand !== true
689
+ ) {
690
+ return config;
691
+ }
692
+ return {
693
+ ...config,
694
+ providers: config.providers.map((provider) => {
695
+ // A dropped snapshot reads as lost, and the composer fetches it again.
696
+ const own = fetched.filter(
697
+ (entry) =>
698
+ entry.instanceId === provider.instanceId &&
699
+ Equal.equals(entry.basis, snapshotBasis(provider)),
700
+ );
701
+ return own.length === 0
702
+ ? provider
703
+ : { ...provider, workspaceSnapshots: own.map((entry) => entry.snapshot) };
704
+ }),
705
+ };
706
+}
707
+
708
+export function recordFetchedWorkspaceSnapshot(
709
+ current: ReadonlyArray<FetchedWorkspaceSnapshot>,
710
+ input: { readonly instanceId: ProviderInstanceId; readonly cwd: string; readonly fresh: boolean },
711
+ providers: ServerConfig["providers"],
712
+ configProvider: ServerProviderEntry | undefined,
713
+): ReadonlyArray<FetchedWorkspaceSnapshot> {
714
+ const basis = snapshotBasis(configProvider);
715
+ const snapshot = providers
716
+ .find((provider) => provider.instanceId === input.instanceId)
717
+ ?.workspaceSnapshots?.find((candidate) => candidate.cwd === input.cwd);
718
+ const stored = current.find(
719
+ (entry) => entry.instanceId === input.instanceId && entry.snapshot.cwd === input.cwd,
720
+ );
721
+ // A cached answer from the server would otherwise re-render every config reader.
722
+ if (
723
+ !input.fresh &&
724
+ snapshot &&
725
+ stored &&
726
+ Equal.equals(stored.snapshot, snapshot) &&
727
+ Equal.equals(stored.basis, basis)
728
+ ) {
729
+ return current;
730
+ }
731
+ // A fresh scan drops the cwd's snapshots for every provider, as the server does.
732
+ const kept = current.filter(
733
+ (entry) =>
734
+ entry.snapshot.cwd !== input.cwd || (!input.fresh && entry.instanceId !== input.instanceId),
735
+ );
736
+ if (!snapshot) return kept.length === current.length ? current : kept;
737
+ return [...kept, { instanceId: input.instanceId, snapshot, basis }].slice(
738
+ -MAX_FETCHED_WORKSPACE_SNAPSHOTS,
739
+ );
740
+}
741
+
742
export function createServerEnvironmentAtoms<R, E>(
743
runtime: Atom.AtomRuntime<
744
EnvironmentRegistry.EnvironmentRegistry | Persistence.EnvironmentCacheStore | R,
@@ -686,6 +777,12 @@ export function createServerEnvironmentAtoms<R, E>(
777
readonly environmentId: EnvironmentId;
778
readonly input: EnvironmentRpcInput<typeof WS_METHODS.subscribeServerConfig>;
779
}) => configProjectionFamily(target.environmentId);
780
+ const fetchedWorkspaceSnapshotsAtom = Atom.family((environmentId: EnvironmentId) =>
781
+ Atom.make<ReadonlyArray<FetchedWorkspaceSnapshot>>([]).pipe(
782
+ Atom.keepAlive,
783
+ Atom.withLabel(`environment-data:server:fetched-workspace-snapshots:${environmentId}`),
784
+ ),
785
+ );
786
const emptyConfigAtom = Atom.make<ServerConfig | null>(null).pipe(
787
Atom.withLabel("environment-data:server:config:empty"),
788
);
@@ -693,14 +790,24 @@ export function createServerEnvironmentAtoms<R, E>(
790
if (environmentId === null) {
791
return emptyConfigAtom;
792
}
793
+ let previousProviders: ServerConfig["providers"] | undefined;
794
return Atom.make((get): ServerConfig | null => {
795
const projection = Option.getOrNull(
796
AsyncResult.value(get(configProjection({ environmentId, input: {} }))),
797
);
700
- return resolveServerConfigValue(
798
+ const config = resolveServerConfigValue(
799
projection,
800
get(options.initialConfigValueAtom(environmentId)),
801
);
802
+ if (config === null) return null;
803
+ const merged = withFetchedWorkspaceSnapshots(
804
+ config,
805
+ get(fetchedWorkspaceSnapshotsAtom(environmentId)),
806
+ );
807
+ if (merged === config) return config;
808
+ // Keep provider identities stable across config events; the projection already reuses the rest.
809
+ previousProviders = reuseUnchanged(previousProviders, merged.providers);
810
+ return { ...merged, providers: previousProviders };
811
}).pipe(Atom.withLabel(`environment-data:server:config:${environmentId}`));
812
});
813
const updateStateValueAtom = Atom.family((environmentId: EnvironmentId) =>
@@ -1227,6 +1334,27 @@ export function createServerEnvironmentAtoms<R, E>(
1334
refreshProviders: createEnvironmentRpcCommand(runtime, {
1335
label: "environment-data:server:refresh-providers",
1336
tag: WS_METHODS.serverRefreshProviders,
1337
+ execute: (input) =>
1338
+ requestGuarded(WS_METHODS.serverRefreshProviders, {
1339
+ ...input,
1340
+ workspaceSnapshotsOnDemand: true,
1341
+ ...(options.usageLimitsCommand === true ? { usageLimitsCommand: true } : {}),
1342
+ }),
1343
+ onSuccess: ({ environmentId, input }, registry, result) =>
1344
+ Effect.sync(() => {
1345
+ const { instanceId, cwd } = input;
1346
+ if (instanceId === undefined || cwd === undefined) return;
1347
+ registry.update(fetchedWorkspaceSnapshotsAtom(environmentId), (current) =>
1348
+ recordFetchedWorkspaceSnapshot(
1349
+ current,
1350
+ { instanceId, cwd, fresh: input.fresh === true },
1351
+ result.providers,
1352
+ registry
1353
+ .get(configValueAtom(environmentId))
1354
+ ?.providers.find((provider) => provider.instanceId === instanceId),
1355
+ ),
1356
+ );
1357
+ }),
1358
concurrency: {
1359
mode: "singleFlight",
1360
key: ({ environmentId, input }) =>
packages/contracts/src/environment.ts
+2
@@ -102,6 +102,8 @@ export const ExecutionEnvironmentCapabilities = Schema.Struct({
102
/** Clear published themes when absent; older servers never send updates. */
103
environmentThemes: Schema.optionalKey(Schema.Boolean),
104
usageLimitSources: Schema.optionalKey(Schema.Boolean),
105
+ /** Honors `workspaceSnapshotsOnDemand`; older servers send every snapshot and drop them in the stream. */
106
+ providerWorkspaceSnapshotsOnDemand: Schema.optionalKey(Schema.Boolean),
107
usagePriceOverrides: Schema.optionalKey(Schema.Boolean),
108
usageModelAliases: Schema.optionalKey(Schema.Boolean),
109
threadPinning: Schema.optionalKey(Schema.Boolean),
packages/contracts/src/rpc.ts
+11
-1
@@ -612,13 +612,21 @@ const WsServerGetConfigRpc = Rpc.make(WS_METHODS.serverGetConfig, {
612
error: Schema.Union([KeybindingsConfigError, ServerSettingsError, EnvironmentAuthorizationError]),
613
});
614
615
-const WsServerRefreshProvidersRpc = Rpc.make(WS_METHODS.serverRefreshProviders, {
615
+export const WsServerRefreshProvidersRpc = Rpc.make(WS_METHODS.serverRefreshProviders, {
616
payload: Schema.Struct({
617
instanceId: Schema.optional(ProviderInstanceId),
618
cwd: Schema.optional(TrimmedNonEmptyString),
619
fresh: Schema.optional(Schema.Boolean),
620
/** Bypass model caches; explicit rediscovery may open sessions, background refreshes must not. */
621
refreshModels: Schema.optional(Schema.Boolean),
622
+ /**
623
+ * Reply without snapshots, or with only the requested instance's cwd snapshot. Snapshots then
624
+ * reach the client only through these replies, so another client's scan shows on its next
625
+ * refresh, at most one TTL later.
626
+ */
627
+ workspaceSnapshotsOnDemand: Schema.optional(Schema.Boolean),
628
+ /** As on `subscribeServerConfig`: add /usage-limits to the replied snapshot. */
629
+ usageLimitsCommand: Schema.optional(Schema.Boolean),
630
}),
631
success: ServerProviderUpdatedPayload,
632
error: Schema.Union([EnvironmentAuthorizationError, ProviderSetupError]),
@@ -1791,6 +1799,8 @@ export const WsSubscribeServerConfigRpc = Rpc.make(WS_METHODS.subscribeServerCon
1799
usageLimitSources: Schema.optional(Schema.Boolean),
1800
/** Advertise client handling before the server offers /usage-limits, or older clients send it as a prompt. */
1801
usageLimitsCommand: Schema.optional(Schema.Boolean),
1802
+ /** Omit per-cwd provider snapshots; the client fetches its cwd through `server.refreshProviders`. */
1803
+ workspaceSnapshotsOnDemand: Schema.optional(Schema.Boolean),
1804
}),
1805
success: ServerConfigStreamEvent,
1806
error: Schema.Union([KeybindingsConfigError, ServerSettingsError, EnvironmentAuthorizationError]),
packages/provider-grok/src/server/status.ts
+8
-7
@@ -527,6 +527,12 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
527
discoveredModels.length > 0
528
? grokModelsFromSettings(grokSettings.customModels, discoveredModels)
529
: fallbackModels;
530
+ // The registry replaces cached models on a ready probe, so a fallback-only list must not be ready.
531
+ const incompleteMessage = acpFailed
532
+ ? "Grok CLI is installed but ACP initialize failed. Model options may be incomplete."
533
+ : discoveredModels.length === 0
534
+ ? "Grok CLI did not list any models. Model options may be incomplete."
535
+ : undefined;
536
537
if (auth.status === "unauthenticated") {
538
return buildServerProvider({
@@ -555,14 +561,9 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
561
probe: {
562
installed: true,
563
version,
558
- status: acpFailed ? "warning" : "ready",
564
+ status: incompleteMessage ? "warning" : "ready",
565
auth,
560
- ...(acpFailed
561
- ? {
562
- message:
563
- "Grok CLI is installed but ACP initialize failed. Model options may be incomplete.",
564
- }
565
- : {}),
566
+ ...(incompleteMessage ? { message: incompleteMessage } : {}),
567
},
568
});
569
});
packages/shared/package.json
+4
@@ -59,6 +59,10 @@
59
"types": "./src/logging.ts",
60
"import": "./src/logging.ts"
61
},
62
+ "./releaseResource": {
63
+ "types": "./src/releaseResource.ts",
64
+ "import": "./src/releaseResource.ts"
65
+ },
66
"./observability": {
67
"types": "./src/observability.ts",
68
"import": "./src/observability.ts"
packages/shared/src/observability.test.ts
+8
@@ -24,8 +24,16 @@ import {
24
type TraceRecord,
25
OtlpHeadersFromString,
26
truncateTraceAttributes,
27
+ processServiceInstanceId,
28
} from "./observability.ts";
29
30
+describe("processServiceInstanceId", () => {
31
+ it("stays the same for the process unless the operator set one", () => {
32
+ expect(processServiceInstanceId()).toBe(processServiceInstanceId({}));
33
+ expect(processServiceInstanceId({ "service.instance.id": "pod-7" })).toBe("pod-7");
34
+ });
35
+});
36
+
37
describe("errorTag", () => {
38
it("reports structural tags without retaining arbitrary values", () => {
39
assert.equal(errorTag({ _tag: "AcpRequestError" }), "AcpRequestError");
packages/shared/src/observability.ts
+15
@@ -26,6 +26,21 @@ export interface SignalExport {
26
readonly exportIntervalMs: number;
27
}
28
29
+let generatedServiceInstanceId: string | undefined;
30
+
31
+/**
32
+ * `service.instance.id` shared by every resource this process exports. Effect lets code
33
+ * attributes beat `OTEL_RESOURCE_ATTRIBUTES`, so callers pass the operator's in to keep it winning.
34
+ */
35
+export const processServiceInstanceId = (
36
+ operatorAttributes: Readonly<Record<string, string>> = {},
37
+): string => {
38
+ if (operatorAttributes["service.instance.id"]) return operatorAttributes["service.instance.id"];
39
+ // @effect-diagnostics-next-line cryptoRandomUUID:off -- Resources are built synchronously, outside any Effect.
40
+ generatedServiceInstanceId ??= crypto.randomUUID();
41
+ return generatedServiceInstanceId;
42
+};
43
+
44
export const DEFAULT_SIGNAL_EXPORT: SignalExport = {
45
protocol: "http/json",
46
headers: undefined,
packages/shared/src/relayTracing.ts
+4
@@ -18,8 +18,10 @@ export interface RelayClientTracingResource {
18
readonly serviceName: string;
19
readonly serviceVersion?: string;
20
readonly runtime: string;
21
+ readonly serviceInstanceId: string;
22
readonly client: string;
23
readonly component?: string;
24
+ readonly attributes?: Readonly<Record<string, string>> | undefined;
25
}
26
27
export class RelayClientTracer extends Context.Reference(
@@ -165,9 +167,11 @@ export function layer(
167
serviceVersion: resource.serviceVersion,
168
attributes: {
169
"service.namespace": "t3code",
170
+ "service.instance.id": resource.serviceInstanceId,
171
"service.runtime": resource.runtime,
172
"t3code.component": resource.component ?? "relay-client",
173
"t3code.client.surface": resource.client,
174
+ ...resource.attributes,
175
},
176
},
177
}).pipe(Layer.provide(OtlpSerialization.layerJson));
packages/shared/src/releaseResource.test.ts
new
+35
@@ -0,0 +1,35 @@
1
+import { describe, expect, it } from "@effect/vitest";
2
+
3
+import { releaseChannelOf, releaseResourceAttributes } from "./releaseResource.ts";
4
+
5
+describe("releaseResourceAttributes", () => {
6
+ it.each([
7
+ ["dev", {}, "dev", "development"],
8
+ ["stable", {}, "stable", "production"],
9
+ ["nightly", {}, "nightly", "production"],
10
+ ["preview", {}, "preview", "staging"],
11
+ [
12
+ "stable",
13
+ { "deployment.environment.name": "staging", "t3code.release.channel": "" },
14
+ "stable",
15
+ "staging",
16
+ ],
17
+ ] as const)(
18
+ "%s (operator: %o) reports %s in %s",
19
+ (channel, operatorAttributes, expectedChannel, environment) => {
20
+ expect(releaseResourceAttributes(channel, operatorAttributes)).toEqual({
21
+ "t3code.release.channel": expectedChannel,
22
+ "deployment.environment.name": environment,
23
+ });
24
+ },
25
+ );
26
+
27
+ it.each([
28
+ ["0.1.2", "stable"],
29
+ ["0.1.2-nightly.20261025.1", "nightly"],
30
+ ["0.1.2-preview.20261025.1", "preview"],
31
+ ["0.1.2-pr.24340.123", "preview"],
32
+ ] as const)("classifies %s as %s", (version, channel) => {
33
+ expect(releaseChannelOf(version)).toBe(channel);
34
+ });
35
+});
packages/shared/src/releaseResource.ts
new
+24
@@ -0,0 +1,24 @@
1
+import { type CliReleaseChannel, cliReleaseChannelOf } from "./cliRelease.ts";
2
+
3
+export type ReleaseChannel = "dev" | CliReleaseChannel;
4
+
5
+// Desktop PR preview builds are stamped `X.Y.Z-pr.<number>.<run>`; the CLI updater must not see them as preview.
6
+export const releaseChannelOf = (version: string): ReleaseChannel =>
7
+ /-pr\.\d+\.\d+$/.test(version) ? "preview" : cliReleaseChannelOf(version);
8
+
9
+// Effect lets code attributes beat OTEL_RESOURCE_ATTRIBUTES, so the operator value is applied here.
10
+export const releaseResourceAttributes = (
11
+ channel: ReleaseChannel,
12
+ operatorAttributes: Readonly<Record<string, unknown>> = {},
13
+) => {
14
+ const operatorValue = (key: string) => {
15
+ const value = operatorAttributes[key];
16
+ return typeof value === "string" && value !== "" ? value : undefined;
17
+ };
18
+ return {
19
+ "t3code.release.channel": operatorValue("t3code.release.channel") ?? channel,
20
+ "deployment.environment.name":
21
+ operatorValue("deployment.environment.name") ??
22
+ (channel === "dev" ? "development" : channel === "preview" ? "staging" : "production"),
23
+ };
24
+};
scripts/effect-budget.json
new
+433
@@ -0,0 +1,433 @@
1
+{
2
+ "apps/mobile/src/App.tsx": 2,
3
+ "apps/mobile/src/Stack.tsx": 1,
4
+ "apps/mobile/src/components/ComposerAttachmentStrip.tsx": 2,
5
+ "apps/mobile/src/components/ComposerContextAttachment.tsx": 1,
6
+ "apps/mobile/src/components/ComposerEditor.tsx": 2,
7
+ "apps/mobile/src/components/FilePreview.ios.tsx": 1,
8
+ "apps/mobile/src/components/FilePreview.tsx": 1,
9
+ "apps/mobile/src/components/FilePreviewModal.tsx": 5,
10
+ "apps/mobile/src/components/MediaVideoPlayer.tsx": 3,
11
+ "apps/mobile/src/components/PdfPreview.android.tsx": 1,
12
+ "apps/mobile/src/components/ProjectFavicon.tsx": 1,
13
+ "apps/mobile/src/components/VideoPreviewModal.ios.tsx": 6,
14
+ "apps/mobile/src/components/VideoPreviewModal.tsx": 3,
15
+ "apps/mobile/src/components/VideoThumbnailImage.tsx": 1,
16
+ "apps/mobile/src/components/ui/AndroidAnchoredMenu.tsx": 1,
17
+ "apps/mobile/src/components/ui/AppBar.android.tsx": 1,
18
+ "apps/mobile/src/components/ui/Dialog.android.tsx": 1,
19
+ "apps/mobile/src/components/ui/Notice.tsx": 1,
20
+ "apps/mobile/src/components/ui/OverlayPortal.tsx": 3,
21
+ "apps/mobile/src/components/ui/SliderRow.android.tsx": 1,
22
+ "apps/mobile/src/components/ui/SliderRow.tsx": 1,
23
+ "apps/mobile/src/components/ui/Toast.tsx": 2,
24
+ "apps/mobile/src/features/agent-awareness/notificationNavigation.ts": 3,
25
+ "apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx": 2,
26
+ "apps/mobile/src/features/browser/PreviewStreamWebView.tsx": 5,
27
+ "apps/mobile/src/features/browser/ThreadBrowserFloat.tsx": 2,
28
+ "apps/mobile/src/features/cloud/CloudAuthProvider.tsx": 3,
29
+ "apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx": 1,
30
+ "apps/mobile/src/features/cloud/connectOnboardingNavigation.ts": 1,
31
+ "apps/mobile/src/features/cloud/managedRelayState.ts": 1,
32
+ "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx": 5,
33
+ "apps/mobile/src/features/connection/PermissionUpdateNotice.tsx": 2,
34
+ "apps/mobile/src/features/devices/DevicePreviewRouteScreen.tsx": 6,
35
+ "apps/mobile/src/features/devices/DeviceStreamWebView.tsx": 2,
36
+ "apps/mobile/src/features/diagnostics/SettingsDiagnosticsRouteScreen.tsx": 1,
37
+ "apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts": 3,
38
+ "apps/mobile/src/features/files/AttachmentFileScreen.tsx": 1,
39
+ "apps/mobile/src/features/files/AudioFilePreview.tsx": 2,
40
+ "apps/mobile/src/features/files/FileTreeBrowser.tsx": 3,
41
+ "apps/mobile/src/features/files/FilesHeader.tsx": 1,
42
+ "apps/mobile/src/features/files/SourceFileSurface.tsx": 1,
43
+ "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx": 1,
44
+ "apps/mobile/src/features/files/WorkspaceFileWebPreview.tsx": 1,
45
+ "apps/mobile/src/features/files/useFileTreeEntries.ts": 1,
46
+ "apps/mobile/src/features/home/HomeRouteScreen.tsx": 2,
47
+ "apps/mobile/src/features/home/HomeScreen.tsx": 4,
48
+ "apps/mobile/src/features/home/ThreadListToolbar.tsx": 1,
49
+ "apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx": 2,
50
+ "apps/mobile/src/features/home/home-list-options.ts": 1,
51
+ "apps/mobile/src/features/home/home-route-visibility.ts": 1,
52
+ "apps/mobile/src/features/home/thread-swipe-actions.tsx": 5,
53
+ "apps/mobile/src/features/keyboard/CommandPalette.tsx": 2,
54
+ "apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx": 1,
55
+ "apps/mobile/src/features/keyboard/hardwareKeyboardCommands.ts": 1,
56
+ "apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx": 3,
57
+ "apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx": 1,
58
+ "apps/mobile/src/features/layout/workspace-inspector-pane.tsx": 2,
59
+ "apps/mobile/src/features/projects/AddProjectScreen.tsx": 2,
60
+ "apps/mobile/src/features/prompt-links/usePromptLinkResolver.ts": 1,
61
+ "apps/mobile/src/features/prompt-links/useThreadPromptLink.ts": 1,
62
+ "apps/mobile/src/features/pull-requests/PullRequestFilterMenuContext.tsx": 1,
63
+ "apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx": 1,
64
+ "apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx": 4,
65
+ "apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx": 1,
66
+ "apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx": 1,
67
+ "apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx": 1,
68
+ "apps/mobile/src/features/pull-requests/usePullRequestDiff.ts": 1,
69
+ "apps/mobile/src/features/pull-requests/usePullRequestEnvironmentFallback.ts": 1,
70
+ "apps/mobile/src/features/pull-requests/usePullRequestFilesViewed.ts": 4,
71
+ "apps/mobile/src/features/pull-requests/usePullRequestList.ts": 3,
72
+ "apps/mobile/src/features/pull-requests/usePullRequestReviewDraft.ts": 1,
73
+ "apps/mobile/src/features/review/ReviewSheet.tsx": 1,
74
+ "apps/mobile/src/features/review/useNativeReviewDiffHighlighting.ts": 2,
75
+ "apps/mobile/src/features/review/useReviewCommentSelectionController.ts": 2,
76
+ "apps/mobile/src/features/review/useReviewDiffData.ts": 2,
77
+ "apps/mobile/src/features/review/useReviewDiffPrewarming.ts": 1,
78
+ "apps/mobile/src/features/review/useReviewSections.ts": 5,
79
+ "apps/mobile/src/features/settings/OutdatedServerUpdateSection.tsx": 1,
80
+ "apps/mobile/src/features/settings/SettingsAboutRouteScreen.tsx": 1,
81
+ "apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx": 2,
82
+ "apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx": 1,
83
+ "apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx": 1,
84
+ "apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsx": 2,
85
+ "apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx": 1,
86
+ "apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx": 2,
87
+ "apps/mobile/src/features/settings/appearance/AppearancePreferencesProvider.tsx": 2,
88
+ "apps/mobile/src/features/settings/components/BranchNamingSettings.tsx": 1,
89
+ "apps/mobile/src/features/settings/components/SettingsLegalDocumentRouteScreen.tsx": 1,
90
+ "apps/mobile/src/features/sharing/IncomingShareProvider.tsx": 4,
91
+ "apps/mobile/src/features/shortcuts/useAppShortcuts.ts": 4,
92
+ "apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx": 11,
93
+ "apps/mobile/src/features/terminal/NativeTerminalSurface.tsx": 4,
94
+ "apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx": 14,
95
+ "apps/mobile/src/features/terminal/terminalLaunchContext.ts": 1,
96
+ "apps/mobile/src/features/terminal/useTerminalGridSync.ts": 1,
97
+ "apps/mobile/src/features/terminal/useTerminalLifecycle.ts": 1,
98
+ "apps/mobile/src/features/threads/ComposerPopoverAnchor.android.tsx": 2,
99
+ "apps/mobile/src/features/threads/ComposerPopoverAnchor.tsx": 1,
100
+ "apps/mobile/src/features/threads/CopyTextButton.tsx": 1,
101
+ "apps/mobile/src/features/threads/CustomSnoozeSheet.android.tsx": 1,
102
+ "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx": 1,
103
+ "apps/mobile/src/features/threads/HtmlRenderWebView.tsx": 1,
104
+ "apps/mobile/src/features/threads/McpAppFullscreenScreen.tsx": 1,
105
+ "apps/mobile/src/features/threads/McpAppWebView.tsx": 7,
106
+ "apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx": 2,
107
+ "apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx": 5,
108
+ "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx": 10,
109
+ "apps/mobile/src/features/threads/NewTaskRouteScreen.tsx": 1,
110
+ "apps/mobile/src/features/threads/QuestionAttachments.tsx": 2,
111
+ "apps/mobile/src/features/threads/ThreadAgentsSheet.tsx": 1,
112
+ "apps/mobile/src/features/threads/ThreadArrangementSheet.tsx": 3,
113
+ "apps/mobile/src/features/threads/ThreadComposer.tsx": 6,
114
+ "apps/mobile/src/features/threads/ThreadDetailScreen.tsx": 20,
115
+ "apps/mobile/src/features/threads/ThreadFeed.tsx": 14,
116
+ "apps/mobile/src/features/threads/ThreadGuestShareBar.tsx": 1,
117
+ "apps/mobile/src/features/threads/ThreadInlineFilePreview.tsx": 2,
118
+ "apps/mobile/src/features/threads/ThreadMarkdownImage.tsx": 3,
119
+ "apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx": 3,
120
+ "apps/mobile/src/features/threads/ThreadQueueControl.tsx": 2,
121
+ "apps/mobile/src/features/threads/ThreadRouteScreen.tsx": 2,
122
+ "apps/mobile/src/features/threads/ThreadScreenHost.tsx": 2,
123
+ "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx": 2,
124
+ "apps/mobile/src/features/threads/UsageLimitRecoveryCard.tsx": 1,
125
+ "apps/mobile/src/features/threads/floating-working-control.tsx": 2,
126
+ "apps/mobile/src/features/threads/git/GitOverviewSheet.tsx": 1,
127
+ "apps/mobile/src/features/threads/new-task-flow-provider.tsx": 6,
128
+ "apps/mobile/src/features/threads/thread-inspector-content-stack.tsx": 1,
129
+ "apps/mobile/src/features/threads/thread-list-v2-items.tsx": 1,
130
+ "apps/mobile/src/features/threads/thread-subagent-group.tsx": 2,
131
+ "apps/mobile/src/features/threads/thread-work-log.tsx": 5,
132
+ "apps/mobile/src/features/threads/use-composer-command-menu.ts": 5,
133
+ "apps/mobile/src/features/threads/use-thread-settings-sheet-presentation.ts": 2,
134
+ "apps/mobile/src/features/threads/use-visible-second-clock.ts": 2,
135
+ "apps/mobile/src/features/threads/use-worktree-setup.ts": 1,
136
+ "apps/mobile/src/features/threads/useFileChipShare.ts": 2,
137
+ "apps/mobile/src/features/usage/UsageLimitsSection.tsx": 1,
138
+ "apps/mobile/src/features/usage/UsageRouteScreen.tsx": 1,
139
+ "apps/mobile/src/features/voice-input/ComposerDictationControl.tsx": 3,
140
+ "apps/mobile/src/features/voice-input/GlobalVoiceInputControl.tsx": 2,
141
+ "apps/mobile/src/features/voice-input/VoiceInputProvider.tsx": 4,
142
+ "apps/mobile/src/features/voice-input/useVoiceInputController.ts": 1,
143
+ "apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx": 1,
144
+ "apps/mobile/src/features/workspace/WorkspaceNativeTabs.ios.tsx": 1,
145
+ "apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx": 1,
146
+ "apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx": 1,
147
+ "apps/mobile/src/features/workspace/WorkspaceToolbar.tsx": 2,
148
+ "apps/mobile/src/lib/attachmentDocument.ts": 4,
149
+ "apps/mobile/src/lib/useDelayedStatus.ts": 2,
150
+ "apps/mobile/src/lib/useUiRuntimeMemoryWarningGc.ts": 1,
151
+ "apps/mobile/src/lib/videoAudioSession.ts": 1,
152
+ "apps/mobile/src/native/NativeHeaderToolbar.tsx": 2,
153
+ "apps/mobile/src/native/NativeWorkspaceColumns.ios.tsx": 1,
154
+ "apps/mobile/src/native/StackHeader.tsx": 2,
155
+ "apps/mobile/src/native/T3ComposerEditor.ios.tsx": 2,
156
+ "apps/mobile/src/native/T3ComposerEditor.native.tsx": 2,
157
+ "apps/mobile/src/native/V5StackHeader.ios.tsx": 1,
158
+ "apps/mobile/src/native/useRetryingImageSource.ts": 1,
159
+ "apps/mobile/src/state/composer-attachment-uploads.ts": 2,
160
+ "apps/mobile/src/state/mediaActions.ts": 1,
161
+ "apps/mobile/src/state/olderSettledShelf.ts": 2,
162
+ "apps/mobile/src/state/queries.ts": 2,
163
+ "apps/mobile/src/state/thread-order.ts": 1,
164
+ "apps/mobile/src/state/threads.ts": 1,
165
+ "apps/mobile/src/state/use-composer-attachment-actions.ts": 1,
166
+ "apps/mobile/src/state/use-composer-drafts.ts": 3,
167
+ "apps/mobile/src/state/use-pull-to-refresh.ts": 1,
168
+ "apps/mobile/src/state/use-selected-thread-git-actions.ts": 1,
169
+ "apps/mobile/src/state/use-selected-thread-requests.ts": 2,
170
+ "apps/mobile/src/state/use-thread-composer-state.ts": 3,
171
+ "apps/mobile/src/state/use-thread-outbox-drain.ts": 4,
172
+ "apps/mobile/src/state/use-thread-pr.ts": 1,
173
+ "apps/mobile/src/state/use-vcs-action-state.ts": 1,
174
+ "apps/mobile/src/widgets/SubscriptionUsageCoordinator.tsx": 1,
175
+ "apps/mobile/src/widgets/useSubscriptionUsage.ts": 1,
176
+ "apps/web/src/AppRoot.tsx": 1,
177
+ "apps/web/src/browser/BrowserProfileReporter.tsx": 1,
178
+ "apps/web/src/browser/BrowserSurfaceSlot.tsx": 2,
179
+ "apps/web/src/browser/ElectronBrowserHost.tsx": 3,
180
+ "apps/web/src/browser/HostedBrowserWebview.tsx": 6,
181
+ "apps/web/src/browser/ServerBrowserSurface.tsx": 5,
182
+ "apps/web/src/browser/useBrowserViewportResize.ts": 2,
183
+ "apps/web/src/cloud/managedAuth.tsx": 2,
184
+ "apps/web/src/cloud/managedRelayState.ts": 2,
185
+ "apps/web/src/components/AddProjectToMachineDialog.tsx": 1,
186
+ "apps/web/src/components/AnimatedHeight.tsx": 2,
187
+ "apps/web/src/components/AnimatedWidth.tsx": 1,
188
+ "apps/web/src/components/AppSidebarLayout.tsx": 4,
189
+ "apps/web/src/components/BackgroundThreadAnnouncer.tsx": 1,
190
+ "apps/web/src/components/BranchPicker.tsx": 2,
191
+ "apps/web/src/components/BranchToolbar.tsx": 4,
192
+ "apps/web/src/components/BranchToolbarBranchSelector.tsx": 1,
193
+ "apps/web/src/components/ChatMarkdown.tsx": 1,
194
+ "apps/web/src/components/ChatView.tsx": 23,
195
+ "apps/web/src/components/CommandPalette.tsx": 5,
196
+ "apps/web/src/components/CommandPaletteContent.tsx": 1,
197
+ "apps/web/src/components/ComposerPromptEditorTiptap.tsx": 13,
198
+ "apps/web/src/components/ConfirmDialogHost.tsx": 1,
199
+ "apps/web/src/components/CustomSnoozeDialog.tsx": 1,
200
+ "apps/web/src/components/DiffPanel.tsx": 4,
201
+ "apps/web/src/components/DiffWorkerPoolProvider.tsx": 2,
202
+ "apps/web/src/components/GitActionsControl.tsx": 4,
203
+ "apps/web/src/components/HostFreezeToastCoordinator.tsx": 1,
204
+ "apps/web/src/components/LegacySidebar.tsx": 5,
205
+ "apps/web/src/components/LegacyThreadMigrationToast.tsx": 2,
206
+ "apps/web/src/components/PermissionUpdateNotice.tsx": 1,
207
+ "apps/web/src/components/PersistentThreadTerminals.tsx": 1,
208
+ "apps/web/src/components/ProjectCloneToastCoordinator.tsx": 2,
209
+ "apps/web/src/components/PullRequestThreadDialog.tsx": 1,
210
+ "apps/web/src/components/QuitHoldOverlay.tsx": 1,
211
+ "apps/web/src/components/ReopenClosedViewShortcut.tsx": 2,
212
+ "apps/web/src/components/RightPanelTabs.tsx": 5,
213
+ "apps/web/src/components/Sidebar.logic.ts": 2,
214
+ "apps/web/src/components/Sidebar.pointer.ts": 1,
215
+ "apps/web/src/components/Sidebar.tsx": 10,
216
+ "apps/web/src/components/SlowRpcRequestToastCoordinator.tsx": 2,
217
+ "apps/web/src/components/ThreadNotificationCoordinator.tsx": 5,
218
+ "apps/web/src/components/ThreadRouteView.tsx": 5,
219
+ "apps/web/src/components/ThreadTerminalDrawer.tsx": 13,
220
+ "apps/web/src/components/auth/ConnectAgentSurface.tsx": 1,
221
+ "apps/web/src/components/auth/PairingRouteSurface.tsx": 2,
222
+ "apps/web/src/components/chat/AgentElapsed.tsx": 1,
223
+ "apps/web/src/components/chat/AssistantCitationChip.tsx": 2,
224
+ "apps/web/src/components/chat/AssistantCitationSource.tsx": 1,
225
+ "apps/web/src/components/chat/AssistantSelectionToolbar.tsx": 2,
226
+ "apps/web/src/components/chat/ChangedFilesTree.tsx": 1,
227
+ "apps/web/src/components/chat/ChatCanvas.tsx": 1,
228
+ "apps/web/src/components/chat/ChatComposer.tsx": 26,
229
+ "apps/web/src/components/chat/ChatHeader.tsx": 2,
230
+ "apps/web/src/components/chat/ChatMarkdownMedia.tsx": 1,
231
+ "apps/web/src/components/chat/ChatOverlayHosts.tsx": 1,
232
+ "apps/web/src/components/chat/CommandOutputPanel.tsx": 1,
233
+ "apps/web/src/components/chat/ComposerAttachmentStrip.tsx": 1,
234
+ "apps/web/src/components/chat/ComposerBannerStack.tsx": 3,
235
+ "apps/web/src/components/chat/ComposerCommandMenu.tsx": 1,
236
+ "apps/web/src/components/chat/ComposerCommandMenuLayer.tsx": 1,
237
+ "apps/web/src/components/chat/ComposerImageThumbnail.tsx": 1,
238
+ "apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx": 2,
239
+ "apps/web/src/components/chat/ComposerStashMenu.tsx": 2,
240
+ "apps/web/src/components/chat/DraftHeroHeadline.tsx": 1,
241
+ "apps/web/src/components/chat/DraftHeroProjectHeading.tsx": 1,
242
+ "apps/web/src/components/chat/ExpandedImageDialog.tsx": 4,
243
+ "apps/web/src/components/chat/HtmlRenderFrame.tsx": 3,
244
+ "apps/web/src/components/chat/MarkdownCodeBlock.tsx": 3,
245
+ "apps/web/src/components/chat/MarkdownTable.tsx": 3,
246
+ "apps/web/src/components/chat/McpAppFrame.tsx": 10,
247
+ "apps/web/src/components/chat/MermaidDiagram.tsx": 1,
248
+ "apps/web/src/components/chat/MessagesTimeline.tsx": 10,
249
+ "apps/web/src/components/chat/ModelPickerContent.tsx": 4,
250
+ "apps/web/src/components/chat/ModelPickerSidebar.tsx": 1,
251
+ "apps/web/src/components/chat/OpenInPicker.tsx": 1,
252
+ "apps/web/src/components/chat/OpenInPickerShortcut.ts": 1,
253
+ "apps/web/src/components/chat/PierreEntryIcon.tsx": 1,
254
+ "apps/web/src/components/chat/ProviderModelPicker.tsx": 1,
255
+ "apps/web/src/components/chat/ProviderSubagentBar.tsx": 1,
256
+ "apps/web/src/components/chat/ThreadActivityAnnouncer.tsx": 1,
257
+ "apps/web/src/components/chat/ThreadDetailsCard.tsx": 4,
258
+ "apps/web/src/components/chat/ThreadFindBar.tsx": 1,
259
+ "apps/web/src/components/chat/ThreadFindProvider.tsx": 1,
260
+ "apps/web/src/components/chat/ThreadTimeline.tsx": 1,
261
+ "apps/web/src/components/chat/ThreadVisitWatermark.tsx": 2,
262
+ "apps/web/src/components/chat/TimelineMinimap.tsx": 1,
263
+ "apps/web/src/components/chat/TimelineWorkGroupRows.tsx": 3,
264
+ "apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx": 1,
265
+ "apps/web/src/components/chat/WorkLog.tsx": 1,
266
+ "apps/web/src/components/chat/WorktreeSetupCard.tsx": 1,
267
+ "apps/web/src/components/chat/ZoomableImage.tsx": 3,
268
+ "apps/web/src/components/chat/composerContextUndo.ts": 1,
269
+ "apps/web/src/components/chat/threadContextDrag.ts": 1,
270
+ "apps/web/src/components/chat/threadFindHighlights.ts": 3,
271
+ "apps/web/src/components/chat/useAssistantCitationTarget.ts": 2,
272
+ "apps/web/src/components/chat/useAttachmentPreviewHandoff.ts": 4,
273
+ "apps/web/src/components/chat/useChatShortcuts.ts": 1,
274
+ "apps/web/src/components/chat/useComposerCommandKey.ts": 1,
275
+ "apps/web/src/components/chat/useComposerMultilinePrompt.ts": 1,
276
+ "apps/web/src/components/chat/useComposerRestingTransition.ts": 5,
277
+ "apps/web/src/components/chat/useComposerSend.ts": 1,
278
+ "apps/web/src/components/chat/useComposerStash.ts": 2,
279
+ "apps/web/src/components/chat/useComposerTypingGuard.ts": 1,
280
+ "apps/web/src/components/chat/useDraftEnvironmentRouting.ts": 3,
281
+ "apps/web/src/components/chat/useDraftHeroLayoutTransition.ts": 1,
282
+ "apps/web/src/components/chat/usePasteToFocusComposer.ts": 1,
283
+ "apps/web/src/components/chat/usePendingThreadRequests.ts": 2,
284
+ "apps/web/src/components/chat/useProviderWorkspaceSnapshotRefresh.ts": 2,
285
+ "apps/web/src/components/chat/useQueuedRunEdit.ts": 1,
286
+ "apps/web/src/components/chat/useRestingComposerControlsLayout.ts": 1,
287
+ "apps/web/src/components/chat/useRightPanelActions.ts": 1,
288
+ "apps/web/src/components/chat/useSystemComposerBanners.tsx": 1,
289
+ "apps/web/src/components/chat/useThreadFind.ts": 6,
290
+ "apps/web/src/components/chat/useThreadFindNavigation.ts": 5,
291
+ "apps/web/src/components/chat/useThreadFindPositionReader.ts": 1,
292
+ "apps/web/src/components/chat/useThreadLifecycle.tsx": 1,
293
+ "apps/web/src/components/chat/useTimelineFollow.ts": 6,
294
+ "apps/web/src/components/chat/useTimelinePositionRestore.ts": 2,
295
+ "apps/web/src/components/cloud/CloudEnvironmentConnectList.tsx": 3,
296
+ "apps/web/src/components/cloud/ConnectCliAuthSurface.tsx": 1,
297
+ "apps/web/src/components/contextChipParts.tsx": 1,
298
+ "apps/web/src/components/desktop/DesktopAppActivationCoordinator.tsx": 1,
299
+ "apps/web/src/components/desktop/DesktopWebLinkCoordinator.tsx": 1,
300
+ "apps/web/src/components/desktop/SnapShotCoordinator.tsx": 2,
301
+ "apps/web/src/components/desktop/SshPasswordPromptDialog.tsx": 3,
302
+ "apps/web/src/components/device/DeviceAndroidFoldControls.tsx": 2,
303
+ "apps/web/src/components/device/DeviceDuoViewport.tsx": 4,
304
+ "apps/web/src/components/device/DevicePanel.tsx": 1,
305
+ "apps/web/src/components/device/DevicePhoneViewport.tsx": 3,
306
+ "apps/web/src/components/device/DeviceSetup.tsx": 1,
307
+ "apps/web/src/components/device/DeviceStreamView.tsx": 4,
308
+ "apps/web/src/components/device/DeviceToolsPanel.tsx": 1,
309
+ "apps/web/src/components/device/DeviceWorkspace.tsx": 1,
310
+ "apps/web/src/components/device/useDeviceControls.ts": 2,
311
+ "apps/web/src/components/diffs/DiffCommentAnnotation.tsx": 1,
312
+ "apps/web/src/components/diffs/DiffFileLoadingBoundary.tsx": 1,
313
+ "apps/web/src/components/diffs/DiffFileTree.tsx": 3,
314
+ "apps/web/src/components/diffs/useCodeViewFileReveal.ts": 1,
315
+ "apps/web/src/components/diffs/useReviewFilePatches.ts": 1,
316
+ "apps/web/src/components/files/AttachmentFilePreview.tsx": 3,
317
+ "apps/web/src/components/files/BrowserDocumentFrame.tsx": 7,
318
+ "apps/web/src/components/files/FileBrowserPanel.tsx": 9,
319
+ "apps/web/src/components/files/FilePreviewPanel.tsx": 3,
320
+ "apps/web/src/components/files/useDirectoryEntries.ts": 1,
321
+ "apps/web/src/components/files/useFileSaveCoordinator.ts": 2,
322
+ "apps/web/src/components/guest/GuestHtmlRender.tsx": 3,
323
+ "apps/web/src/components/guest/GuestPage.tsx": 7,
324
+ "apps/web/src/components/media/AttachmentImage.tsx": 1,
325
+ "apps/web/src/components/media/MediaVideoPlayer.tsx": 2,
326
+ "apps/web/src/components/onboarding/FirstRunGate.tsx": 3,
327
+ "apps/web/src/components/onboarding/WelcomeWizard.tsx": 7,
328
+ "apps/web/src/components/permissions/usePermissionStatus.ts": 1,
329
+ "apps/web/src/components/preview/AgentBrowserCursor.tsx": 1,
330
+ "apps/web/src/components/preview/PreviewChromeRow.tsx": 1,
331
+ "apps/web/src/components/preview/PreviewPanelShell.tsx": 3,
332
+ "apps/web/src/components/preview/PreviewView.tsx": 7,
333
+ "apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx": 3,
334
+ "apps/web/src/components/preview/ZoomIndicator.tsx": 1,
335
+ "apps/web/src/components/preview/useAgentOpenedPreviews.ts": 3,
336
+ "apps/web/src/components/preview/usePreviewBridge.ts": 2,
337
+ "apps/web/src/components/projectScriptEditor.tsx": 1,
338
+ "apps/web/src/components/promptLinks/HostedPromptLinkLanding.tsx": 1,
339
+ "apps/web/src/components/promptLinks/NewThreadLinkView.tsx": 2,
340
+ "apps/web/src/components/promptLinks/ThreadLinkPrompt.tsx": 1,
341
+ "apps/web/src/components/pullRequest/LinkPullRequestDialog.tsx": 1,
342
+ "apps/web/src/components/pullRequest/PullRequestCodeTab.tsx": 5,
343
+ "apps/web/src/components/pullRequest/PullRequestCommentBody.tsx": 1,
344
+ "apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx": 5,
345
+ "apps/web/src/components/pullRequest/PullRequestGuideTab.tsx": 2,
346
+ "apps/web/src/components/pullRequest/PullRequestsColumn.tsx": 5,
347
+ "apps/web/src/components/pullRequest/PullRequestsPage.tsx": 9,
348
+ "apps/web/src/components/pullRequest/guide/GuideTour.tsx": 1,
349
+ "apps/web/src/components/pullRequest/guide/PullRequestGuideRunCoordinator.tsx": 2,
350
+ "apps/web/src/components/pullRequest/guide/useReviewGuideWriter.ts": 1,
351
+ "apps/web/src/components/pullRequest/useInlineActionConfirm.ts": 1,
352
+ "apps/web/src/components/pullRequest/usePullRequestDetail.ts": 1,
353
+ "apps/web/src/components/pullRequest/usePullRequestFilesViewed.ts": 2,
354
+ "apps/web/src/components/pullRequest/useThreadLinkedPullRequest.ts": 1,
355
+ "apps/web/src/components/search/ProjectContentSearchDialog.tsx": 1,
356
+ "apps/web/src/components/settings/AcpRegistryIcon.tsx": 1,
357
+ "apps/web/src/components/settings/AcpRegistrySearchStep.tsx": 2,
358
+ "apps/web/src/components/settings/AddCodexAccountDialog.tsx": 1,
359
+ "apps/web/src/components/settings/AddEnvironmentDialog.tsx": 1,
360
+ "apps/web/src/components/settings/CliCommandSettingsRow.tsx": 1,
361
+ "apps/web/src/components/settings/CodexSetupSection.tsx": 6,
362
+ "apps/web/src/components/settings/ConnectionDiagnosisDetails.tsx": 1,
363
+ "apps/web/src/components/settings/DiagnosticsSettings.tsx": 2,
364
+ "apps/web/src/components/settings/EasDeviceHostsSettings.tsx": 1,
365
+ "apps/web/src/components/settings/FontFamilyPicker.tsx": 2,
366
+ "apps/web/src/components/settings/OpenSourceLicenses.tsx": 1,
367
+ "apps/web/src/components/settings/ProjectFaviconThumbnail.tsx": 1,
368
+ "apps/web/src/components/settings/ProjectIconPickerDialog.tsx": 1,
369
+ "apps/web/src/components/settings/ProjectSettingsPanel.tsx": 2,
370
+ "apps/web/src/components/settings/ProviderAccentColorPicker.tsx": 3,
371
+ "apps/web/src/components/settings/ProviderAuthCallbackCoordinator.tsx": 1,
372
+ "apps/web/src/components/settings/ProviderAuthTerminal.tsx": 2,
373
+ "apps/web/src/components/settings/ProviderInstanceCard.tsx": 1,
374
+ "apps/web/src/components/settings/ProviderModelsSection.tsx": 1,
375
+ "apps/web/src/components/settings/ProviderSettingsForm.tsx": 1,
376
+ "apps/web/src/components/settings/ResourceTelemetryDiagnostics.tsx": 2,
377
+ "apps/web/src/components/settings/SavedEnvironmentRows.tsx": 1,
378
+ "apps/web/src/components/settings/ScheduledTasksSettings.tsx": 2,
379
+ "apps/web/src/components/settings/SettingsFontPreviews.tsx": 5,
380
+ "apps/web/src/components/settings/SettingsPanels.tsx": 1,
381
+ "apps/web/src/components/settings/SettingsSidebarNav.tsx": 3,
382
+ "apps/web/src/components/settings/SnapShotSettings.tsx": 4,
383
+ "apps/web/src/components/settings/TelemetryExportSettings.tsx": 1,
384
+ "apps/web/src/components/settings/ThemeColorPicker.tsx": 1,
385
+ "apps/web/src/components/settings/ThemeEditorPanel.tsx": 5,
386
+ "apps/web/src/components/settings/ThemeImportDialog.tsx": 1,
387
+ "apps/web/src/components/settings/ThemeSearchSection.tsx": 3,
388
+ "apps/web/src/components/settings/TypographySettings.tsx": 2,
389
+ "apps/web/src/components/settings/settingsLayout.tsx": 1,
390
+ "apps/web/src/components/settings/useSnapShotShortcutRecorder.tsx": 1,
391
+ "apps/web/src/components/sidebar/SidebarProviderUpdatePill.tsx": 2,
392
+ "apps/web/src/components/sidebar/SidebarThreadRow.tsx": 5,
393
+ "apps/web/src/components/sidebar/SidebarThreadUndoNotice.tsx": 1,
394
+ "apps/web/src/components/sidebar/SidebarUpdatePill.tsx": 1,
395
+ "apps/web/src/components/sidebar/mainAppLocation.ts": 1,
396
+ "apps/web/src/components/sidebar/updateEverythingRun.tsx": 2,
397
+ "apps/web/src/components/ui/sidebar.tsx": 3,
398
+ "apps/web/src/components/ui/toast.tsx": 2,
399
+ "apps/web/src/components/ui/tooltip.tsx": 1,
400
+ "apps/web/src/components/usage/UsageLimits.tsx": 1,
401
+ "apps/web/src/components/usage/UsageLimitsPooled.tsx": 1,
402
+ "apps/web/src/components/usage/UsagePage.tsx": 3,
403
+ "apps/web/src/components/usage/UsageProviderChart.tsx": 1,
404
+ "apps/web/src/connection/useDesktopLocalBootstraps.ts": 1,
405
+ "apps/web/src/hooks/FileMetadataThreadProvider.tsx": 1,
406
+ "apps/web/src/hooks/useCopyToClipboard.ts": 1,
407
+ "apps/web/src/hooks/useDefaultTheme.ts": 1,
408
+ "apps/web/src/hooks/useDelayedStatus.ts": 2,
409
+ "apps/web/src/hooks/useEnvironmentDisconnectDelay.ts": 1,
410
+ "apps/web/src/hooks/useEnvironmentTheme.ts": 1,
411
+ "apps/web/src/hooks/useLiveRefresh.ts": 1,
412
+ "apps/web/src/hooks/useLiveRegion.ts": 1,
413
+ "apps/web/src/hooks/useNavigateBack.ts": 1,
414
+ "apps/web/src/hooks/usePreviewPanelInlineSize.ts": 1,
415
+ "apps/web/src/hooks/useProactivePanels.ts": 1,
416
+ "apps/web/src/hooks/useResizableWidth.ts": 2,
417
+ "apps/web/src/hooks/useResizeDrag.ts": 2,
418
+ "apps/web/src/hooks/useSettings.ts": 1,
419
+ "apps/web/src/hooks/useStableCallback.ts": 1,
420
+ "apps/web/src/hooks/useTheme.ts": 1,
421
+ "apps/web/src/hooks/useThreadVisitedMigration.ts": 1,
422
+ "apps/web/src/hooks/useWorkspaceMutationRefresh.ts": 1,
423
+ "apps/web/src/panelAnimations.ts": 2,
424
+ "apps/web/src/remoteOpen.ts": 1,
425
+ "apps/web/src/routes/__root.tsx": 13,
426
+ "apps/web/src/routes/_chat.index.tsx": 1,
427
+ "apps/web/src/routes/_chat.tsx": 1,
428
+ "apps/web/src/shortcutModifierState.ts": 1,
429
+ "apps/web/src/state/olderSettledShelf.ts": 2,
430
+ "apps/web/src/state/pullRequests.ts": 2,
431
+ "apps/web/src/state/queries.ts": 2,
432
+ "apps/web/src/state/threads.ts": 1
433
+}
scripts/install.ps1
+13
-2
@@ -133,8 +133,19 @@ if (-not $version) {
133
"preview" { '^v\d+\.\d+\.\d+-preview\.\d+\.\d+$' }
134
default { Fail "T3CODE_CHANNEL must be stable, nightly, or preview" }
135
}
136
- $releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases?per_page=100" -Headers @{ "User-Agent" = "t3-install" }
137
- $tag = ($releases | Where-Object { -not $_.draft -and $_.tag_name -match $tagPattern } | Select-Object -First 1).tag_name
136
+ if ($channel -eq "stable") {
137
+ # release.yml marks only plain stable releases latest. This is a github.com
138
+ # page, so it is not cut off by a page of newer nightlies or the API quota.
139
+ $release = Invoke-RestMethod -Uri "https://github.com/$repo/releases/latest" -Headers @{ "User-Agent" = "t3-install"; "Accept" = "application/json" }
140
+ $tag = ($release | Where-Object { $_.tag_name -match $tagPattern }).tag_name
141
+ } else {
142
+ $tag = $null
143
+ for ($page = 1; -not $tag -and $page -le 10; $page++) {
144
+ $releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases?per_page=100&page=$page" -Headers @{ "User-Agent" = "t3-install" }
145
+ $tag = ($releases | Where-Object { -not $_.draft -and $_.tag_name -match $tagPattern } | Select-Object -First 1).tag_name
146
+ if (-not $releases) { break }
147
+ }
148
+ }
149
if (-not $tag) { Fail "could not find a $channel release; set T3CODE_VERSION" }
150
$version = $tag.Substring(1)
151
}
scripts/install.sh
+16
-4
@@ -53,14 +53,14 @@ step "Finding your release..."
53
# Exit 44 on a 404 so callers can tell "no such asset" from a network failure.
54
fetch() {
55
if command -v curl >/dev/null 2>&1; then
56
- status="$(curl -sSL -w '%{http_code}' "$1" -o "$2")" || return 1
56
+ status="$(curl -sSL -H "Accept: ${3:-*/*}" -w '%{http_code}' "$1" -o "$2")" || return 1
57
case "$status" in
58
2??) return 0 ;;
59
404) return 44 ;;
60
*) printf 'GET %s returned HTTP %s\n' "$1" "$status" >&2; return 1 ;;
61
esac
62
elif command -v wget >/dev/null 2>&1; then
63
- wget -q --server-response "$1" -O "$2" 2>"$2.headers" && rm -f "$2.headers" && return 0
63
+ wget -q --server-response --header="Accept: ${3:-*/*}" "$1" -O "$2" 2>"$2.headers" && rm -f "$2.headers" && return 0
64
if grep -q ' 404 ' "$2.headers" 2>/dev/null; then rm -f "$2.headers"; return 44; fi
65
cat "$2.headers" >&2; rm -f "$2.headers"; return 1
66
else
@@ -151,8 +151,20 @@ if [ -z "$version" ]; then
151
*) fail "T3CODE_CHANNEL must be stable, nightly, or preview" ;;
152
esac
153
tmp_index="$(mktemp)"
154
- fetch "https://api.github.com/repos/${repo}/releases?per_page=100" "$tmp_index"
155
- version="$(sed -n "s/.*\"tag_name\": *\"${tag_pattern}\".*/\1/p" "$tmp_index" | head -n 1)"
154
+ if [ "$channel" = stable ]; then
155
+ # release.yml marks only plain stable releases latest. This is a github.com
156
+ # page, so it is not cut off by a page of newer nightlies or the API quota.
157
+ fetch "https://github.com/${repo}/releases/latest" "$tmp_index" application/json
158
+ version="$(sed -n "s/.*\"tag_name\": *\"${tag_pattern}\".*/\1/p" "$tmp_index" | head -n 1)"
159
+ else
160
+ page=1
161
+ while [ -z "$version" ] && [ "$page" -le 10 ]; do
162
+ fetch "https://api.github.com/repos/${repo}/releases?per_page=100&page=${page}" "$tmp_index"
163
+ version="$(sed -n "s/.*\"tag_name\": *\"${tag_pattern}\".*/\1/p" "$tmp_index" | head -n 1)"
164
+ grep -q '"tag_name"' "$tmp_index" || break
165
+ page=$((page + 1))
166
+ done
167
+ fi
168
rm -f "$tmp_index"
169
[ -n "$version" ] || fail "could not find a ${channel} release; set T3CODE_VERSION"
170
fi
scripts/install.test.ts
new
+80
@@ -0,0 +1,80 @@
1
+// @effect-diagnostics nodeBuiltinImport:off - Drives the real shell installer against a local GitHub fixture.
2
+import * as HostProcess from "@t3tools/shared/HostProcess";
3
+import * as NodeChildProcess from "node:child_process";
4
+import * as NodeFSP from "node:fs/promises";
5
+import * as NodeHttp from "node:http";
6
+import * as NodeOS from "node:os";
7
+import * as NodePath from "node:path";
8
+import { describe, expect, it } from "vite-plus/test";
9
+
10
+const nightlies = Array.from({ length: 100 }, (_, index) => ({
11
+ tag_name: `v1.2.4-nightly.20261020.${200 - index}`,
12
+}));
13
+
14
+// regression: #22490
15
+describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer channel lookup", () => {
16
+ it.each([
17
+ ["stable", "1.2.3"],
18
+ ["preview", "1.2.4-preview.20261019.50"],
19
+ ])("finds the newest %s release behind a full page of nightlies", async (channel, version) => {
20
+ const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-install-index-"));
21
+ const target = NodePath.join(root, "home/runtime/versions", version);
22
+ const server = NodeHttp.createServer((request, response) => {
23
+ const url = new URL(request.url ?? "/", "http://fixture");
24
+ const body =
25
+ url.pathname === "/pingdotgg/t3code/releases/latest" &&
26
+ request.headers.accept === "application/json"
27
+ ? { tag_name: "v1.2.3" }
28
+ : url.pathname === "/repos/pingdotgg/t3code/releases"
29
+ ? { "1": nightlies, "2": [{ tag_name: `v${version}` }, { tag_name: "v1.2.3" }] }[
30
+ url.searchParams.get("page") ?? ""
31
+ ]
32
+ : undefined;
33
+ if (body === undefined) response.statusCode = 404;
34
+ // The API pretty-prints and the installer reads it line by line.
35
+ response.end(JSON.stringify(body ?? [], null, 2));
36
+ });
37
+ try {
38
+ // An existing completed install isolates release resolution from archive downloads.
39
+ await NodeFSP.mkdir(target, { recursive: true });
40
+ await NodeFSP.writeFile(NodePath.join(target, ".install-complete"), `${version}\n`);
41
+ await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
42
+ const address = server.address();
43
+ if (!address || typeof address === "string") throw new Error("Expected a TCP listener");
44
+ const origin = `http://127.0.0.1:${address.port}`;
45
+ const source = await NodeFSP.readFile(
46
+ NodePath.resolve(import.meta.dirname, "install.sh"),
47
+ "utf8",
48
+ );
49
+ const installer = NodePath.join(root, "install.sh");
50
+ await NodeFSP.writeFile(installer, source.replace(/https:\/\/(api\.)?github\.com/g, origin));
51
+ const { code, output } = await new Promise<{ code: number | null; output: string }>(
52
+ (resolve, reject) => {
53
+ const child = NodeChildProcess.spawn("sh", [installer], {
54
+ env: {
55
+ ...process.env,
56
+ T3CODE_VERSION: "",
57
+ T3CODE_CHANNEL: channel,
58
+ T3CODE_HOME: NodePath.join(root, "home"),
59
+ T3CODE_INSTALL_BIN_DIR: NodePath.join(root, "bin"),
60
+ // A wrong version must fail here instead of downloading a real release.
61
+ T3CODE_RELEASE_BASE_URL: origin,
62
+ },
63
+ stdio: ["ignore", "pipe", "pipe"],
64
+ });
65
+ let output = "";
66
+ child.stdout.on("data", (chunk: Buffer) => (output += chunk.toString()));
67
+ child.stderr.on("data", (chunk: Buffer) => (output += chunk.toString()));
68
+ child.on("error", reject);
69
+ child.on("close", (code) => resolve({ code, output }));
70
+ },
71
+ );
72
+ expect(code, output).toBe(0);
73
+ expect(output).toContain(`Installed T3 Code ${version}`);
74
+ } finally {
75
+ server.closeAllConnections();
76
+ await new Promise<void>((resolve) => server.close(() => resolve()));
77
+ await NodeFSP.rm(root, { recursive: true, force: true });
78
+ }
79
+ });
80
+});
vite.config.ts
+4
@@ -585,6 +585,10 @@ export default defineConfig({
585
files: ["apps/mobile/src/**/*.{ts,tsx}"],
586
rules: { "t3code/no-manual-memo": ["error", { allowMemoHooks: true }] },
587
},
588
+ {
589
+ files: ["apps/web/src/**", "apps/mobile/src/**", "packages/*/src/**"],
590
+ rules: { "t3code/react-effect-budget": "error" },
591
+ },
592
{
593
// React Compiler caches use* functions only if they call a hook.
594
files: ["apps/web/src/**/*.{ts,tsx}", "apps/mobile/src/**/*.{ts,tsx}"],