Skip to content

Commit ed38f7e

Browse files
shivamhwpclaude
andcommitted
fix(web): saved T3 Connect rows follow the runtime's compatibility
A compatible discovery result hid a newer socket rejection on a saved server, and on a server with both direct and relay routes it offered an update based on the relay descriptor alone. Saved rows now read only the runtime's compatibility, which already applies fresh discovery per route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a4b1a7e commit ed38f7e

3 files changed

Lines changed: 32 additions & 39 deletions

File tree

‎apps/web/src/components/cloud/CloudEnvironmentConnectList.browser.test.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const endpoint = {
4646
providerKind: "manual" as const,
4747
};
4848

49-
function setup(selfUpdate: boolean) {
49+
function setup(selfUpdate: boolean, protocol = ORCHESTRATION_PROTOCOL_VERSION - 1) {
5050
discovery.refresh.mockReset().mockResolvedValue(AsyncResult.success(undefined));
5151
discovery.register.mockReset().mockResolvedValue(AsyncResult.success(undefined));
5252
discovery.update.mockReset();
@@ -77,7 +77,7 @@ function setup(selfUpdate: boolean) {
7777
label: "Work laptop",
7878
platform: { os: "linux", arch: "x64" },
7979
serverVersion: "0.0.45",
80-
orchestrationProtocolVersion: ORCHESTRATION_PROTOCOL_VERSION - 1,
80+
orchestrationProtocolVersion: protocol,
8181
capabilities: {
8282
repositoryIdentity: true,
8383
...(selfUpdate ? { serverSelfUpdate: "boot-service" as const } : {}),
@@ -143,4 +143,13 @@ describe("outdated T3 Connect servers", () => {
143143
await expect.element(screen.getByRole("button", { name: "Add" })).toBeDisabled();
144144
expect(discovery.register).not.toHaveBeenCalled();
145145
});
146+
147+
it("keeps a saved server's rejection when discovery reports it compatible", async () => {
148+
setup(false, ORCHESTRATION_PROTOCOL_VERSION);
149+
await using screen = await render(rows([{ ...savedOutdated, entry: {} }]));
150+
await expect
151+
.element(screen.getByRole("button", { name: "Client not supported" }))
152+
.toBeDisabled();
153+
expect(screen.getByRole("button", { name: "Update" }).query()).toBeNull();
154+
});
146155
});

‎apps/web/src/components/cloud/CloudEnvironmentConnectList.tsx‎

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,28 @@ function cloudEnvironmentCompatibility(
5050
saved?: SavedCloudEnvironmentConnection,
5151
) {
5252
const descriptor = status === undefined ? undefined : Option.getOrNull(status)?.descriptor;
53+
// The runtime owns a saved server's compatibility. It knows which route a
54+
// rejection came from and keeps a newer socket rejection over replayed discovery.
55+
if (saved !== undefined) {
56+
const updatable = saved.entry?.serverUpdateRequired === true;
57+
const unsupported = updatable || saved.connection.phase === "unsupported";
58+
return {
59+
descriptor,
60+
unsupported,
61+
updatable,
62+
blocked: unsupported && !updatable,
63+
detail: unsupported ? saved.connection.error : null,
64+
};
65+
}
5366
const error =
5467
descriptor === undefined ? null : orchestrationProtocolCompatibilityError(descriptor);
55-
// Relay discovery cannot clear a rejection from another route to the same environment.
56-
const useSavedCompatibility =
57-
descriptor === undefined ||
58-
(error === null && (saved?.entry?.alternateRoutes?.length ?? 0) > 0);
59-
const unsupported = useSavedCompatibility
60-
? saved?.connection.phase === "unsupported"
61-
: error !== null;
62-
const updatable = useSavedCompatibility
63-
? saved?.entry?.serverUpdateRequired === true
64-
: error?.serverUpdateRequired === true;
68+
const updatable = error?.serverUpdateRequired === true;
6569
return {
6670
descriptor,
67-
unsupported,
71+
unsupported: error !== null,
6872
updatable,
69-
blocked: unsupported && !updatable,
70-
detail: error?.message ?? (unsupported ? saved?.connection.error : null) ?? null,
73+
blocked: error !== null && !updatable,
74+
detail: error?.message ?? null,
7175
};
7276
}
7377

@@ -98,9 +102,7 @@ export interface SavedCloudEnvironmentConnection {
98102
readonly connection: EnvironmentConnectionPresentation;
99103
readonly relayManaged: boolean;
100104
readonly serverConfig?: Pick<ServerConfig, "environment"> | null;
101-
readonly entry?: Partial<
102-
Pick<ConnectionCatalogEntry, "serverUpdateRequired" | "enabled" | "alternateRoutes">
103-
>;
105+
readonly entry?: Partial<Pick<ConnectionCatalogEntry, "serverUpdateRequired" | "enabled">>;
104106
}
105107

106108
function RemoteEnvironmentRowsSkeleton() {
@@ -368,11 +370,7 @@ export function CloudEnvironmentConnectRows({
368370
traceId: null,
369371
})
370372
: savedEnvironment
371-
? presentSavedCloudEnvironmentConnection(
372-
savedEnvironment.connection.phase === "unsupported"
373-
? { phase: "available", error: null, traceId: null }
374-
: savedEnvironment.connection,
375-
)
373+
? presentSavedCloudEnvironmentConnection(savedEnvironment.connection)
376374
: null;
377375
const relayStatus = status === undefined ? null : Option.getOrNull(status);
378376
const updateAction =
@@ -439,13 +437,7 @@ export function CloudEnvironmentConnectRows({
439437
if (checked && !savedEnvironment) {
440438
const connected = await connectEnvironment(environment);
441439
if (!connected) selection.onChange(environment.environmentId, false);
442-
} else if (
443-
checked &&
444-
!unsupported &&
445-
savedEnvironment?.connection.phase !== "unsupported" &&
446-
!savedEnvironment?.entry?.serverUpdateRequired &&
447-
savedEnvironment?.entry?.enabled === false
448-
) {
440+
} else if (checked && !unsupported && savedEnvironment?.entry?.enabled === false) {
449441
const result = await setEnvironmentEnabled({
450442
environmentId: environment.environmentId,
451443
enabled: true,

‎packages/client-runtime/src/connection/outdatedHostUpdate.test.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class OutdatedHostSocket {
152152
}
153153

154154
describe("updateOutdatedHost", () => {
155-
it.effect("checks an outdated host before updating it and switching it back on", () =>
155+
it.effect("refuses a newer host, then updates an outdated one and switches it back on", () =>
156156
Effect.gen(function* () {
157157
const blocked = orchestrationProtocolCompatibilityError(descriptor(undefined, "0.0.45"));
158158
expect(blocked).toMatchObject({ serverUpdateRequired: true });
@@ -207,14 +207,6 @@ describe("updateOutdatedHost", () => {
207207
);
208208

209209
const result = yield* Effect.gen(function* () {
210-
const before = yield* describeOutdatedHost(TARGET.environmentId);
211-
expect(before.serverVersion).toBe("0.0.45");
212-
expect(orchestrationProtocolCompatibilityError(before)).toMatchObject({
213-
serverUpdateRequired: true,
214-
});
215-
expect(sockets).toHaveLength(0);
216-
expect(calls).toEqual([]);
217-
218210
served = descriptor(ORCHESTRATION_PROTOCOL_VERSION + 1, "0.0.99");
219211
const unsupported = orchestrationProtocolCompatibilityError(served);
220212
const futureError = yield* updateOutdatedHost(

0 commit comments

Comments
 (0)