fix(mobile): block incompatible server connections (#11974)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-15 15:09:25 -07:00
1 parent e6ae764f47
commit 2c16c1d264
20 files changed
+234 -22

No files matched your search

@@ -35,6 +35,7 @@ function statusDotTone(state: ConnectionStatusDotState): {
haloColor: "rgba(245,158,11,0.5)",
};
case "offline":
case "unsupported":
case "error":
return {
dotColor: "#ef4444",
@@ -16,6 +16,8 @@ function noticeTitle(phase: EnvironmentConnectionPhase, environmentLabel: string
return `Connecting to ${environmentLabel}...`;
case "reconnecting":
return `Reconnecting to ${environmentLabel}...`;
case "unsupported":
return "Client not supported";
case "error":
return `${environmentLabel} is unavailable`;
case "available":
@@ -31,7 +33,7 @@ function noticeDetail(
error: string | null,
): string {
if (error) {
return `The app will keep retrying automatically. ${error}`;
return phase === "reconnecting" ? `The app will keep retrying automatically. ${error}` : error;
}
switch (phase) {
@@ -40,6 +42,8 @@ function noticeDetail(
case "connecting":
case "reconnecting":
return `The ${resourceName} will load as soon as the environment is ready.`;
case "unsupported":
return "Use compatible versions of the app and server to connect.";
case "available":
case "error":
return `Reconnect the environment to load the ${resourceName}.`;
@@ -95,7 +99,7 @@ export function EnvironmentConnectionNotice(props: {
) : null}
</Text>
{props.connection.phase !== "offline" ? (
{props.connection.phase !== "offline" && props.connection.phase !== "unsupported" ? (
<Pressable
accessibilityRole="button"
className="mt-1 rounded-full bg-subtle px-4 py-2.5 active:opacity-70"
@@ -21,6 +21,12 @@ export function connectionTone(state: RemoteClientConnectionState): StatusTone {
pillClassName: "bg-primary/10",
textClassName: "text-foreground-secondary",
};
case "unsupported":
return {
label: "Client not supported",
pillClassName: "bg-danger",
textClassName: "text-danger-foreground",
};
case "error":
return {
label: "Connection failed",
+6 -2
View File
@@ -169,11 +169,15 @@ function deriveEmptyState(props: {
if (
(catalogState.connectionState === "available" ||
catalogState.connectionState === "offline" ||
catalogState.connectionState === "error") &&
catalogState.connectionState === "error" ||
catalogState.connectionState === "unsupported") &&
!catalogState.hasLoadedShellSnapshot
) {
return {
title: "Environment unavailable",
title:
catalogState.connectionState === "unsupported"
? "Client not supported"
: "Environment unavailable",
detail:
catalogState.connectionError ??
"The saved environment is offline. Check the URL or start the environment, then retry.",
@@ -51,6 +51,8 @@ export function connectionFloatingStatus(input: {
};
case "offline":
return unavailable("You are offline");
case "unsupported":
return unavailable("Client not supported");
case "error":
return unavailable(
input.connectionError
+2 -1
View File
@@ -21,7 +21,8 @@ export function deriveAssetUrlState(input: {
if (
input.connectionPhase === "offline" ||
input.connectionPhase === "reconnecting" ||
input.connectionPhase === "error"
input.connectionPhase === "error" ||
input.connectionPhase === "unsupported"
) {
return { _tag: "Failure", reason: "disconnected" };
}
+3
View File
@@ -65,6 +65,9 @@ function overallConnectionState(
if (environments.some((environment) => environment.connectionState === "connecting")) {
return "connecting";
}
if (environments.some((environment) => environment.connectionState === "unsupported")) {
return "unsupported";
}
if (environments.some((environment) => environment.connectionState === "error")) {
return "error";
}
@@ -1,4 +1,5 @@
import * as NodeServices from "@effect/platform-node/NodeServices";
import { ORCHESTRATION_PROTOCOL_VERSION } from "@t3tools/contracts";
import { expect, it } from "@effect/vitest";
import * as Crypto from "effect/Crypto";
import * as Deferred from "effect/Deferred";
@@ -163,6 +164,7 @@ it.layer(NodeServices.layer)("ServerEnvironmentLive", (it) => {
}).pipe(Effect.provide(makeServerEnvironmentLayer(baseDir)));
expect(first.environmentId).toBe(second.environmentId);
expect(first.orchestrationProtocolVersion).toBe(ORCHESTRATION_PROTOCOL_VERSION);
expect(second.capabilities.repositoryIdentity).toBe(true);
expect(second.capabilities.connectionProbe).toBe(true);
expect(second.capabilities.attachmentUploads).toBe(true);
@@ -1,5 +1,6 @@
import {
EnvironmentId,
ORCHESTRATION_PROTOCOL_VERSION,
PROVIDER_SEND_TURN_MAX_FILE_BYTES,
type ExecutionEnvironmentDescriptor,
} from "@t3tools/contracts";
@@ -212,6 +213,7 @@ export const make = Effect.gen(function* () {
...(machine === null ? {} : { machine }),
},
serverVersion: packageJson.version,
orchestrationProtocolVersion: ORCHESTRATION_PROTOCOL_VERSION,
capabilities: {
repositoryIdentity: true,
connectionProbe: true,
@@ -11,6 +11,7 @@ export function connectionPhaseDotClassName(phase: EnvironmentConnectionPhase):
case "connecting":
case "reconnecting":
return "bg-warning";
case "unsupported":
case "error":
return "bg-destructive";
default:
@@ -29,6 +29,7 @@ function normalizeConnectionState(phase: string | undefined): EnvironmentUpdateC
case "connecting":
case "reconnecting":
return "connecting";
case "unsupported":
case "error":
return "error";
case "offline":
@@ -36,9 +36,11 @@ export function presentSavedCloudEnvironmentConnection(
statusText: connectionStatusText(connection),
tone: "connecting",
};
case "unsupported":
case "error":
return {
buttonLabel: "Connection failed",
buttonLabel:
connection.phase === "unsupported" ? "Client not supported" : "Connection failed",
statusText: connectionStatusText(connection),
tone: "error",
};
@@ -1456,6 +1456,8 @@ function savedBackendStatus(environment: EnvironmentPresentation): {
text: connection.error ? `Reconnecting: ${connection.error}` : "Reconnecting",
tone: "error",
};
case "unsupported":
return { text: "Client not supported", tone: "error" };
case "error":
return {
text: connection.error ? `Connection failed: ${connection.error}` : "Connection failed",