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: 4 additions & 0 deletions apps/mobile/src/computer-status.ts
Original file line number Diff line number Diff line change
@@ -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";
}
9 changes: 4 additions & 5 deletions apps/mobile/src/computer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 (
<Pressable
accessibilityRole="button"
accessibilityLabel="Agent computer — take control"
accessibilityLabel={`Agent computer — ${status}`}
onPress={() => open({ type: "computer" })}
style={[
s.row,
Expand All @@ -41,10 +43,7 @@ export function ComputerEntry() {
]}
>
<Monitor size={13} color={colors.muted} />
<Text style={{ fontSize: 12, color: colors.muted }}>
Computer
{!available ? " · offline" : active ? " · take control" : " · ready"}
</Text>
<Text style={{ fontSize: 12, color: colors.muted }}>Computer · {status}</Text>
<View
style={{
width: 5,
Expand Down
10 changes: 10 additions & 0 deletions apps/mobile/test/computer-status.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import assert from "node:assert/strict";
import test from "node:test";
import { computerStatus } from "../src/computer-status.ts";

test("the computer status says offline before anything else", () => {
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");
});
Loading