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 24, 19:00 UTC
fix(server): bound editor discovery during config loading (#4291)
maria committed
Jul 27, 2026 at 15:18 UTC
6e3b73884bf40eeb2859cb16f1200c8e2f9cf7c3
2 files changed
+30
-1
apps/server/src/server.test.ts
+18
@@ -73,6 +73,7 @@ const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");
73
74
import * as ServerConfig from "./config.ts";
75
import { makeRoutesLayer } from "./server.ts";
76
+import { resolveAvailableEditorsForConfig } from "./ws.ts";
77
import * as CheckpointDiffQuery from "./checkpointing/CheckpointDiffQuery.ts";
78
import * as GitManager from "./git/GitManager.ts";
79
import * as Keybindings from "./keybindings.ts";
@@ -3763,6 +3764,23 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
3764
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
3765
);
3766
3767
+ it.effect("does not block server config when editor discovery never resolves", () =>
3768
+ Effect.gen(function* () {
3769
+ const discoveryInterrupted = yield* Deferred.make<void>();
3770
+ const responseFiber = yield* resolveAvailableEditorsForConfig(
3771
+ Effect.never.pipe(
3772
+ Effect.onInterrupt(() => Deferred.succeed(discoveryInterrupted, undefined)),
3773
+ ),
3774
+ ).pipe(Effect.forkChild);
3775
+
3776
+ yield* TestClock.adjust(Duration.seconds(5));
3777
+
3778
+ const availableEditors = yield* Fiber.join(responseFiber);
3779
+ yield* Deferred.await(discoveryInterrupted);
3780
+ assert.deepEqual(availableEditors, []);
3781
+ }),
3782
+ );
3783
+
3784
it.effect(
3785
"rejects websocket rpc handshake when a session token is only provided via query string",
3786
() =>
apps/server/src/ws.ts
+12
-1
@@ -123,6 +123,15 @@ import * as RelayClient from "@t3tools/shared/relayClient";
123
const isOrchestrationDispatchCommandError = Schema.is(OrchestrationDispatchCommandError);
124
125
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
126
+const EDITOR_DISCOVERY_TIMEOUT = Duration.seconds(5);
127
+
128
+export const resolveAvailableEditorsForConfig = <A, E, R>(
129
+ discovery: Effect.Effect<ReadonlyArray<A>, E, R>,
130
+) =>
131
+ discovery.pipe(
132
+ Effect.timeoutOption(EDITOR_DISCOVERY_TIMEOUT),
133
+ Effect.map(Option.getOrElse(() => [])),
134
+ );
135
136
function unexpectedCompatibilityError(error: never): never {
137
throw new Error(`Unhandled compatibility error: ${String(error)}`);
@@ -1087,7 +1096,9 @@ const makeWsRpcLayer = (
1096
keybindings: keybindingsConfig.keybindings,
1097
issues: keybindingsConfig.issues,
1098
providers,
1090
- availableEditors: yield* externalLauncher.resolveAvailableEditors(),
1099
+ availableEditors: yield* resolveAvailableEditorsForConfig(
1100
+ externalLauncher.resolveAvailableEditors(),
1101
+ ),
1102
observability: {
1103
logsDirectoryPath: config.logsDir,
1104
localTracingEnabled: true,