Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
TerminalOpenInput,
} from "@t3tools/contracts";
import {
connectionStatusText,
connectionStatusTitle,
type EnvironmentConnectionPresentation,
} from "@t3tools/client-runtime/connection";
import {
Expand Down Expand Up @@ -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.",
Expand Down
19 changes: 6 additions & 13 deletions apps/web/src/components/chat/ChatComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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}
/>
Expand Down
17 changes: 10 additions & 7 deletions packages/client-runtime/src/connection/presentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
connectionCatalogDisplayUrl,
connectionPhaseMessage,
connectionStatusText,
connectionStatusTitle,
presentEnvironmentConnection,
presentConnectionState,
} from "./presentation.ts";
Expand Down Expand Up @@ -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", () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/client-runtime/src/connection/presentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading