diff --git a/apps/mobile/src/computer-status.ts b/apps/mobile/src/computer-status.ts new file mode 100644 index 000000000..4d39a7e68 --- /dev/null +++ b/apps/mobile/src/computer-status.ts @@ -0,0 +1,4 @@ +/** The agent computer's status, shown in the header and read out by its button label. */ +export function computerStatus(available: boolean, activeSessions: number) { + return !available ? "offline" : activeSessions > 0 ? "take control" : "ready"; +} diff --git a/apps/mobile/src/computer.tsx b/apps/mobile/src/computer.tsx index 85aea8331..285e0516b 100644 --- a/apps/mobile/src/computer.tsx +++ b/apps/mobile/src/computer.tsx @@ -13,6 +13,7 @@ import type { BrowserSession } from "../../../packages/domain/src"; import type { ComputerSnapshot } from "../../../packages/domain/src/computer"; import { browserAddress } from "./browser-address"; import { useComputerDraft } from "./computer-drafts"; +import { computerStatus } from "./computer-status"; import { LinuxWorkspace } from "./computer-workspace"; import { Button, Card, colors, ErrorNotice, Field, LinkRow, Sheet, s } from "./ui"; import { useWorkspace } from "./workspace"; @@ -23,10 +24,11 @@ export function ComputerEntry() { (c) => c.id === "browser" && c.status === "connected", ); const active = workspace.browsers.filter((b) => b.status === "active").length; + const status = computerStatus(available, active); return ( open({ type: "computer" })} style={[ s.row, @@ -41,10 +43,7 @@ export function ComputerEntry() { ]} > - - Computer - {!available ? " · offline" : active ? " · take control" : " · ready"} - + Computer · {status} { + assert.equal(computerStatus(false, 0), "offline"); + assert.equal(computerStatus(false, 2), "offline"); + assert.equal(computerStatus(true, 0), "ready"); + assert.equal(computerStatus(true, 1), "take control"); +});