Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
[codex] Deduplicate connection failure messaging (#4367)
Julius Marminge315b27385d7e
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex 43a1a8756..1ef1a7a88 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -22,7 +22,7 @@ import {TerminalOpenInput,} from "@t3tools/contracts";import {- connectionStatusText,+ connectionStatusTitle,type EnvironmentConnectionPresentation,} from "@t3tools/client-runtime/connection";import {@@ -1815,7 +1815,7 @@ function ChatViewContent(props: ChatViewProps) {id: `environment-unavailable:${activeEnvironmentUnavailableState.environmentId}`,variant: connection.phase === "error" ? "error" : "warning",icon: <WifiOffIcon />,- title: `${activeEnvironmentUnavailableState.label}: ${connectionStatusText(connection)}`,+ title: `${activeEnvironmentUnavailableState.label}: ${connectionStatusTitle(connection)}`,description:connection.error ??"Reconnect this environment before sending messages or running actions.",diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsxindex 2fc688678..b427037bd 100644--- a/apps/web/src/components/chat/ChatComposer.tsx+++ b/apps/web/src/components/chat/ChatComposer.tsx@@ -18,10 +18,7 @@ import {PROVIDER_SEND_TURN_MAX_ATTACHMENTS,PROVIDER_SEND_TURN_MAX_IMAGE_BYTES,} from "@t3tools/contracts";-import {- connectionStatusText,- type EnvironmentConnectionPresentation,-} from "@t3tools/client-runtime/connection";+import type { EnvironmentConnectionPresentation } from "@t3tools/client-runtime/connection";import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model";import {@@ -2577,15 +2574,11 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)? "Add feedback to refine the plan, or leave this blank to implement it": projectSelectionRequired? "Choose a project above to start a thread"- : environmentUnavailable- ? `${environmentUnavailable.label}: ${connectionStatusText(- environmentUnavailable.connection,- )}`- : noProviderAvailable- ? "Enable a provider in Settings to send a message"- : phase === "disconnected"- ? "Ask for follow-up changes or attach images"- : "Ask anything, @tag files/folders, $use skills, or / for commands"+ : noProviderAvailable+ ? "Enable a provider in Settings to send a message"+ : phase === "disconnected"+ ? "Ask for follow-up changes or attach images"+ : "Ask anything, @tag files/folders, $use skills, or / for commands"}disabled={isConnecting || isComposerApprovalState || projectSelectionRequired}/>diff --git a/packages/client-runtime/src/connection/presentation.test.ts b/packages/client-runtime/src/connection/presentation.test.tsindex 354b003a2..e13638a2b 100644--- a/packages/client-runtime/src/connection/presentation.test.ts+++ b/packages/client-runtime/src/connection/presentation.test.ts@@ -12,6 +12,7 @@ import {connectionCatalogDisplayUrl,connectionPhaseMessage,connectionStatusText,+ connectionStatusTitle,presentEnvironmentConnection,presentConnectionState,} from "./presentation.ts";@@ -123,13 +124,15 @@ describe("connection presentation", () => {});it("combines reconnect progress with the latest failure", () => {- expect(- connectionStatusText({- phase: "reconnecting",- error: "Relay request timed out.",- traceId: "trace-retry",- }),- ).toBe("Failed to connect. Reconnecting... Reason: Relay request timed out.");+ const connection = {+ phase: "reconnecting",+ error: "Relay request timed out.",+ traceId: "trace-retry",+ } as const;+ expect(connectionStatusText(connection)).toBe(+ "Failed to connect. Reconnecting... Reason: Relay request timed out.",+ );+ expect(connectionStatusTitle(connection)).toBe("Failed to connect. Reconnecting...");});it("presents the supervisor's offline state without consulting shell state", () => {diff --git a/packages/client-runtime/src/connection/presentation.ts b/packages/client-runtime/src/connection/presentation.tsindex ec7687dfe..168443dec 100644--- a/packages/client-runtime/src/connection/presentation.ts+++ b/packages/client-runtime/src/connection/presentation.ts@@ -76,6 +76,13 @@ export function connectionStatusText(connection: EnvironmentConnectionPresentati}}+export function connectionStatusTitle(connection: EnvironmentConnectionPresentation): string {+ if (connection.phase === "reconnecting" && connection.error) {+ return "Failed to connect. Reconnecting...";+ }+ return connectionStatusText({ ...connection, error: null });+}+export function presentEnvironmentConnection(state: SupervisorConnectionState,): EnvironmentConnectionPresentation {