Skip to content

Commit 2eae6f1

Browse files
fix(mobile): block incompatible server connections
1 parent 719a76c commit 2eae6f1

20 files changed

Lines changed: 234 additions & 22 deletions

‎apps/mobile/src/features/connection/ConnectionStatusDot.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function statusDotTone(state: ConnectionStatusDotState): {
3535
haloColor: "rgba(245,158,11,0.5)",
3636
};
3737
case "offline":
38+
case "unsupported":
3839
case "error":
3940
return {
4041
dotColor: "#ef4444",

‎apps/mobile/src/features/connection/EnvironmentConnectionNotice.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ function noticeTitle(phase: EnvironmentConnectionPhase, environmentLabel: string
1616
return `Connecting to ${environmentLabel}...`;
1717
case "reconnecting":
1818
return `Reconnecting to ${environmentLabel}...`;
19+
case "unsupported":
20+
return "Client not supported";
1921
case "error":
2022
return `${environmentLabel} is unavailable`;
2123
case "available":
@@ -31,7 +33,7 @@ function noticeDetail(
3133
error: string | null,
3234
): string {
3335
if (error) {
34-
return `The app will keep retrying automatically. ${error}`;
36+
return phase === "reconnecting" ? `The app will keep retrying automatically. ${error}` : error;
3537
}
3638

3739
switch (phase) {
@@ -40,6 +42,8 @@ function noticeDetail(
4042
case "connecting":
4143
case "reconnecting":
4244
return `The ${resourceName} will load as soon as the environment is ready.`;
45+
case "unsupported":
46+
return "Use compatible versions of the app and server to connect.";
4347
case "available":
4448
case "error":
4549
return `Reconnect the environment to load the ${resourceName}.`;
@@ -95,7 +99,7 @@ export function EnvironmentConnectionNotice(props: {
9599
) : null}
96100
</Text>
97101

98-
{props.connection.phase !== "offline" ? (
102+
{props.connection.phase !== "offline" && props.connection.phase !== "unsupported" ? (
99103
<Pressable
100104
accessibilityRole="button"
101105
className="mt-1 rounded-full bg-subtle px-4 py-2.5 active:opacity-70"

‎apps/mobile/src/features/connection/connectionTone.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export function connectionTone(state: RemoteClientConnectionState): StatusTone {
2121
pillClassName: "bg-primary/10",
2222
textClassName: "text-foreground-secondary",
2323
};
24+
case "unsupported":
25+
return {
26+
label: "Client not supported",
27+
pillClassName: "bg-danger",
28+
textClassName: "text-danger-foreground",
29+
};
2430
case "error":
2531
return {
2632
label: "Connection failed",

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,15 @@ function deriveEmptyState(props: {
169169
if (
170170
(catalogState.connectionState === "available" ||
171171
catalogState.connectionState === "offline" ||
172-
catalogState.connectionState === "error") &&
172+
catalogState.connectionState === "error" ||
173+
catalogState.connectionState === "unsupported") &&
173174
!catalogState.hasLoadedShellSnapshot
174175
) {
175176
return {
176-
title: "Environment unavailable",
177+
title:
178+
catalogState.connectionState === "unsupported"
179+
? "Client not supported"
180+
: "Environment unavailable",
177181
detail:
178182
catalogState.connectionError ??
179183
"The saved environment is offline. Check the URL or start the environment, then retry.",

‎apps/mobile/src/features/threads/floating-working-status.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export function connectionFloatingStatus(input: {
5151
};
5252
case "offline":
5353
return unavailable("You are offline");
54+
case "unsupported":
55+
return unavailable("Client not supported");
5456
case "error":
5557
return unavailable(
5658
input.connectionError

‎apps/mobile/src/state/asset-url-state.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export function deriveAssetUrlState(input: {
2121
if (
2222
input.connectionPhase === "offline" ||
2323
input.connectionPhase === "reconnecting" ||
24-
input.connectionPhase === "error"
24+
input.connectionPhase === "error" ||
25+
input.connectionPhase === "unsupported"
2526
) {
2627
return { _tag: "Failure", reason: "disconnected" };
2728
}

‎apps/mobile/src/state/workspaceModel.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ function overallConnectionState(
6565
if (environments.some((environment) => environment.connectionState === "connecting")) {
6666
return "connecting";
6767
}
68+
if (environments.some((environment) => environment.connectionState === "unsupported")) {
69+
return "unsupported";
70+
}
6871
if (environments.some((environment) => environment.connectionState === "error")) {
6972
return "error";
7073
}

‎apps/server/src/environment/ServerEnvironment.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
2+
import { ORCHESTRATION_PROTOCOL_VERSION } from "@t3tools/contracts";
23
import { expect, it } from "@effect/vitest";
34
import * as Crypto from "effect/Crypto";
45
import * as Deferred from "effect/Deferred";
@@ -163,6 +164,7 @@ it.layer(NodeServices.layer)("ServerEnvironmentLive", (it) => {
163164
}).pipe(Effect.provide(makeServerEnvironmentLayer(baseDir)));
164165

165166
expect(first.environmentId).toBe(second.environmentId);
167+
expect(first.orchestrationProtocolVersion).toBe(ORCHESTRATION_PROTOCOL_VERSION);
166168
expect(second.capabilities.repositoryIdentity).toBe(true);
167169
expect(second.capabilities.connectionProbe).toBe(true);
168170
expect(second.capabilities.attachmentUploads).toBe(true);

‎apps/server/src/environment/ServerEnvironment.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
EnvironmentId,
3+
ORCHESTRATION_PROTOCOL_VERSION,
34
PROVIDER_SEND_TURN_MAX_FILE_BYTES,
45
type ExecutionEnvironmentDescriptor,
56
} from "@t3tools/contracts";
@@ -212,6 +213,7 @@ export const make = Effect.gen(function* () {
212213
...(machine === null ? {} : { machine }),
213214
},
214215
serverVersion: packageJson.version,
216+
orchestrationProtocolVersion: ORCHESTRATION_PROTOCOL_VERSION,
215217
capabilities: {
216218
repositoryIdentity: true,
217219
connectionProbe: true,

‎apps/web/src/components/ConnectionStatusDot.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function connectionPhaseDotClassName(phase: EnvironmentConnectionPhase):
1111
case "connecting":
1212
case "reconnecting":
1313
return "bg-warning";
14+
case "unsupported":
1415
case "error":
1516
return "bg-destructive";
1617
default:

0 commit comments

Comments
 (0)