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
perf: opening a thread loads 85% less data (#24899)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 25, 2026 at 14:01 UTC
abd9d9f9709b8873f542f53dd12d26b33690d5e1
16 files changed
+615
-28
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/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/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/ProviderRegistry.test.ts
+92
@@ -1246,6 +1246,98 @@ it.layer(
1246
);
1247
});
1248
1249
+ it.effect(
1250
+ "a second request for a cwd being scanned gets its result, even if the first leaves",
1251
+ () =>
1252
+ Effect.gen(function* () {
1253
+ const driver = ProviderDriverKind.make("codex");
1254
+ const instanceId = ProviderInstanceId.make("codex");
1255
+ const provider = {
1256
+ instanceId,
1257
+ driver,
1258
+ status: "ready",
1259
+ enabled: true,
1260
+ installed: true,
1261
+ auth: { status: "authenticated" },
1262
+ checkedAt: "2026-06-10T00:00:00.000Z",
1263
+ version: "1.0.0",
1264
+ models: [],
1265
+ slashCommands: [],
1266
+ skills: [],
1267
+ } as const satisfies ServerProvider;
1268
+ const scanStarted = yield* Deferred.make<void>();
1269
+ const releaseScan = yield* Deferred.make<void>();
1270
+ const scans = yield* Ref.make(0);
1271
+ const instance: ProviderInstance = {
1272
+ instanceId,
1273
+ driverKind: driver,
1274
+ continuationIdentity: { driverKind: driver, continuationKey: "codex:instance:codex" },
1275
+ displayName: undefined,
1276
+ enabled: true,
1277
+ snapshot: {
1278
+ resolveMaintenance: () =>
1279
+ Effect.succeed(
1280
+ makeManualOnlyProviderMaintenanceCapabilities({
1281
+ provider: driver,
1282
+ packageName: null,
1283
+ }),
1284
+ ),
1285
+ getSnapshot: Effect.succeed(provider),
1286
+ refresh: Effect.succeed(provider),
1287
+ streamChanges: Stream.empty,
1288
+ applyUsageLimits: () => Effect.void,
1289
+ },
1290
+ snapshotForCwd: () =>
1291
+ Ref.update(scans, (count) => count + 1).pipe(
1292
+ Effect.andThen(Deferred.succeed(scanStarted, undefined)),
1293
+ Effect.andThen(Deferred.await(releaseScan)),
1294
+ Effect.as(provider),
1295
+ ),
1296
+ orchestrationAdapter: {} as ProviderInstance["orchestrationAdapter"],
1297
+ textGeneration: {} as ProviderInstance["textGeneration"],
1298
+ };
1299
+ const layerInstanceRegistry = Layer.succeed(
1300
+ ProviderInstanceRegistry.ProviderInstanceRegistry,
1301
+ {
1302
+ getInstance: (requestedId) =>
1303
+ Effect.succeed(requestedId === instanceId ? instance : undefined),
1304
+ listInstances: Effect.succeed([instance]),
1305
+ listUnavailable: Effect.succeed([]),
1306
+ streamChanges: Stream.empty,
1307
+ subscribeChanges: Effect.flatMap(PubSub.unbounded<void>(), PubSub.subscribe),
1308
+ },
1309
+ );
1310
+ const scope = yield* Scope.make();
1311
+ yield* Effect.addFinalizer(() => Scope.close(scope, Exit.void));
1312
+ const runtimeServices = yield* Layer.build(
1313
+ ProviderRegistry.layer.pipe(
1314
+ Layer.provideMerge(layerInstanceRegistry),
1315
+ Layer.provideMerge(
1316
+ ServerConfig.layerTest(process.cwd(), {
1317
+ prefix: "t3-provider-registry-shared-workspace-scan-",
1318
+ }),
1319
+ ),
1320
+ Layer.provideMerge(NodeServices.layer),
1321
+ ),
1322
+ ).pipe(Scope.provide(scope));
1323
+
1324
+ yield* Effect.gen(function* () {
1325
+ const registry = yield* ProviderRegistry.ProviderRegistry;
1326
+ const refresh = registry.refreshWorkspaceSnapshot({ instanceId, cwd: "/workspace" });
1327
+ const first = yield* Effect.forkChild(refresh);
1328
+ yield* Deferred.await(scanStarted);
1329
+ const second = yield* Effect.forkChild(refresh, { startImmediately: true });
1330
+ yield* Fiber.interrupt(first);
1331
+ yield* Deferred.succeed(releaseScan, undefined);
1332
+ assert.deepStrictEqual(
1333
+ (yield* Fiber.join(second))[0]?.workspaceSnapshots?.map((snapshot) => snapshot.cwd),
1334
+ ["/workspace"],
1335
+ );
1336
+ assert.strictEqual(yield* Ref.get(scans), 1);
1337
+ }).pipe(Effect.provide(runtimeServices));
1338
+ }),
1339
+ );
1340
+
1341
it.effect("publishes workspace skills while machine health is in error", () =>
1342
Effect.gen(function* () {
1343
const driver = ProviderDriverKind.make("codex");
apps/server/src/provider/ProviderRegistry.ts
+29
-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";
@@ -405,7 +406,7 @@ export const layer = Layer.effect(
406
cachedProviders.map((provider) => classifyCompatibility(provider, initialManifest)),
407
);
408
const workspaceRefreshesRef = yield* Ref.make<
408
- ReadonlyMap<ProviderInstance, ReadonlyMap<string, symbol>>
409
+ ReadonlyMap<ProviderInstance, ReadonlyMap<string, Deferred.Deferred<void>>>
410
>(new Map());
411
const maintenanceActionStatesRef = yield* Ref.make<
412
ReadonlyMap<ProviderInstanceId, { readonly update?: ServerProviderUpdateState | undefined }>
@@ -922,21 +923,13 @@ export const layer = Layer.effect(
923
const scannedAt = DateTime.formatIso(now);
924
const instance = yield* instanceRegistry.getInstance(input.instanceId);
925
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);
926
+ const token = yield* Deferred.make<void>();
927
const refreshMachineSnapshot = input.fresh
928
? (instance.invalidateCaches ?? Effect.void).pipe(
929
Effect.andThen(refreshInstance(input.instanceId)),
930
)
931
: Effect.void;
939
- return yield* refreshMachineSnapshot.pipe(
932
+ const runScan = refreshMachineSnapshot.pipe(
933
Effect.andThen(instance.snapshotForCwd(input.cwd)),
934
// Scans fail on error; returned inventory remains valid even when provider health reports an error.
935
Effect.flatMap((scopedSnapshot) =>
@@ -974,9 +967,33 @@ export const layer = Layer.effect(
967
if (nextCwds.size) next.set(instance, nextCwds);
968
else next.delete(instance);
969
return next;
977
- }),
970
+ }).pipe(Effect.andThen(Deferred.succeed(token, undefined))),
971
),
972
);
973
+ // The claim and the fork happen together, so the token is always completed. The scan is
974
+ // detached so a disconnecting owner cannot cancel the result its waiters depend on.
975
+ const claim = yield* Effect.uninterruptible(
976
+ Effect.gen(function* () {
977
+ const inFlight = yield* Ref.modify(workspaceRefreshesRef, (refreshes) => {
978
+ const current = refreshes.get(instance);
979
+ const running = current?.get(input.cwd);
980
+ if (!input.fresh && running) return [running, refreshes] as const;
981
+ const next = new Map(refreshes);
982
+ next.set(instance, new Map(current).set(input.cwd, token));
983
+ return [undefined, next] as const;
984
+ });
985
+ if (inFlight) return { inFlight } as const;
986
+ return {
987
+ // Starting now attaches the scan's `ensuring` before anything can close the scope.
988
+ scan: yield* Effect.forkIn(runScan, serviceScope, { startImmediately: true }),
989
+ } as const;
990
+ }),
991
+ );
992
+ // Wait for the running scan: on-demand clients get its result only in this reply.
993
+ if ("inFlight" in claim) {
994
+ return yield* Deferred.await(claim.inFlight).pipe(Effect.andThen(Ref.get(providersRef)));
995
+ }
996
+ return yield* Fiber.join(claim.scan);
997
});
998
999
return {
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/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);
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]),