Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

feat(web): word Agent and local Runtime status from TeamHub's codes

yunhe5b77390802f5
diff --git a/apps/web/src/features/local-computer/agent-availability.ts b/apps/web/src/features/local-computer/agent-availability.ts
index 59897649..f796d767 100644
--- a/apps/web/src/features/local-computer/agent-availability.ts
+++ b/apps/web/src/features/local-computer/agent-availability.ts
@@ -14,7 +14,10 @@ import { computersMessages } from "./computers.messages";
export interface AgentAvailability {
readonly available: boolean;
readonly activeTaskCount: number;
+ /** TeamHub's English label, the fallback when `reason` is unknown. */
readonly label: string;
+ /** Why the Agent has its status, worded on the client. */
+ readonly reason?: TeamHubTenantAgentAvailabilitySnapshot["availability"]["reason"];
readonly status: TeamHubTenantAgentAvailabilitySnapshot["availability"]["status"];
readonly currentActivity?: TeamHubTenantAgentAvailabilitySnapshot["availability"]["current_activity"];
/** Which AI app and Computer state TeamHub derived the availability from. */
@@ -45,6 +48,7 @@ export function projectAgentAvailabilitySnapshots(
currentActivity: snapshot.availability.current_activity,
label: snapshot.availability.label,
localRuntimeStatus: snapshot.local_runtime_status,
+ reason: snapshot.availability.reason,
status: snapshot.availability.status,
});
}
diff --git a/apps/web/src/features/local-computer/computer-agent-chips.tsx b/apps/web/src/features/local-computer/computer-agent-chips.tsx
index ec3ecb5a..0aec430b 100644
--- a/apps/web/src/features/local-computer/computer-agent-chips.tsx
+++ b/apps/web/src/features/local-computer/computer-agent-chips.tsx
@@ -3,6 +3,10 @@ import { useState } from "react";
import { Icon } from "@/components/ui/icon";
import { ActorAvatar } from "@/features/rooms/members/actor-avatar";
+import {
+ availabilityLabel,
+ availabilitySummary,
+} from "@/features/rooms/members/agent-availability-text";
import type { TeamHubTenantAgent } from "@/features/teamhub/teamhub-types";
import type { Translate } from "@/i18n/language";
import { useT } from "@/i18n/use-translation";
@@ -166,11 +170,18 @@ function availabilityText(
availability.localRuntimeStatus?.runtime_type ??
agent.runtime.placement?.runtime_type;
const app = runtimeType ? appNames[runtimeType] : undefined;
- const reason = availability.currentActivity?.summary;
+ const wording = {
+ current_activity: availability.currentActivity,
+ label: availability.label,
+ reason: availability.reason,
+ status: availability.status,
+ };
+ const label = availabilityLabel(wording, t);
+ const reason = availabilitySummary(wording, t);
if (availability.status === "online") {
const tasks = availability.activeTaskCount;
return [
- availability.label,
+ label,
app,
tasks ? t(computersMessages.tasksRunning, { count: tasks }) : null,
]
@@ -178,6 +189,6 @@ function availabilityText(
.join(" · ");
}
if (needsSignIn(availability) && app)
- return `${availability.label} · ${t(computersMessages.appSignInNeeded, { app })}`;
- return reason ? `${availability.label} · ${reason}` : availability.label;
+ return `${label} · ${t(computersMessages.appSignInNeeded, { app })}`;
+ return reason ? `${label} · ${reason}` : label;
}
diff --git a/apps/web/src/features/local-computer/computer-detail.tsx b/apps/web/src/features/local-computer/computer-detail.tsx
index 1cc9e847..7e3e3726 100644
--- a/apps/web/src/features/local-computer/computer-detail.tsx
+++ b/apps/web/src/features/local-computer/computer-detail.tsx
@@ -63,6 +63,7 @@ import { relativeTime } from "./computer-relative-time";
import { ComputerRow, ProgressChip, RowMark, StatusDot } from "./computer-row";
import { computersMessages } from "./computers.messages";
import { isUpgradeRecommended } from "./computer-version";
+import { localRuntimeMessage } from "./local-runtime-message";
type LocalComputer = TeamHubLocalComputerPage["items"][number];
interface AppSetup {
@@ -731,8 +732,9 @@ function runtimeMessage(
app: TeamHubLocalRuntimeType,
t: Translate,
) {
+ const runtime = computer.runtimes.find((item) => item.type === app);
return (
- computer.runtimes.find((item) => item.type === app)?.message ??
+ (runtime && localRuntimeMessage(runtime, app, computer.display_name, t)) ??
t(computersMessages.couldNotCheckApp, { app: appNames[app] })
);
}
diff --git a/apps/web/src/features/local-computer/local-runtime-message.messages.ts b/apps/web/src/features/local-computer/local-runtime-message.messages.ts
new file mode 100644
index 00000000..a388f4a5
--- /dev/null
+++ b/apps/web/src/features/local-computer/local-runtime-message.messages.ts
@@ -0,0 +1,15 @@
+import { defineMessages } from "@/i18n/messages";
+
+/**
+ * Why an AI app on a Computer cannot run, worded from the `error_code`
+ * TeamHub sends beside its English `message`.
+ */
+export const localRuntimeMessageMessages = defineMessages(
+ "localRuntimeMessage",
+ {
+ notInstalled: "{app} is not installed on {computer}.",
+ signInRequired: "{app} on {computer} needs you to sign in.",
+ needsUpdate: "{computer} needs an update to run {app}.",
+ computerOffline: "{computer} is offline.",
+ },
+);
diff --git a/apps/web/src/features/local-computer/local-runtime-message.test.ts b/apps/web/src/features/local-computer/local-runtime-message.test.ts
new file mode 100644
index 00000000..86d17d63
--- /dev/null
+++ b/apps/web/src/features/local-computer/local-runtime-message.test.ts
@@ -0,0 +1,73 @@
+import { afterEach, describe, expect, it } from "vitest";
+
+import { resetLanguageForTest, setLanguage, translate } from "@/i18n/language";
+import zhCN from "@/i18n/locales/zh-CN.json";
+
+import { localRuntimeMessage } from "./local-runtime-message";
+
+afterEach(() => resetLanguageForTest());
+
+describe("localRuntimeMessage", () => {
+ it("words a known code in the interface language", async () => {
+ await setLanguage("zh-CN");
+ expect(
+ localRuntimeMessage(
+ {
+ error_code: "RUNTIME_NOT_INSTALLED",
+ message: "Runtime executable not found",
+ },
+ "codex",
+ "Studio Mac",
+ translate,
+ ),
+ ).toBe(
+ zhCN.localRuntimeMessage.notInstalled
+ .replace("{computer}", "Studio Mac")
+ .replace("{app}", "Codex"),
+ );
+ });
+
+ it("words a known code in English", () => {
+ expect(
+ localRuntimeMessage(
+ {
+ error_code: "LOCAL_COMPUTER_OFFLINE",
+ message: "Local Computer is offline",
+ },
+ "claude",
+ "Studio Mac",
+ translate,
+ ),
+ ).toBe("Studio Mac is offline.");
+ });
+
+ it("keeps the Runtime's diagnostic as TeamHub sent it", async () => {
+ await setLanguage("zh-CN");
+ expect(
+ localRuntimeMessage(
+ {
+ error_code: "RUNTIME_DIAGNOSTIC_FAILED",
+ message: "Claude authentication status probe failed",
+ },
+ "claude",
+ "Studio Mac",
+ translate,
+ ),
+ ).toBe("Claude authentication status probe failed");
+ });
+
+ it("falls back to TeamHub's English for an unknown or missing code", async () => {
+ await setLanguage("zh-CN");
+ expect(
+ localRuntimeMessage(
+ { error_code: "RUNTIME_QUOTA_EXCEEDED", message: "Quota exceeded" },
+ "pi",
+ "Studio Mac",
+ translate,
+ ),
+ ).toBe("Quota exceeded");
+ expect(
+ localRuntimeMessage({}, "pi", "Studio Mac", translate),
+ ).toBeUndefined();
+ });
+});
diff --git a/apps/web/src/features/local-computer/local-runtime-message.ts b/apps/web/src/features/local-computer/local-runtime-message.ts
new file mode 100644
index 00000000..d1198963
--- /dev/null
+++ b/apps/web/src/features/local-computer/local-runtime-message.ts
@@ -0,0 +1,32 @@
+import type { TeamHubLocalRuntimeType } from "@/features/teamhub/teamhub-types";
+import type { Translate } from "@/i18n/language";
+
+import { appNames } from "./computer-readiness";
+import { localRuntimeMessageMessages as m } from "./local-runtime-message.messages";
+
+/**
+ * The sentence for a local Runtime status: worded by its error code, or the
+ * English message TeamHub sent when the code is unknown or missing.
+ * RUNTIME_DIAGNOSTIC_FAILED carries the Runtime's own diagnostic, so it keeps
+ * the message as sent.
+ */
+export function localRuntimeMessage(
+ status: { readonly error_code?: string; readonly message?: string },
+ runtimeType: TeamHubLocalRuntimeType,
+ computer: string,
+ t: Translate,
+): string | undefined {
+ const app = appNames[runtimeType];
+ switch (status.error_code) {
+ case "RUNTIME_NOT_INSTALLED":
+ return t(m.notInstalled, { app, computer });
+ case "RUNTIME_AUTHENTICATION_REQUIRED":
+ return t(m.signInRequired, { app, computer });
+ case "RUNTIME_INCOMPATIBLE":
+ return t(m.needsUpdate, { app, computer });
+ case "LOCAL_COMPUTER_OFFLINE":
+ return t(m.computerOffline, { computer });
+ default:
+ return status.message;
+ }
+}
diff --git a/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsx b/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsx
index f413352b..1efb550d 100644
--- a/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsx
+++ b/apps/web/src/features/rooms/chat/room-chat-direct-rooms.test.tsx
@@ -190,7 +190,9 @@ describe("Room Chat", () => {
testQueryClient(),
"/t/tenant-northstar/rooms/room-dm-codex/chat",
);
- expect(await screen.findByText("Local Computer is offline")).toBeVisible();
+ expect(
+ await screen.findByText("Offline computer is offline."),
+ ).toBeVisible();
expect(screen.getByText("Agent unavailable")).toBeVisible();
expect(screen.getByLabelText("Message Room")).toBeEnabled();
});
diff --git a/apps/web/src/features/rooms/chat/room-composer-dock.tsx b/apps/web/src/features/rooms/chat/room-composer-dock.tsx
index d96c2dd9..03689cbc 100644
--- a/apps/web/src/features/rooms/chat/room-composer-dock.tsx
+++ b/apps/web/src/features/rooms/chat/room-composer-dock.tsx
@@ -7,6 +7,7 @@ import type { PropsWithChildren } from "react";
import { Button } from "@/components/ui/button";
import { StatusDot } from "@/features/local-computer/computer-row";
import { LocalRuntimeAuthenticationGuidance } from "@/features/local-computer/local-runtime-authentication-guidance";
+import { localRuntimeMessage } from "@/features/local-computer/local-runtime-message";
import type {
TeamHubRoom,
TeamHubTenantAgent,
@@ -187,8 +188,13 @@ function LocalRuntimeAttentionNotice({
computerName={status.display_name}
/>
) : (
- <p className="mt-1 text-app-muted">
- {status.message ?? t(composerMessages.checkLocalRuntime)}
+ <p className="mt-1 text-app-muted" title={status.message}>
+ {localRuntimeMessage(
+ status,
+ status.runtime_type,
+ status.display_name,
+ t,
+ ) ?? t(composerMessages.checkLocalRuntime)}
</p>
)}
<p className="mt-1 text-app-muted">
diff --git a/apps/web/src/features/rooms/members/agent-availability-text.ts b/apps/web/src/features/rooms/members/agent-availability-text.ts
new file mode 100644
index 00000000..99758899
--- /dev/null
+++ b/apps/web/src/features/rooms/members/agent-availability-text.ts
@@ -0,0 +1,60 @@
+import type { TeamHubTenantAgentAvailabilitySnapshot } from "@/features/teamhub/teamhub-types";
+import type { Translate } from "@/i18n/language";
+import type { Message } from "@/i18n/messages";
+
+import { agentAvailabilityMessages } from "./agent-availability.messages";
+import { agentInfoMessages } from "./agent-info.messages";
+
+type Availability = TeamHubTenantAgentAvailabilitySnapshot["availability"];
+type AvailabilityReason = NonNullable<Availability["reason"]>;
+
+// TeamHub words the same states in English in `label` and the summary.
+const labels: Record<AvailabilityReason, Message<string>> = {
+ online: agentInfoMessages.online,
+ status_unavailable: agentAvailabilityMessages.statusUnavailable,
+ reconnecting: agentAvailabilityMessages.reconnecting,
+ authentication_required: agentAvailabilityMessages.offline,
+ waiting_for_computer: agentAvailabilityMessages.offline,
+ runtime_not_installed: agentAvailabilityMessages.needsAttention,
+ runtime_incompatible: agentAvailabilityMessages.needsAttention,
+ runtime_error: agentAvailabilityMessages.needsAttention,
+};
+
+// `runtime_error` keeps the Runtime's own diagnostic, as TeamHub sent it.
+const summaries: Partial<Record<AvailabilityReason, Message<string>>> = {
+ authentication_required: agentAvailabilityMessages.authenticationRequired,
+ waiting_for_computer: agentAvailabilityMessages.waitingForComputer,
+ runtime_not_installed: agentAvailabilityMessages.runtimeNotInstalled,
+ runtime_incompatible: agentAvailabilityMessages.runtimeIncompatible,
+};
+
+function knownReason(reason: string | undefined) {
+ return reason !== undefined && Object.hasOwn(labels, reason)
+ ? (reason as AvailabilityReason)
+ : undefined;
+}
+
+/**
+ * The status label. A reason this client does not know, or a TeamHub that
+ * sends none, falls back to the English label TeamHub sent.
+ */
+export function availabilityLabel(
+ availability: Pick<Availability, "label" | "reason" | "status">,
+ t: Translate,
+): string {
+ const reason = knownReason(availability.reason);
+ if (reason) return t(labels[reason]);
+ return availability.status === "online"
+ ? t(agentInfoMessages.online)
+ : availability.label;
+}
+
+/** Why the Agent has its status, falling back to TeamHub's English summary. */
+export function availabilitySummary(
+ availability: Pick<Availability, "current_activity" | "reason">,
+ t: Translate,
+): string | undefined {
+ const reason = knownReason(availability.reason);
+ const message = reason ? summaries[reason] : undefined;
+ return message ? t(message) : availability.current_activity?.summary;
+}
diff --git a/apps/web/src/features/rooms/members/agent-availability.messages.ts b/apps/web/src/features/rooms/members/agent-availability.messages.ts
new file mode 100644
index 00000000..342e47f1
--- /dev/null
+++ b/apps/web/src/features/rooms/members/agent-availability.messages.ts
@@ -0,0 +1,16 @@
+import { defineMessages } from "@/i18n/messages";
+
+/**
+ * An Agent's status, worded from the `reason` code TeamHub sends beside its
+ * English `label` and summary.
+ */
+export const agentAvailabilityMessages = defineMessages("agentAvailability", {
+ offline: "Offline",
+ needsAttention: "Needs attention",
+ statusUnavailable: "Status unavailable",
+ reconnecting: "Reconnecting",
+ authenticationRequired: "Authentication required",
+ waitingForComputer: "Waiting for the computer to connect",
+ runtimeNotInstalled: "The AI app is not installed",
+ runtimeIncompatible: "The AI app needs an update",
+});
diff --git a/apps/web/src/features/rooms/members/agent-status.test.tsx b/apps/web/src/features/rooms/members/agent-status.test.tsx
index 41015676..a4ade55f 100644
--- a/apps/web/src/features/rooms/members/agent-status.test.tsx
+++ b/apps/web/src/features/rooms/members/agent-status.test.tsx
@@ -50,7 +50,49 @@ describe("AgentStatus", () => {
).toBeInTheDocument();
});
- it("shows the label TeamHub sent for any other status as it is", async () => {
+ it("words the status and its detail from the reason TeamHub sends", async () => {
+ await setLanguage("zh-CN");
+ render(
+ <AgentStatus
+ availability={{
+ status: "offline",
+ label: "Offline",
+ reason: "waiting_for_computer",
+ active_task_count: 0,
+ current_activity: { summary: "Waiting for the computer to connect" },
+ }}
+ showDetails
+ />,
+ );
+ expect(
+ screen.getByText(zhCN.agentAvailability.offline),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText(new RegExp(zhCN.agentAvailability.waitingForComputer)),
+ ).toBeInTheDocument();
+ });
+
+ it("keeps the Runtime's own diagnostic beside a worded label", async () => {
+ await setLanguage("zh-CN");
+ render(
+ <AgentStatus
+ availability={{
+ status: "error",
+ label: "Needs attention",
+ reason: "runtime_error",
+ active_task_count: 0,
+ current_activity: { summary: "codex exited with status 2" },
+ }}
+ showDetails
+ />,
+ );
+ expect(
+ screen.getByText(zhCN.agentAvailability.needsAttention),
+ ).toBeInTheDocument();
+ expect(screen.getByText(/codex exited with status 2/)).toBeInTheDocument();
+ });
+
+ it("shows TeamHub's English label when there is no reason", async () => {
await setLanguage("zh-CN");
render(
<AgentStatus
@@ -63,4 +105,23 @@ describe("AgentStatus", () => {
);
expect(screen.getByText("Status unavailable")).toBeInTheDocument();
});
+
+ it("falls back to TeamHub's English for a reason it does not know", async () => {
+ await setLanguage("zh-CN");
+ render(
+ <AgentStatus
+ availability={{
+ status: "offline",
+ label: "Paused by admin",
+ // A reason added to TeamHub after this client was built.
+ reason: "paused_by_admin" as never,
+ active_task_count: 0,
+ current_activity: { summary: "An admin paused this Agent" },
+ }}
+ showDetails
+ />,
+ );
+ expect(screen.getByText("Paused by admin")).toBeInTheDocument();
+ expect(screen.getByText(/An admin paused this Agent/)).toBeInTheDocument();
+ });
});
diff --git a/apps/web/src/features/rooms/members/agent-status.tsx b/apps/web/src/features/rooms/members/agent-status.tsx
index 3943400f..565b7dc6 100644
--- a/apps/web/src/features/rooms/members/agent-status.tsx
+++ b/apps/web/src/features/rooms/members/agent-status.tsx
@@ -3,6 +3,10 @@ import { type Translate, translate } from "@/i18n/language";
import { useT } from "@/i18n/use-translation";
import { agentInfoMessages } from "./agent-info.messages";
+import {
+ availabilityLabel,
+ availabilitySummary,
+} from "./agent-availability-text";
type AgentAvailability = TeamHubTenantAgentAvailabilitySnapshot["availability"];
@@ -21,7 +25,7 @@ function agentStatusDetail(
return activeTaskCount > 0
? t(agentInfoMessages.tasksInProgress, { count: activeTaskCount })
: availability.status !== "online"
- ? availability.current_activity?.summary
+ ? availabilitySummary(availability, t)
: undefined;
}
@@ -50,9 +54,7 @@ export function AgentStatus({
}) {
const t = useT();
const status = availability.status;
- // Any other status shows the label TeamHub sent, in TeamHub's own words.
- const label =
- status === "online" ? t(agentInfoMessages.online) : availability.label;
+ const label = availabilityLabel(availability, t);
const detail = agentStatusDetail(availability, t);
return (
<span className="inline-flex min-w-0 items-center gap-1.5">
diff --git a/apps/web/src/features/rooms/members/edit-agent-runtime-dialog.tsx b/apps/web/src/features/rooms/members/edit-agent-runtime-dialog.tsx
index 61f7a515..062f77b4 100644
--- a/apps/web/src/features/rooms/members/edit-agent-runtime-dialog.tsx
+++ b/apps/web/src/features/rooms/members/edit-agent-runtime-dialog.tsx
@@ -9,6 +9,7 @@ import { runtimeStatusLabels } from "@/features/local-computer/computer-readines
import { localComputersQueryKey } from "@/features/local-computer/local-computer-queries";
import { LocalRuntimeAuthenticationGuidance } from "@/features/local-computer/local-runtime-authentication-guidance";
import { LocalRuntimeInstallGuidance } from "@/features/local-computer/local-runtime-install-guidance";
+import { localRuntimeMessage } from "@/features/local-computer/local-runtime-message";
import { localModelsQueryOptions } from "@/features/local-models/local-models-queries";
import type { TeamHubClient } from "@/features/teamhub/teamhub-client";
import type {
@@ -363,8 +364,9 @@ function RuntimeSetupGuidance({
</div>
);
return (
- <p className="text-sm text-app-danger" role="alert">
- {runtime.message ?? t(agentRuntimeMessages.installAndSignIn)}
+ <p className="text-sm text-app-danger" role="alert" title={runtime.message}>
+ {localRuntimeMessage(runtime, runtime.type, computer.display_name, t) ??
+ t(agentRuntimeMessages.installAndSignIn)}
</p>
);
}
diff --git a/apps/web/src/i18n/locales/zh-CN.json b/apps/web/src/i18n/locales/zh-CN.json
index b0f9eaf4..6256c708 100644
--- a/apps/web/src/i18n/locales/zh-CN.json
+++ b/apps/web/src/i18n/locales/zh-CN.json
@@ -2762,5 +2762,21 @@
"sourceRevision": "team.md · 第 {revision} 版",
"viewSource": "查看源文件",
"hideSource": "隐藏源文件"
+ },
+ "agentAvailability": {
+ "offline": "离线",
+ "needsAttention": "需要处理",
+ "statusUnavailable": "无法获取状态",
+ "reconnecting": "正在重新连接",
+ "authenticationRequired": "需要登录",
+ "waitingForComputer": "正在等待电脑连接",
+ "runtimeNotInstalled": "未安装 AI 应用",
+ "runtimeIncompatible": "AI 应用需要更新"
+ },
+ "localRuntimeMessage": {
+ "notInstalled": "{computer} 上未安装 {app}。",
+ "signInRequired": "需要在 {computer} 上登录 {app}。",
+ "needsUpdate": "{computer} 需要更新后才能运行 {app}。",
+ "computerOffline": "{computer} 已离线。"
}
}