Computer

A live view of the computer an agent is using, full size or as a thumbnail with Take over.

Ledger bot's browser

Needs you

Ledger bot is working for Grace

https://portal.northwind.example/sign-in
Ledger bot's browser, showing https://portal.northwind.example/sign-in

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/computer

Usage

import type { ComputerControl } from "./ui/uicontext/components/kit/Computer.ts"import { ComputerView } from "./ui/uicontext/components/kit/Computer.ts"
const Message = UiSchema.TaggedEnum({ TookControl: {}, ReturnedControl: {}, Reconnected: {} })// your app owns who drives and the machine's state; the view asks for changesexport const AgentScreen = (h: Html.H<typeof Message.Type>, frame: string, control: ComputerControl) =>	ComputerView(h, {		props: {			id: "vm-1",			label: "Ledger bot's browser",			state: "live",			source: { _tag: "Image", src: frame },			control,			can: ["take", "return", "reconnect"],			timeZone: "Europe/London",		},		onEmit: {			RequestedTakeControl: () => Message.TookControl(),			RequestedReturnControl: () => Message.ReturnedControl(),			RequestedReconnect: () => Message.Reconnected(),			RequestedStartRecording: () => undefined,			RequestedStopRecording: () => undefined,			RequestedAction: () => undefined,		},	})

Examples

Losing the connection

The view keeps the last frame, dimmed, and says the agent is still working. Reconnect tries again; the first try fails here, the second gets through.

Ledger bot's browser

Offline

Ledger bot is working for Grace

https://portal.northwind.example/invoices
Ledger bot's browser, showing https://portal.northwind.example/invoices

Lost connection

The view lost its connection. Ledger bot keeps working.

Screen beside a conversation

The agent's screen as a thumbnail with a live dot. When it needs you, it says why; Take over, then Hand back.

Vendor Bills' screen
Vendor Bills' screen

The portal wants the code sent to your phone. Take over to enter it; I'll wait.

API reference

ComputerViewComponent

Props

ComputerView props
NameTypeDescription
idrequiredstringIdentifies the computer in the events the view sends
labelrequiredstringWhat it is, for the label and the image's alt: "Research bot's screen", "Browser"
sourceComputerSource | nullWhat to show: a live image or stream, a recording, or an interactive frame; null before there's a screen
staterequiredComputerStateThe machine's lifecycle: unassigned, booting, live, idle, asleep, maintenance, offline or ended
stateLabelstringThe product's words for the state, and why: "Updating", "Asleep: idle for 10 minutes"
reasonstringWhy it's in this state, shown under the screen: "Lost connection 2 minutes ago"
activitystringWho is on screen and for whom: "Research bot is working for Ada"
urlstringThe page the browser is on, shown in an address bar
controlrequiredComputerControlWho drives: the agent, the person, the agent offering control, or nobody
controlNotestringWhy the agent asks: "Sign in to your bank; I'll wait."
recording{ state, endsAt, note }Recording what the person shows: off, recording or processing, and when it stops
actionsComputerAction[]The machine's own actions: Update, Restart browser, Reset computer
canrequired("take" | "return" | "record" | "reconnect")[]What this person may do: take or return control, record, and reconnect a lost view
timeZonerequiredstringThe person's time zone, for times shown
localestringFormats times shown; the reader's own when left out
aspect"16/9" | "16/10" | "4/3"The screen's shape; "16/10" by default
hrefstringOpens the live view on its own (a larger window)
outcomeOutcome | nullThe app's answer to the request in flight; its request is the action's id
agentIdstringThis view's id for agents; defaults to computer:<id>

Events

ComputerView events
EventPayloadDescription
RequestedTakeControl{ id: string }The person asked to take control, after confirming when the agent is working
RequestedReturnControl{ id: string }"Hand back"
RequestedStartRecording{ id: string }The person started recording what they show the agent
RequestedStopRecording{ id: string }The person stopped the recording
RequestedAction{ id: string; action: string }The person picked one of actions, after confirming a destructive one
RequestedReconnect{ id: string }The person asked to reach the machine again after the view lost it

Agent actions

What agents can do with ComputerView
ActionDescription
ClickedTakeControlTake control of the screen (the agent pauses). Taking it from a working agent asks first.
ConfirmedTakeControlasks firstTake control from the working agent. Name the computer as your target.
ClickedReturnControlHand control back to the agent
ClickedReconnectReach the machine again after the view lost its connection
ClickedStartRecordingStart recording a task to teach it
ClickedStopRecordingStop recording
ClickedActionRun one of the machine's actions by id (see page_query). Destructive ones ask first.
ConfirmedActionasks firstRun the destructive action being confirmed. Name it as your target.

ComputerPreviewView function

Options

ComputerPreview options
NameTypeDescription
srcrequiredstringThe latest frame of the screen; a quiet blank before there is one
labelrequiredstringWhat it is: "Chief of Staff's screen"; the caption and the image's description
liverequiredbooleanThe agent is working on it now: a live dot
controlrequired"agent" | "offered" | "person" | "none"Who drives: the agent, the person, or the agent asking the person to take over
notestringWhy the agent asks for the person: "Sign in to the bank portal; I'll wait."
onOpenMessageOpens the full view
onTakeOverMessage—
onHandBackMessage—
busybooleanA control change is on its way

Accessibility

  • The screen is an image, video or frame named for the computer and the page it shows; what the agent is doing is announced as it changes.
  • When the agent needs you, an alert says so with a Take over button. Taking control from a working agent asks first, and Hand back returns it.
  • Agents can take or return control and run its actions, and must name the computer when a step can't be undone.

Source