fix(mobile): incompatible environments now say whether to update the app or the host (#19331)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
5fc1c5cb4c
commit
d10621de5f
6 files changed
+61
-9
No files matched your search
@@ -48,7 +48,7 @@ describe("available cloud environment presentation", () => {
|
||||
}),
|
||||
).toMatchObject({
|
||||
connectionState: "unsupported",
|
||||
statusText: "Client not supported",
|
||||
statusText: expect.stringContaining("Update your app"),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export function availableCloudEnvironmentPresentation(input: {
|
||||
connectionError: compatibilityError.message,
|
||||
connectionErrorTraceId: null,
|
||||
connectionState: "unsupported",
|
||||
statusText: "Client not supported",
|
||||
statusText: compatibilityError.message,
|
||||
};
|
||||
}
|
||||
if (input.status?.status === "online") {
|
||||
|
||||
@@ -2,10 +2,7 @@ import { AppActivityIndicator } from "../../components/AppActivityIndicator";
|
||||
import { ConnectionTraceId } from "./ConnectionTraceId";
|
||||
import { useAuth } from "@clerk/expo";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import {
|
||||
connectionStatusText,
|
||||
type EnvironmentConnectionPhase,
|
||||
} from "@t3tools/client-runtime/connection";
|
||||
import { type EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
|
||||
import {
|
||||
type EnvironmentId,
|
||||
type EnvironmentMachineKind,
|
||||
@@ -26,6 +23,7 @@ import { serverEnvironment } from "../../state/server";
|
||||
import { availableCloudEnvironmentPresentation } from "../cloud/cloudEnvironmentPresentation";
|
||||
import { hasCloudPublicConfig } from "../cloud/publicConfig";
|
||||
import { ConnectionStatusDot } from "./ConnectionStatusDot";
|
||||
import { environmentStatusText } from "./environmentStatusText";
|
||||
import { type RelayEnvironmentView, useConnectionController } from "./useConnectionController";
|
||||
|
||||
interface CloudEnvironmentRowsProps {
|
||||
@@ -307,7 +305,7 @@ function CloudEnvironmentRowShell(props: {
|
||||
const shouldPulse = isRetrying;
|
||||
const statusText =
|
||||
props.statusText ??
|
||||
connectionStatusText({
|
||||
environmentStatusText({
|
||||
phase: props.connectionState,
|
||||
error: props.connectionError,
|
||||
traceId: props.connectionErrorTraceId,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ConnectionTraceId } from "./ConnectionTraceId";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { connectionStatusText } from "@t3tools/client-runtime/connection";
|
||||
import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
|
||||
import { type EnvironmentId, resolveEnvironmentMachineKind } from "@t3tools/contracts";
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
@@ -20,12 +19,13 @@ import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-typ
|
||||
import { serverEnvironment } from "../../state/server";
|
||||
import { ConnectionFormField } from "./ConnectionFormField";
|
||||
import { ConnectionStatusDot } from "./ConnectionStatusDot";
|
||||
import { environmentStatusText } from "./environmentStatusText";
|
||||
|
||||
function connectionStatusLabel(environment: ConnectedEnvironmentSummary): string | null {
|
||||
if (!environment.isEnabled && environment.connectionState !== "unsupported") {
|
||||
return "Off";
|
||||
}
|
||||
return connectionStatusText({
|
||||
return environmentStatusText({
|
||||
phase: environment.connectionState,
|
||||
error: environment.connectionError,
|
||||
traceId: environment.connectionErrorTraceId,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { EnvironmentId, ORCHESTRATION_PROTOCOL_VERSION } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { orchestrationProtocolCompatibilityError } from "@t3tools/client-runtime/connection";
|
||||
|
||||
import { environmentStatusText } from "./environmentStatusText";
|
||||
|
||||
function compatibilityMessage(serverProtocolVersion: number): string {
|
||||
const error = orchestrationProtocolCompatibilityError({
|
||||
environmentId: EnvironmentId.make("environment-preview"),
|
||||
label: "Studio Mac",
|
||||
platform: { os: "darwin", arch: "arm64" },
|
||||
serverVersion: "1.0.0",
|
||||
orchestrationProtocolVersion: serverProtocolVersion,
|
||||
capabilities: { repositoryIdentity: true },
|
||||
});
|
||||
if (error === null) throw new Error("expected an incompatible protocol");
|
||||
return error.message;
|
||||
}
|
||||
|
||||
describe("environment status text", () => {
|
||||
it.each([
|
||||
["a newer server", ORCHESTRATION_PROTOCOL_VERSION + 1, "Update your app"],
|
||||
["an older server", ORCHESTRATION_PROTOCOL_VERSION - 1, "Update T3 Code on Studio Mac"],
|
||||
])("tells the user what to update for %s", (_, serverProtocolVersion, guidance) => {
|
||||
const text = environmentStatusText({
|
||||
phase: "unsupported",
|
||||
error: compatibilityMessage(serverProtocolVersion),
|
||||
traceId: null,
|
||||
});
|
||||
expect(text).toContain(guidance);
|
||||
});
|
||||
|
||||
it("falls back to the generic label when there is no detail", () => {
|
||||
expect(environmentStatusText({ phase: "unsupported", error: null, traceId: null })).toBe(
|
||||
"Client not supported",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import {
|
||||
connectionStatusText,
|
||||
type EnvironmentConnectionPresentation,
|
||||
} from "@t3tools/client-runtime/connection";
|
||||
|
||||
/**
|
||||
* Status line for mobile environment rows. Mobile has no tooltip like web, so
|
||||
* an unsupported environment shows its compatibility detail, which says
|
||||
* whether to update the app or the host.
|
||||
*/
|
||||
export function environmentStatusText(connection: EnvironmentConnectionPresentation): string {
|
||||
return connection.phase === "unsupported" && connection.error !== null
|
||||
? connection.error
|
||||
: connectionStatusText(connection);
|
||||
}
|
||||
Reference in new issue
Block a user