Skip to content

Commit 0c5a109

Browse files
t3dotggclaude
andcommitted
fix(mobile): incompatible environments say whether to update the app or the host
Mobile Environments rows showed only "Client not supported" for an incompatible environment. Web shows the compatibility sentence in a tooltip, but mobile has no tooltip, so the guidance was lost. Mobile rows now show that sentence, falling back to the generic label when there is no detail. Fixes #15835 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3213a0c commit 0c5a109

6 files changed

Lines changed: 61 additions & 9 deletions

File tree

‎apps/mobile/src/features/cloud/cloudEnvironmentPresentation.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("available cloud environment presentation", () => {
4848
}),
4949
).toMatchObject({
5050
connectionState: "unsupported",
51-
statusText: "Client not supported",
51+
statusText: expect.stringContaining("Update your app"),
5252
});
5353
});
5454

‎apps/mobile/src/features/cloud/cloudEnvironmentPresentation.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function availableCloudEnvironmentPresentation(input: {
2727
connectionError: compatibilityError.message,
2828
connectionErrorTraceId: null,
2929
connectionState: "unsupported",
30-
statusText: "Client not supported",
30+
statusText: compatibilityError.message,
3131
};
3232
}
3333
if (input.status?.status === "online") {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { AppActivityIndicator } from "../../components/AppActivityIndicator";
22
import { ConnectionTraceId } from "./ConnectionTraceId";
33
import { useAuth } from "@clerk/expo";
44
import { SymbolView } from "../../components/AppSymbol";
5-
import {
6-
connectionStatusText,
7-
type EnvironmentConnectionPhase,
8-
} from "@t3tools/client-runtime/connection";
5+
import { type EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
96
import {
107
type EnvironmentId,
118
type EnvironmentMachineKind,
@@ -26,6 +23,7 @@ import { serverEnvironment } from "../../state/server";
2623
import { availableCloudEnvironmentPresentation } from "../cloud/cloudEnvironmentPresentation";
2724
import { hasCloudPublicConfig } from "../cloud/publicConfig";
2825
import { ConnectionStatusDot } from "./ConnectionStatusDot";
26+
import { environmentStatusText } from "./environmentStatusText";
2927
import { type RelayEnvironmentView, useConnectionController } from "./useConnectionController";
3028

3129
interface CloudEnvironmentRowsProps {
@@ -307,7 +305,7 @@ function CloudEnvironmentRowShell(props: {
307305
const shouldPulse = isRetrying;
308306
const statusText =
309307
props.statusText ??
310-
connectionStatusText({
308+
environmentStatusText({
311309
phase: props.connectionState,
312310
error: props.connectionError,
313311
traceId: props.connectionErrorTraceId,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ConnectionTraceId } from "./ConnectionTraceId";
22
import { SymbolView } from "../../components/AppSymbol";
3-
import { connectionStatusText } from "@t3tools/client-runtime/connection";
43
import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
54
import { type EnvironmentId, resolveEnvironmentMachineKind } from "@t3tools/contracts";
65
import { useAtomValue } from "@effect/atom-react";
@@ -20,12 +19,13 @@ import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-typ
2019
import { serverEnvironment } from "../../state/server";
2120
import { ConnectionFormField } from "./ConnectionFormField";
2221
import { ConnectionStatusDot } from "./ConnectionStatusDot";
22+
import { environmentStatusText } from "./environmentStatusText";
2323

2424
function connectionStatusLabel(environment: ConnectedEnvironmentSummary): string | null {
2525
if (!environment.isEnabled && environment.connectionState !== "unsupported") {
2626
return "Off";
2727
}
28-
return connectionStatusText({
28+
return environmentStatusText({
2929
phase: environment.connectionState,
3030
error: environment.connectionError,
3131
traceId: environment.connectionErrorTraceId,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { EnvironmentId, ORCHESTRATION_PROTOCOL_VERSION } from "@t3tools/contracts";
2+
import { describe, expect, it } from "vite-plus/test";
3+
4+
import { orchestrationProtocolCompatibilityError } from "@t3tools/client-runtime/connection";
5+
6+
import { environmentStatusText } from "./environmentStatusText";
7+
8+
function compatibilityMessage(serverProtocolVersion: number): string {
9+
const error = orchestrationProtocolCompatibilityError({
10+
environmentId: EnvironmentId.make("environment-preview"),
11+
label: "Studio Mac",
12+
platform: { os: "darwin", arch: "arm64" },
13+
serverVersion: "1.0.0",
14+
orchestrationProtocolVersion: serverProtocolVersion,
15+
capabilities: { repositoryIdentity: true },
16+
});
17+
if (error === null) throw new Error("expected an incompatible protocol");
18+
return error.message;
19+
}
20+
21+
describe("environment status text", () => {
22+
it.each([
23+
["a newer server", ORCHESTRATION_PROTOCOL_VERSION + 1, "Update your app"],
24+
["an older server", ORCHESTRATION_PROTOCOL_VERSION - 1, "Update T3 Code on Studio Mac"],
25+
])("tells the user what to update for %s", (_, serverProtocolVersion, guidance) => {
26+
const text = environmentStatusText({
27+
phase: "unsupported",
28+
error: compatibilityMessage(serverProtocolVersion),
29+
traceId: null,
30+
});
31+
expect(text).toContain(guidance);
32+
});
33+
34+
it("falls back to the generic label when there is no detail", () => {
35+
expect(environmentStatusText({ phase: "unsupported", error: null, traceId: null })).toBe(
36+
"Client not supported",
37+
);
38+
});
39+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {
2+
connectionStatusText,
3+
type EnvironmentConnectionPresentation,
4+
} from "@t3tools/client-runtime/connection";
5+
6+
/**
7+
* Status line for mobile environment rows. Mobile has no tooltip like web, so
8+
* an unsupported environment shows its compatibility detail, which says
9+
* whether to update the app or the host.
10+
*/
11+
export function environmentStatusText(connection: EnvironmentConnectionPresentation): string {
12+
return connection.phase === "unsupported" && connection.error !== null
13+
? connection.error
14+
: connectionStatusText(connection);
15+
}

0 commit comments

Comments
 (0)