Skip to content

An open-source, faster Devin alternative

TypeScript

web: triage answers in one dock shaped by the ask; list rows by kind

Igor Zalutski via Computerb19031cfc3ba
diff --git a/TRIAGE_WEB_NOTES.md b/TRIAGE_WEB_NOTES.md
new file mode 100644
index 00000000..983af4fe
--- /dev/null
+++ b/TRIAGE_WEB_NOTES.md
@@ -0,0 +1,72 @@
+# Triage (web): design notes
+
+Second pass on the Triage screen (ux-spec 3). What the screen does is
+unchanged; how it is arranged and answered is redesigned. Same family as the
+Board's visual pass (WORK_WEB_NOTES.md): Inter, `text-sm` (14/20) for names
+and body, `text-xs` (12/16, 12/20) for everything quiet, warm neutral tokens,
+1px `border`, `rounded-lg`/`rounded-xl` panels, a 4/8 px rhythm, tabular
+numerals for ages, amber only for "needs you".
+
+## The person's loop
+
+They arrive with 3-10 things waiting, each worth 5-30 seconds. Their eyes go:
+headline (what is needed) -> the thing to decide on (the command, the options,
+the secret) -> the agent's last words for context -> one click. Nothing of
+that requires scrolling, and nothing on screen offers two ways to do the same
+thing.
+
+Prior art: Claude Code / Cursor permission prompts (the exact command, one
+click to allow, typing means "no, do this instead"); GitHub's review box (one
+text field; the verdict is the submit choice); Slack interactive messages
+(the dialog's own buttons, a typed reply declines); Linear Triage and
+Superhuman (one item at a time, auto-advance, calm density).
+
+## Layout
+
+- Left list (320 px): "Needs you" (count in amber), then "Set aside", then
+ "Agents working". Only "Needs you" is a primary heading (`text-sm`
+ medium); the other two are quiet (`text-xs` medium, muted) and their rows
+ are muted. A row: a 14 px glyph for the kind of ask (approval, question,
+ secret, reply), the headline (`text-sm`, one line), the age (`text-xs`
+ tabular, right), and the thread name under it (`text-xs` muted).
+- Main column, 720 px of content, centred, three bands:
+ 1. Header (fixed): thread name (a link to the session) and age, `text-xs`
+ muted; then the headline, `text-xl` semibold, at most two lines.
+ 2. Excerpt (scrolls): no frame. The agent's last words sit at the bottom,
+ directly on the dock (the column is bottom-aligned, chat order); older
+ turns scroll up under a soft fade and "N earlier messages" heads them.
+ The "where it stopped" rule is kept, quieter.
+ 3. The answer dock (fixed to the bottom with air around it).
+
+## One answer dock, shaped by the ask
+
+One card: the ask attached on top, one text box, one footer. Typing is
+always the free-form answer to whatever was asked; there is never a second
+input. The footer's left holds the quiet "Set aside"; its right holds the
+verdict.
+
+| Ask | Attached on top | Footer actions | Typing + Enter |
+|---|---|---|---|
+| Approval | Tool label and target (file, cwd, server) on one line; the exact command / diff / file content / arguments in a mono block, wrapped, scrolling past 12 lines | Deny, "Allow <tool> for this session" (when `alwaysAllows`), Allow (primary) | The verdict buttons give way to Send: the message declines the call and tells the agent what to do instead (a steer, which declines open asks with the message) |
+| Plan approval (ExitPlanMode) | The plan, rendered, scrolling | Keep planning, Approve (ask before edits), Approve (accept edits) | Same as approval |
+| Question | Options as full-width rows: label and description; single choice answers on click, multiple choice toggles with check boxes | Send (enabled once something is chosen or typed) | Free-form answer to the question (`answers[].text`); typed text alongside a clicked option goes with it as a note |
+| Secret | Key glyph, the secret's name (mono), its purpose; "Add in Secrets" button. A masked field can replace the button in place later | Send | A message to the agent (declines the request) |
+| Reply (plain text turn, future `attention.reason = reply`) | nothing | Send | The reply |
+| Answered elsewhere | "Answered elsewhere" and Next replace the attachment | Send | An ordinary message (queued) |
+
+Answering advances to the next ask at once. A one-line confirmation of what
+was sent ("Allowed · Rotate the staging password") shows above the next
+headline for a few seconds and blocks nothing. A failed send keeps the text
+and the ask on screen, with "Not sent · Retry" in the footer. Empty list:
+a calm "All clear".
+
+## What an approval ask carries (API)
+
+`approval: { toolName, callId, input, title, alwaysAllows }`. `input` is the
+tool's raw input: Bash `{command, description?, timeout?}` (Codex adds
+`cwd`); Edit `{file_path, old_string, new_string}` or `{file_path, diff}`;
+MultiEdit `{file_path, edits[]}`; Write `{file_path, content}`; ExitPlanMode
+`{plan}`; MCP and Calvin tools their arguments. `title` is Claude Code's
+permission title or "Claude wants to use <tool>". The reason/description the
+Slack prompt shows is not in the API payload, and neither is the working
+directory for Claude sessions.
diff --git a/web/src/managed-agents/computer-sessions/AnswerDock.tsx b/web/src/managed-agents/computer-sessions/AnswerDock.tsx
new file mode 100644
index 00000000..00815f98
--- /dev/null
+++ b/web/src/managed-agents/computer-sessions/AnswerDock.tsx
@@ -0,0 +1,466 @@
+import { useEffect, useRef, useState, type ReactNode } from 'react'
+import { Link } from 'react-router-dom'
+import { useMutation, useQueryClient } from '@tanstack/react-query'
+import {
+ ArrowRight,
+ ArrowUp,
+ ArrowUpRight,
+ Check,
+ KeyRound,
+ Loader2,
+} from 'lucide-react'
+import { ChatTextarea } from '@/components/chat-textarea'
+import { Button } from '@/components/ui/button'
+import { notifyError } from '@/lib/errors'
+import { cn } from '@/lib/utils'
+import {
+ answerAsk,
+ bringBack,
+ sendTurn,
+ sessionKeys,
+ setAside,
+ type Ask,
+ type AskAnswer,
+} from '../computer-sessions-api'
+import { ApprovalDetail } from './ask-detail'
+import { isPlan } from './ask-line'
+import { useCapabilities } from './state'
+import type { TriageEntry } from './triage'
+
+// The answer dock (TRIAGE_WEB_NOTES.md): one card at the bottom of the ask,
+// shaped by it. What the agent asked for is attached on top, the text box is
+// the one place to type, and the footer holds the verdict. Typing is always
+// the free-form answer: on an approval it declines the call and tells the
+// agent what to do instead, on a question it is the answer in the person's
+// words, otherwise it is the reply.
+
+type Action =
+ | { type: 'text'; text: string }
+ | { type: 'answer'; answer: AskAnswer; said: string }
+
+type Question = NonNullable<Ask['question']>['questions'][number]
+
+export function AnswerDock({
+ entry,
+ gone,
+ draft,
+ setDraft,
+ onAnswered,
+ onAside,
+ onBack,
+ onNext,
+}: {
+ entry: TriageEntry
+ /** Answered somewhere else while on screen: the box sends plain messages. */
+ gone: boolean
+ draft: string
+ setDraft: (text: string) => void
+ /** Accepted; `said` is the one-line confirmation of what was sent. */
+ onAnswered: (said: string) => void
+ onAside: () => Promise<void>
+ onBack: () => void
+ onNext: () => void
+}) {
+ const { session: s, ask, kind } = entry
+ const qc = useQueryClient()
+ const { data: caps } = useCapabilities()
+ const questions = ask?.question?.questions ?? []
+ // One question with one answer: a click on an option is the answer.
+ const oneClick = questions.length === 1 && !questions[0].multiSelect
+ const [chosen, setChosen] = useState<Record<string, string[]>>({})
+ const text = draft.trim()
+
+ const box = useRef<HTMLDivElement>(null)
+ useEffect(() => box.current?.querySelector('textarea')?.focus(), [])
+
+ const act = useMutation({
+ mutationFn: async (a: Action) => {
+ if (a.type === 'answer') return answerAsk(s.id, ask!.id, a.answer)
+ // A question in the person's own words is its answer; anything else
+ // typed is a message. Steering closes the open asks with it ("Open asks
+ // close as declined; the message is the answer"); once the ask is
+ // gone it goes as an ordinary message.
+ if (!gone && kind === 'question' && questions.length === 1)
+ return answerAsk(s.id, ask!.id, {
+ answers: [{ questionId: questions[0].id, choices: [], text: a.text }],
+ })
+ return sendTurn(
+ s.id,
+ a.text,
+ !gone && caps?.features.steer !== false ? 'steer' : 'queue',
+ )
+ },
+ onSuccess: (_, a) => {
+ void qc.invalidateQueries({ queryKey: sessionKeys.all })
+ if (gone) return setDraft('')
+ onAnswered(a.type === 'answer' ? a.said : sentLine(kind))
+ },
+ })
+ const aside = useMutation({
+ mutationFn: () =>
+ entry.aside ? bringBack(s.id) : setAside(s.id, entry.ref),
+ onSuccess: () => (entry.aside ? onBack() : onAside()),
+ onError: (e) =>
+ notifyError(
+ entry.aside ? 'Could not bring it back' : 'Could not set it aside',
+ e,
+ ),
+ })
+ const busy = act.isPending
+
+ const decide = (decision: 'allow' | 'deny' | 'always', said: string) =>
+ act.mutate({ type: 'answer', answer: { decision }, said })
+ // Every question answered by its choices; typed text goes with the last.
+ const answerChoices = (picked: Record<string, string[]>) =>
+ act.mutate({
+ type: 'answer',
+ said: `Answered: ${questions.flatMap((q) => picked[q.id] ?? []).join(', ')}`,
+ answer: {
+ answers: questions.map((q, i) => ({
+ questionId: q.id,
+ choices: picked[q.id] ?? [],
+ text: i === questions.length - 1 && text ? text : null,
+ })),
+ },
+ })
+ const picked = questions.some((q) => chosen[q.id]?.length)
+ const allPicked =
+ questions.length > 0 && questions.every((q) => chosen[q.id]?.length)
+ const submit = () => {
+ if (busy) return
+ if (kind === 'question' && !gone && picked) {
+ if (allPicked) answerChoices(chosen)
+ return
+ }
+ if (text) act.mutate({ type: 'text', text })
+ }
+ const retry = () => act.variables && act.mutate(act.variables)
+
+ const verdict = kind === 'approval' && !gone && !text
+ const canSend =
+ !busy && (kind === 'question' && !gone && picked ? allPicked : !!text)
+
+ return (
+ <div
+ ref={box}
+ className="bg-card focus-within:border-ring/50 rounded-xl border shadow-sm transition-colors"
+ >
+ {gone ? (
+ <Attached>
+ <div className="flex items-center justify-between gap-3">
+ <p className="text-muted-foreground text-sm">
+ This was answered elsewhere.
+ </p>
+ <Button size="sm" variant="outline" onClick={onNext}>
+ Next
+ </Button>
+ </div>
+ </Attached>
+ ) : kind === 'approval' && ask ? (
+ <Attached>
+ <ApprovalDetail ask={ask} />
+ </Attached>
+ ) : kind === 'question' && questions.length ? (
+ <Attached>
+ <div className="space-y-3">
+ {questions.map((q) => (
+ <Options
+ key={q.id}
+ question={q}
+ // One question is the headline already.
+ titled={questions.length > 1}
+ chosen={chosen[q.id] ?? []}
+ disabled={busy}
+ onPick={(label) => {
+ if (oneClick) return answerChoices({ [q.id]: [label] })
+ setChosen((c) => {
+ const have = c[q.id] ?? []
+ const next = have.includes(label)
+ ? have.filter((l) => l !== label)
+ : q.multiSelect
+ ? [...have, label]
+ : [label]
+ return { ...c, [q.id]: next }
+ })
+ }}
+ />
+ ))}
+ </div>
+ </Attached>
+ ) : kind === 'secret' && ask ? (
+ <Attached>
+ <SecretRequest ask={ask} />
+ </Attached>
+ ) : null}
+
+ <ChatTextarea
+ value={draft}
+ onChange={(e) => setDraft(e.target.value)}
+ onSend={submit}
+ placeholder={placeholder(gone ? 'gone' : kind, ask)}
+ aria-label="Reply"
+ className="min-h-11 resize-none border-0 bg-transparent px-4 pt-3 pb-1 leading-5 shadow-none focus-visible:ring-0 dark:bg-transparent"
+ />
+
+ <div className="flex items-center gap-2 px-2 pb-2">
+ {gone ? null : (
+ <Button
+ size="sm"
+ variant="ghost"
+ className="text-muted-foreground"
+ disabled={aside.isPending}
+ onClick={() => aside.mutate()}
+ >
+ {entry.aside ? 'Bring back' : 'Set aside'}
+ </Button>
+ )}
+ <div className="ml-auto flex items-center gap-2">
+ {act.isError ? (
+ <p
+ role="alert"
+ className="text-destructive flex items-center gap-1.5 text-xs"
+ >
+ Not sent
+ <span aria-hidden>·</span>
+ <button
+ type="button"
+ className="font-medium underline underline-offset-2"
+ onClick={retry}
+ >
+ Retry
+ </button>
+ </p>
+ ) : null}
+ {verdict ? (
+ <Verdict ask={ask!} busy={busy} decide={decide} />
+ ) : (
+ <>
+ {kind === 'approval' && !gone ? (
+ <span className="text-muted-foreground text-xs">
+ Declines, and sends this instead
+ </span>
+ ) : null}
+ <Button
+ size="icon"
+ className="rounded-full"
+ aria-label="Send"
+ disabled={!canSend}
+ onClick={submit}
+ >
+ {busy ? (
+ <Loader2 className="animate-spin" aria-hidden />
+ ) : (
+ <ArrowUp aria-hidden />
+ )}
+ </Button>
+ </>
+ )}
+ </div>
+ </div>
+ </div>
+ )
+}
+
+function Attached({ children }: { children: ReactNode }) {
+ return <div className="border-b p-3">{children}</div>
+}
+
+function sentLine(kind: TriageEntry['kind']) {
+ return kind === 'approval' || kind === 'secret'
+ ? 'Declined with your message'
+ : 'Reply sent'
+}
+
+function placeholder(kind: TriageEntry['kind'] | 'gone', ask: Ask | null) {
+ switch (kind) {
+ case 'gone':
+ return 'Message the agent'
+ case 'approval':
+ return ask && isPlan(ask)
+ ? 'Or say what to change in the plan'
+ : 'Or tell it what to do instead'
+ case 'question':
+ return 'Or answer in your own words'
+ case 'secret':
+ return 'Or reply instead'
+ default:
+ return 'Reply'
+ }
+}
+
+// The approval's own buttons, as in Slack: Deny, Allow for this session when
+// the call can be remembered, Allow. A plan has its own three.
+function Verdict({
+ ask,
+ busy,
+ decide,
+}: {
+ ask: Ask
+ busy: boolean
+ decide: (d: 'allow' | 'deny' | 'always', said: string) => void
+}) {
+ if (isPlan(ask))
+ return (
+ <>
+ <Button
+ variant="outline"
+ disabled={busy}
+ onClick={() => decide('deny', 'Kept planning')}
+ >
+ Keep planning
+ </Button>
+ <Button
+ variant="outline"
+ disabled={busy}
+ onClick={() => decide('allow', 'Plan approved, asking before edits')}
+ >
+ Approve, ask before edits
+ </Button>
+ <Button
+ disabled={busy}
+ onClick={() => decide('always', 'Plan approved, accepting edits')}
+ >
+ Approve, accept edits
+ </Button>
+ </>
+ )
+ const always = ask.approval?.alwaysAllows
+ return (
+ <>
+ <Button
+ variant="outline"
+ disabled={busy}
+ onClick={() => decide('deny', 'Denied')}
+ >
+ Deny
+ </Button>
+ {always ? (
+ <Button
+ variant="outline"
+ disabled={busy}
+ title={`Allows ${always} without asking again in this session`}
+ onClick={() => decide('always', `Allowed ${always} for the session`)}
+ >
+ Allow for this session
+ </Button>
+ ) : null}
+ <Button disabled={busy} onClick={() => decide('allow', 'Allowed')}>
+ {busy ? <Loader2 className="animate-spin" aria-hidden /> : null}
+ Allow
+ </Button>
+ </>
+ )
+}
+
+function Options({
+ question,
+ titled,
+ chosen,
+ disabled,
+ onPick,
+}: {
+ question: Question
+ titled: boolean
+ chosen: string[]
+ disabled: boolean
+ onPick: (label: string) => void
+}) {
+ const box = question.multiSelect
+ return (
+ <fieldset className="space-y-2">
+ {titled || box ? (
+ <legend className="text-muted-foreground mb-2 flex gap-2 text-xs">
+ {titled ? (
+ <span className="text-foreground font-medium">
+ {question.text || question.header}
+ </span>
+ ) : null}
+ {box ? <span>Choose any</span> : null}
+ </legend>
+ ) : null}
+ <div className="divide-y overflow-hidden rounded-lg border">
+ {question.options.map((o) => {
+ const on = chosen.includes(o.label)
+ return (
+ <button
+ key={o.label}
+ type="button"
+ disabled={disabled}
+ aria-pressed={box || !titled ? on : undefined}
+ onClick={() => onPick(o.label)}
+ className={cn(
+ 'group/opt hover:bg-muted/60 flex w-full items-start gap-3 px-3 py-2 text-left text-sm transition-colors disabled:opacity-60',
+ on && 'bg-muted',
+ )}
+ >
+ {box || titled ? (
+ <span
+ aria-hidden
+ className={cn(
+ 'border-input mt-0.5 flex size-4 shrink-0 items-center justify-center border',
+ box ? 'rounded-[3px]' : 'rounded-full',
+ on && 'border-primary bg-primary text-primary-foreground',
+ )}
+ >
+ {on ? <Check className="size-3" strokeWidth={3} /> : null}
+ </span>
+ ) : null}
+ <span className="min-w-0 flex-1">
+ <span className="font-medium">{o.label}</span>
+ {o.description ? (
+ <span className="text-muted-foreground">
+ {' '}
+ · {o.description}
+ </span>
+ ) : null}
+ </span>
+ {box || titled ? null : (
+ <ArrowRight
+ aria-hidden
+ className="text-muted-foreground mt-0.5 size-4 shrink-0 opacity-0 transition-opacity group-hover/opt:opacity-100 group-focus-visible/opt:opacity-100"
+ />
+ )}
+ </button>
+ )
+ })}
+ </div>
+ </fieldset>
+ )
+}
+
+// A secret is set privately, in Secrets; the agent goes on once it is. A
+// masked field can take the button's place here when the API takes values.
+function SecretRequest({ ask }: { ask: Ask }) {
+ const req = (ask.secret ?? {}) as {
+ name?: string
+ purpose?: string
+ file?: boolean
+ }
+ return (
+ <div className="flex items-start gap-3">
+ <KeyRound
+ className="text-muted-foreground mt-0.5 size-4 shrink-0"
+ aria-hidden
+ />
+ <div className="min-w-0 flex-1 space-y-0.5">
+ <p className="flex items-baseline gap-2 text-sm">
+ <span className="font-mono font-medium break-all">
+ {req.name ?? 'A secret'}
+ </span>
+ {req.file ? (
+ <span className="text-muted-foreground text-xs">file</span>
+ ) : null}
+ </p>
+ {req.purpose ? (
+ <p className="text-muted-foreground text-sm">{req.purpose}</p>
+ ) : null}
+ </div>
+ <Button asChild size="sm" variant="outline" className="shrink-0">
+ <Link to="/computer/secrets">
+ Add in Secrets
+ <ArrowUpRight aria-hidden />
+ </Link>
+ </Button>
+ </div>
+ )
+}
diff --git a/web/src/managed-agents/computer-sessions/Triage.tsx b/web/src/managed-agents/computer-sessions/Triage.tsx
index 1e86b805..1fdb5c38 100644
--- a/web/src/managed-agents/computer-sessions/Triage.tsx
+++ b/web/src/managed-agents/computer-sessions/Triage.tsx
@@ -4,36 +4,45 @@ import {
useMemo,
useRef,
useState,
+ type ComponentType,
type ReactNode,
} from 'react'
import { Link, useSearchParams } from 'react-router-dom'
-import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
-import { ArrowUp, Loader2 } from 'lucide-react'
-import { ChatTextarea } from '@/components/chat-textarea'
+import { useQuery, useQueryClient } from '@tanstack/react-query'
+import {
+ ArrowUpRight,
+ Check,
+ CircleHelp,
+ KeyRound,
+ MessageSquareText,
+ ShieldCheck,
+} from 'lucide-react'
import { Button } from '@/components/ui/button'
-import { notifyError } from '@/lib/errors'
import { cn } from '@/lib/utils'
-import {
- bringBack,
- getEvents,
- sendTurn,
- sessionKeys,
- setAside,
- type Session,
-} from '../computer-sessions-api'
+import { getEvents, sessionKeys, type Session } from '../computer-sessions-api'
+import { AnswerDock } from './AnswerDock'
import { Item } from './conversation'
import { useMemberEmails } from './members'
-import { AskCard, StatusDot } from './parts'
-import { sessionLine, sessionTitle, useCapabilities } from './state'
-import { TRIAGE_NEEDS, useTriage, type TriageEntry } from './triage'
+import { StatusDot } from './parts'
+import { sessionLine, sessionTitle } from './state'
+import {
+ TRIAGE_NEEDS,
+ useTriage,
+ type TriageEntry,
+ type TriageKind,
+} from './triage'
import { buildTranscript, timeAgo } from './transcript'
-// Triage (work-tracking ux-spec 3): one ask at a time, answer, next. The ask
-// on screen is `?ask=<id>`; nothing replaces it while it is shown.
+// Triage (work-tracking ux-spec 3; TRIAGE_WEB_NOTES.md): one ask at a time,
+// answer, next. The ask on screen is `?ask=<id>`; nothing replaces it while
+// it is shown.
const WORKING_ROWS = 5
-// Asks the agent put as a dialog, answered with AskCard's buttons.
-const DIALOGS = new Set(['approval', 'question', 'secret'])
+// How long the line saying what was just sent stays.
+const SENT_MS = 5_000
+
+/** What was just sent, and where: shown over the next ask for a moment. */
+type Sent = { said: string; title: string }
export default function Triage() {
const qc = useQueryClient()
@@ -45,6 +54,12 @@ export default function Triage() {
// Asks answered from here: they leave the list before the next poll says so.
const [done, setDone] = useState<ReadonlySet<string>>(new Set())
const open = needs.filter((e) => !done.has(e.ref))
+ const [sent, setSent] = useState<Sent | null>(null)
+ useEffect(() => {
+ if (!sent) return
+ const t = setTimeout(() => setSent(null), SENT_MS)
+ return () => clearTimeout(t)
+ }, [sent])
// The ask on screen, kept once its row is gone so the card does not vanish.
const live = [...needs, ...aside].find((e) => e.ref === want) ?? null
@@ -67,14 +82,15 @@ export default function Triage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [loaded, entry, first, want])
- const answered = (ref: string) => {
- setDone((d) => new Set(d).add(ref))
+ const answered = (e: TriageEntry, said: string) => {
+ setDone((d) => new Set(d).add(e.ref))
setDrafts((d) => {
const rest = { ...d }
- delete rest[ref]
+ delete rest[e.ref]
return rest
})
- go(next(ref))
+ setSent({ said, title: sessionTitle(e.session) })
+ go(next(e.ref))
}
const refetch = () =>
qc.refetchQueries({ queryKey: sessionKeys.list(TRIAGE_NEEDS) })
@@ -82,10 +98,14 @@ export default function Triage() {
return (
<div className="flex h-full">
<aside className="border-border hidden w-80 shrink-0 flex-col overflow-y-auto border-r md:flex">
- <Section label="Needs you" count={loaded ? open.length : undefined}>
+ <Section
+ label="Needs you"
+ count={loaded ? open.length : undefined}
+ primary
+ >
{loaded && !open.length ? (
- <p className="text-muted-foreground px-3 py-1 text-sm">
- Nothing right now.
+ <p className="text-muted-foreground px-3 py-2 text-xs">
+ Nothing waits on you.
</p>
) : null}
{open.map((e) => (
@@ -103,6 +123,7 @@ export default function Triage() {
<AskRow
key={e.ref}
entry={e}
+ quiet
current={e.ref === entry?.ref}
onClick={() => go(e.ref)}
/>
@@ -132,9 +153,10 @@ export default function Triage() {
key={entry.ref}
entry={entry}
gone={gone}
+ sent={sent}
draft={drafts[entry.ref] ?? ''}
setDraft={(text) => setDrafts((d) => ({ ...d, [entry.ref]: text }))}
- onAnswered={() => answered(entry.ref)}
+ onAnswered={(said) => answered(entry, said)}
onAside={async () => {
await refetch()
go(next(entry.ref))
@@ -144,6 +166,7 @@ export default function Triage() {
/>
) : loaded ? (
<AllClear
+ sent={sent}
working={working.length}
aside={aside.length}
onAside={() => go(aside[0]?.ref ?? null)}
@@ -157,55 +180,105 @@ export default function Triage() {
function Section({
label,
count,
+ primary,
children,
}: {
label: string
count?: number
+ /** "Needs you": the one heading in the foreground, its count in amber. */
+ primary?: boolean
children: ReactNode
}) {
return (
- <section className="border-border space-y-0.5 border-b px-2 py-4 last:border-b-0">
- <h2 className="flex items-baseline gap-2 px-3 pb-1.5 text-sm font-medium">
+ <section className="border-border border-b px-2 pt-4 pb-3 last:border-b-0">
+ <h2
+ className={cn(
+ 'flex h-8 items-center gap-2 px-3',
+ primary
+ ? 'text-sm font-medium'
+ : 'text-muted-foreground text-xs leading-5 font-medium',
+ )}
+ >
{label}
{count !== undefined ? (
- <span className="text-muted-foreground text-xs font-normal">
+ <span
+ className={cn(
+ 'text-xs font-normal tabular-nums',
+ primary && count
+ ? 'font-medium text-amber-600 dark:text-amber-500'
+ : 'text-muted-foreground',
+ )}
+ >
{count}
</span>
) : null}
</h2>
- {children}
+ <div className="space-y-px">{children}</div>
</section>
)
}
+const KIND: Record<
+ TriageKind,
+ { icon: ComponentType<{ className?: string }>; label: string }
+> = {
+ approval: { icon: ShieldCheck, label: 'Approval' },
+ question: { icon: CircleHelp, label: 'Question' },
+ secret: { icon: KeyRound, label: 'Secret' },
+ reply: { icon: MessageSquareText, label: 'Reply' },
+}
+
function AskRow({
entry,
current,
+ quiet,
onClick,
}: {
entry: TriageEntry
current: boolean
+ /** Set aside: outside the loop, so muted. */
+ quiet?: boolean
onClick: () => void
}) {
+ const { icon: Icon, label } = KIND[entry.kind]
return (
<button
type="button"
onClick={onClick}
aria-current={current ? 'true' : undefined}
className={cn(
- 'hover:bg-muted/60 flex w-full items-start gap-2 rounded-md px-3 py-1.5 text-left',
- current && 'bg-muted',
+ 'hover:bg-muted/60 grid w-full grid-cols-[16px_1fr_auto] gap-x-2.5 rounded-md px-3 py-2 text-left',
+ current && 'bg-muted hover:bg-muted',
)}
>
- <span className="min-w-0 flex-1">
- <span className="block truncate text-sm">{entry.line}</span>
- <span className="text-muted-foreground block truncate text-xs">
- {sessionTitle(entry.session)}
- </span>
+ <span
+ className={cn(
+ 'text-muted-foreground flex h-5 items-center',
+ quiet && 'opacity-70',
+ )}
+ title={label}
+ >
+ <Icon className="size-3.5" aria-label={label} />
</span>
- <span className="text-muted-foreground shrink-0 pt-0.5 text-xs">
+ <span
+ className={cn(
+ 'truncate text-sm leading-5',
+ quiet && 'text-muted-foreground',
+ )}
+ >
+ {entry.line}
+ </span>
+ <span className="text-muted-foreground text-xs leading-5 tabular-nums">
{timeAgo(entry.at)}
</span>
+ <span
+ className={cn(
+ 'text-muted-foreground col-start-2 col-end-4 truncate text-xs leading-4',
+ quiet && 'opacity-80',
+ )}
+ >
+ {sessionTitle(entry.session)}
+ </span>
</button>
)
}
@@ -215,42 +288,65 @@ function WorkingRow({ session }: { session: Session }) {
return (
<Link
to={`/computer/sessions/${session.id}`}
- className="hover:bg-muted/60 flex items-start gap-2 rounded-md px-3 py-1.5"
+ className="hover:bg-muted/60 grid grid-cols-[16px_1fr] gap-x-2.5 rounded-md px-3 py-2"
>
- <StatusDot status={session.status} className="mt-1.5" />
- <span className="min-w-0 flex-1">
- <span className="block truncate text-sm">{sessionTitle(session)}</span>
- {line ? (
- <span className="text-muted-foreground block truncate text-xs">
- {line}
- </span>
- ) : null}
+ <span className="flex h-5 items-center justify-center">
+ <StatusDot status={session.status} />
+ </span>
+ <span className="text-muted-foreground truncate text-sm leading-5">
+ {sessionTitle(session)}
</span>
+ {line ? (
+ <span className="text-muted-foreground/80 col-start-2 truncate text-xs leading-4">
+ {line}
+ </span>
+ ) : null}
</Link>
)
}
+function SentLine({ sent }: { sent: Sent }) {
+ return (
+ <p
+ role="status"
+ className="text-muted-foreground animate-in fade-in flex min-w-0 items-center gap-1.5 text-xs"
+ >
+ <Check className="text-status-running size-3.5 shrink-0" aria-hidden />
+ <span className="text-foreground shrink-0">{sent.said}</span>
+ <span aria-hidden>·</span>
+ <span className="truncate">{sent.title}</span>
+ </p>
+ )
+}
+
function AllClear({
+ sent,
working,
aside,
onAside,
}: {
+ sent: Sent | null
working: number
aside: number
onAside: () => void
}) {
return (
- <div className="flex h-full flex-col items-center justify-center gap-3 px-6 text-center">
- <h1 className="text-2xl font-semibold tracking-tight">All clear</h1>
+ <div className="flex h-full flex-col items-center justify-center gap-2 px-6 pb-16 text-center">
+ <div className="mb-2 flex h-5 justify-center">
+ {sent ? <SentLine sent={sent} /> : null}
+ </div>
+ <h1 className="text-xl leading-7 font-semibold tracking-tight">
+ All clear
+ </h1>
+ <p className="text-muted-foreground max-w-sm text-sm">
+ {working
+ ? `${working} ${working === 1 ? 'agent is' : 'agents are'} working. The next one that needs you appears here.`
+ : 'Nothing waits on you.'}
+ </p>
{aside ? (
- <Button variant="outline" size="sm" onClick={onAside}>
+ <Button variant="outline" size="sm" className="mt-2" onClick={onAside}>
{aside} set aside
</Button>
- ) : working ? (
- <p className="text-muted-foreground max-w-sm text-sm">
- {working} {working === 1 ? 'agent is' : 'agents are'} working. The
- next one that needs you appears here.
- </p>
) : null}
</div>
)
@@ -261,6 +357,7 @@ function AskView({
gone,
draft,
setDraft,
+ sent,
onAnswered,
onAside,
onBack,
@@ -270,120 +367,61 @@ function AskView({
gone: boolean
draft: string
setDraft: (text: string) => void
- onAnswered: () => void
+ sent: Sent | null
+ onAnswered: (said: string) => void
onAside: () => Promise<void>
onBack: () => void
onNext: () => void
}) {
- const { session: s, ask } = entry
- const { data: caps } = useCapabilities()
- // Focus in the box when the ask appears.
- const answer = useRef<HTMLDivElement>(null)
- useEffect(() => answer.current?.querySelector('textarea')?.focus(), [])
-
- // A reply is the answer: steering closes the open asks with the message
- // (turns, "Open asks close as declined; the message is the answer"). Once
- // the ask is gone, the text goes as an ordinary message.
- const send = useMutation({
- mutationFn: (text: string) =>
- sendTurn(
- s.id,
- text,
- !gone && caps?.features.steer !== false ? 'steer' : 'queue',
- ),
- onSuccess: () => (gone ? setDraft('') : onAnswered()),
- })
- const aside = useMutation({
- mutationFn: () =>
- entry.aside ? bringBack(s.id) : setAside(s.id, entry.ref),
- onSuccess: () => (entry.aside ? onBack() : onAside()),
- onError: (e) =>
- notifyError(
- entry.aside ? 'Could not bring it back' : 'Could not set it aside',
- e,
- ),
- })
- const submit = () => {
- if (draft.trim() && !send.isPending) send.mutate(draft.trim())
- }
- const dialog = !gone && DIALOGS.has(ask.kind)
-
+ const s = entry.session
return (
- <div className="mx-auto flex h-full w-full max-w-3xl flex-col px-6 pt-8 pb-5">
- <header className="shrink-0 space-y-1 pb-4">
- <p className="text-muted-foreground flex min-w-0 items-center gap-1.5 text-sm">
- <span className="truncate">{sessionTitle(s)}</span>
- <span aria-hidden>·</span>
- <span className="shrink-0">{timeAgo(entry.at)} ago</span>
- </p>
- <h1 className="text-xl font-semibold tracking-tight">{entry.line}</h1>
- </header>
-
- <Conversation session={s} turnId={ask.turnId} />
-
- <div ref={answer} className="shrink-0 space-y-2 pt-4">
- {gone ? (
- <div className="flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm">
- <span className="text-muted-foreground">
- This was answered elsewhere.
+ <div className="mx-auto flex h-full w-full max-w-[47rem] flex-col px-6 pt-6 pb-6">
+ <header className="shrink-0">
+ <div className="flex h-5 items-center gap-4 text-xs">
+ <p className="text-muted-foreground flex min-w-0 items-center gap-1.5">
+ <Link
+ to={`/computer/sessions/${s.id}`}
+ className="hover:text-foreground truncate"
+ >
+ {sessionTitle(s)}
+ </Link>
+ <span aria-hidden>·</span>
+ <span className="shrink-0 tabular-nums">
+ {timeAgo(entry.at)} ago
</span>
- <Button size="sm" onClick={onNext}>
- Next
- </Button>
- </div>
- ) : dialog ? (
- <AskCard ask={ask} session={s} hideTitle onAnswered={onAnswered} />
- ) : null}
- <div className="bg-card focus-within:border-ring/60 rounded-xl border shadow-sm transition-colors">
- <ChatTextarea
- value={draft}
- onChange={(e) => setDraft(e.target.value)}
- onSend={submit}
- placeholder={gone ? 'Message the agent' : 'Reply'}
- aria-label="Reply"
- className="min-h-11 resize-none border-0 bg-transparent px-4 pt-3 shadow-none focus-visible:ring-0 dark:bg-transparent"
- />
- <div className="flex items-center justify-end gap-1.5 px-2 pb-2">
- {send.isError ? (
- <p
- role="alert"
- className="text-destructive mr-auto flex items-center gap-2 px-2 text-xs"
+ </p>
+ <div className="ml-auto flex min-w-0 shrink-0 justify-end">
+ {sent ? (
+ <SentLine sent={sent} />
+ ) : (
+ <Link
+ to={`/computer/sessions/${s.id}`}
+ className="text-muted-foreground hover:text-foreground flex items-center gap-1"
>
- Not sent
- <button
- type="button"
- className="underline underline-offset-2"
- onClick={submit}
- >
- Retry
- </button>
- </p>
- ) : null}
- {gone ? null : (
- <Button
- size="sm"
- variant="ghost"
- disabled={aside.isPending}
- onClick={() => aside.mutate()}
- >
- {entry.aside ? 'Bring back' : 'Set aside'}
- </Button>
+ Open the session
+ <ArrowUpRight className="size-3.5" aria-hidden />
+ </Link>
)}
- <Button
- size="icon"
- className="rounded-full"
- aria-label="Send"
- disabled={!draft.trim() || send.isPending}
- onClick={submit}
- >
- {send.isPending ? (
- <Loader2 className="animate-spin" aria-hidden />
- ) : (
- <ArrowUp aria-hidden />
- )}
- </Button>
</div>
</div>
+ <h1 className="mt-1 line-clamp-2 text-xl leading-7 font-semibold tracking-tight">
+ {entry.line}
+ </h1>
+ </header>
+
+ <Conversation session={s} turnId={entry.ask?.turnId ?? null} />
+
+ <div className="shrink-0 pt-4">
+ <AnswerDock
+ entry={entry}
+ gone={gone}
+ draft={draft}
+ setDraft={setDraft}
+ onAnswered={onAnswered}
+ onAside={onAside}
+ onBack={onBack}
+ onNext={onNext}
+ />
</div>
</div>
)
@@ -391,8 +429,9 @@ function AskView({
const TAIL_TURNS = 3
-// The excerpt: a link to the earlier messages, then the last turns, with a
-// rule where the asking turn starts.
+// The excerpt, unframed: a link to the earlier messages, then the last turns,
+// with a rule where the asking turn starts. It sits on the dock: short
+// excerpts are pushed to the bottom, long ones open scrolled to the end.
function Conversation({
session,
turnId,
@@ -434,37 +473,27 @@ function Conversation({
return (
<section
aria-label="Conversation"
- className="flex min-h-0 flex-1 flex-col rounded-xl border"
+ ref={scroller}
+ className="-mx-2 mt-2 min-h-0 flex-1 overflow-y-auto [mask-image:linear-gradient(to_bottom,transparent,black_24px)] px-2"
>
- <div className="border-border flex h-10 shrink-0 items-center justify-between gap-3 border-b px-4 text-xs">
- <span className="font-medium">Conversation</span>
- <Link
- to={`/computer/sessions/${session.id}`}
- className="text-muted-foreground hover:text-foreground underline-offset-2 hover:underline"
- >
- Open the session
- </Link>
- </div>
- <div ref={scroller} className="min-h-0 flex-1 overflow-y-auto">
- <div className="space-y-5 px-5 py-4">
- {earlier ? (
- <Link
- to={`/computer/sessions/${session.id}`}
- className="text-muted-foreground hover:text-foreground block text-center text-xs"
- >
- {earlier} earlier {earlier === 1 ? 'message' : 'messages'}
- </Link>
- ) : null}
- {items(before)}
- {after.length ? (
- <div className="text-muted-foreground flex items-center gap-3 text-xs">
- <span className="bg-border h-px flex-1" />
- where it stopped
- <span className="bg-border h-px flex-1" />
- </div>
- ) : null}
- {items(after)}
- </div>
+ <div className="flex min-h-full flex-col justify-end gap-5 pt-6 pb-1">
+ {earlier ? (
+ <Link
+ to={`/computer/sessions/${session.id}`}
+ className="text-muted-foreground hover:text-foreground self-center text-xs"
+ >
+ {earlier} earlier {earlier === 1 ? 'message' : 'messages'}
+ </Link>
+ ) : null}
+ {items(before)}
+ {after.length ? (
+ <div className="text-muted-foreground/80 flex items-center gap-3 text-xs">
+ <span className="bg-border h-px flex-1" />
+ where it stopped
+ <span className="bg-border h-px flex-1" />
+ </div>
+ ) : null}
+ {items(after)}
</div>
</section>
)
diff --git a/web/src/managed-agents/computer-sessions/triage.ts b/web/src/managed-agents/computer-sessions/triage.ts
index 332ab502..4ec88541 100644
--- a/web/src/managed-agents/computer-sessions/triage.ts
+++ b/web/src/managed-agents/computer-sessions/triage.ts
@@ -7,6 +7,7 @@ import {
type ListSessionsQuery,
type Session,
} from '../computer-sessions-api'
+import { approvalLine } from './ask-line'
import { askTitle } from './state'
// What triage shows (work-tracking, ux-spec 3): the caller's own sessions
@@ -27,11 +28,16 @@ export const TRIAGE_WORKING: ListSessionsQuery = {
limit: 50,
}
+/** What the person is asked for; decides the answer dock's shape. */
+export type TriageKind = 'approval' | 'question' | 'secret' | 'reply'
+
export type TriageEntry = {
/** The ask's id: what Set aside stores, and what the screen selects by. */
ref: string
session: Session
- ask: Ask
+ /** The open ask; null when the session needs a reply to plain text. */
+ ask: Ask | null
+ kind: TriageKind
/** The ask in one line, the screen's headline. */
line: string
/** When the ask opened. */
@@ -39,17 +45,47 @@ export type TriageEntry = {
aside: boolean
}
+const KINDS = new Set(['approval', 'question', 'secret'])
+
+/** The ask in one line, as triage heads it. */
+export function askLine(ask: Ask): string {
+ return ask.kind === 'approval' ? approvalLine(ask) : askTitle(ask)
+}
+
+// Tech design 3.7, read ahead of the server: a session whose last turn ended
+// in text that needs its person. Absent today; the schema is loose.
+type Attention = {
+ reason?: string
+ ref?: string
+ line?: string | null
+ at?: string
+}
+
/** The session's ask for triage: its oldest open ask, or null when none is open. */
export function triageEntry(s: Session): TriageEntry | null {
const ask = s.asks
.filter((a) => a.status === 'open')
.sort((a, b) => a.createdAt.localeCompare(b.createdAt))[0]
- if (!ask) return null
+ if (!ask) {
+ const att = (s as { attention?: Attention | null }).attention
+ if (!att?.ref || (att.reason !== 'reply' && att.reason !== 'failed'))
+ return null
+ return {
+ ref: att.ref,
+ session: s,
+ ask: null,
+ kind: 'reply',
+ line: att.line || 'Needs a reply',
+ at: att.at ?? s.lastActiveAt ?? s.createdAt,
+ aside: s.aside,
+ }
+ }
return {
ref: ask.id,
session: s,
ask,
- line: askTitle(ask),
+ kind: KINDS.has(ask.kind) ? (ask.kind as TriageKind) : 'reply',
+ line: askLine(ask),
at: ask.createdAt,
aside: s.aside,
}