@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 32 lines 1.05 KB
Raw
1 import {
2 connectionErrorText,
3 connectionStatusText,
4 type EnvironmentConnectionPresentation,
5 } from "@t3tools/client-runtime/connection";
6 import type { MarkedText } from "@t3tools/client-runtime/errors";
7
8 import { m, type MessageResolver } from "../../i18n/messages";
9
10 /** Connection error text from runtime state, in the current language when the error is marked. */
11 export function runtimeConnectionErrorText(
12 state: { readonly connectionError: string | null; readonly i18nConnectionError?: MarkedText },
13 resolve: MessageResolver = m,
14 ): string | null {
15 return connectionErrorText(
16 {
17 error: state.connectionError,
18 ...(state.i18nConnectionError === undefined ? {} : { i18nError: state.i18nConnectionError }),
19 },
20 resolve,
21 );
22 }
23
24 export function environmentStatusText(
25 connection: EnvironmentConnectionPresentation,
26 resolve: MessageResolver = m,
27 ): string {
28 const error = connectionErrorText(connection, resolve);
29 return connection.phase === "unsupported" && error !== null
30 ? error
31 : connectionStatusText(connection, resolve);
32 }