[codex] Deduplicate connection failure messaging (#4367)
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
719c905eac
commit
315b27385d
4 files changed
+25
-22
No files matched your search
@@ -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.",
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user