Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(pro): Super Tab waits on the Harness Pro — needs you, stuck (#1492)

0xdiego258eb3542c50f1
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.ts
index fce6f905a..5ebfa058c 100644
--- a/backend/integration/superTabs.test.ts
+++ b/backend/integration/superTabs.test.ts
@@ -863,6 +863,22 @@ describe('Super Tabs on a real Mongo replica set', () => {
expect((await store.hostTabs(host, 'test-host')).find(t => t.tabId === tab)?.observers).not.toContainEqual({ email: peer.email, userId: peer.sub })
})
+ it('tells the execution host which of its agents need a decision or are stuck', async () => {
+ const { tab } = await fixture()
+ const group = (await run(tab, { type: 'conversation.create', title: 'Release', brief: 'Ship it.', checks: [{ description: 'Shipped.', independent: false }] })).result.conversationId as string
+ const worker = (await run(tab, { type: 'agent.add', conversationId: group, machineId: 'test-host', harnessId: randomUUID(),
+ name: 'Builder', configuration: config, lead: false })).result.agentId as string
+ const assignmentId = (await run(tab, { type: 'work.assign', conversationId: group, agentId: worker })).result.assignmentId as string
+ const row = async () => (await store.hostTabs(host, 'test-host')).find(t => t.tabId === tab && t.agent.id === worker)!
+ expect(await row()).toMatchObject({ tabName: 'Pilot', attention: null })
+ await run(tab, { type: 'work.status', conversationId: group, assignmentId, status: 'blocked', result: 'No access to staging.' } as Command, host, worker)
+ expect((await row()).attention).toEqual({ assignmentId, status: 'blocked', result: 'No access to staging.' })
+ await run(tab, { type: 'work.status', conversationId: group, assignmentId, status: 'needs_human', result: null } as Command, host, worker)
+ expect((await row()).attention).toEqual({ assignmentId, status: 'needs_human', result: null })
+ await run(tab, { type: 'work.status', conversationId: group, assignmentId, status: 'working', result: null } as Command, host, worker)
+ expect((await row()).attention).toBeNull()
+ })
+
it('marks members of only archived groups inactive for host retention', async () => {
const { tab, lead } = await fixture()
const group = (await run(tab, { type: 'conversation.create', title: 'Done work', brief: '', checks: [] })).result.conversationId as string
diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.ts
index 02f869c8c..b983bc3ff 100644
--- a/backend/src/superTabs/commands.test.ts
+++ b/backend/src/superTabs/commands.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { applyCommand, commandSchema, type Command, type CommandContext } from './commands.js'
-import { createSuperTab, visibleState, type Actor, type AgentConfiguration } from './model.js'
+import { activeWork, createSuperTab, visibleState, type Actor, type AgentConfiguration } from './model.js'
import type { RouteDecision } from './routeRecord.js'
const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }
@@ -169,6 +169,24 @@ describe('Super Tab collaboration policy', () => {
expect(f.state.conversations[1]!.checks[0]!.evidence).toBeNull()
})
+ it('tells the Lead when the assignee is stuck and keeps the work active', () => {
+ const f = fixture()
+ const lead = f.add('lead', 'owner', 'lead', true)
+ const group = f.group()
+ const worker = f.add('worker', 'owner', group)
+ const assignmentId = f.run({ type: 'work.assign', conversationId: group, agentId: worker }).result.assignmentId as string
+ const as: Actor = { kind: 'agent', agentId: worker, machineOwnerId: 'host-owner' }
+ const stuck = f.run({ type: 'work.status', conversationId: group, assignmentId, status: 'blocked', result: 'The staging database refuses my key.' }, as)
+ expect(stuck.messages[0]).toMatchObject({ conversationId: group, text: 'Stuck\n\nThe staging database refuses my key.', recipients: [lead] })
+ expect(f.state.conversations[1]!.assignment!.status).toBe('blocked')
+ expect(activeWork(f.state.conversations[1]!)).toBe(true)
+ expect(() => f.run({ type: 'work.assign', conversationId: f.group(), agentId: worker })).toThrow('active assignment')
+ const decision = f.run({ type: 'work.status', conversationId: group, assignmentId, status: 'needs_human', result: 'Ship to everyone, or behind a flag?' }, as)
+ expect(decision.messages[0]).toMatchObject({ text: 'Needs a human\n\nShip to everyone, or behind a flag?', recipients: [lead] })
+ f.run({ type: 'work.status', conversationId: group, assignmentId, status: 'working', result: null }, as)
+ expect(f.state.conversations[1]!.assignment!.status).toBe('working')
+ })
+
it('allows discussion while paused and refuses new work, without mutating rejected state', () => {
const f = fixture()
f.run({ type: 'tab.pause', paused: true })
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index 70eac2564..7006c411f 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -78,7 +78,7 @@ export const commandSchema = z.discriminatedUnion('type', [
z.object({ type: z.literal('work.define'), conversationId: id, brief: text, checks: z.array(check).min(1).max(40) }).strict(),
z.object({ type: z.literal('work.assign'), conversationId: id, agentId: id, routeDecisionId: id.optional(), overrideReason: reason.optional() }).strict(),
z.object({ type: z.literal('work.status'), conversationId: id, assignmentId: id,
- status: z.enum(['working', 'needs_human', 'review', 'done', 'stopped']), result: text.nullable() }).strict(),
+ status: z.enum(['working', 'needs_human', 'blocked', 'review', 'done', 'stopped']), result: text.nullable() }).strict(),
z.object({ type: z.literal('route.record'), conversationId: id, decision: routeRecordSchema }).strict(),
z.object({ type: z.literal('route.override'), decisionId: id, candidateId: z.string().regex(/^c\d{1,2}$/), reason }).strict(),
z.object({ type: z.literal('route.modelResult'), decisionId: id, startId: id, model: z.string().min(1).max(200), effort: z.string().min(1).max(80) }).strict(),
@@ -691,10 +691,11 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
assignment.status = command.status
assignment.result = command.result
if (changed) {
- const label = { working: 'Working', needs_human: 'Needs a human', review: 'Ready for review', done: 'Done', stopped: 'Stopped' }[command.status]
+ const label = { working: 'Working', needs_human: 'Needs a human', blocked: 'Stuck', review: 'Ready for review', done: 'Done', stopped: 'Stopped' }[command.status]
const lead = group.leadId
+ // Stuck is the Lead's to hear as a human decision is: either way the work waits on someone.
const tellLead = actor.kind === 'agent' && actor.agentId === assignment.agentId && lead && lead !== actor.agentId &&
- ['needs_human', 'review', 'done'].includes(command.status)
+ ['needs_human', 'blocked', 'review', 'done'].includes(command.status)
message(group.id, `${label}${command.result ? `\n\n${command.result}` : ''}`, tellLead ? [lead] : [])
}
break
diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.ts
index 7c3761747..149e45ec6 100644
--- a/backend/src/superTabs/model.ts
+++ b/backend/src/superTabs/model.ts
@@ -57,7 +57,9 @@ export interface AgentStart {
dispatched: boolean
error: string | null
}
-export type WorkStatus = 'planned' | 'working' | 'needs_human' | 'review' | 'done' | 'stopped' | 'reconciling'
+/** `needs_human`: the agent needs a person's decision (its result is the question). `blocked`: it cannot go on (its result
+ * says why). Both stay active work; the machine running the agent alerts its Harness Pro (cli/src/superTabs/attention.ts). */
+export type WorkStatus = 'planned' | 'working' | 'needs_human' | 'blocked' | 'review' | 'done' | 'stopped' | 'reconciling'
export interface Check {
id: string
description: string
diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.ts
index d9ca59d88..4ba734e3d 100644
--- a/backend/src/superTabs/store.ts
+++ b/backend/src/superTabs/store.ts
@@ -684,7 +684,12 @@ export class SuperTabStore {
catch (error) { if (error instanceof SuperTabError) continue; throw error }
// `active` lets the host release members that are only in archived groups to automatic cleanup.
const active = state.conversations.some(c => !c.archived && c.agentIds.includes(target.id))
- result.push({ tabId: row.id, revision: row.revision, paused: state.paused, active, agent: target,
+ // The agent's own work waiting on a person, for this host's Harness Pro (cli/src/superTabs/attention.ts): the
+ // assignment it runs here that needs a decision or is stuck, and what it said. Nothing the agent cannot read itself.
+ const waiting = state.conversations.find(c => activeWork(c) && c.assignment!.agentId === target.id &&
+ c.assignment!.execution.machineId === machineId && ['needs_human', 'blocked'].includes(c.assignment!.status))?.assignment
+ const attention = waiting ? { assignmentId: waiting.id, status: waiting.status, result: waiting.result?.slice(0, 500) ?? null } : null
+ result.push({ tabId: row.id, tabName: state.name, revision: row.revision, paused: state.paused, active, attention, agent: target,
observers: people.filter(p => p.id !== user.sub &&
canReadAgent(state, { kind: 'person', userId: p.id, email: p.email }, target))
.map(p => ({ email: p.email, userId: p.id })) })
diff --git a/cli/src/cable/cableHost.ts b/cli/src/cable/cableHost.ts
index 57449a4e9..3ae61ca0f 100644
--- a/cli/src/cable/cableHost.ts
+++ b/cli/src/cable/cableHost.ts
@@ -28,7 +28,7 @@ import type { FleetRouting } from '../services/fleet.js'
import { ServiceUnavailableError } from '../core/serviceHost.js'
import { PLAYER_STATES, type PlayerSession } from './playerLibrary.js'
-import type { ActivitySnapshot, AppSwarms, CableAgent, CableHost, CableMachine, CableMachineSource, CableSwarm, CableTile, DialStatus, OpenReason, RouteDecision } from './cableSession.js'
+import type { ActivitySnapshot, AppSwarms, SuperTabAsk, CableAgent, CableHost, CableMachine, CableMachineSource, CableSwarm, CableTile, DialStatus, OpenReason, RouteDecision } from './cableSession.js'
import type { WindowRoute } from './windowRoute.js'
import type { SelectionCommand, SelectionResult } from './windowSelection.js'
import type { VisitCommand, VisitResult } from './windowVisit.js'
@@ -925,13 +925,16 @@ export function cableEventFor(
* question screen was complete, wired and unreachable: nothing on this side ever produced the message.
*/
export function cableQuestionFor(
- frame: { type?: string; agentId?: string; payload?: { requestId?: string; questions?: unknown } },
-): { agentId: string; requestId: string; questions: unknown } | null {
+ frame: { type?: string; agentId?: string; payload?: { requestId?: string; questions?: unknown; superTab?: unknown; attention?: unknown } },
+): { agentId: string; requestId: string; questions: unknown; superTab?: SuperTabAsk } | null {
if (frame.type !== 'commander_question' || !frame.agentId) return null
const requestId = frame.payload?.requestId
const questions = frame.payload?.questions
if (typeof requestId !== 'string' || !requestId || !Array.isArray(questions)) return null
- return { agentId: frame.agentId, requestId, questions }
+ // A Super Tab member waiting on a person (core/superTabAttention.ts): the tab's name and what it needs ride along.
+ const superTab = frame.payload?.superTab, attention = frame.payload?.attention
+ const tab = typeof superTab === 'string' && superTab && (attention === 'decision' || attention === 'stuck') ? { superTab, attention } as SuperTabAsk : null
+ return { agentId: frame.agentId, requestId, questions, ...(tab ? { superTab: tab } : {}) }
}
/**
diff --git a/cli/src/cable/cableSession.spec.ts b/cli/src/cable/cableSession.spec.ts
index 7e1c5b8d4..a7fef4833 100644
--- a/cli/src/cable/cableSession.spec.ts
+++ b/cli/src/cable/cableSession.spec.ts
@@ -3108,6 +3108,77 @@ describe('hello capabilities', () => {
} finally { await session.stop() }
})
+ it('carries a Super Tab wait on the question frame, keeps its agent asking through its turns and resyncs it', async () => {
+ const { session, port } = await connect(richHost())
+ try {
+ port.say({ ...PRO_HELLO, superTab: 'wait-v1' })
+ await vi.waitFor(() => expect(port.types()).toContain('notif.replace'))
+ port.sent.length = 0
+ const asked = [{ q: 'Stuck: no access to staging' }]
+ await session.question('a1', 'supertab:as1:blocked', asked, { superTab: 'Pilot', attention: 'stuck' })
+ expect(ofType(port, 'question')).toMatchObject([{ agentId: 'a1', id: 'supertab:as1:blocked', questions: asked, superTab: 'Pilot', attention: 'stuck' }])
+ // Not answerable on a device: nothing to read or review.
+ port.say({ t: 'question.read', agentId: 'a1', requestId: 'read-1' })
+ await vi.waitFor(() => expect(port.types()).toContain('question.state'))
+ expect(ofType(port, 'question.state')[0]).toMatchObject({ ok: false })
+ // It outlives the agent's turns on the device itself (the Pro keeps it): nothing is asked again, so it alerts
+ // once, and the library page keeps the agent asking.
+ port.sent.length = 0
+ await session.turnStarted('a1')
+ await session.summary('a1', 'Tried again.', 'Still no access.', 'list')
+ await session.turnDone('a1')
+ await session.turnError('a1', 'Failed')
+ expect(port.types()).not.toContain('question')
+ expect(port.types()).not.toContain('question.close')
+ expect((session as unknown as { liveTurns: Map<string, string> }).liveTurns.get('a1')).toBe('question')
+ // A resync shows it again, with the tab.
+ port.sent.length = 0
+ port.say({ t: 'resync' })
+ await vi.waitFor(() => expect(port.types()).toContain('question'))
+ expect(ofType(port, 'question')).toMatchObject([{ agentId: 'a1', id: 'supertab:as1:blocked', superTab: 'Pilot', attention: 'stuck' }])
+ // A Pro whose session came back asks for the agents, having dropped its questions: the wait is asked again.
+ port.sent.length = 0
+ port.say({ t: 'agents.list' })
+ await vi.waitFor(() => expect(port.types()).toContain('question'))
+ expect(ofType(port, 'question')).toMatchObject([{ agentId: 'a1', id: 'supertab:as1:blocked', superTab: 'Pilot' }])
+ // Closed with no turn open, it leaves the agent idle, not working; closed mid-turn, the turn goes on.
+ const live = (session as unknown as { liveTurns: Map<string, string> }).liveTurns
+ await session.questionClose('a1', 'supertab:as1:other') // not the wait it holds: nothing
+ expect(live.get('a1')).toBe('question')
+ await session.questionClose('a1', 'supertab:as1:blocked')
+ expect(live.has('a1')).toBe(false)
+ await session.question('a1', 'supertab:as1:needs_human', asked, { superTab: 'Pilot', attention: 'decision' })
+ await session.turnStarted('a1')
+ await session.questionClose('a1', 'supertab:as1:needs_human')
+ expect(live.get('a1')).toBe('working')
+ await session.turnDone('a1')
+ expect(live.has('a1')).toBe(false)
+ // An engine's question in its place is a plain one.
+ await session.question('a2', 'supertab:as2:needs_human', [{ q: 'Which?' }], { superTab: 'Pilot', attention: 'decision' })
+ await session.question('a2', 'tool-1', [{ key: 'k', q: 'Go?', options: ['yes'] }])
+ await session.turnDone('a2')
+ expect((session as unknown as { liveTurns: Map<string, string> }).liveTurns.has('a2')).toBe(false)
+ // Without a Super Tab, the frame is as it always was.
+ await session.question('a3', 'tool-2', [{ key: 'k', q: 'Go?', options: ['yes'] }])
+ expect(ofType(port, 'question').at(-1)).not.toHaveProperty('superTab')
+ } finally { await session.stop() }
+ })
+
+ it('sends Super Tab waits only to a device that says it shows them', async () => {
+ const { session, port } = await connect(richHost())
+ try {
+ port.say({ ...PRO_HELLO }) // a Pro from before the wait, or a round dial: it would offer an answer screen
+ await vi.waitFor(() => expect(port.types()).toContain('notif.replace'))
+ port.sent.length = 0
+ await session.question('a1', 'supertab:as1:blocked', [{ q: 'Stuck: no key' }], { superTab: 'Pilot', attention: 'stuck' })
+ await session.questionClose('a1', 'supertab:as1:blocked')
+ port.say({ t: 'agents.list' })
+ await settle()
+ expect(port.types()).not.toContain('question')
+ expect(port.types()).not.toContain('question.close')
+ } finally { await session.stop() }
+ })
+
it('sends turn.stats only to a stats: turn-v1 device, and only when there is something to say', async () => {
const { session, port } = await connect(richHost())
try {
diff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.ts
index b5545c9d0..33ceddad9 100644
--- a/cli/src/cable/cableSession.ts
+++ b/cli/src/cable/cableSession.ts
@@ -33,6 +33,7 @@ import { SerialLink, findDialPort } from './serial.js'
import { PLAYER_PAGE_SIZE, playerPage, type PlayerSession } from './playerLibrary.js'
import { PassageCarry, withCarriedPassage, type CarryRead } from './passageCarry.js'
import { VoiceDraft, type DraftPin } from './voiceDraft.js'
+import { SUPER_TAB_REQUEST_PREFIX } from '../core/api.js'
import { QuestionInbox, type ReviewedAnswer, type AnswerReceipt, type QuestionSpeech } from './questionInbox.js'
import { notificationReadToken, type UnreadNotification } from '../lib/notificationRead.js'
@@ -257,6 +258,13 @@ export interface AppSwarms {
/** Why the list is as short as it is. The dial renders this, instead of drawing an empty wheel. */
export type CableMachineSource = 'backend' | 'local' | 'signed-out'
+/**
+ * What a Super Tab member's wait adds to its `question` (core/superTabAttention.ts): the tab's name and whether it needs a
+ * decision or is stuck. The Harness Pro makes it an alert whose toast stays; firmware without it, and the round dial,
+ * read the words alone. Nobody answers it on a device.
+ */
+export interface SuperTabAsk { superTab: string; attention: 'decision' | 'stuck' }
+
/** Why the dial sent an `agent.open`: a tap (absent) or a question screen that came up on its own. */
export type OpenReason = 'question'
@@ -601,6 +609,10 @@ export class CableSession {
private statsTurn = false
/** `player: 'library-v1'`: the paged `player.library`. */
private playerCapable = false
+ /** `superTab: 'wait-v1'`: a `question` with `superTab` and `attention` is shown as a Super Tab wait, which nobody
+ * answers on the device. Any other device is not sent one: the round dial would open a question screen for it that
+ * cannot load. */
+ private superTabWaits = false
private playerOffset = 0
private playerRequest = 0
private playerLibraryKey = ''
@@ -614,13 +626,13 @@ export class CableSession {
/** For the greeting's log line: which capabilities this hello named, or nothing. */
private capabilitiesNamed(): string {
- const named = [this.swarmMembers && 'swarms', this.longRecap && 'recap', this.stepsActivity && 'activity', this.statsTurn && 'stats', this.playerCapable && 'player']
+ const named = [this.swarmMembers && 'swarms', this.longRecap && 'recap', this.stepsActivity && 'activity', this.statsTurn && 'stats', this.playerCapable && 'player', this.superTabWaits && 'superTab']
.filter(Boolean)
return named.length ? ` caps ${named.join(',')}` : ''
}
private resetCapabilities(): void {
- this.swarmMembers = this.longRecap = this.stepsActivity = this.statsTurn = this.playerCapable = false
+ this.swarmMembers = this.longRecap = this.stepsActivity = this.statsTurn = this.playerCapable = this.superTabWaits = false
this.seqOn = false
this.seq = 0
this.resyncAt = 0
@@ -1179,6 +1191,7 @@ export class CableSession {
this.stepsActivity = str('activity') === 'steps-v1'
this.statsTurn = str('stats') === 'turn-v1'
this.playerCapable = str('player') === 'library-v1'
+ this.superTabWaits = str('superTab') === 'wait-v1'
this.seqOn = str('board') === 'pro'
this.seq = 0
const mac = str('mac') ?? ''
@@ -1262,6 +1275,9 @@ export class CableSession {
return
case 'agents.list':
await this.pushAgents()
+ // A Pro asks for this as its session comes back, having dropped every question with the link (pro_app_link):
+ // the Super Tab waits still open are asked again. The same alert, so it does not beep twice.
+ await this.resendSuperTabAsks()
return
case 'agents.refresh':
// A workspace receipt needs the roster, not machines, notices and history.
@@ -2497,6 +2513,7 @@ export class CableSession {
for (const { agentId, id, questions } of this.questionInbox.open()) {
if (this.liveTurns.get(agentId) === 'question') await this.send({ t: 'question', agentId, ...this.whoIs(agentId), id, questions })
}
+ await this.resendSuperTabAsks()
}
// ── swarms ────────────────────────────────────────────────────────────────────────────────────────
@@ -2745,6 +2762,8 @@ export class CableSession {
*/
private readonly liveTurns = new Map<string, 'working' | 'question'>()
private markLive(agentId: string): void {
+ this.turnOpen.add(agentId)
+ if (this.turnOpen.size > 256) this.turnOpen.delete(this.turnOpen.values().next().value!)
if (this.liveTurns.get(agentId) === 'question') return
if (!this.liveTurns.has(agentId) && this.liveTurns.size >= 256) this.liveTurns.delete(this.liveTurns.keys().next().value!)
this.liveTurns.set(agentId, 'working')
@@ -2809,7 +2828,7 @@ export class CableSession {
await this.send({ t: 'turn.stats', agentId, ...stats })
}
async turnDone(agentId: string): Promise<void> {
- this.liveTurns.delete(agentId)
+ this.endLive(agentId)
this.activityReads.delete(agentId)
this.activityEndedAt.set(agentId, Date.now())
await this.send({ t: 'turn.done', agentId })
@@ -2822,7 +2841,7 @@ export class CableSession {
* `tier`, so firmware that predates `tier` still behaves. `subagent`: a sub-agent's end is not its main agent's.
*/
async summary(agentId: string, recap: string, text: string, tier: Tier = 'alert', fullText?: string, subagent = false): Promise<void> {
- if (!subagent) this.liveTurns.delete(agentId) // a sub-agent's end is not its main agent's
+ if (!subagent) this.endLive(agentId) // a sub-agent's end is not its main agent's
this.activityReads.delete(agentId)
this.activityEndedAt.set(agentId, Date.now())
recap = extendShortRecap(recap, text)
@@ -2921,7 +2940,7 @@ export class CableSession {
await this.send({ t: 'notif.seen', agentId, ...(readToken ? { readToken } : {}) })
}
async turnError(agentId: string, message: string): Promise<void> {
- this.liveTurns.delete(agentId)
+ this.endLive(agentId)
this.activityReads.delete(agentId)
this.activityEndedAt.set(agentId, Date.now())
await this.send({ t: 'turn.error', agentId, message })
@@ -2938,10 +2957,34 @@ export class CableSession {
* forward, so by the time anyone could answer "is it on screen" the answer was yes — every question
* came through quiet, no row was ever recorded, and looking away later left nothing behind.
*/
- async question(agentId: string, id: string, questions: unknown): Promise<void> {
+ async question(agentId: string, id: string, questions: unknown, superTab?: SuperTabAsk): Promise<void> {
+ if (superTab && !this.superTabWaits) return
this.questionInbox.set(agentId, id, questions)
this.liveTurns.set(agentId, 'question')
- await this.send({ t: 'question', agentId, ...this.whoIs(agentId), id, questions })
+ // The inbox keeps only questions a device can answer, so a Super Tab wait is kept here for a resync.
+ if (superTab) this.superTabAsks.set(agentId, { id, questions, superTab })
+ else this.superTabAsks.delete(agentId)
+ await this.send({ t: 'question', agentId, ...this.whoIs(agentId), id, questions, ...(superTab ? { superTab: superTab.superTab, attention: superTab.attention } : {}) })
+ }
+ /** Asks a Pro again for every Super Tab wait still open (a resync, a relink). */
+ private async resendSuperTabAsks(): Promise<void> {
+ if (!this.superTabWaits) return
+ for (const [agentId, { id, questions, superTab }] of this.superTabAsks) {
+ await this.send({ t: 'question', agentId, ...this.whoIs(agentId), id, questions, ...superTab })
+ }
+ }
+ /** The agents whose turn this session saw start and not end, whatever their question says. */
+ private readonly turnOpen = new Set<string>()
+ /** The Super Tab waits the device was last shown, by agent (`question`), for `resync`. */
+ private readonly superTabAsks = new Map<string, { id: string; questions: unknown; superTab: SuperTabAsk }>()
+ /**
+ * A turn ended. A Super Tab wait outlives the agent's turns (the Pro keeps it through them, pod_model `set_state`), so
+ * its agent stays `question` in the library page; any other is no longer live.
+ */
+ private endLive(agentId: string): void {
+ this.turnOpen.delete(agentId)
+ if (this.superTabAsks.has(agentId)) this.liveTurns.set(agentId, 'question')
+ else this.liveTurns.delete(agentId)
}
/**
@@ -2952,9 +2995,16 @@ export class CableSession {
* halfway through giving.
*/
async questionClose(agentId: string, id: string): Promise<void> {
+ const wait = this.superTabAsks.get(agentId)
+ // A wait this device was never sent (it cannot show one) has nothing to close.
+ if (id.startsWith(SUPER_TAB_REQUEST_PREFIX) && wait?.id !== id) return
if (!this.questionInbox.close(agentId, id)) return
- // Answered: the turn goes on (its end clears it).
- if (this.liveTurns.get(agentId) === 'question') this.liveTurns.set(agentId, 'working')
+ this.superTabAsks.delete(agentId)
+ // Answered: the turn goes on (its end clears it). A Super Tab wait outlived its turns: working only if one is open.
+ if (this.liveTurns.get(agentId) === 'question') {
+ if (!wait || this.turnOpen.has(agentId)) this.liveTurns.set(agentId, 'working')
+ else this.liveTurns.delete(agentId)
+ }
await this.send({ t: 'question.close', agentId, id })
}
diff --git a/cli/src/core/api.spec.ts b/cli/src/core/api.spec.ts
index 0ccbef058..e230a879f 100644
--- a/cli/src/core/api.spec.ts
+++ b/cli/src/core/api.spec.ts
@@ -129,6 +129,10 @@ describe('the core API services stand on', () => {
expect(core.cloud).toBeUndefined()
const cloud = { publish: vi.fn(), ask: vi.fn(), unask: vi.fn() }
expect(createCoreApi({ ...deps, cloud }).cloud).toBe(cloud)
+ // The Super Tab service's door, the same way.
+ expect(core.superTabs).toBeUndefined()
+ const superTabs = { attention: vi.fn() }
+ expect(createCoreApi({ ...deps, superTabs }).superTabs).toBe(superTabs)
expect(core.agents.cloud).toBeUndefined()
const rows = [{ agentId: 'cloud_1' }] as RegisteredSession[]
expect(createCoreApi({ ...deps, cloudRows: () => rows }).agents.cloud!()).toBe(rows)
diff --git a/cli/src/core/api.ts b/cli/src/core/api.ts
index d7c9b514d..553415379 100644
--- a/cli/src/core/api.ts
+++ b/cli/src/core/api.ts
@@ -342,6 +342,8 @@ export interface CoreApi {
daemon: DaemonAddress
/** The cloud agents' doors into the core (services/cloud.ts): absent from a core or a process that offers them none. */
cloud?: CloudCore
+ /** The Super Tab service's door into the core (superTabs/attention.ts): absent from a core or a process that offers it none. */
+ superTabs?: SuperTabsCore
/** The Wi-Fi device's doors into the core (services/wifi.ts): each one call it made when it ran here. */
wifi: {
/** What it lists and reads in line (`WifiView`), asked again before each request it answers. */
@@ -1136,6 +1138,32 @@ export interface CloudCore {
unask(agentId: string, requestId: string): void
}
+/** The request ids of the Super Tab waits on the devices: never an engine's (theirs are its tool ids), so an answer
+ * sent back for one is never typed into a pane (services/devices.ts). */
+export const SUPER_TAB_REQUEST_PREFIX = 'supertab:'
+
+/**
+ * A Super Tab member on this machine waits on a person: its assignment needs a decision or is stuck
+ * (superTabs/attention.ts). Shown on the devices cabled here as a question nobody answers there: display only.
+ */
+export interface SuperTabAttention {
+ /** The local agent (its harness id). */
+ agentId: string
+ /** `supertab:<assignment>:<status>`: stable for one wait, never an engine's question id. */
+ requestId: string
+ /** The Super Tab's name, at most 48 bytes. */
+ superTab: string
+ attention: 'decision' | 'stuck'
+ /** What the device reads: the decision asked for, or why it is stuck. */
+ text: string
+}
+
+/** The Super Tab service's door into the core (core/superTabAttention.ts): the waits of its members here. */
+export interface SuperTabsCore {
+ /** Every wait, replacing the last set: the core raises what is new on the devices and closes what is gone. */
+ attention(items: SuperTabAttention[]): void
+}
+
/** What the cloud service answers the core: done, or why not, in words a person reads. */
export type CloudResult = { ok: true; detail?: string } | { ok: false; error: string; detail?: string }
@@ -1750,6 +1778,8 @@ export interface CoreApiDeps {
wifi: CoreApi['wifi']
/** The cloud agents' doors (core/agents/cloud.ts). */
cloud?: CloudCore
+ /** The Super Tab service's door (core/superTabAttention.ts). */
+ superTabs?: SuperTabsCore
/** The running cloud harnesses as list rows (`agents.cloud`). */
cloudRows?: () => RegisteredSession[]
lastTurn: CoreApi['transcripts']['lastTurn']
@@ -1765,7 +1795,7 @@ export function createCoreApi({
gridNamed, gridModelsChanged, dshInstallStatus, mintGridName, accessToken, lane, observerKey, tabKey, tabRelay, connectorVault, observer, privateGridName, machineName, backend, onNotice,
runtimeProfile, setRuntime, fork, create, creationStatus, dsh, windows, daemon, turns, questions, terminals = TERMINALS_OFF, conversations = CONVERSATIONS_OFF, viewerFrame, machine, activityText, activitySnapshot, activity, summaries,
closeAgent, activityAt,
- signedIn, environment, machines, sendLocal, sendToWindow, hasWindow, devicesChanged, dialWatching, wifi, cloud, cloudRows, lastTurn, nativeTurns, turnCard, turnSummary,
+ signedIn, environment, machines, sendLocal, sendToWindow, hasWindow, devicesChanged, dialWatching, wifi, cloud, superTabs, cloudRows, lastTurn, nativeTurns, turnCard, turnSummary,
log = (line) => console.warn(line),
}: CoreApiDeps): CoreApi {
// The devices reach the windows through these alone, and only with their own frames: a devices process
@@ -1841,5 +1871,6 @@ export function createCoreApi({
daemon,
wifi,
...(cloud ? { cloud } : {}),
+ ...(superTabs ? { superTabs } : {}),
}
}
diff --git a/cli/src/core/experimentQueries.spec.ts b/cli/src/core/experimentQueries.spec.ts
index 034121782..5e112258d 100644
--- a/cli/src/core/experimentQueries.spec.ts
+++ b/cli/src/core/experimentQueries.spec.ts
@@ -26,6 +26,21 @@ describe('the cloud agents\' doors', () => {
})
})
+describe('the Super Tab service\'s door', () => {
+ it('is the Super Tab service\'s alone, and hands its members\' waits to the core whole', async () => {
+ const superTabs = { attention: vi.fn() }
+ const core = fakeCore({ superTabs })
+ const both = new Set(['orchestrator', 'superTabs'])
+ const item = { agentId: 'a1', requestId: 'supertab:x:blocked', superTab: 'Pilot', attention: 'stuck', text: 'Stuck: no key' }
+ expect(await answerExperimentQuery(core, both, 'superTabs', 'super_tab_attention', { items: [item] })).toEqual({})
+ expect(superTabs.attention).toHaveBeenLastCalledWith([item])
+ await answerExperimentQuery(core, both, 'superTabs', 'super_tab_attention', { items: 'x' })
+ expect(superTabs.attention).toHaveBeenLastCalledWith([])
+ expect(await answerExperimentQuery(core, both, 'orchestrator', 'super_tab_attention', {})).toEqual({ error: 'NOT_SUPER_TABS' })
+ expect(await answerExperimentQuery(fakeCore(), both, 'superTabs', 'super_tab_attention', {})).toEqual({ error: 'NOT_SUPER_TABS' })
+ })
+})
+
describe('what an experiment in its own process may ask of the core', () => {
it('reads exact creation observations without treating an unavailable provider as an absent launch', async () => {
const id = 'creation-fixture-1234'
diff --git a/cli/src/core/experimentQueries.ts b/cli/src/core/experimentQueries.ts
index a00ea0281..c1d183d56 100644
--- a/cli/src/core/experimentQueries.ts
+++ b/cli/src/core/experimentQueries.ts
@@ -18,7 +18,9 @@
* - `account`: the account signed in here, its id and email, as the core reads it (`core.account.identity`), for Share
* alone: the observers a shared tab wants are derived for this account's harnesses;
* - `cloud_publish`, `cloud_ask`, `cloud_unask`: the cloud agents' harnesses and their questions
- * (`core.cloud`, core/agents/cloud.ts), for the cloud service alone.
+ * (`core.cloud`, core/agents/cloud.ts), for the cloud service alone;
+ * - `super_tab_attention`: the Super Tab members here waiting on a person (`core.superTabs`,
+ * core/superTabAttention.ts), for the Super Tab service alone.
* The core answers them only for the experiments (core/api.ts `EXPERIMENTS`): creating an agent or
* telling the windows something is no other process's to ask. The process's side is
* services/processCoreApi.ts. Agent Messages, an experiment until 2026-10-12, asks a few of the same and is
@@ -30,9 +32,9 @@ import { creationObservation } from '../lib/creationObservation.js'
import { nativeTurnCursorIn } from '../lib/nativeTurnObservations.js'
type Payload = Record<string, unknown>
-type Core = Pick<CoreApi, 'agents' | 'turns' | 'clients' | 'daemon' | 'account' | 'cloud' | 'transcripts'>
+type Core = Pick<CoreApi, 'agents' | 'turns' | 'clients' | 'daemon' | 'account' | 'cloud' | 'superTabs' | 'transcripts'>
-const QUERIES: ReadonlySet<string> = new Set(['shown', 'stopped', 'creation_status', 'native_turns', 'create', 'stop_turn', 'windows', 'daemon', 'backend', 'observer_key', 'observer_send', 'account', 'cloud_publish', 'cloud_ask', 'cloud_unask'])
+const QUERIES: ReadonlySet<string> = new Set(['shown', 'stopped', 'creation_status', 'native_turns', 'create', 'stop_turn', 'windows', 'daemon', 'backend', 'observer_key', 'observer_send', 'account', 'cloud_publish', 'cloud_ask', 'cloud_unask', 'super_tab_attention'])
const METHODS: ReadonlySet<string> = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
const text = (value: unknown): string => (typeof value === 'string' ? value : '')
@@ -118,6 +120,12 @@ export async function answerExperimentQuery(core: Core, experiments: ReadonlySet
else core.cloud.unask(text(payload.agentId), text(payload.questionId))
return {}
}
+ case 'super_tab_attention': {
+ // The core checks each item (core/superTabAttention.ts): what reaches the devices is decided there, not here.
+ if (service !== 'superTabs' || !core.superTabs) return { error: 'NOT_SUPER_TABS' }
+ core.superTabs.attention(Array.isArray(payload.items) ? payload.items : [])
+ return {}
+ }
case 'account': {
const known = await core.account.identity()
return known ? { ...known } : { error: 'ACCOUNT_UNAVAILABLE' }
diff --git a/cli/src/core/main.ts b/cli/src/core/main.ts
index fffe100e2..445df23f4 100644
--- a/cli/src/core/main.ts
+++ b/cli/src/core/main.ts
@@ -198,6 +198,7 @@ import { createTerminalWatch } from './terminalWatch.js'
import { createSharingLink } from './sharingLink.js'
import { createAgentSettingsSync, createExperimentHooks, wakeExperiments } from './experiments.js'
import { answerExperimentQuery, createForExperiment, creationForExperiment } from './experimentQueries.js'
+import { createSuperTabAttention } from './superTabAttention.js'
import { answerConnectorsQuery } from './connectorsQueries.js'
import { answerSharedMachinesQuery } from './sharedMachinesQueries.js'
import { inlineSharedMachinesPort } from '../lib/sharedMachinesPort.js'
@@ -794,6 +795,12 @@ async function runForeground(session: AuthSession | null): Promise<void> {
ask: (agentId, requestId, question) => cloudAgents?.doors.ask(agentId, requestId, question),
unask: (agentId, requestId) => cloudAgents?.doors.unask(agentId, requestId),
}
+ // The Super Tab members here waiting on a person, on the devices alone (core/superTabAttention.ts). Read only once
+ // the questions exist, below: the service starts after them.
+ const superTabWaits = createSuperTabAttention({
+ send: (frame) => ports.devices?.card(frame),
+ asking: (agentId) => [...openQuestions.values()].some((asked) => asked.agentId === agentId),
+ })
// Shared tabs' relay, a socket per shared tab held by the gateway (gateway/tabRelay.ts), and which of them the core saw
// opened: opened again after a gateway-only restart, closed when Agent Messages' process goes (core/gatewayLink.ts).
const tabRelay = tabRelayOf(() => gatewayOps.tabRelay)
@@ -803,6 +810,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
const coreApi = createCoreApi({
nativeTurns: async (agentId, cursor) => nativeTurns.read(agentId, cursor),
cloud: cloudDoors,
+ superTabs: { attention: (items) => superTabWaits.attention(items) },
cloudRows: () => (cloudAgents?.dialRows() ?? []) as unknown as RegisteredSession[],
// Agents' terminals: a literal-argv launch, and a read-only view for Share's observers (core/terminalWatch.ts).
terminals: { ...TERMINALS_OFF, ...createTerminalOpener({ createBackend, registry, announceSession, blocksFolder: (cwd) => !!backendRef?.purgeAgentService?.blocksFolder(cwd), noBackendCode: createUnavailable }), watch: terminalWatch.watch },
@@ -892,6 +900,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
if (attached) for (const frame of openQuestions.values()) ports.devices?.card(frame)
if (attached) void mirror.liveCards().then((cards) => { for (const frame of cards) ports.devices?.card(frame) })
if (attached) for (const frame of cloudAgents?.liveCards() ?? []) ports.devices?.card(frame)
+ if (attached) superTabWaits.replay()
},
// What a device or another machine asks of an agent here: the SAME handlers the backend socket
// drives, called directly — the slash-command adaptation and the turn and question plumbing live there.
@@ -2962,7 +2971,10 @@ async function runForeground(session: AuthSession | null): Promise<void> {
const payload = card.payload as Record<string, unknown> | undefined
const full = card.type === 'commander_event' && payload?.kind === 'summary' && typeof card.agentId === 'string'
? mirror.lastFullText(registry.byAgent(card.agentId)?.sessionId ?? card.agentId) ?? cloudAgents?.said(card.agentId) : undefined
+ // An engine's question takes the place of a Super Tab wait on the devices, which shows again once it closes.
+ superTabWaits.before(card)
ports.devices?.card(full ? { ...card, payload: { ...payload, fullText: full } } : card)
+ superTabWaits.after(card)
}
// Last: every handler is wired and the restored agents are confirmed, so requests that arrived while
diff --git a/cli/src/core/superTabAttention.spec.ts b/cli/src/core/superTabAttention.spec.ts
new file mode 100644
index 000000000..361030f92
--- /dev/null
+++ b/cli/src/core/superTabAttention.spec.ts
@@ -0,0 +1,106 @@
+import { describe, expect, it, vi } from 'vitest'
+import type { SuperTabAttention } from './api.js'
+import { createSuperTabAttention } from './superTabAttention.js'
+
+const wait = (agentId: string, over: Partial<SuperTabAttention> = {}): SuperTabAttention =>
+ ({ agentId, requestId: `supertab:as-${agentId}:needs_human`, superTab: 'Pilot', attention: 'decision', text: 'Ship it?', ...over })
+const raised = (item: SuperTabAttention) => ({ type: 'commander_question', agentId: item.agentId,
+ payload: { requestId: item.requestId, questions: [{ q: item.text }], superTab: item.superTab, attention: item.attention } })
+const closed = (item: SuperTabAttention) => ({ type: 'commander_question_close', agentId: item.agentId, payload: { requestId: item.requestId } })
+
+function setup() {
+ const send = vi.fn()
+ const asking = new Set<string>()
+ const log = vi.fn()
+ const waits = createSuperTabAttention({ send, asking: (agentId) => asking.has(agentId), log })
+ return { send, asking, log, waits }
+}
+
+describe('the Super Tab waits on the devices', () => {
+ it('raises what is new, keeps what is unchanged and closes what is gone or changed', () => {
+ const { send, waits, log } = setup()
+ const a = wait('a1'), b = wait('a2', { attention: 'stuck', requestId: 'supertab:as-a2:blocked', text: 'Stuck: no key' })
+ waits.attention([a, b])
+ expect(send.mock.calls.map(([frame]) => frame)).toEqual([raised(a), raised(b)])
+ expect(log).toHaveBeenCalledWith(expect.stringContaining('waits on a person (stuck)'))
+ send.mockClear()
+ waits.attention([a, b])
+ expect(send).not.toHaveBeenCalled()
+ // A new reason is a new alert; a status that moved on closes it.
+ const reworded = { ...a, text: 'Ship it today?' }
+ waits.attention([reworded])
+ expect(send.mock.calls.map(([frame]) => frame)).toEqual([closed(a), closed(b), raised(reworded)])
+ send.mockClear()
+ waits.attention('not a list')
+ expect(send.mock.calls.map(([frame]) => frame)).toEqual([closed(reworded)])
+ })
+
+ it('refuses what a device could not show or close, and keeps one wait per agent', () => {
+ const { send, waits } = setup()
+ const bad = [null, 'x', { ...wait('a1'), agentId: 'bad id' }, { ...wait('a1'), agentId: 7 },
+ { ...wait('a1'), requestId: 'tool-1' }, { ...wait('a1'), requestId: `supertab:${'x'.repeat(60)}` },
+ { ...wait('a1'), superTab: 'x'.repeat(49) }, { ...wait('a1'), superTab: '' }, { ...wait('a1'), text: 'x'.repeat(1201) },
+ { ...wait('a1'), attention: 'urgent' }]
+ waits.attention(bad)
+ expect(send).not.toHaveBeenCalled()
+ const first = wait('a1'), second = wait('a1', { requestId: 'supertab:other:needs_human' })
+ waits.attention([first, second, ...Array.from({ length: 70 }, (_, i) => wait(`b${i}`))])
+ // The first for an agent, and at most 64 items.
+ expect(send.mock.calls[0][0]).toEqual(raised(first))
+ expect(send).toHaveBeenCalledTimes(63)
+ })
+
+ it('lets an engine\'s question come first, and shows the wait again once it closes', () => {
+ const { send, asking, waits } = setup()
+ const a = wait('a1')
+ // Raised while the agent's own question is open: it waits for that question.
+ asking.add('a1')
+ waits.attention([a])
+ expect(send).not.toHaveBeenCalled()
+ waits.after({ type: 'commander_question_close', agentId: 'a1', payload: { requestId: 'tool-1' } })
+ expect(send).toHaveBeenLastCalledWith(raised(a))
+ asking.delete('a1')
+ // An engine's question for it takes its place: closed before the question goes out.
+ send.mockClear()
+ waits.before({ type: 'commander_question', agentId: 'a1', payload: { requestId: 'tool-2' } })
+ expect(send.mock.calls.map(([frame]) => frame)).toEqual([closed(a)])
+ // Its own frames, other cards and other agents change nothing.
+ send.mockClear()
+ for (const frame of [raised(a), closed(a), { type: 'commander_event', agentId: 'a1', payload: { kind: 'done' } },
+ { type: 'commander_question', payload: {} }, { type: 'commander_question', agentId: 'a9', payload: { requestId: 'tool-3' } },
+ { type: 'commander_question_close', agentId: 'a9', payload: { requestId: 'tool-3' } }]) {
+ waits.before(frame)
+ waits.after(frame)
+ }
+ expect(send).not.toHaveBeenCalled()
+ waits.before({ type: 'commander_question', agentId: 'a1', payload: { requestId: 'tool-4' } })
+ expect(send).not.toHaveBeenCalled()
+ waits.after({ type: 'commander_question_close', agentId: 'a1', payload: { requestId: 'tool-2' } })
+ expect(send).toHaveBeenLastCalledWith(raised(a))
+ send.mockClear()
+ waits.after({ type: 'commander_question_close', agentId: 'a1', payload: { requestId: 'tool-2' } })
+ expect(send).not.toHaveBeenCalled()
+ })
+
+ it('shows every wait again to a dial that attaches, after the engines\' questions', () => {
+ const { send, asking, waits } = setup()
+ const a = wait('a1'), b = wait('a2')
+ waits.attention([a, b])
+ send.mockClear()
+ asking.add('a2')
+ waits.replay()
+ expect(send.mock.calls.map(([frame]) => frame)).toEqual([raised(a)])
+ // Hidden behind a2's question, it is not closed when it goes.
+ send.mockClear()
+ waits.attention([a])
+ expect(send).not.toHaveBeenCalled()
+ })
+
+ it('logs to the console by default', () => {
+ const spy = vi.spyOn(console, 'log').mockImplementation(() => {})
+ try {
+ createSuperTabAttention({ send: () => {}, asking: () => false }).attention([wait('a1')])
+ expect(spy).toHaveBeenCalledWith(expect.stringContaining('[super-tabs] a1 waits on a person'))
+ } finally { spy.mockRestore() }
+ })
+})
diff --git a/cli/src/core/superTabAttention.ts b/cli/src/core/superTabAttention.ts
new file mode 100644
index 000000000..275e91efc
--- /dev/null
+++ b/cli/src/core/superTabAttention.ts
@@ -0,0 +1,98 @@
+/**
+ * The Super Tab members here that wait on a person (superTabs/attention.ts), shown on the devices cabled to this
+ * computer: a question frame with the tab's name and what it needs (`superTab`, `attention`), which the Harness Pro
+ * turns into an alert that stays (the round dial reads the words alone). Display only: nobody answers it on a device;
+ * the agent's Lead and the people in the tab do, in the tab.
+ *
+ * Only the devices hear these (`send` is `ports.devices.card`): never the Wi-Fi device, the backend or a window. The
+ * windows show the wait in the Super Tab itself, and the cloud has no business with it.
+ *
+ * The set is the service's to say, whole, each time it changes (`attention`); the core keeps it, so a dial that attaches
+ * later is shown it (`replay`) as it is shown the engines' own questions. A device holds one question per agent, so an
+ * engine's question comes first: ours is taken down before it shows (`before`) and put back once it is gone (`after`),
+ * and one raised while an engine's question is open waits for that question to close.
+ */
+import { SUPER_TAB_REQUEST_PREFIX, type SuperTabAttention } from './api.js'
+
+type Frame = Record<string, unknown>
+
+export interface SuperTabAttentionDeps {
+ /** The devices' door for cards (`ports.devices.card`). */
+ send(frame: Frame): void
+ /** Whether an engine's own question is open for this agent (core/questions.ts `openQuestions`). */
+ asking(agentId: string): boolean
+ log?: (line: string) => void
+}
+
+const LIMIT = 64
+const fits = (value: unknown, bytes: number): value is string => typeof value === 'string' && !!value && Buffer.byteLength(value) <= bytes
+
+/** An item the service sent, checked: what reaches a device is decided here. */
+function itemIn(value: unknown): SuperTabAttention | null {
+ const item = (value && typeof value === 'object' ? value : {}) as Record<string, unknown>
+ if (!fits(item.agentId, 160) || !/^[A-Za-z0-9_-]+$/.test(item.agentId)) return null
+ // The Pro drops a `question.close` whose id is 64 bytes or more: one it could not close is never raised.
+ if (!fits(item.requestId, 63) || !item.requestId.startsWith(SUPER_TAB_REQUEST_PREFIX)) return null
+ if (!fits(item.superTab, 48) || !fits(item.text, 1200) || (item.attention !== 'decision' && item.attention !== 'stuck')) return null
+ return { agentId: item.agentId, requestId: item.requestId, superTab: item.superTab, attention: item.attention, text: item.text }
+}
+
+export function createSuperTabAttention({ send, asking, log = (line) => console.log(line) }: SuperTabAttentionDeps) {
+ /** The waits, by agent, and whether the devices were last shown each. */
+ const open = new Map<string, { item: SuperTabAttention; shown: boolean }>()
+ const ours = (frame: Frame): boolean => {
+ const requestId = (frame.payload as { requestId?: unknown } | undefined)?.requestId
+ return typeof requestId === 'string' && requestId.startsWith(SUPER_TAB_REQUEST_PREFIX)
+ }
+ const raise = (entry: { item: SuperTabAttention; shown: boolean }): void => {
+ const { agentId, requestId, superTab, attention, text } = entry.item
+ entry.shown = true
+ send({ type: 'commander_question', agentId, payload: { requestId, questions: [{ q: text }], superTab, attention } })
+ }
+ const show = (entry: { item: SuperTabAttention; shown: boolean }): void => { if (!asking(entry.item.agentId)) raise(entry) }
+ const hide = (entry: { item: SuperTabAttention; shown: boolean }): void => {
+ if (!entry.shown) return
+ entry.shown = false
+ send({ type: 'commander_question_close', agentId: entry.item.agentId, payload: { requestId: entry.item.requestId } })
+ }
+
+ return {
+ /** Every wait, replacing the last set: what is gone or changed is closed, what is new is raised. */
+ attention(items: unknown): void {
+ const next = new Map<string, SuperTabAttention>()
+ for (const value of Array.isArray(items) ? items.slice(0, LIMIT) : []) {
+ const item = itemIn(value)
+ if (item && !next.has(item.agentId)) next.set(item.agentId, item)
+ }
+ for (const [agentId, entry] of open) {
+ if (JSON.stringify(next.get(agentId)) === JSON.stringify(entry.item)) { next.delete(agentId); continue }
+ hide(entry)
+ open.delete(agentId)
+ log(`[super-tabs] ${agentId} no longer waits · req=${entry.item.requestId}`)
+ }
+ for (const [agentId, item] of next) {
+ const entry = { item, shown: false }
+ open.set(agentId, entry)
+ show(entry)
+ log(`[super-tabs] ${agentId} waits on a person (${item.attention}) · req=${item.requestId}`)
+ }
+ },
+ /** A dial attached: it has nothing, so every wait is shown again (after the engines' own questions). */
+ replay(): void {
+ for (const entry of open.values()) { entry.shown = false; show(entry) }
+ },
+ /** A card about to reach the devices: an engine's question for an agent showing ours takes its place. */
+ before(frame: Frame): void {
+ if (frame.type !== 'commander_question' || typeof frame.agentId !== 'string' || ours(frame)) return
+ const entry = open.get(frame.agentId)
+ if (entry) hide(entry)
+ },
+ /** A card that reached the devices: once an engine's question closes, the agent's wait shows again. */
+ after(frame: Frame): void {
+ if (frame.type !== 'commander_question_close' || typeof frame.agentId !== 'string' || ours(frame)) return
+ const entry = open.get(frame.agentId)
+ // Not `show`: the engine's question is still in `openQuestions` until its close has been sent.
+ if (entry && !entry.shown) raise(entry)
+ },
+ }
+}
diff --git a/cli/src/services/devices.spec.ts b/cli/src/services/devices.spec.ts
index ffa0a92a9..110fdaa75 100644
--- a/cli/src/services/devices.spec.ts
+++ b/cli/src/services/devices.spec.ts
@@ -271,6 +271,11 @@ describe('the dial\'s host, wired to the core', () => {
expect(core.agents.setRuntime).toHaveBeenCalledWith('a1', 'opus', 'high')
expect(core.agents.runtimeModels).toHaveBeenCalledWith('a1')
expect(core.agents.fork).toHaveBeenCalledWith('a1')
+ // A Super Tab wait is shown, never answered: nothing reaches the pane.
+ w.answer('a1', 'supertab:as-1:needs_human', { q: 'Yes' })
+ expect(await w.answerReviewed!({ agentId: 'a1', requestId: 'supertab:as-1:needs_human' } as never)).toBe(false)
+ expect(core.questions.answer).toHaveBeenCalledTimes(1)
+ expect(core.questions.answerReviewed).toHaveBeenCalledTimes(1)
})
it('tells the windows on this computer what a hand at this desk did, and the owner\'s apps the device status', () => {
@@ -550,6 +555,15 @@ describe('what the windows say, reaching the dial', () => {
expect(seen.cable.calls.map(([name]) => name)).toEqual(['start', 'turnStarted', 'turnDone', 'turnError', 'turnStep', 'question', 'questionClose'])
})
+ it('hands the dial a Super Tab wait with its tab and what it needs, as an alert', () => {
+ const { port } = start()
+ port.card({ type: 'commander_question', agentId: 'a1', payload: { requestId: 'supertab:as-1:blocked', questions: [{ q: 'Stuck: no key' }], superTab: 'Pilot', attention: 'stuck' } })
+ port.card({ type: 'commander_question', agentId: 'a2', payload: { requestId: 'r2', questions: [], superTab: 'Pilot', attention: 'urgent' } })
+ expect(calls('question')).toEqual([['a1', 'supertab:as-1:blocked', [{ q: 'Stuck: no key' }], { superTab: 'Pilot', attention: 'stuck' }],
+ ['a2', 'r2', [], undefined]])
+ expect(logs.some((l) => /notify · .* · alert · rule:super-tab · question/.test(l))).toBe(true)
+ })
+
it('hands the dial a tool card as a step, and a processing card\'s latest sentence beside the status', () => {
const { port } = start()
port.card({ type: 'commander_event', agentId: 'a1', payload: { kind: 'tool', text: 'Read', recap: '/work/cli/src/cable/cableSession.ts' } })
diff --git a/cli/src/services/devices.ts b/cli/src/services/devices.ts
index c5cc40e49..25c734705 100644
--- a/cli/src/services/devices.ts
+++ b/cli/src/services/devices.ts
@@ -19,7 +19,7 @@
import { existsSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import { env } from '../config/env.js'
-import { DEVICES_REQUESTS, type CoreApi, type CorePorts, type DevicesPort, type RouteAnswer, type SendResult, type ServiceRequests, type WindowFocus } from '../core/api.js'
+import { DEVICES_REQUESTS, SUPER_TAB_REQUEST_PREFIX, type CoreApi, type CorePorts, type DevicesPort, type RouteAnswer, type SendResult, type ServiceRequests, type WindowFocus } from '../core/api.js'
import { CableFleet, testDialDiscovery, type CableFleetOptions } from '../cable/cableFleet.js'
import { isLocalOnly } from '../lib/cardUpdate.js'
import { TurnStats, type TurnStatsFields } from '../cable/turnStats.js'
@@ -82,6 +82,7 @@ const sid = (id: string): string => id.slice(0, 8)
export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps): ServiceRequests {
const log = deps.log ?? ((line: string) => console.log(line))
const monotonic = deps.now ?? (() => performance.now())
+ const superTabWait = (requestId: unknown): boolean => typeof requestId === 'string' && requestId.startsWith(SUPER_TAB_REQUEST_PREFIX)
const tally = createTally((line) => log(`[cable] ${line}`))
const tierOf = deps.decideTier ?? createTierDecider({
tally,
@@ -180,8 +181,9 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)
// these only when it routes by itself, with the fleet off.
sendTurn: (agentId, text) => core.turns.send(agentId, text),
stopTurn: (agentId) => core.turns.stop(agentId),
- answer: (agentId, requestId, answers) => core.questions.answer(agentId, requestId, answers),
- answerReviewed: (answer) => core.questions.answerReviewed(answer),
+ // A Super Tab wait is shown, never answered here: its id is no pane's, and nothing is typed for it.
+ answer: (agentId, requestId, answers) => { if (!superTabWait(requestId)) core.questions.answer(agentId, requestId, answers) },
+ answerReviewed: (answer) => superTabWait(answer.requestId) ? Promise.resolve(false) : core.questions.answerReviewed(answer),
recent: (agentId, n) => core.turns.recent(agentId, n),
recentAsks: (agentId) => core.turns.asks(agentId),
runtimeProfile: (session) => core.agents.runtimeProfile(session),
@@ -402,7 +404,8 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)
const close = cableQuestionCloseFor(frame as Parameters<typeof cableQuestionCloseFor>[0])
if (close) { inOrder(close.agentId, () => { void cable.questionClose(close.agentId, close.requestId) }); return }
const question = cableQuestionFor(frame as Parameters<typeof cableQuestionFor>[0])
- if (question) { tally(cableHost.describe(question.agentId)?.name ?? '', 'alert', 'rule:question', 'question', 0); inOrder(question.agentId, () => { void cable.question(question.agentId, question.requestId, question.questions) }); return }
+ // A Super Tab member waiting on a person (core/superTabAttention.ts) is an alert as any question is.
+ if (question) { tally(cableHost.describe(question.agentId)?.name ?? '', 'alert', question.superTab ? 'rule:super-tab' : 'rule:question', 'question', 0); inOrder(question.agentId, () => { void cable.question(question.agentId, question.requestId, question.questions, question.superTab) }); return }
// A shell result is only the stats' input: the dial is told the sums when the turn ends.
const ran = frame as { type?: string; agentId?: string; payload?: { kind?: string; id?: string; command?: string; isError?: boolean; outputTail?: string } }
if (ran.payload?.kind === 'reply_text' && ran.agentId) {
diff --git a/cli/src/services/processCoreApi.spec.ts b/cli/src/services/processCoreApi.spec.ts
index b0364227c..1002fe535 100644
--- a/cli/src/services/processCoreApi.spec.ts
+++ b/cli/src/services/processCoreApi.spec.ts
@@ -213,6 +213,14 @@ describe('the core API a light service runs on in its own process', () => {
expect(ask.mock.calls.map(([query]) => query)).toEqual(['cloud_publish', 'cloud_ask', 'cloud_unask'])
})
+ it('gives the Super Tab service its door only with a core to ask, and never waits on or throws from it', async () => {
+ expect(processCoreApi('/data', 'superTabs').superTabs).toBeUndefined()
+ const ask = vi.fn(async (_query: string, _payload: Record<string, unknown>): Promise<Record<string, unknown>> => { throw new Error('gone') })
+ processCoreApi('/data', 'superTabs', { ask }).superTabs!.attention([])
+ await new Promise((resolve) => setTimeout(resolve, 0))
+ expect(ask).toHaveBeenCalledWith('super_tab_attention', { items: [] })
+ })
+
it('acts on the core for an experiment: agents made, turns stopped and delivered, windows told, each asked', async () => {
const answers: Record<string, Record<string, unknown> | Error> = {
create: { ok: true, agentId: 'made' }, stop_turn: {}, windows: {}, deliver: {}, cancel_delivery: { cancelled: true },
diff --git a/cli/src/services/processCoreApi.ts b/cli/src/services/processCoreApi.ts
index 22930b67b..fd1161401 100644
--- a/cli/src/services/processCoreApi.ts
+++ b/cli/src/services/processCoreApi.ts
@@ -14,7 +14,7 @@ import { usageTarget, usageTargetKey, usageSnapshot, validUsage, validUsageTarge
* each asked of the core over its link (`ask`). The agents it reads come as the apps are shown them (`service_query shown`): each with its
* name, whether its terminal is there and its harness's viewer.
*/
-import { CONNECTOR_VAULT_OFF, CONVERSATIONS_OFF, DAEMON_UNKNOWN, DELIVERIES_OFF, LANE_OFF, OBSERVER_KEY_OFF, resolveAgent, TAB_KEY_OFF, TAB_RELAY_OFF, TERMINALS_OFF, WIFI_OFF, type CloudCore, type CoreApi, type DaemonAddress, type TerminalWatch } from '../core/api.js'
+import { CONNECTOR_VAULT_OFF, CONVERSATIONS_OFF, DAEMON_UNKNOWN, DELIVERIES_OFF, LANE_OFF, OBSERVER_KEY_OFF, resolveAgent, TAB_KEY_OFF, TAB_RELAY_OFF, TERMINALS_OFF, WIFI_OFF, type CloudCore, type SuperTabsCore, type CoreApi, type DaemonAddress, type TerminalWatch } from '../core/api.js'
import type { AgentDshContext } from '../lib/agentFrame.js'
import type { RegisteredSession } from '../lib/registry.js'
import type { turnsLink } from './turnsLink.js'
@@ -233,6 +233,11 @@ export function processCoreApi(dataDir: string, service: string, view: AgentsVie
ask: (agentId, requestId, question) => { void ask('cloud_ask', { agentId, questionId: requestId, question }).catch(() => {}) },
unask: (agentId, requestId) => { void ask('cloud_unask', { agentId, questionId: requestId }).catch(() => {}) },
} satisfies CloudCore,
+ // The Super Tab service's waits (core/superTabAttention.ts), the whole set each time: a core that missed one
+ // hears the next, and a new core the host's first roster (superTabs/host.ts).
+ superTabs: {
+ attention: (items) => { void ask('super_tab_attention', { items }).catch(() => {}) },
+ } satisfies SuperTabsCore,
} : {}),
}
}
diff --git a/cli/src/superTabs/attention.spec.ts b/cli/src/superTabs/attention.spec.ts
new file mode 100644
index 000000000..09dcfa88b
--- /dev/null
+++ b/cli/src/superTabs/attention.spec.ts
@@ -0,0 +1,49 @@
+import { describe, expect, it } from 'vitest'
+import { attentionOf, attentionRequestId } from './attention.js'
+
+const row = (over: Record<string, unknown> = {}, attention: Record<string, unknown> | null = { assignmentId: 'as-1', status: 'needs_human', result: 'Ship to everyone, or behind a flag?' }) =>
+ ({ tabId: 'tab', tabName: 'Pilot', paused: false, attention, agent: { id: 'agent', harnessId: 'h1', machineId: 'm1' }, ...over })
+const live = () => true
+
+describe('the Super Tab members here that wait on a person', () => {
+ it('reads a decision and a stuck agent off the host roster', () => {
+ expect(attentionOf([row()], 'm1', live)).toEqual([{ agentId: 'h1', requestId: 'supertab:as-1:needs_human', superTab: 'Pilot',
+ attention: 'decision', text: 'Ship to everyone, or behind a flag?' }])
+ const stuck = row({ agent: { id: 'b', harnessId: 'h2', machineId: 'm1' } }, { assignmentId: 'as-2', status: 'blocked', result: ' No access to staging. ' })
+ expect(attentionOf([stuck], 'm1', live)).toEqual([{ agentId: 'h2', requestId: 'supertab:as-2:blocked', superTab: 'Pilot',
+ attention: 'stuck', text: 'Stuck: No access to staging.' }])
+ })
+
+ it('says something even when the agent gave no reason, and names an unnamed tab', () => {
+ expect(attentionOf([row({ tabName: ' ' }, { assignmentId: 'as-1', status: 'needs_human', result: null })], 'm1', live)[0])
+ .toMatchObject({ superTab: 'Super Tab', text: 'Needs your decision' })
+ expect(attentionOf([row({ tabName: 7 }, { assignmentId: 'as-1', status: 'blocked' })], 'm1', live)[0])
+ .toMatchObject({ superTab: 'Super Tab', text: 'Stuck: needs help to go on' })
+ })
+
+ it('cuts a long name on a character and a long reason', () => {
+ const [item] = attentionOf([row({ tabName: `${'a'.repeat(47)}é and more` }, { assignmentId: 'as-1', status: 'needs_human', result: 'x'.repeat(400) })], 'm1', live)
+ expect(item.superTab).toBe('a'.repeat(47))
+ expect(item.text).toHaveLength(300)
+ })
+
+ it('raises nothing for a paused tab, another machine, an agent not live here, another status or a malformed row', () => {
+ const rows = [row({ paused: true }), row({ agent: { id: 'agent', harnessId: 'h1', machineId: 'm2' } }), row({ tabId: 'bad id' }),
+ row({}, null), row({}, { assignmentId: 'as-1', status: 'working' }), row({}, { assignmentId: 'bad id', status: 'blocked' }), null, 'x']
+ expect(attentionOf(rows, 'm1', live)).toEqual([])
+ expect(attentionOf([row()], 'm1', () => false)).toEqual([])
+ })
+
+ it('keeps the first wait for an agent in two rows', () => {
+ const second = row({ tabId: 'other' }, { assignmentId: 'as-9', status: 'blocked', result: 'x' })
+ expect(attentionOf([row(), second], 'm1', live).map(i => i.requestId)).toEqual(['supertab:as-1:needs_human'])
+ })
+
+ it('makes one short id per assignment and status, which a Pro can close', () => {
+ expect(attentionRequestId('as-1', 'blocked')).toBe('supertab:as-1:blocked')
+ const long = attentionRequestId('x'.repeat(160), 'needs_human')
+ expect(long).toMatch(/^supertab:[0-9a-f]{32}:needs_human$/)
+ expect(Buffer.byteLength(long)).toBeLessThan(64)
+ expect(attentionRequestId('x'.repeat(160), 'needs_human')).toBe(long)
+ })
+})
diff --git a/cli/src/superTabs/attention.ts b/cli/src/superTabs/attention.ts
new file mode 100644
index 000000000..79a55fa5a
--- /dev/null
+++ b/cli/src/superTabs/attention.ts
@@ -0,0 +1,57 @@
+/**
+ * Which of this machine's Super Tab members wait on a person, for the Harness Pro cabled to it: an assignment the agent
+ * runs here that needs a decision (`needs_human`) or is stuck (`blocked`). Read off the host roster the host polls each
+ * second anyway (backend superTabs/store.ts `hostTabs`, its `attention`), so nothing more is asked of the backend; a
+ * backend from before it sends no `attention`, and nothing is raised.
+ *
+ * The roster is the whole truth each time: the set is handed to the core whole (`core.superTabs.attention`), which
+ * raises what is new and closes what is gone (core/superTabAttention.ts). A status that moves on, a new attempt, a
+ * removed agent, a paused or deleted tab: each is a row that no longer says so, and its alert closes.
+ */
+import { createHash } from 'node:crypto'
+import { SUPER_TAB_REQUEST_PREFIX, type SuperTabAttention } from '../core/api.js'
+import { identifier, object } from './wire.js'
+
+/**
+ * One id per assignment and status: the same wait raised again (a restart, a replay) is the same question, and the
+ * other status is a new one. The Pro drops a `question.close` id of 64 bytes or more, so a long assignment id is hashed.
+ */
+export function attentionRequestId(assignmentId: string, status: string): string {
+ const key = /^[A-Za-z0-9_-]{1,40}$/.test(assignmentId) ? assignmentId : createHash('sha256').update(assignmentId).digest('hex').slice(0, 32)
+ return `${SUPER_TAB_REQUEST_PREFIX}${key}:${status}`
+}
+
+/** The Pro shows at most 48 bytes of the tab's name; cut on a character, never inside one. */
+function cut(text: string, bytes: number): string {
+ let out = ''
+ for (const char of text) {
+ if (Buffer.byteLength(out + char) > bytes) break
+ out += char
+ }
+ return out
+}
+
+/**
+ * The waits among the roster's rows for agents live on this machine (`live`: the core has that harness). One per
+ * agent: an agent owns one active assignment at a time (backend `AGENT_BUSY`), and the first row wins otherwise.
+ */
+export function attentionOf(rows: unknown[], machineId: string, live: (harnessId: string) => boolean): SuperTabAttention[] {
+ const out = new Map<string, SuperTabAttention>()
+ for (const item of rows) {
+ const row = object(item), agent = object(row.agent), wait = object(row.attention)
+ if (row.paused === true || !identifier(row.tabId) || !identifier(agent.harnessId) || agent.machineId !== machineId) continue
+ if (!identifier(wait.assignmentId) || (wait.status !== 'needs_human' && wait.status !== 'blocked')) continue
+ if (out.has(agent.harnessId) || !live(agent.harnessId)) continue
+ const said = typeof wait.result === 'string' ? wait.result.trim().slice(0, 300) : ''
+ const stuck = wait.status === 'blocked'
+ out.set(agent.harnessId, {
+ agentId: agent.harnessId,
+ requestId: attentionRequestId(wait.assignmentId, wait.status),
+ superTab: cut(typeof row.tabName === 'string' && row.tabName.trim() ? row.tabName.trim() : 'Super Tab', 48),
+ attention: stuck ? 'stuck' : 'decision',
+ // What the device reads first. Stuck says so in words too: a dial that predates `attention` shows the text alone.
+ text: stuck ? `Stuck: ${said || 'needs help to go on'}` : said || 'Needs your decision',
+ })
+ }
+ return [...out.values()]
+}
diff --git a/cli/src/superTabs/host.spec.ts b/cli/src/superTabs/host.spec.ts
index 74c864ae5..ba3739a6f 100644
--- a/cli/src/superTabs/host.spec.ts
+++ b/cli/src/superTabs/host.spec.ts
@@ -418,3 +418,76 @@ describe('Super Tab attachments in delivered input', () => {
expect(vi.mocked(t.core.turns.deliver).mock.calls[0]?.[1]).toMatch(/from Collaborator:\nAttached files:\n/)
})
})
+
+describe('Super Tab waits for the Harness Pro', () => {
+ it('hands the core the roster\'s waits on the first roster and on each change, and takes them back on stop', async () => {
+ const dir = mkdtempSync(join(tmpdir(), 'super-tab-host-')); roots.push(dir)
+ const waiting = { tabId: 'tab', tabName: 'Pilot', attention: { assignmentId: 'as-1', status: 'blocked', result: 'No key' },
+ agent: { id: 'agent', harnessId: 'harness', machineId: 'machine-1' } }
+ let rows: unknown[] = [waiting], offline = false
+ const call: CoreApi['account']['backend'] = vi.fn(async (_method, path) => {
+ if (offline) throw new Error('Host offline')
+ return { status: 200, body: { success: true, data: path.includes('/hosts/') ? rows : [] } }
+ })
+ const superTabs = { attention: vi.fn() }
+ const core = fakeCore({ dataDir: dir, superTabs, account: { backend: call },
+ agents: { byAgent: vi.fn(() => ({ agentId: 'harness' }) as never), terminalAvailable: vi.fn(() => true) } })
+ const open = () => { const host = new SuperTabHost(core, 'machine-1', { log: vi.fn() }); hosts.push(host); return host }
+ const first = open()
+ await first.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(1)
+ expect(superTabs.attention).toHaveBeenLastCalledWith([{ agentId: 'harness', requestId: 'supertab:as-1:blocked', superTab: 'Pilot', attention: 'stuck', text: 'Stuck: No key' }])
+ await first.tick()
+ // A failed roster read closes nothing.
+ offline = true
+ await first.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(1)
+ offline = false
+ rows = [{ ...waiting, attention: null }]
+ await first.tick()
+ expect(superTabs.attention).toHaveBeenLastCalledWith([])
+ first.stop()
+ expect(superTabs.attention).toHaveBeenCalledTimes(2)
+ // A new host always hands over its first roster, so it closes what an earlier one raised; stopping takes its own back.
+ const next = open()
+ await next.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(3)
+ rows = [waiting]
+ await next.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(4)
+ superTabs.attention.mockImplementationOnce(() => { throw new Error('Core gone') })
+ next.stop()
+ expect(superTabs.attention).toHaveBeenLastCalledWith([])
+ })
+
+ it('keeps a wait through a moment its harness is missing from the live agents, and closes it after 3 s', async () => {
+ const dir = mkdtempSync(join(tmpdir(), 'super-tab-host-')); roots.push(dir)
+ const rows = [{ tabId: 'tab', tabName: 'Pilot', attention: { assignmentId: 'as-1', status: 'needs_human', result: 'Ship it?' },
+ agent: { id: 'agent', harnessId: 'harness', machineId: 'machine-1' } }]
+ const call: CoreApi['account']['backend'] = vi.fn(async (_method, path) => ({ status: 200, body: { success: true, data: path.includes('/hosts/') ? rows : [] } }))
+ let here = true, clock = 0
+ const superTabs = { attention: vi.fn() }
+ const core = fakeCore({ dataDir: dir, superTabs, account: { backend: call },
+ agents: { byAgent: vi.fn(() => (here ? { agentId: 'harness' } : undefined) as never), terminalAvailable: vi.fn(() => true) } })
+ const host = new SuperTabHost(core, 'machine-1', { log: vi.fn(), now: () => clock }); hosts.push(host)
+ await host.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(1)
+ here = false
+ await host.tick()
+ clock += 2_000
+ await host.tick()
+ here = true
+ await host.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(1) // back within 3 s: the same wait, never closed
+ here = false
+ await host.tick()
+ clock += 3_000
+ await host.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(2)
+ expect(superTabs.attention).toHaveBeenLastCalledWith([])
+ // Never raised while missing: a harness the core does not have is not waited on.
+ clock += 10_000
+ await host.tick()
+ expect(superTabs.attention).toHaveBeenCalledTimes(2)
+ })
+})
diff --git a/cli/src/superTabs/host.ts b/cli/src/superTabs/host.ts
index d79a9a913..009ff6efb 100644
--- a/cli/src/superTabs/host.ts
+++ b/cli/src/superTabs/host.ts
@@ -10,6 +10,7 @@ import { dirname, join } from 'node:path'
import type { CoreApi, TurnDelivery } from '../core/api.js'
import { shellQuote } from '../orchestrator/prompts.js'
import { noticeReason, WithheldDeliveries } from './withheld.js'
+import { attentionOf } from './attention.js'
type Json = Record<string, unknown>
export class SuperTabHostError extends Error {
@@ -96,6 +97,12 @@ export class SuperTabHost {
private timer: ReturnType<typeof setTimeout> | null = null
private native: NativeRecorder | null = null
private machines: ContributedMachines | null = null
+ /** The waits last handed to the core (superTabs/attention.ts); null until the first roster, which is always handed
+ * over whole, so a restarted service closes what its predecessor raised and no longer holds. */
+ private attention: string | null = null
+ /** The harnesses last handed over waiting, and since when each has been missing from the core's live agents. */
+ private waiting = new Set<string>()
+ private missing = new Map<string, number>()
constructor(private readonly core: CoreApi, readonly machineId: string, options: SuperTabHostOptions = {}) {
if (!identifier(machineId)) throw new SuperTabHostError('MACHINE_UNAVAILABLE', 'This machine is not signed in.')
@@ -153,6 +160,14 @@ export class SuperTabHost {
this.machines?.stop()
this.authorized.clear()
try { this.observers(this.core.dataDir, this.machineId, [], 0) } catch { /* The old snapshot expires. */ }
+ // Signed out or another machine: this host's alerts are no longer anyone's. A core that is gone heard nothing, and
+ // the next host's first roster replaces them anyway.
+ if (this.attention !== null && this.attention !== '[]') {
+ try { this.core.superTabs?.attention([]) } catch { /* The next host's first roster replaces them. */ }
+ }
+ this.attention = null
+ this.waiting.clear()
+ this.missing.clear()
void this.core.turns.leaseDeliveries('superTabs', {})
for (const id of this.active) this.core.turns.cancelDelivery(id)
this.active.clear()
@@ -250,6 +265,7 @@ export class SuperTabHost {
this.retentionError = message
}
this.observers(this.core.dataDir, this.machineId, data, requestedAt + 2500)
+ this.publishAttention(data)
// Runtime observations cannot delay the live input leases. A stale host
// observation is fenced by the backend's per-agent configuration version.
if (!this.configurationsRunning && this.now() >= this.nextConfigurationsAt) {
@@ -303,6 +319,27 @@ export class SuperTabHost {
await this.leases()
}
+ /** Hands the core this roster's waits when they changed (or on the first roster). A failed roster read changes
+ * nothing: a network blip does not close an alert. */
+ private publishAttention(rows: unknown[]): void {
+ // A harness the core's live list misses for a moment (a process-side snapshot between reads, a restart of its
+ // terminal) keeps its wait for 3 s: closing and raising it again would alert twice for the same wait.
+ const now = this.now(), missing = new Map<string, number>()
+ const live = (harnessId: string) => {
+ if (this.core.agents.byAgent(harnessId)) return true
+ const since = this.missing.get(harnessId) ?? now
+ missing.set(harnessId, since)
+ return this.waiting.has(harnessId) && now - since < 3_000
+ }
+ const items = attentionOf(rows, this.machineId, live)
+ this.missing = missing
+ const key = JSON.stringify(items)
+ if (key === this.attention) return
+ this.attention = key
+ this.waiting = new Set(items.map(item => item.agentId))
+ this.core.superTabs?.attention(items)
+ }
+
private retire(deliveryId: string): void {
const entry = this.journal.entries[deliveryId]
if (!entry) return
diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.ts
index 76699f2c1..3d4c0f67b 100644
--- a/cli/src/superTabs/service.spec.ts
+++ b/cli/src/superTabs/service.spec.ts
@@ -377,3 +377,10 @@ describe('post --attach steps', () => {
.toEqual({ ok: true, value: { agentId: t.agentId, attachmentIds: null } })
})
})
+
+it('teaches agents to say when their work needs a person or is stuck', async () => {
+ const t = setup()
+ const help = (await t.ask({ action: 'help' }, owner)) as { help: { command: string; commands: Array<Record<string, unknown>> } }
+ expect(help.help.commands.filter(c => c.type === 'work.status').map(c => c.status)).toEqual(['working', 'needs_human', 'blocked', 'done'])
+ expect(help.help.command).toContain('needs_human')
+})
diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.ts
index 974efa038..60302318a 100644
--- a/cli/src/superTabs/service.ts
+++ b/cli/src/superTabs/service.ts
@@ -22,7 +22,7 @@ const HELP = {
capacity: 'capacity MACHINE_ID JSON: inspect machine, engine and quota headroom. JSON uses the start request fields below. Unknown allowances are not reported as free tokens.',
startRequest: { conversationId: 'GROUP', machineId: 'MACHINE', engine: 'codex', name: 'Builder', cwd: '/absolute/repo/on/that/machine', worktree: true, requirements: START_REQUIREMENTS,
model: 'opus', effort: 'high', routeDecisionId: 'DECISION' },
- command: 'command OPERATION_ID JSON: send one of the commands below. Reuse exactly the same ID and JSON after an interrupted request.',
+ command: 'command OPERATION_ID JSON: send one of the commands below. Reuse exactly the same ID and JSON after an interrupted request. When your assignment needs a person to decide, set work.status needs_human; when you cannot go on, blocked. Set working again once it moves.',
commands: [
{ type: 'project.report', projectId: 'PROJECT', throughRevision: 123, text: 'What changed, what is blocked, and what comes next. Use null when nothing merits repeating.' },
{ type: 'project.repository', projectId: 'PROJECT', repositoryUrl: 'https://github.com/OWNER/REPOSITORY' },
@@ -32,6 +32,9 @@ const HELP = {
{ type: 'work.define', conversationId: 'GROUP', brief: 'What to deliver', checks: [{ description: 'Observable acceptance evidence', independent: false }] },
{ type: 'work.assign', conversationId: 'GROUP', agentId: 'AGENT', routeDecisionId: 'DECISION' },
{ type: 'work.status', conversationId: 'GROUP', assignmentId: 'ATTEMPT', status: 'working', result: null },
+ // Both reach the Lead and alert the Harness Pro on the machine running the agent until the status moves on.
+ { type: 'work.status', conversationId: 'GROUP', assignmentId: 'ATTEMPT', status: 'needs_human', result: 'The decision you need from a person, asked as one short question' },
+ { type: 'work.status', conversationId: 'GROUP', assignmentId: 'ATTEMPT', status: 'blocked', result: 'Why you are stuck and what would unblock you, in one or two sentences' },
{ type: 'work.check', conversationId: 'GROUP', assignmentId: 'ATTEMPT', checkId: 'CHECK', passed: true, evidence: 'Exact test command, revision and observed result' },
{ type: 'work.status', conversationId: 'GROUP', assignmentId: 'ATTEMPT', status: 'done', result: 'Exact revision, evidence and deliverable links' },
],
diff --git a/cli/src/testing/fakeCore.ts b/cli/src/testing/fakeCore.ts
index a243e7b6f..a8af38339 100644
--- a/cli/src/testing/fakeCore.ts
+++ b/cli/src/testing/fakeCore.ts
@@ -93,5 +93,7 @@ export function fakeCore(over: Overrides = {}): CoreApi {
},
// Only a spec that gives the cloud agents doors has them, as only a core that offers them does.
...(over.cloud ? { cloud: Object.assign({ publish: vi.fn(), ask: vi.fn(), unask: vi.fn() }, over.cloud) } : {}),
+ // The Super Tab service's door, likewise.
+ ...(over.superTabs ? { superTabs: Object.assign({ attention: vi.fn() }, over.superTabs) } : {}),
}
}
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index 9a65c1a93..70fe5e5fb 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -12,6 +12,16 @@ List<T> _list<T>(Object? value, T Function(Map<String, dynamic>) read) =>
? List.unmodifiable(value.map((row) => read(superTabMap(row))))
: throw const FormatException('Invalid Swarm list.');
+/// Work that waits on a person: the agent needs a decision (`needs_human`) or
+/// is stuck (`blocked`). Both stay active work until the agent moves on.
+bool superTabWorkWaits(Object? status) =>
+ status == 'needs_human' || status == 'blocked';
+
+/// How a work status reads in the app. `blocked` is what the agent calls it;
+/// people read Stuck. Statuses this build does not know read as sent.
+String superTabWorkStatusLabel(String status) =>
+ status == 'blocked' ? 'stuck' : status.replaceAll('_', ' ');
+
class SuperTabPerson {
SuperTabPerson.fromJson(Map<String, dynamic> row)
: id = _text(row, 'id'),
diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dart
index a5c0b0d90..a405f1b61 100644
--- a/desktop/lib/super_tabs/roster.dart
+++ b/desktop/lib/super_tabs/roster.dart
@@ -59,7 +59,7 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
(group) =>
!group.archived &&
group.assignment?['agentId'] == agent.id &&
- group.assignment?['status'] == 'needs_human',
+ superTabWorkWaits(group.assignment?['status']),
) ==
true) {
return HarnessActivity.needsInput;
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index c13ce8bcd..3e24527a6 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -624,7 +624,7 @@ class _SuperTabViewState extends State<SuperTabView> {
group.agentIds.contains(agent.id) &&
(widget.app?.questionFor(agent.machineId, agent.harnessId) !=
null ||
- (group.assignment?['status'] == 'needs_human' &&
+ (superTabWorkWaits(group.assignment?['status']) &&
group.assignment?['agentId'] == agent.id)),
)
.toList() ??
diff --git a/desktop/lib/super_tabs/work_details.dart b/desktop/lib/super_tabs/work_details.dart
index 6e2088dc0..b977ad72c 100644
--- a/desktop/lib/super_tabs/work_details.dart
+++ b/desktop/lib/super_tabs/work_details.dart
@@ -6,6 +6,7 @@ import '../widgets/desktop_chrome.dart';
import 'controller.dart';
import 'dialog_scope.dart';
import 'message_text.dart';
+import 'model.dart';
Future<void> showSuperTabWork(
BuildContext context,
@@ -35,7 +36,7 @@ Future<void> showSuperTabWork(
if (assignment != null) ...[
const SizedBox(height: 16),
Text(
- '${c.snapshot?.agentName(assignment['agentId'] as String, fallback: 'Agent unavailable') ?? 'Agent unavailable'} · ${(assignment['status'] as String).replaceAll('_', ' ')}',
+ '${c.snapshot?.agentName(assignment['agentId'] as String, fallback: 'Agent unavailable') ?? 'Agent unavailable'} · ${superTabWorkStatusLabel(assignment['status'] as String)}',
),
],
for (final check
diff --git a/desktop/test/super_tab_chat_test.dart b/desktop/test/super_tab_chat_test.dart
index 8251443b9..0c6fe460a 100644
--- a/desktop/test/super_tab_chat_test.dart
+++ b/desktop/test/super_tab_chat_test.dart
@@ -13,6 +13,16 @@ import 'package:harness/super_tabs/view.dart';
import 'support/super_tab_fixture.dart';
void main() {
+ test('work that waits on a person reads as people say it', () {
+ expect(superTabWorkWaits('needs_human'), isTrue);
+ expect(superTabWorkWaits('blocked'), isTrue);
+ expect(superTabWorkWaits('working'), isFalse);
+ expect(superTabWorkWaits(null), isFalse);
+ expect(superTabWorkStatusLabel('blocked'), 'stuck');
+ expect(superTabWorkStatusLabel('needs_human'), 'needs human');
+ expect(superTabWorkStatusLabel('reconciling'), 'reconciling');
+ });
+
Future<SuperTabController> show(
WidgetTester tester,
ConversationServer server,
@@ -263,6 +273,14 @@ void main() {
await c.refresh();
await tester.pumpAndSettle();
expect(find.text('Builder needs you'), findsNothing);
+ // Stuck waits on a person as a decision does.
+ group['assignment']
+ ..['status'] = 'blocked'
+ ..['result'] = 'The staging key is missing.';
+ server.revision++;
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(find.text('Builder needs you'), findsOneWidget);
},
);
diff --git a/devices/harness-pro/docs/cable.md b/devices/harness-pro/docs/cable.md
index 34eb49dbd..2986e5c51 100644
--- a/devices/harness-pro/docs/cable.md
+++ b/devices/harness-pro/docs/cable.md
@@ -28,6 +28,7 @@ Full key list, in the order the Pro sends it:
| `activity` | `"steps-v1"` | capability |
| `stats` | `"turn-v1"` | capability |
| `player` | `"library-v1"` | capability |
+| `superTab` | `"wait-v1"` | capability: Super Tab waits on `question` (below) |
| `ota` | `"v1"` | capability: the Pro takes firmware offers |
| `mac` | `aa:bb:...` | existing |
| `settings` | object | existing: brightness, character, face, voiceLang, muted, quiet, straightTitle, focusFace, scrollReversed, round |
@@ -45,6 +46,7 @@ Capabilities are per session: they reset on a new port and on close, like the br
| `recap: "long-v1"` | `full` on `summary` (live and `restore:true`) | `{t:"summary", agentId, recap, text, full?:string, restore?:true, ...}`. `full` is the whole answer's prose: markdown stripped, whitespace collapsed, at most **1200 chars**, at most **3600 UTF-8 bytes**, cut on a word boundary with `…`. Omitted (not empty) when the answer has no text. Firmware recap buffer is 2048 B. `recap` and `text` are unchanged. |
| `activity: "steps-v1"` | `step`, `action`, `elapsedSeconds` on `turn.activity` | `{t:"turn.activity", agentId, text, action?:string, elapsedSeconds?:int, step?:string}`. `step`: one tool card as `"Tool · arg"` (a path argument keeps its last segment), at most **120 chars**, sent as `{text:"", step}` the moment the tool starts; the firmware cuts at 400. `action`: latest assistant-written progress paragraph, whitespace collapsed, at most **188 bytes** (firmware keeps 192 B). `elapsedSeconds`: integer **0..2592000**, parsed from the engine footer (`1h 2m 3s`); anything else is omitted. `action` also rides on the first `turn.activity` right after `turn.started`. |
| `player: "library-v1"` | feature `player.library` in `welcome.features`; the `player.library.get` request and the `player.library` reply | Request (device to host): `{t:"player.library.get", offset:int 0..1000000, request:int 0..4294967295}`; anything else is ignored. Reply: `{t:"player.library", request, offset, total, machines, rows:[...]}`. `rows` has at most **6** (page size); `offset` is clamped to `max(0, total-6)`; the page is never re-sorted (desktop order). Row: `{id, machineId, name, engine, status, ageSeconds}`; `id`, `machineId` non-empty and < 48 B; `name` <= 95 B, `engine` <= 15 B (control chars to spaces, UTF-8 safe); `status` one of `idle working question finished failed paused offline`; `ageSeconds` is -1 (unknown) or 0..315360000. The firmware rejects the whole page if `count != min(6, total - offset)`. `request` echoes the latest request; a reply for an older request is dropped. Resent at most every 10 s unless the page changed. |
+| `superTab: "wait-v1"` | `question` frames for Super Tab waits | `{t:"question", agentId, id:"supertab:…", questions:[{q}], superTab:string ≤48 B, attention:"decision"\|"stuck"}`; see "Super Tab waits on `question`". Without it the daemon sends none. |
Order of arrival the firmware tolerates: any. Every field above is optional on the device side; a missing one
leaves the Pod showing an empty body, never an error.
@@ -163,3 +165,22 @@ frame for each question still open. It does not replay recent `summary` history
wake or toast) or `"silent"` (the card updates, nothing else). The host still sends the older flags beside it
for firmware that predates `tier`: `alert` sets neither, `list` sets `quiet: true`, `silent` sets `silent: true`.
`question` and `turn.error` carry no `tier`; treat both as `alert`.
+
+## Super Tab waits on `question`
+
+When a Super Tab member running on this machine needs a person (its assignment's `work.status` is `needs_human` or
+`blocked`), the daemon sends it as a `question` with two optional fields: `superTab` (the tab's name, at most 48 bytes)
+and `attention` (`"decision"` or `"stuck"`). Only a device whose hello says `superTab: "wait-v1"` (the Pro) is sent
+one; the round dial would open a question screen that cannot load. `questions[0].q` is the decision asked for, or
+`Stuck: <reason>`; the question has no `key` or `options` and is not answered on a device (`question.read` says so; an
+`answer` or `answer.reviewed` for its id is dropped), and it does not hold Talk back: talking to the agent is how a
+person unblocks it. Its `id` is `supertab:<assignment>:<status>`, under 64 bytes. It is closed with `question.close`
+when the status moves on, the attempt or agent changes, or the tab is paused.
+
+The Pro keeps such a question through the agent's turns (`turn.started`, `turn.done`, `turn.error`, a `summary`, a
+library sweep), so it alerts once: a finished turn meanwhile neither beeps nor replaces its Notices entry or toast, a
+failed one still alerts. Closed, the agent takes the state its turns left it in (idle or done, working only mid-turn).
+A link drop ends it as it ends any question (it becomes a plain one the next turn ends); the daemon asks it again when
+the Pro's session comes back (its `agents.list`) and on a resync. The library page reports a waiting agent as
+`question`. An engine's own question for the same agent replaces it (the daemon closes the wait first) and the daemon
+asks the wait again once that question closes.
diff --git a/devices/harness-pro/firmware/main/app/pod_glue.c b/devices/harness-pro/firmware/main/app/pod_glue.c
index 37b85dfe7..3777202e2 100644
--- a/devices/harness-pro/firmware/main/app/pod_glue.c
+++ b/devices/harness-pro/firmware/main/app/pod_glue.c
@@ -34,7 +34,9 @@ void pod_ui_render(pod_ui_t *u, ht_scene_t *scene, uint32_t now_ms)
pod_nav_flip_recaps(&u->nav, &u->model); // the clock alone can end a stale Working: show the recap it opens on
// The banner shows while its entry is still unread, the time has not run out, the cable is up and nobody is recording.
const pod_unread_t *ban = NULL;
- if (u->ban_on && (int32_t)(now_ms - u->ban_until) >= 0) u->ban_on = false;
+ // A Super Tab question's toast does not run out; Notices lists it, so once Notices is on screen it has been seen.
+ if (u->ban_on && !u->ban_stay && (int32_t)(now_ms - u->ban_until) >= 0) u->ban_on = false;
+ if (u->ban_on && u->ban_stay && top(u) && top(u)->view == POD_V_INBOX) u->ban_on = false;
if (u->ban_on && !(ban = pod_model_unread_find(&u->model, u->ban_agent))) u->ban_on = false;
u->frame.banner = ban && u->model.linked && !pod_ui_talking(u) && toast_fits(u); // the toast, only over a room
pod_render(&u->frame, &u->nav, &u->model, now_ms);
@@ -168,9 +170,9 @@ pod_out_t pod_ui_sent(pod_ui_t *u, const char *id, uint32_t now_ms)
return synced(u);
}
-pod_out_t pod_ui_question(pod_ui_t *u, const char *id, const char *text)
+pod_out_t pod_ui_question(pod_ui_t *u, const char *id, const char *text, const char *super_tab, pod_attention_t attention)
{
- pod_model_question(&u->model, id, text);
+ pod_model_question_tab(&u->model, id, text, super_tab, attention);
return synced(u);
}
@@ -235,6 +237,13 @@ static bool swipes(const pod_ui_t *u)
// Tap to talk: only on the agent's own screens (Agent, Recap). Not in the top band, not on the back crumb or the
// Notices hit, not on an agent that asks (voice stays refused there, so the tap does not arm and no notice fires).
// Returns the agent id the tap would talk to, or NULL.
+// An agent with a question to answer here, which talking must not go around. A Super Tab wait is not one: nobody answers
+// it on the Pro, and talking to the agent is how a person unblocks it.
+static bool asks_here(const pod_model_t *m, const pod_agent_t *a)
+{
+ return pod_model_eff(m, a) == POD_ASKING && pod_model_attention(m, a) == POD_ATTN_NONE;
+}
+
static const char *talk_target(const pod_ui_t *u)
{
const pod_frame_t *f = top(u);
@@ -243,7 +252,7 @@ static const char *talk_target(const pod_ui_t *u)
if (u->hit_valid && (u->hit.action == POD_A_BACK || u->hit.action == POD_A_INBOX)) return NULL;
const char *id = f->view == POD_V_AGENT || f->view == POD_V_RECAP ? f->agent : NULL;
const pod_agent_t *a = id ? pod_model_find(&u->model, id) : NULL;
- return a && pod_model_eff(&u->model, a) != POD_ASKING ? id : NULL;
+ return a && !asks_here(&u->model, a) ? id : NULL;
}
static bool wide(int dx, int dy) { return iabs(dx) * 2 > iabs(dy) * 3; }
static bool inside(const pod_hit_t *h, int x, int y)
@@ -293,7 +302,7 @@ static pod_out_t talk_fire(pod_ui_t *u, uint32_t now_ms)
char id[ID_MAX];
pod_copy_str(id, sizeof id, u->talk_agent);
const pod_agent_t *ag = pod_model_find(&u->model, id);
- if (!ag || pod_model_eff(&u->model, ag) == POD_ASKING) return none;
+ if (!ag || asks_here(&u->model, ag)) return none;
if (ag->state == POD_OFFLINE) {
pod_ui_notice(u, "That machine is offline", now_ms);
return none;
@@ -585,13 +594,16 @@ static uint32_t edge_ms(const pod_ui_t *u, uint32_t now_ms)
if (left < 1) left = 1;
if ((uint32_t)left < edge) edge = (uint32_t)left;
}
- if (u->ban_on) { // so does the banner
+ if (u->ban_on && !u->ban_stay) { // so does the banner
int32_t left = (int32_t)(u->ban_until - now_ms);
if (left < 1) left = 1;
if ((uint32_t)left < edge) edge = (uint32_t)left;
if (u->model.linked && !pod_ui_talking(u) && !u->ota && toast_fits(u)) { // the timer line shrinks (only while the toast is drawn): 66 ms (Home, Notices and Talk keep their own beat)
if (edge > 66) edge = 66;
}
+ } else if (u->ban_on && u->model.linked && !pod_ui_talking(u) && !u->ota && toast_fits(u) &&
+ (int32_t)(now_ms - pod_ui_banner_shown_ms(u)) < POD_TOAST_SLIDE_MS) { // a toast that stays: its bar is still, only the slide-in moves
+ if (edge > 66) edge = 66;
}
return edge;
}
@@ -770,6 +782,10 @@ bool pod_ui_notify_text(pod_ui_t *u, const char *agent_id, pod_tier_t tier, cons
pod_model_clock(&u->model, now_ms);
const pod_agent_t *a = pod_model_find(&u->model, agent_id);
if (!a || tier == POD_TIER_SILENT) return false;
+ // A Super Tab's question is the agent's notice until it closes: what its turns say meanwhile is on its card, and
+ // replaces neither the wait's entry nor its toast. The wait alerted once.
+ // A failed turn still alerts: a crash while it waits is news.
+ if (!question && !a->failed && pod_model_attention(&u->model, a) != POD_ATTN_NONE) return false;
const pod_frame_t *t = top(u);
const bool looking = awake && t && (t->view == POD_V_AGENT || t->view == POD_V_RECAP) && !strcmp(t->agent, a->id);
char joined[POD_UNREAD_TEXT];
@@ -801,6 +817,7 @@ bool pod_ui_notify_text(pod_ui_t *u, const char *agent_id, pod_tier_t tier, cons
pod_copy_str(u->ban_agent, sizeof u->ban_agent, a->id);
u->ban_until = now_ms + POD_TOAST_MS;
u->ban_on = true;
+ u->ban_stay = question && pod_model_attention(&u->model, a) != POD_ATTN_NONE; // a Super Tab's question waits for you
}
}
return tier == POD_TIER_ALERT;
diff --git a/devices/harness-pro/firmware/main/app/pod_glue.h b/devices/harness-pro/firmware/main/app/pod_glue.h
index 05207651c..f397de400 100644
--- a/devices/harness-pro/firmware/main/app/pod_glue.h
+++ b/devices/harness-pro/firmware/main/app/pod_glue.h
@@ -52,9 +52,11 @@ typedef struct {
bool notice_on;
bool notice_bad; // the red pill (a failure), not the dark one
// The notice toast (ph_toast, POD_TOAST_MS) (see pod_ui_notify): which entry (by agent), until when, and a contact that began on it.
+ // ban_stay: a Super Tab question's toast (pod_model_attention), which does not run out: it goes when swiped up, when the question
+ // closes (its entry goes) or once Notices is on screen; ban_until then only dates its slide-in.
char ban_agent[ID_MAX];
uint32_t ban_until;
- bool ban_on, ban_touch;
+ bool ban_on, ban_touch, ban_stay;
// player.library sweep: see pod_ui_sweep_*.
struct {
bool active, restart, ever;
@@ -109,7 +111,8 @@ pod_out_t pod_ui_swarms(pod_ui_t *, const cable_swarm_t *items, int n, const cab
pod_out_t pod_ui_turn(pod_ui_t *, const char *id, const char *kind, const char *text, int elapsed_s, uint32_t now_ms);
// turn.stats for an agent (-1 leaves a field unknown); unknown agents are ignored.
pod_out_t pod_ui_turn_stats(pod_ui_t *, const char *id, int32_t passed, int32_t failed, int32_t commits, int32_t tokens_in, int32_t tokens_out);
-pod_out_t pod_ui_question(pod_ui_t *, const char *id, const char *text);
+// super_tab: the Super Tab the question was asked in (NULL = a plain question) and its attention (pod_model_question_tab).
+pod_out_t pod_ui_question(pod_ui_t *, const char *id, const char *text, const char *super_tab, pod_attention_t attention);
// The daemon took a recording for this agent (voice.result): Working now, before its turn starts (pod_model_sent).
pod_out_t pod_ui_sent(pod_ui_t *, const char *id, uint32_t now_ms);
pod_out_t pod_ui_question_close(pod_ui_t *, const char *id);
@@ -163,7 +166,8 @@ bool pod_ui_updating(const pod_ui_t *);
// ---- notifications ----
// A live summary ended a turn: file an unread entry for the agent (its recap, name, elapsed; one per agent, the newest) and, for an
// alert, show the toast for POD_TOAST_MS over a room (a newer one replaces it; none while TALK is on top; a tap opens Notices, a
-// swipe up dismisses). Nothing is filed when the agent is not on the roster.
+// swipe up dismisses). A Super Tab question's toast (pod_model_attention) stays instead: until swiped up, until the question
+// closes, or until Notices opens. Nothing is filed when the agent is not on the roster.
#define POD_BANNER_SWIPE_PX 40
// `awake`: the glass is lit. A dark one is not looking, even when it rests on that agent's screen.
// When the current toast started (it shows for POD_TOAST_MS); the toast draw reads it for its timer line.
diff --git a/devices/harness-pro/firmware/main/app/pro_app.c b/devices/harness-pro/firmware/main/app/pro_app.c
index 42cd6dbe2..6ed44bbb6 100644
--- a/devices/harness-pro/firmware/main/app/pro_app.c
+++ b/devices/harness-pro/firmware/main/app/pro_app.c
@@ -447,7 +447,9 @@ static void turn_locked(const char *id, const char *kind, const char *text, int
// R1: only a NEW turn starts the clock; a heartbeat refreshes the word it carries.
const bool new_turn = set_find(s_busy, id) < 0;
if (!set_add(s_busy, id)) return;
- set_remove(s_quest, id); // only turn.started or question.close ends a question
+ // Only turn.started or question.close ends a question; a Super Tab's survives the turn (pod_model set_state).
+ const pod_agent_t *asked = pod_model_find(&s_pod.model, id);
+ if (!(asked && asked->state == POD_ASKING && asked->super_tab[0])) set_remove(s_quest, id);
if (new_turn) settle(pod_ui_turn(&s_pod, id, "started", "", 0, now));
feed_verb(id, text, now);
} else if (!strcmp(kind, "verb")) {
@@ -534,13 +536,13 @@ void pro_app_notif_seen(const char *id, const char *token)
leave();
}
-void pro_app_question(const char *id, const char *request, const char *text)
+void pro_app_question(const char *id, const char *request, const char *text, const char *super_tab, pod_attention_t attention)
{
if (!id_ok(id)) return;
pro_app_lock();
if (s_linked && held(id) && set_add(s_quest, id)) {
const char *q = text && text[0] ? text : "Needs your answer";
- settle(pod_ui_question(&s_pod, id, q));
+ settle(pod_ui_question(&s_pod, id, q, super_tab, attention));
uint32_t h = 2166136261u; // FNV-1a of the request id and the prompt: a lost close must not mute the next one
for (const char *c = request ? request : ""; *c; c++) h = (h ^ (uint8_t)*c) * 16777619u;
h = (h ^ 0u) * 16777619u;
@@ -622,7 +624,8 @@ const char *pro_app_voice_block_reason(const char *agent_id)
if (!strcmp(pa->engine, "terminal")) why = "Choose an agent pane.";
else if (mach && !strcmp(mach->state, "offline")) why = "This computer is offline.";
else if (mach && !strcmp(mach->state, "needs-link")) why = "Link this computer in Harness.";
- else if (set_find(s_quest, agent_id) >= 0) why = "Answer its question first.";
+ // A Super Tab wait is not answered here: talking to the agent is how a person unblocks it.
+ else if (set_find(s_quest, agent_id) >= 0 && !pa->super_tab[0]) why = "Answer its question first.";
}
pro_app_unlock();
return why; // a literal, valid after the unlock
diff --git a/devices/harness-pro/firmware/main/cable/cable_types.h b/devices/harness-pro/firmware/main/cable/cable_types.h
index c0bc51c8d..17931ff22 100644
--- a/devices/harness-pro/firmware/main/cable/cable_types.h
+++ b/devices/harness-pro/firmware/main/cable/cable_types.h
@@ -49,6 +49,14 @@ typedef struct {
*/
typedef enum { POD_TIER_ALERT, POD_TIER_LIST, POD_TIER_SILENT } pod_tier_t;
+/*
+ * WHAT A SUPER TAB QUESTION ASKS FOR (the question frame's optional `attention`, sent with `superTab`, the shared
+ * multi-agent project's name): decision = a human has to choose, stuck = the agent cannot go on. Both are alerts whose
+ * toast stays until it is dismissed, answered or seen in Notices. NONE: a plain question (no `superTab`), as before.
+ */
+typedef enum { POD_ATTN_NONE, POD_ATTN_DECISION, POD_ATTN_STUCK } pod_attention_t;
+#define SUPER_TAB_MAX 49 // the Super Tab's name: at most 48 bytes, NUL included here
+
/*
* ONE TILE OF THE SELECTED TAB'S GRID, exactly where the window put it: a unit rectangle in THOUSANDTHS of the
* grid. `agent_id` is empty for a tile this device cannot drive (a shell, a viewer); it still holds its place.
diff --git a/devices/harness-pro/firmware/main/cable/pro_cable.c b/devices/harness-pro/firmware/main/cable/pro_cable.c
index 6654cc400..0754de4ff 100644
--- a/devices/harness-pro/firmware/main/cable/pro_cable.c
+++ b/devices/harness-pro/firmware/main/cable/pro_cable.c
@@ -221,6 +221,7 @@ static void send_hello(void)
msg_string(&root, "activity", "steps-v1");
msg_string(&root, "stats", "turn-v1");
msg_string(&root, "player", "library-v1");
+ msg_string(&root, "superTab", "wait-v1"); // a question with superTab + attention is shown as a wait (handle_question)
msg_string(&root, "ota", "v1");
char mac[24] = "";
device_mac_str(mac, sizeof(mac));
@@ -667,14 +668,21 @@ static void handle_notif_seen(const cJSON *p)
pro_app_notif_seen(id, token ? token->valuestring : NULL);
}
+// question {agentId, id, questions:[{q}], superTab?, attention?}. A Super Tab's question names the project (`superTab`, cut to
+// SUPER_TAB_MAX - 1 bytes) and what it needs (`attention`: "stuck", else a decision, whatever an unknown value says). Without
+// a non-empty superTab it is a plain question, attention or not.
static void handle_question(const char *id, const cJSON *p)
{
+ static char s_tab[SUPER_TAB_MAX];
const char *request = str_of(p, "id"); // the request this question belongs to
if (!request) return;
const cJSON *questions = cJSON_GetObjectItemCaseSensitive(p, "questions");
const char *prompt = str_of(cJSON_GetArrayItem(questions, 0), "q");
copy_cut(s_text, PRO_QUESTION_BYTES, prompt ? prompt : "Needs your answer");
- pro_app_question(id, request, s_text);
+ const char *tab = cut_of(p, "superTab", s_tab, sizeof s_tab), *attn = str_of(p, "attention");
+ if (tab && !tab[0]) tab = NULL;
+ const pod_attention_t a = !tab ? POD_ATTN_NONE : attn && !strcmp(attn, "stuck") ? POD_ATTN_STUCK : POD_ATTN_DECISION;
+ pro_app_question(id, request, s_text, tab, a);
}
static void handle_question_close(const char *id, const cJSON *p)
diff --git a/devices/harness-pro/firmware/main/pod/home/ph.h b/devices/harness-pro/firmware/main/pod/home/ph.h
index d83487703..9bc897dfd 100644
--- a/devices/harness-pro/firmware/main/pod/home/ph.h
+++ b/devices/harness-pro/firmware/main/pod/home/ph.h
@@ -95,7 +95,7 @@ int ph_notices_top(const pod_model_t *, int max, ph_notice_line_t *out);
// ---- The notice toast (ph_toast.c) ----
// The toast for unread entry `u` over whatever the frame holds (call it last, as the glue draws it): see the file's header. shown_ms: when it appeared; it
-// slides in over POD_TOAST_SLIDE_MS and its bar runs out at shown_ms + POD_TOAST_MS. Adds one POD_A_BANNER hit (arg 0, id = the agent). Returns the
+// slides in over POD_TOAST_SLIDE_MS and its bar runs out at shown_ms + POD_TOAST_MS (a Super Tab question's bar stays full: pod_model_attention). Adds one POD_A_BANNER hit (arg 0, id = the agent). Returns the
// card's height. At most 9 runs.
int ph_toast(pod_out_frame_t *, const pod_model_t *, const pod_unread_t *u, uint32_t shown_ms, uint32_t now_ms);
diff --git a/devices/harness-pro/firmware/main/pod/home/ph_inbox.c b/devices/harness-pro/firmware/main/pod/home/ph_inbox.c
index ed7f90b8b..d0d2460f5 100644
--- a/devices/harness-pro/firmware/main/pod/home/ph_inbox.c
+++ b/devices/harness-pro/firmware/main/pod/home/ph_inbox.c
@@ -4,6 +4,11 @@
// then the text in at most two rows, the second cut with an ellipsis. Order: the asking agents (model order, their question), then the unread
// entries newest first (the entry's first sentence). A tap on a row registers POD_A_OPEN_NOTIF with the agent id (the glue resolves it against
// model->unread); an asking agent has no unread entry: POD_A_FOLLOW, which the glue resolves to an index in model->agents.
+// A Super Tab's question (pod_model_attention; owner's mockup pro-supertab/notify.html A3) is an asking row with three marks: the name line reads
+// "<name> · <Super Tab>" (the Super Tab in purple #6B4FA3), the meta "needs you" (a decision) or "stuck", a 6 px edge inside the bubble's left side
+// (amber #FFB340 / red #FF5C5C: the bubble less a copy of itself 6 px to the right, so it follows the corners; the tail, here a whole turned square,
+// is drawn over it as in the mockup), and on the avatar's bottom right corner a 40 px badge (#3B2E55, radius 12, a 3 px ring of the room's ground)
+// holding a diamond 16 px across in the room's ink (two triangles; the mockup's ◆ inherits that colour).
#include <stdio.h>
#include <string.h>
@@ -16,6 +21,11 @@
#define ELL "\xe2\x80\xa6"
enum { BG = PH_ROOM_BG, TOP = 120, PITCH = 170, SHOWN = 3, ROW_H = 150, AV_X = 60, AV_Y = 8, AV = 110, AV_ART = 92, BUB_X = 190, BUB_W = 470, PAD_X = 26, PAD_TOP = 20,
PAD_BOT = 22, NAME_H = 30, MSG_PITCH = 39, MAX_ITEMS = 40, TAIL_X = 181, TAIL_Y = 52 };
+// A Super Tab's row: the edge's width, the badge (its size, how far it hangs past the avatar's corner, its radius and ring) and the diamond's half width.
+// TAG_GAP: from the name's measured end to the "·": the measured width runs ~4 px past the ink and the dot has its own bearing, so 2 px reads as
+// the mockup's word space. The diamond is the mockup's glyph colour (the room's ink, inherited there).
+enum { EDGE_W = 6, BADGE = 40, BADGE_OUT = 8, BADGE_R = 12, RING = 3, DIAMOND = 8, TAG_GAP = 2 };
+enum { TAB_INK = 0x6B4FA3, BADGE_FILL = 0x3B2E55, DIAMOND_INK = PH_ROOM_INK, DECIDE_EDGE = 0xFFB340, STUCK_EDGE = 0xFF5C5C };
// The room's warm ground and the Notices letter's paper (owner, UI review option B): the letter card, this list and the recap are one family.
enum { BUB_FILL = PH_LETTER, INK = PH_LETTER_INK, META = PH_LETTER_WHO, AV_FILL = PH_RAISED, HEAD_INK = PH_ROOM_INK, HEAD_MUTED = PH_ROOM_MUTED };
static const ht_pro_font_t *const MSG = &ph_sb_32, *const META_F = &ph_sb_22;
@@ -113,8 +123,9 @@ static void row(pod_out_frame_t *f, const pod_model_t *m, const item_t *it, int
{
ht_scene_t *s = f->scene;
const pod_agent_t *a = it->a;
- char text[POD_UNREAD_TEXT > 320 ? POD_UNREAD_TEXT : 320], rows[3][POD_ROW_MAX], age[8];
+ char text[POD_UNREAD_TEXT > 320 ? POD_UNREAD_TEXT : 320], rows[3][POD_ROW_MAX], age[12];
const char *name;
+ const pod_attention_t attn = it->u ? POD_ATTN_NONE : pod_model_attention(m, a);
if (it->u) {
ph_first_sentence(text, sizeof text, it->u->text);
int32_t d = (int32_t)(m->clock_ms - it->u->at_ms);
@@ -123,7 +134,7 @@ static void row(pod_out_frame_t *f, const pod_model_t *m, const item_t *it, int
} else {
snprintf(text, sizeof text, "%s", a->question);
for (char *c = text; *c; c++) if (*c == '\n' || *c == '\r' || *c == '\t') *c = ' ';
- snprintf(age, sizeof age, "asks");
+ snprintf(age, sizeof age, "%s", attn == POD_ATTN_STUCK ? "stuck" : attn == POD_ATTN_DECISION ? "needs you" : "asks");
name = a->name[0] ? a->name : "Agent";
}
const int tw = BUB_W - 2 * PAD_X, n = two_rows(text, tw, rows);
@@ -131,15 +142,39 @@ static void row(pod_out_frame_t *f, const pod_model_t *m, const item_t *it, int
ht_pro_rect_aa(s, AV_X, y + AV_Y, AV, AV, 28, C(AV_FILL));
face_art(s, AV_X + AV / 2, y + AV_Y + AV / 2, a ? a->engine : NULL);
- ht_pro_rect_aa(s, BUB_X, y, BUB_W, h, 30, C(BUB_FILL));
- { // the tail: the left half of a 26 px square turned 45 degrees at (181, y + 52), pointing at the avatar
+ if (attn != POD_ATTN_NONE) { // the Super Tab badge: a ring of the ground, the purple square, the white diamond
+ const int bx = AV_X + AV + BADGE_OUT - BADGE, by = y + AV_Y + AV + BADGE_OUT - BADGE, cx = bx + BADGE / 2, cy = by + BADGE / 2;
+ ht_pro_rect_aa(s, bx, by, BADGE, BADGE, BADGE_R, C(BG));
+ ht_pro_rect_aa(s, bx + RING, by + RING, BADGE - 2 * RING, BADGE - 2 * RING, BADGE_R - RING, C(BADGE_FILL));
+ pod_tri_inner(s, (cx - DIAMOND) * 16, cy * 16, cx * 16, (cy - DIAMOND) * 16, (cx + DIAMOND) * 16, cy * 16, C(DIAMOND_INK), 4u);
+ pod_tri_inner(s, (cx + DIAMOND) * 16, cy * 16, cx * 16, (cy + DIAMOND) * 16, (cx - DIAMOND) * 16, cy * 16, C(DIAMOND_INK), 4u);
+ ht_pro_rect_aa(s, BUB_X, y, BUB_W, h, 30, C(attn == POD_ATTN_STUCK ? STUCK_EDGE : DECIDE_EDGE));
+ ht_pro_rect_aa(s, BUB_X + EDGE_W, y, BUB_W - EDGE_W, h, 30, C(BUB_FILL));
+ } else {
+ ht_pro_rect_aa(s, BUB_X, y, BUB_W, h, 30, C(BUB_FILL));
+ }
+ { // the tail: the left half of a 26 px square turned 45 degrees at (181, y + 52), pointing at the avatar (a Super Tab row: the whole square, over the edge)
const int cy = y + TAIL_Y + 13, x0 = TAIL_X - 5;
pod_tri(s, (BUB_X + 1) * 16, (cy - 18) * 16, (BUB_X + 1) * 16, (cy + 18) * 16, x0 * 16, cy * 16, C(BUB_FILL));
+ if (attn != POD_ATTN_NONE)
+ pod_tri_inner(s, (BUB_X + 1) * 16, (cy - 18) * 16, (BUB_X + 22) * 16, cy * 16, (BUB_X + 1) * 16, (cy + 18) * 16, C(BUB_FILL), 4u);
}
int aw = ht_pro_width(META_F, age), nw = ht_pro_width(META_F, name), room = tw - aw - 16;
+ char tag[SUPER_TAB_MAX + 4] = "";
+ int gw = 0;
+ if (attn != POD_ATTN_NONE) { // "name · Super Tab": the name keeps at least half the room, the Super Tab the rest (cut with dots)
+ snprintf(tag, sizeof tag, "\xc2\xb7 %s", a->super_tab);
+ const int want = ht_pro_width(META_F, tag);
+ int keep = room - TAG_GAP - want; // what the name may take beside the whole tag
+ if (keep < room / 2) keep = room / 2;
+ if (nw > keep) nw = keep;
+ gw = room - nw - TAG_GAP;
+ if (gw > want + 2) gw = want + 2;
+ }
if (nw > room) nw = room > 0 ? room : 0;
const int ly = y + PAD_TOP;
if (nw > 0) ht_pro_text(s, BUB_X + PAD_X, ly, nw, META_F, C(META), name);
+ if (gw > 0) ht_pro_text(s, BUB_X + PAD_X + nw + TAG_GAP, ly, gw, META_F, C(TAB_INK), tag);
ht_pro_text(s, BUB_X + BUB_W - PAD_X - aw, ly, aw + 2, META_F, C(META), age);
for (int i = 0; i < n; i++) ht_pro_text(s, BUB_X + PAD_X, ly + NAME_H + 4 + i * MSG_PITCH, tw, MSG, C(INK), rows[i]);
diff --git a/devices/harness-pro/firmware/main/pod/home/ph_toast.c b/devices/harness-pro/firmware/main/pod/home/ph_toast.c
index 967e2a47b..f147e6669 100644
--- a/devices/harness-pro/firmware/main/pod/home/ph_toast.c
+++ b/devices/harness-pro/firmware/main/pod/home/ph_toast.c
@@ -3,6 +3,10 @@
// 56 px slot (the 44 px baked one centred in it), then the agent's name (ph_sb_26, #FFB36B) over the notice's first sentence (ph_rg_28, #F2F7FC), each on one
// line cut with an ellipsis. Along the bottom a 7 px progress bar (a white 8 % track, #FF8A3D fill) shrinks from full to nothing over POD_TOAST_MS; it is
// inset 26 px each side and lifted 10 px so its ends clear the card's rounded corners. The card slides in from y -170 over POD_TOAST_SLIDE_MS (ease out).
+// A Super Tab question's toast (an `ask` entry whose agent asks with pod_model_attention; owner's mockup pro-supertab/notify.html A1 / A2) does not
+// run out: the name is followed, a 10 px gap on, by "· <Super Tab>" (ph_sb_22, #8EA3BD, centred on the name's line), the line is the question as asked,
+// and in place of the timer a still bar fills the whole inset (no track): amber #FFB340 with a #6A4A1C edge for a decision, red #FF5C5C with a
+// #6A2626 edge and the name in #FF8F8F for a stuck agent. The glue keeps it up until it is swiped away, the question closes or Notices opens.
// One POD_A_BANNER hit over the card (the glue opens Notices on a tap, a swipe up dismisses it). At most 9 runs.
#include <stdio.h>
#include <string.h>
@@ -13,7 +17,9 @@
#define C(rgb) ht_rgb(rgb)
enum { TX = 40, TY = 24, TW = 640, TH = 118, TR = 30, EDGE = 2, PAD = 26, SLOT = 56, LOGO = 44, GAP = 18, FROM_Y = -170,
- BAR_H = 7, BAR_LIFT = 10 };
+ BAR_H = 7, BAR_LIFT = 10, TAG_GAP = 7 }; // TAG_GAP: the mockup's 10 px flex gap, less the ~3 px the measured name runs past its ink
+// A Super Tab question's colours: a decision's edge and bar, a stuck agent's edge, bar and name, and the Super Tab's name after the agent's.
+enum { DECIDE_EDGE = 0x6A4A1C, DECIDE_BAR = 0xFFB340, STUCK_EDGE = 0x6A2626, STUCK_BAR = 0xFF5C5C, STUCK_NAME = 0xFF8F8F, TAG_INK = 0x8EA3BD };
int ph_toast(pod_out_frame_t *f, const pod_model_t *m, const pod_unread_t *u, uint32_t shown_ms, uint32_t now_ms)
{
@@ -27,7 +33,9 @@ int ph_toast(pod_out_frame_t *f, const pod_model_t *m, const pod_unread_t *u, ui
y = FROM_Y + (TY - FROM_Y) * e / 1000;
}
const pod_agent_t *a = pod_model_find(m, u->agent);
- ht_pro_rect_aa(s, TX, y, TW, TH, TR, C(PH_TOAST_EDGE));
+ const pod_attention_t attn = u->ask ? pod_model_attention(m, a) : POD_ATTN_NONE; // a Super Tab's question: the toast stays
+ const bool stuck = attn == POD_ATTN_STUCK;
+ ht_pro_rect_aa(s, TX, y, TW, TH, TR, C(attn == POD_ATTN_NONE ? PH_TOAST_EDGE : stuck ? STUCK_EDGE : DECIDE_EDGE));
ht_pro_rect_aa(s, TX + EDGE, y + EDGE, TW - 2 * EDGE, TH - 2 * EDGE, TR - EDGE, C(PH_TOAST_FILL));
ph_engine_logo(s, TX + PAD + (SLOT - LOGO) / 2, y + (TH - LOGO) / 2, LOGO, a ? a->engine : NULL, PH_TOAST_FILL);
const int tx = TX + PAD + SLOT + GAP, tw = TX + TW - PAD - tx;
@@ -35,10 +43,26 @@ int ph_toast(pod_out_frame_t *f, const pod_model_t *m, const pod_unread_t *u, ui
char line[160];
ph_first_sentence(line, sizeof line, u->text);
if (!line[0]) snprintf(line, sizeof line, "%s", u->kind == POD_UNREAD_FAILED ? "Failed" : "Done");
- ph_text(s, tx, y + 42, tw, &ph_sb_26, PH_TOAST_NAME, name);
+ if (attn == POD_ATTN_NONE) {
+ ph_text(s, tx, y + 42, tw, &ph_sb_26, PH_TOAST_NAME, name);
+ } else { // "name · Super Tab": the name keeps at least half the line; the Super Tab takes what is left, cut with an ellipsis
+ char tag[SUPER_TAB_MAX + 4];
+ snprintf(tag, sizeof tag, "\xc2\xb7 %s", a->super_tab);
+ const int tagw = ht_pro_width(&ph_sb_22, tag), want = ht_pro_width(&ph_sb_26, name);
+ int nw = tw - TAG_GAP - tagw;
+ if (nw < tw / 2) nw = tw / 2;
+ if (want < nw) nw = want;
+ ph_text(s, tx, y + 42, nw + 2, &ph_sb_26, stuck ? STUCK_NAME : PH_TOAST_NAME, name);
+ ph_text(s, tx + nw + TAG_GAP, y + 42, tw - nw - TAG_GAP, &ph_sb_22, TAG_INK, tag);
+ }
ph_text(s, tx, y + 77, tw, &ph_rg_28, PH_TOAST_INK, line);
- // the bar: a track the full width of the inset, the fill the share of the time left
const int bx = TX + PAD, bw = TW - 2 * PAD, by = y + TH - BAR_H - BAR_LIFT;
+ if (attn != POD_ATTN_NONE) { // the still bar: waiting for you, not running out
+ ht_pro_rect(s, bx, by, bw, BAR_H, BAR_H / 2, C(stuck ? STUCK_BAR : DECIDE_BAR));
+ pod_hit_add_id(f, TX, TY, TW, TH, POD_A_BANNER, 0, u->agent);
+ return TH;
+ }
+ // the bar: a track the full width of the inset, the fill the share of the time left
ht_pro_rect(s, bx, by, bw, BAR_H, BAR_H / 2, C(ph_mix(0xFFFFFF, PH_TOAST_FILL, 8)));
const int32_t left = POD_TOAST_MS - age;
const int fw = left <= 0 ? 0 : left >= (int32_t)POD_TOAST_MS ? bw : (int)((int64_t)bw * left / POD_TOAST_MS);
diff --git a/devices/harness-pro/firmware/main/pod/pod_model.c b/devices/harness-pro/firmware/main/pod/pod_model.c
index e5c4f6b07..d31043e4c 100644
--- a/devices/harness-pro/firmware/main/pod/pod_model.c
+++ b/devices/harness-pro/firmware/main/pod/pod_model.c
@@ -166,6 +166,8 @@ static uint64_t agent_sig(const pod_agent_t *a, bool with_event) {
h = fnv_bytes(h, &a->tokens_in, sizeof a->tokens_in);
h = fnv_bytes(h, &a->tokens_out, sizeof a->tokens_out);
h = fnv_str(h, a->question);
+ h = fnv_str(h, a->super_tab);
+ h = fnv_bytes(h, &a->attention, sizeof a->attention);
h = fnv_bytes(h, &a->state, sizeof a->state);
h = fnv_bytes(h, &a->since_ms, sizeof a->since_ms);
h = fnv_bytes(h, &a->elapsed_s, sizeof a->elapsed_s);
@@ -450,9 +452,14 @@ static pod_agent_t *fresh_agent(pod_model_t *m, const char *id, uint32_t now_ms)
}
static void set_state(pod_model_t *m, pod_agent_t *a, pod_state_t s, uint32_t now_ms) {
+ // A Super Tab's question is the agent's work waiting on a person, not a dialog in its pane: a turn that starts or
+ // ends, a library sweep or a send does not end it. Only question.close (or the link going) does.
+ if (a->state == POD_ASKING && a->super_tab[0] && s != POD_ASKING) { a->wait_after = (uint8_t)s; return; }
if (s == POD_WORKING && a->state != POD_WORKING) a->since_ms = now_ms;
if (s != POD_ASKING) {
a->question[0] = 0;
+ a->super_tab[0] = 0;
+ a->attention = POD_ATTN_NONE;
if (a->state == POD_ASKING) { // the question is over, however: its toast entry is stale
int u = unread_idx(m, a->id);
if (u >= 0 && m->unread[u].ask) unread_drop(m, u);
@@ -568,24 +575,44 @@ void pod_model_turn_stats(pod_model_t *m, const char *id, int32_t passed, int32_
// question / question_close carry no clock, so they leave event_ms alone (the library status that
// accompanies a question refreshes it).
-void pod_model_question(pod_model_t *m, const char *id, const char *text) {
+void pod_model_question(pod_model_t *m, const char *id, const char *text) { pod_model_question_tab(m, id, text, NULL, POD_ATTN_NONE); }
+
+void pod_model_question_tab(pod_model_t *m, const char *id, const char *text, const char *super_tab, pod_attention_t attention) {
int i = find_idx(m, id);
if (i < 0) return;
pod_agent_t *a = &m->agents[i];
uint64_t before = agent_sig(a, true);
if (a->state != POD_ASKING && m->clock_set) { a->act_ms = m->clock_ms; a->has_act = true; }
a->sent = false;
+ const bool tab = super_tab && super_tab[0];
+ // A plain question that ends goes back to work (question_close); a Super Tab wait to what it held back.
+ if (tab && !(a->state == POD_ASKING && a->super_tab[0]))
+ a->wait_after = (uint8_t)(a->state == POD_ASKING ? POD_WORKING : a->state);
a->state = POD_ASKING;
a->activity[0] = 0;
copy_str(a->question, sizeof a->question, text);
+ copy_str(a->super_tab, sizeof a->super_tab, tab ? super_tab : "");
+ a->attention = (uint8_t)(!tab ? POD_ATTN_NONE : attention == POD_ATTN_STUCK ? POD_ATTN_STUCK : POD_ATTN_DECISION);
if (before != agent_sig(a, true)) m->revision++;
}
+pod_attention_t pod_model_attention(const pod_model_t *m, const pod_agent_t *a) {
+ if (!a || !a->super_tab[0] || pod_model_eff(m, a) != POD_ASKING) return POD_ATTN_NONE;
+ return a->attention == POD_ATTN_STUCK ? POD_ATTN_STUCK : POD_ATTN_DECISION;
+}
+
void pod_model_question_close(pod_model_t *m, const char *id) {
int i = find_idx(m, id);
if (i < 0 || m->agents[i].state != POD_ASKING) return;
- m->agents[i].state = POD_WORKING;
+ pod_agent_t *a = &m->agents[i];
+ // A plain question is answered mid-turn: the turn goes on. A Super Tab wait outlived its turns, so the agent takes
+ // the state they left it in: idle or done, not a Working nobody is doing.
+ const pod_state_t next = a->super_tab[0] ? (pod_state_t)a->wait_after : POD_WORKING;
+ a->state = next == POD_ASKING ? POD_WORKING : next;
+ if (a->state != POD_WORKING) { a->activity[0] = 0; a->verb[0] = 0; a->step_count = 0; a->turn_started = false; }
m->agents[i].question[0] = 0;
+ m->agents[i].super_tab[0] = 0;
+ m->agents[i].attention = POD_ATTN_NONE;
int u = unread_idx(m, id);
if (u >= 0 && m->unread[u].ask) unread_drop(m, u); // answered: its toast entry is stale
m->revision++;
@@ -673,9 +700,16 @@ void pod_model_recap(pod_model_t *m, const char *id, const char *recap, bool res
void pod_model_link(pod_model_t *m, bool up) {
if (m->linked == up) return;
m->linked = up;
- if (!up) // a drop forgets every open question (pro_app clears them): the daemon re-sends what is still owed
+ if (!up) { // a drop forgets every open question (pro_app clears them): the daemon re-sends what is still owed
for (int i = m->unread_count - 1; i >= 0; i--)
if (m->unread[i].ask) unread_drop(m, i);
+ // A Super Tab wait becomes a plain question, which the next turn or sweep ends as any other: nothing vouches
+ // for it with the cable gone, and the daemon asks it again on the next link if it still waits.
+ for (int i = 0; i < m->agent_count; i++) {
+ m->agents[i].super_tab[0] = 0;
+ m->agents[i].attention = POD_ATTN_NONE;
+ }
+ }
m->revision++;
}
diff --git a/devices/harness-pro/firmware/main/pod/pod_model.h b/devices/harness-pro/firmware/main/pod/pod_model.h
index a64414421..885700477 100644
--- a/devices/harness-pro/firmware/main/pod/pod_model.h
+++ b/devices/harness-pro/firmware/main/pod/pod_model.h
@@ -37,6 +37,13 @@ typedef struct {
uint32_t since_ms, elapsed_s, event_ms;
bool has_event; // event_ms is set (an agent with none takes any feed, wrap or not)
char activity[POD_ACTIVITY_BYTES], question[320], recap[POD_RECAP_BYTES];
+ // The open question's Super Tab (the shared project it was asked in; "" = a plain question) and what it needs
+ // (pod_attention_t: decision or stuck; NONE without a Super Tab). Set and cleared with question[].
+ char super_tab[SUPER_TAB_MAX];
+ uint8_t attention;
+ // What a Super Tab question holds back (a pod_state_t): the state the agent's turns and sweeps would have given it,
+ // taken once the question closes. Before the first such feed, the state it had when asked.
+ uint8_t wait_after;
char verb[POD_VERB_BYTES];
char steps[POD_STEPS_MAX][POD_STEP_BYTES]; // this turn's tools and previous activity sentences, newest first (cut on a codepoint)
uint16_t step_at_s[POD_STEPS_MAX]; // seconds into the turn each step arrived (steps[] order); 0xFFFF = unknown (no turn start seen)
@@ -157,6 +164,11 @@ void pod_model_turn(pod_model_t *, const char *id, const char *kind, const char
// turn.stats: the last turn's test and commit counts (-1 leaves a field unknown). Unknown agents are ignored.
void pod_model_turn_stats(pod_model_t *, const char *id, int32_t passed, int32_t failed, int32_t commits, int32_t tokens_in, int32_t tokens_out);
void pod_model_question(pod_model_t *, const char *id, const char *text);
+// The same for a Super Tab's question: super_tab (NULL or "" = a plain one, attention ignored) and what it needs.
+// Unlike a plain one it survives the agent's turns and library sweeps: only question_close (or the link) ends it.
+void pod_model_question_tab(pod_model_t *, const char *id, const char *text, const char *super_tab, pod_attention_t attention);
+// What the agent's open question asks for: DECISION or STUCK while it asks (pod_model_eff) a Super Tab's question, else NONE.
+pod_attention_t pod_model_attention(const pod_model_t *, const pod_agent_t *);
void pod_model_question_close(pod_model_t *, const char *id);
void pod_model_recap(pod_model_t *, const char *id, const char *recap, bool restore);
void pod_model_link(pod_model_t *, bool up);
diff --git a/devices/harness-pro/firmware/main/pro_app_api.h b/devices/harness-pro/firmware/main/pro_app_api.h
index 38563cc33..e80977699 100644
--- a/devices/harness-pro/firmware/main/pro_app_api.h
+++ b/devices/harness-pro/firmware/main/pro_app_api.h
@@ -76,8 +76,10 @@ void pro_app_notif_replace(const pro_notif_row_t *rows, int n);
// notif.seen: read elsewhere. token is NULL without one.
void pro_app_notif_seen(const char *id, const char *token);
-// request is the question's request id: with the prompt it tells a re-sent question from a new one.
-void pro_app_question(const char *id, const char *request, const char *text);
+// request is the question's request id: with the prompt it tells a re-sent question from a new one. super_tab is the Super Tab
+// the asking agent works in (NULL for a plain question; never "", at most SUPER_TAB_MAX - 1 bytes) and attention what it needs
+// (POD_ATTN_DECISION or POD_ATTN_STUCK with a super_tab, POD_ATTN_NONE without).
+void pro_app_question(const char *id, const char *request, const char *text, const char *super_tab, pod_attention_t attention);
void pro_app_question_close(const char *id);
// The daemon's surface moved to this agent.
diff --git a/devices/harness-pro/firmware/test/golden-liberation.txt b/devices/harness-pro/firmware/test/golden-liberation.txt
index ee8deb0af..f09a50c31 100644
--- a/devices/harness-pro/firmware/test/golden-liberation.txt
+++ b/devices/harness-pro/firmware/test/golden-liberation.txt
@@ -183,6 +183,11 @@ a06283fd15df5fd37792b2657fb797aed4d084b8d9d654f2ccbb6c1e998b946c ota:restart@25
a06283fd15df5fd37792b2657fb797aed4d084b8d9d654f2ccbb6c1e998b946c ota:restart@5000
a06283fd15df5fd37792b2657fb797aed4d084b8d9d654f2ccbb6c1e998b946c ota:restart@600
a1e3940d58d67287e25827d39eb9a5c7a75c295bf58de28b7b6793caa748cb30 tabs:mock@2500
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@0
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@1234
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@2500
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@5000
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@600
a6712f0052fbad9b33cf4511c4fbf0e4731c42df8c5533fa33b21a3439caddf2 agent:desk@2500
a6712f0052fbad9b33cf4511c4fbf0e4731c42df8c5533fa33b21a3439caddf2 recap:desk:banner@2500
a6712f0052fbad9b33cf4511c4fbf0e4731c42df8c5533fa33b21a3439caddf2 recap:desk:extreme@2500
@@ -227,6 +232,11 @@ cacbb92aabbda5f6c5f2a3415fe6ee6738d297ad04a965a2d75146def704c6f9 recap:desk:med
cb3173536ee26106bde53894630e1e172f58d7186f8170bb193309b2f1908a1f agent:cli:banner@2500
cb3173536ee26106bde53894630e1e172f58d7186f8170bb193309b2f1908a1f agent:cli@2500
cb737bbe219b16e101016fef367cf5301af9955f9830a0607304e0cf0dd83187 tabs:mock@1234
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@0
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@1234
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@2500
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@5000
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@600
cbd36c0793fbcda1b9b1d265152e864a0b9ca64c76e0f05808b0a3edf7a9a672 tabs:seven@5000
cc493be5ebd9400df8eef0fea1c92270fe2c29e8dc9654acaf812e802136abb6 tabs:long@0
ce2c1196b58d9ed5a3e4b0976475ded835cb447ec8f7e8c46b54d427356f4eb1 recap:desk:viet@2500
@@ -255,6 +265,11 @@ d6591213f2e6735084c2d4ba74350a14ef40e0e4b008b32d86d3bf0c11f9e49f inbox:viet@500
d6591213f2e6735084c2d4ba74350a14ef40e0e4b008b32d86d3bf0c11f9e49f inbox:viet@600
d750a984bfeeb870e18c3291aad2cdd2f6f12b7c4c04c87bdf60f1143ea8ad02 tabs:working@1234
d95387eb8f4a5e443d31a5fe2c2a25b5d8cba9b0304b25ed2b63250f6ce3d308 recap:desk:viet@600
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@0
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@1234
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@2500
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@5000
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@600
de7fccfd4d9ed624772a2c8d137e182ca0697f72b421dc21d1bb4ce4bc8bf594 tabs:none@2500
e01801d7676609320823ae0c55a805defab02449150ee721b8b774f8e85a7294 recap:desk:medium@0
e16e322edb920b4cff7d04ca1cb2c8202987f3734183bea64c59a7086b6ba830 agent:cli:long@5000
diff --git a/devices/harness-pro/firmware/test/golden.sh b/devices/harness-pro/firmware/test/golden.sh
index 88e8a2ff3..8cac1ecea 100644
--- a/devices/harness-pro/firmware/test/golden.sh
+++ b/devices/harness-pro/firmware/test/golden.sh
@@ -32,10 +32,11 @@ cc -std=c11 -D_DEFAULT_SOURCE -Wall -Wextra -Werror -O1 -g -DHT_FACE_PX=720 -I"$
screens=(tabs tabs:bell tabs:mock tabs:0+2 tabs:2+2 tabs:long tabs:9 tabs:linkdown tabs:1 tabs:3 tabs:5 tabs:seven tabs:single tabs:notices tabs:working tabs:none
agent:fw agent:cli agent:be agent:desk agent:kilo agent:fw:long agent:cli:long agent:be:offline agent:fw:banner agent:cli:banner tabs:banner agent:fw:toast@0 agent:fw:toast@200 agent:fw:toast@2500 agent:fw:toast@4900
+ agent:fw:toast:decision@2500 agent:fw:toast:stuck@9000
recap:desk:toast@200 recap:desk:toast@2500 recap:docs:toast@4900
recap:desk recap:desk:unread recap:desk:long recap:desk:viet recap:desk:short recap:desk:medium recap:docs:long recap:docs:unreadfail agent:fw:unread recap:docs recap:kilo recap:desk:testfail recap:desk:extreme recap:desk:banner
talk:fw talk:fw:quiet talk:fw:send talk:cur talk:cur:send talk:be talk:be:send
- inbox inbox:viet inbox:quiet inbox:failed ota:0 ota:62 ota:100 ota:restart)
+ inbox inbox:viet inbox:quiet inbox:failed inbox:supertab ota:0 ota:62 ota:100 ota:restart)
for s in "${screens[@]}"; do
for now in 0 600 1234 2500 5000; do
"$out/pod_render" "$s" "$out/r.ppm" "$now" >/dev/null
diff --git a/devices/harness-pro/firmware/test/golden.txt b/devices/harness-pro/firmware/test/golden.txt
index ee8deb0af..f09a50c31 100644
--- a/devices/harness-pro/firmware/test/golden.txt
+++ b/devices/harness-pro/firmware/test/golden.txt
@@ -183,6 +183,11 @@ a06283fd15df5fd37792b2657fb797aed4d084b8d9d654f2ccbb6c1e998b946c ota:restart@25
a06283fd15df5fd37792b2657fb797aed4d084b8d9d654f2ccbb6c1e998b946c ota:restart@5000
a06283fd15df5fd37792b2657fb797aed4d084b8d9d654f2ccbb6c1e998b946c ota:restart@600
a1e3940d58d67287e25827d39eb9a5c7a75c295bf58de28b7b6793caa748cb30 tabs:mock@2500
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@0
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@1234
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@2500
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@5000
+a2d12802ab968c819af74e829d50ad2a1e9545268a4a917a93c849d708294723 inbox:supertab@600
a6712f0052fbad9b33cf4511c4fbf0e4731c42df8c5533fa33b21a3439caddf2 agent:desk@2500
a6712f0052fbad9b33cf4511c4fbf0e4731c42df8c5533fa33b21a3439caddf2 recap:desk:banner@2500
a6712f0052fbad9b33cf4511c4fbf0e4731c42df8c5533fa33b21a3439caddf2 recap:desk:extreme@2500
@@ -227,6 +232,11 @@ cacbb92aabbda5f6c5f2a3415fe6ee6738d297ad04a965a2d75146def704c6f9 recap:desk:med
cb3173536ee26106bde53894630e1e172f58d7186f8170bb193309b2f1908a1f agent:cli:banner@2500
cb3173536ee26106bde53894630e1e172f58d7186f8170bb193309b2f1908a1f agent:cli@2500
cb737bbe219b16e101016fef367cf5301af9955f9830a0607304e0cf0dd83187 tabs:mock@1234
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@0
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@1234
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@2500
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@5000
+cbcf97eb88150c0578ec8b63d18aee56d222bfba8b630eacb4d67ece4ef4d550 agent:fw:toast:stuck@9000@600
cbd36c0793fbcda1b9b1d265152e864a0b9ca64c76e0f05808b0a3edf7a9a672 tabs:seven@5000
cc493be5ebd9400df8eef0fea1c92270fe2c29e8dc9654acaf812e802136abb6 tabs:long@0
ce2c1196b58d9ed5a3e4b0976475ded835cb447ec8f7e8c46b54d427356f4eb1 recap:desk:viet@2500
@@ -255,6 +265,11 @@ d6591213f2e6735084c2d4ba74350a14ef40e0e4b008b32d86d3bf0c11f9e49f inbox:viet@500
d6591213f2e6735084c2d4ba74350a14ef40e0e4b008b32d86d3bf0c11f9e49f inbox:viet@600
d750a984bfeeb870e18c3291aad2cdd2f6f12b7c4c04c87bdf60f1143ea8ad02 tabs:working@1234
d95387eb8f4a5e443d31a5fe2c2a25b5d8cba9b0304b25ed2b63250f6ce3d308 recap:desk:viet@600
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@0
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@1234
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@2500
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@5000
+d98e5146f84246d2e794ca51cc07961c82d1d5c7368c958638c0fdc21b9b4ff0 agent:fw:toast:decision@2500@600
de7fccfd4d9ed624772a2c8d137e182ca0697f72b421dc21d1bb4ce4bc8bf594 tabs:none@2500
e01801d7676609320823ae0c55a805defab02449150ee721b8b774f8e85a7294 recap:desk:medium@0
e16e322edb920b4cff7d04ca1cb2c8202987f3734183bea64c59a7086b6ba830 agent:cli:long@5000
diff --git a/devices/harness-pro/firmware/test/pod_render.c b/devices/harness-pro/firmware/test/pod_render.c
index 4294c86c7..3dcbce93b 100644
--- a/devices/harness-pro/firmware/test/pod_render.c
+++ b/devices/harness-pro/firmware/test/pod_render.c
@@ -3,7 +3,8 @@
// screens: tabs[:<tab>[+<more tabs>] | :mock | :9 | :seven | :single | :long | :notices | :linkdown | :banner] (Home),
// agent:<id>, recap:<id>, talk:<id> (ids: fw ota be cli web desk docs vault site cur notes2 kilo; suffixes :long :offline :unread :viet ...),
// talk:listen|send, inbox[:viet|:quiet|:failed], ota:<pct>|ota:restart (the update screen), notice:updated|notice:failed (the Home screen with that pill),
-// <room>:toast[@<ms after it showed>] (the notice toast), and ":bell" / ":banner" on a screen (unread entries; banner adds the toast). The demo is the
+// <room>:toast[@<ms after it showed>] (the notice toast; <room>:toast:decision / :stuck: a Super Tab question's staying toast, backend deciding or
+// desktop stuck), inbox:supertab (Notices with those two asking rows above a plain entry), and ":bell" / ":banner" on a screen (unread entries; banner adds the toast). The demo is the
// HTML mockup's: the same agents, tabs and times. `--skin pets` is accepted and ignored (Pets is the only interface).
#include <stdio.h>
#include <stdlib.h>
@@ -283,12 +284,20 @@ static void write_spec(const char *path, const char *screen)
}
// What the glue adds after pod_render, once the entry is still unread: the toast over a room (not Home or Notices) of another agent.
+static const char *s_toast_agent = "be"; // the entry the toast shows: "be", or "desk" for the stuck Super Tab toast
static void overlay(bool banner, bool toast, uint32_t now)
{
- const pod_unread_t *bn = pod_model_unread_find(&M, "be"); // "be" is the entry the toast shows
+ const pod_unread_t *bn = pod_model_unread_find(&M, s_toast_agent);
if (!bn) return;
const pod_frame_t *top = N.depth ? &N.stack[N.depth - 1] : NULL;
- if ((banner || toast) && top && (top->view == POD_V_AGENT || top->view == POD_V_RECAP) && strcmp(top->agent, "be")) ph_toast(&F, &M, bn, T0, now);
+ if ((banner || toast) && top && (top->view == POD_V_AGENT || top->view == POD_V_RECAP) && strcmp(top->agent, s_toast_agent)) ph_toast(&F, &M, bn, T0, now);
+}
+
+// A Super Tab ("Launch v2") question: the agent asks with that attention and the question's entry is filed, as pro_app does.
+static void supertab_ask(const char *id, const char *name, const char *q, pod_attention_t attn)
+{
+ pod_model_question_tab(&M, id, q, "Launch v2", attn);
+ pod_model_unread_ask(&M, id, name, q, T0);
}
int main(int argc, char **argv)
@@ -324,6 +333,17 @@ int main(int argc, char **argv)
snprintf(((pod_unread_t *)pod_model_unread_find(&M, "be"))->text, POD_UNREAD_TEXT, "Đã sửa lỗi đồng bộ cáp. Mọi bài kiểm thử đều xanh trên máy chủ và thiết bị.");
snprintf(((pod_unread_t *)pod_model_unread_find(&M, "ota"))->text, POD_UNREAD_TEXT, "Đã nạp mặt mới cho núm xoay, kênh cập nhật không đổi và mọi thứ vẫn chạy ổn định như trước đó.");
}
+ if (toast && strstr(screen, ":decision")) supertab_ask("be", "backend", "Run the migration on staging first, or straight to prod?", POD_ATTN_DECISION);
+ if (toast && strstr(screen, ":stuck")) {
+ s_toast_agent = "desk";
+ supertab_ask("desk", "desktop", "Stuck: e2e failed 3 times, no write access to staging", POD_ATTN_STUCK);
+ }
+ if (inbox && strstr(screen, "supertab")) { // the mockup's A3: a decision, a stuck agent, then the newest plain entry (ota's is read)
+ pod_model_question_close(&M, "cli");
+ pod_model_unread_seen(&M, "ota", NULL);
+ supertab_ask("be", "backend", "Run the migration on staging first, or straight to prod?", POD_ATTN_DECISION);
+ supertab_ask("desk", "desktop", "e2e failed 3 times, no write access to staging", POD_ATTN_STUCK);
+ }
if (inbox) pod_nav_act(&N, &M, POD_A_INBOX, 0, T0);
else if (!strcmp(screen, "tabs:notices")) { // Home on the Notices card (the entries are added above; the asking agent counts too)
pod_nav_act(&N, &M, POD_A_SCROLL, POD_HOME_NOTICES, T0);
diff --git a/devices/harness-pro/firmware/test/test_ph_glue.c b/devices/harness-pro/firmware/test/test_ph_glue.c
index b58309637..0cd989dbe 100644
--- a/devices/harness-pro/firmware/test/test_ph_glue.c
+++ b/devices/harness-pro/firmware/test/test_ph_glue.c
@@ -1023,6 +1023,83 @@ static void toast_shows_and_expires(void) {
CHECK(pod_ui_notify(&U, "a2", POD_TIER_ALERT, true, 3000));
CHECK(!strcmp(U.ban_agent, "a2") && U.ban_until == 8000 && pod_ui_banner_shown_ms(&U) == 3000);
}
+// A Super Tab's question (decision or stuck) raises a toast that does not run out: it stays past POD_TOAST_MS with no 66 ms
+// beat after its slide, and goes when swiped up, when the question closes, or once Notices is on screen. A plain question's runs out.
+static void supertab_ask(const char *id, const char *q, pod_attention_t attn, uint32_t t) {
+ pod_ui_question(&U, id, q, attn == POD_ATTN_NONE ? NULL : "Launch v2", attn);
+ pod_ui_notify_text(&U, id, POD_TIER_ALERT, q, true, true, t);
+}
+static void supertab_toast_stays(void) {
+ fresh();
+ calm();
+ to_agent(0, 2); // a3's Recap: a still room
+ supertab_ask("a1", "Staging first, or straight to prod?", POD_ATTN_DECISION, 1000);
+ CHECK(U.ban_on && U.ban_stay && pod_ui_banner_shown_ms(&U) == 1000);
+ for (uint32_t t = 1000; t < 1000 + POD_TOAST_SLIDE_MS; t += 7) { render(t); CHECK(U.frame.banner && pod_ui_wake_ms(&U, t) <= 66); }
+ { // after the slide nothing on the toast moves: the room's own beat, as if there were no toast
+ render(3000);
+ const uint32_t with = pod_ui_wake_ms(&U, 3000);
+ U.ban_on = false;
+ const uint32_t without = pod_ui_wake_ms(&U, 3000);
+ U.ban_on = true;
+ CHECK(with == without);
+ }
+ render(6000);
+ CHECK(U.frame.banner && U.ban_on); // past the 5 s of a plain toast
+ render(600000);
+ CHECK(U.frame.banner && U.ban_on && find(POD_A_BANNER) && !strcmp(find(POD_A_BANNER)->id, "a1"));
+ pod_ui_question_close(&U, "a1"); // answered elsewhere: its entry goes, and the toast with it
+ render(600100);
+ CHECK(!U.frame.banner && !U.ban_on && !pod_model_unread_find(&U.model, "a1"));
+
+ // a stuck agent's stays too; a swipe up dismisses it, the entry stays listed
+ supertab_ask("a2", "Stuck: no write access to staging", POD_ATTN_STUCK, 700000);
+ render(700000);
+ render(800000);
+ CHECK(U.frame.banner && U.ban_stay);
+ t_(true, 360, 110, 800100); t_(true, 360, 80, 800140); t_(false, 360, 40, 800180);
+ render(800200);
+ CHECK(!U.ban_on && !U.frame.banner && pod_model_unread_find(&U.model, "a2") && top()->view == POD_V_RECAP);
+
+ // Notices on screen ends it: back in the room it does not return
+ fresh();
+ calm();
+ to_agent(0, 2);
+ supertab_ask("a1", "Staging first, or straight to prod?", POD_ATTN_DECISION, 1000);
+ render(9000);
+ CHECK(U.frame.banner);
+ const int depth = U.nav.depth;
+ act(POD_A_INBOX, 0);
+ render(9100);
+ CHECK(!U.ban_on && !U.frame.banner && top()->view == POD_V_INBOX);
+ act(POD_A_BACK, 0);
+ render(9200);
+ CHECK(U.nav.depth == depth && top()->view == POD_V_RECAP && !U.frame.banner && pod_model_unread_find(&U.model, "a1"));
+
+ // a plain question's toast runs out as before
+ fresh();
+ calm();
+ to_agent(0, 2);
+ supertab_ask("a1", "Which branch?", POD_ATTN_NONE, 1000);
+ CHECK(U.ban_on && !U.ban_stay);
+ render(5999);
+ CHECK(U.frame.banner);
+ render(6000);
+ CHECK(!U.frame.banner && !U.ban_on && pod_model_unread_find(&U.model, "a1"));
+ // and a newer plain notice replaces a staying toast (and runs out)
+ supertab_ask("a2", "Staging first, or straight to prod?", POD_ATTN_DECISION, 7000);
+ CHECK(U.ban_stay);
+ CHECK(pod_ui_notify(&U, "a4", POD_TIER_ALERT, true, 8000));
+ CHECK(!strcmp(U.ban_agent, "a4") && !U.ban_stay);
+ // not while talking: no toast is raised for it at all (as for any alert)
+ fresh();
+ calm();
+ to_agent(0, 2);
+ act(POD_A_TALK, 0);
+ CHECK(top()->view == POD_V_TALK);
+ supertab_ask("a1", "Staging first, or straight to prod?", POD_ATTN_DECISION, 1000);
+ CHECK(!U.ban_on);
+}
static void toast_tap_opens_notices(void) {
fresh();
calm();
@@ -1584,6 +1661,7 @@ int main(void) {
toast_shows_and_expires();
toast_tap_opens_notices();
toast_swipe_up_dismisses();
+ supertab_toast_stays();
toast_not_here();
home_notices_pages();
home_notices_come_and_go();
diff --git a/devices/harness-pro/firmware/test/test_ph_views.c b/devices/harness-pro/firmware/test/test_ph_views.c
index d525b6a3b..31d57d6a9 100644
--- a/devices/harness-pro/firmware/test/test_ph_views.c
+++ b/devices/harness-pro/firmware/test/test_ph_views.c
@@ -501,6 +501,46 @@ int main(void) {
snprintf(M.agents[0].name, sizeof M.agents[0].name, "%s", "an-agent-name-that-is-far-too-long-for-the-toast-to-hold-on-one-line");
fresh(); ph_toast(&F, &M, pod_model_unread_find(&M, "b"), t0, t0 + 1000);
for (int i = 0; i < S.count; i++) if (S.runs[i].pro_kind == K_TEXT) CHECK(S.runs[i].x + S.runs[i].w <= 640 + 40 - 26 + 2);
+
+ // A Super Tab's question: "name · Super Tab", the question, a still full bar (amber decision, red stuck), its own edge; no timer
+ snprintf(M.agents[0].name, sizeof M.agents[0].name, "%s", "api");
+ pod_model_question_tab(&M, "b", "Staging first, or straight to prod?", "Launch v2", POD_ATTN_DECISION);
+ pod_model_unread_ask(&M, "b", "api", "Staging first, or straight to prod?", t0);
+ u = pod_model_unread_find(&M, "b");
+ for (uint32_t age = POD_TOAST_SLIDE_MS; age <= 60000; age += 4950) {
+ fresh(); ph_toast(&F, &M, u, t0, t0 + age);
+ CHECK(S.count <= 9 && S.runs[0].fg == ht_rgb(0x6A4A1C) && S.runs[0].y == 24);
+ int bars = 0;
+ for (int i = 0; i < S.count; i++) if (S.runs[i].pro_kind == K_RECT && S.runs[i].pro_height == 7) {
+ bars++;
+ CHECK(S.runs[i].w == 588 && S.runs[i].x == 66 && S.runs[i].fg == ht_rgb(0xFFB340)); // full, whatever the time
+ }
+ CHECK(bars == 1);
+ const ht_run_t *nm = text_run("api"), *tag = text_run("\xc2\xb7 Launch v2"), *msg = text_run("Staging first, or straight to prod?");
+ CHECK(nm && nm->fg == ht_rgb(PH_TOAST_NAME) && nm->pro_font == &ph_sb_26 && nm->x == 140);
+ CHECK(tag && tag->fg == ht_rgb(0x8EA3BD) && tag->pro_font == &ph_sb_22 && tag->x == nm->x + ht_pro_width(&ph_sb_26, "api") + 7);
+ CHECK(msg && msg->fg == ht_rgb(PH_TOAST_INK) && msg->x == nm->x);
+ CHECK(hits_of(POD_A_BANNER) == 1);
+ }
+ pod_model_question_tab(&M, "b", "Stuck: e2e failed 3 times", "Launch v2", POD_ATTN_STUCK);
+ pod_model_unread_ask(&M, "b", "api", "Stuck: e2e failed 3 times", t0);
+ u = pod_model_unread_find(&M, "b");
+ fresh(); ph_toast(&F, &M, u, t0, t0 + 20000);
+ CHECK(S.runs[0].fg == ht_rgb(0x6A2626) && text_run("api") && text_run("api")->fg == ht_rgb(0xFF8F8F) && text_run("Stuck: e2e failed 3 times"));
+ { int red = 0; for (int i = 0; i < S.count; i++) red += S.runs[i].pro_kind == K_RECT && S.runs[i].w == 588 && S.runs[i].fg == ht_rgb(0xFF5C5C); CHECK(red == 1); }
+ // a long name and Super Tab stay inside the card, the name keeping at least half the line
+ snprintf(M.agents[0].name, sizeof M.agents[0].name, "%s", "an-agent-name-that-is-far-too-long-for-the-toast-to-hold-on-one-line");
+ pod_model_question_tab(&M, "b", "Which?", "A Super Tab whose name is as long as it may be", POD_ATTN_DECISION);
+ fresh(); ph_toast(&F, &M, u, t0, t0 + 1000);
+ for (int i = 0; i < S.count; i++) if (S.runs[i].pro_kind == K_TEXT) CHECK(S.runs[i].x + S.runs[i].w <= 640 + 40 - 26 + 2);
+ CHECK(text_prefix("an-agent") && text_prefix("\xc2\xb7 A Super") && text_prefix("\xc2\xb7 A Super")->x - text_prefix("an-agent")->x >= (640 - 2 * 26 - 56 - 18) / 2);
+ // the question answered (or a plain question): back to the timed toast with its default edge
+ pod_model_question_tab(&M, "b", "Which?", NULL, POD_ATTN_STUCK);
+ fresh(); ph_toast(&F, &M, u, t0, t0 + 2500);
+ CHECK(S.runs[0].fg == ht_rgb(PH_TOAST_EDGE) && !text_prefix("\xc2\xb7"));
+ { int half = 0; for (int i = 0; i < S.count; i++) half += S.runs[i].pro_kind == K_RECT && S.runs[i].fg == ht_rgb(PH_TOAST_BAR) && S.runs[i].w == 294; CHECK(half == 1); }
+ pod_model_question_close(&M, "b");
+ CHECK(pod_model_attention(&M, pod_model_find(&M, "b")) == POD_ATTN_NONE && !pod_model_find(&M, "b")->super_tab[0]);
}
// ---- Agent, Recap, Talk, Inbox, Toast, Update (Task 10) ----
@@ -967,6 +1007,50 @@ int main(void) {
CHECK(hits_of(POD_A_FOLLOW) == 0 && hits_of(POD_A_OPEN_NOTIF) == 3 && ph_runs(&F) <= HT_RUNS);
N.stack[1].scroll = 0;
}
+ // Notices: a Super Tab's asking rows (decision, stuck) above a plain entry: "name · Super Tab", "needs you" / "stuck", the edge, the badge
+ {
+ pod_model_unread_clear(&M);
+ pod_model_question_tab(&M, "q", "Staging first, or straight to prod?", "Launch v2", POD_ATTN_DECISION);
+ pod_model_question_tab(&M, "d", "e2e failed 3 times, no write access to staging", "Launch v2", POD_ATTN_STUCK);
+ pod_model_unread_add(&M, "f", "api-retry", "Picked the blue hero image.", 40, now - 300000u);
+ pod_model_clock(&M, now);
+ pod_nav_init(&N);
+ N.depth = 2; N.stack[0].view = POD_V_TABS; N.stack[1].view = POD_V_INBOX;
+ fresh();
+ ph_view_inbox(&F, &N, &M, now);
+ const ht_run_t *nd = text_run("needs you"), *ns = text_run("stuck"), *rq = text_prefix("Staging first"), *rd = text_prefix("e2e failed"), *rf = text_prefix("Picked the blue");
+ CHECK(nd && ns && rq && rd && rf && rq->y < rd->y && rd->y < rf->y && !text_run("asks") && text_run("5m"));
+ CHECK(nd->y < rq->y && ns->y < rd->y && ns->y > rq->y);
+ int tags = 0, badges = 0, rings = 0, amber = 0, red = 0, letters = 0;
+ for (int i = 0; i < S.count; i++) {
+ const ht_run_t *r = &S.runs[i];
+ if (r->pro_kind == K_TEXT && !strcmp(r->text, "\xc2\xb7 Launch v2")) { tags++; CHECK(r->fg == ht_rgb(0x6B4FA3) && r->pro_font == &ph_sb_22); }
+ badges += r->pro_kind == K_RECT_AA && r->w == 34 && r->fg == ht_rgb(0x3B2E55) && r->x == 60 + 110 + 8 - 40 + 3;
+ rings += r->pro_kind == K_RECT_AA && r->w == 40 && r->fg == ht_rgb(PH_ROOM_BG);
+ amber += r->pro_kind == K_RECT_AA && r->w == 470 && r->x == 190 && r->fg == ht_rgb(0xFFB340);
+ red += r->pro_kind == K_RECT_AA && r->w == 470 && r->x == 190 && r->fg == ht_rgb(0xFF5C5C);
+ letters += r->pro_kind == K_RECT_AA && r->fg == ht_rgb(PH_LETTER) && ((r->w == 464 && r->x == 196) || (r->w == 470 && r->x == 190));
+ }
+ CHECK(tags == 2 && badges == 2 && rings == 2 && amber == 1 && red == 1 && letters == 3 && ph_runs(&F) <= HT_RUNS);
+ { // the tag follows the name on its line
+ const ht_run_t *nm = NULL;
+ for (int i = 0; i < S.count; i++) if (S.runs[i].pro_kind == K_TEXT && S.runs[i].y == nd->y && S.runs[i].x == 216) nm = &S.runs[i];
+ CHECK(nm && nm->fg == ht_rgb(PH_LETTER_WHO));
+ int beside = 0;
+ for (int i = 0; i < S.count; i++) if (S.runs[i].pro_kind == K_TEXT && S.runs[i].fg == ht_rgb(0x6B4FA3) && S.runs[i].y == nd->y) beside += S.runs[i].x > nm->x + nm->w - 2;
+ CHECK(beside == 1);
+ }
+ CHECK(hits_of(POD_A_FOLLOW) == 2 && hits_of(POD_A_OPEN_NOTIF) == 1);
+ // closed: a plain row again
+ pod_model_question_close(&M, "q");
+ pod_model_question_close(&M, "d");
+ pod_model_question(&M, "q", "Delete 14 old files?");
+ fresh();
+ ph_view_inbox(&F, &N, &M, now);
+ CHECK(text_run("asks") && !text_run("needs you") && !text_prefix("\xc2\xb7"));
+ pod_model_question_close(&M, "q");
+ pod_model_unread_clear(&M);
+ }
// Notices wakes only when a visible age text turns over ("now", minutes, hours, days), not on a beat: a quiet list is neither redrawn nor rebuilt
{
pod_model_unread_clear(&M);
diff --git a/devices/harness-pro/firmware/test/test_pro_app.py b/devices/harness-pro/firmware/test/test_pro_app.py
index b98fd4bf9..7168b0662 100644
--- a/devices/harness-pro/firmware/test/test_pro_app.py
+++ b/devices/harness-pro/firmware/test/test_pro_app.py
@@ -909,7 +909,7 @@ static void *cable_task(void *arg) {
pro_app_turn("a1", "verb", "Reading...", -1);
pro_app_turn("a1", "activity", "Reading files", 3);
pro_app_turn("a1", "step", "Read - pod_model.c", -1);
- pro_app_question("a3", "r1", "Which branch?");
+ pro_app_question("a3", "r1", "Which branch?", NULL, POD_ATTN_NONE);
pro_app_question_close("a3");
pro_app_summary("a2", "Fixed the parser.", "Fixed the parser. Added two tests.", "Fixed the parser. Added two tests. Then more.", false, POD_TIER_SILENT);
pro_app_focus("a4");
@@ -1494,15 +1494,15 @@ static void pro_app_test_summary_and_question(void) {
pro_app_summary("a3", "done", NULL, NULL, false, POD_TIER_SILENT);
CHECK(agent("a3")->recap[0] == 0);
// Questions: held while open, closed by the daemon or by a new turn.
- pro_app_question("a1", "r1", "Which branch?");
+ pro_app_question("a1", "r1", "Which branch?", NULL, POD_ATTN_NONE);
CHECK(pro_app_question_open("a1") && agent("a1")->state == POD_ASKING);
pro_app_question_close("a1");
CHECK(!pro_app_question_open("a1"));
- pro_app_question("a1", "r1", NULL);
+ pro_app_question("a1", "r1", NULL, NULL, POD_ATTN_NONE);
CHECK(pro_app_question_open("a1") && !strcmp(agent("a1")->question, "Needs your answer"));
pro_app_turn("a1", "started", "", 0);
CHECK(!pro_app_question_open("a1"));
- pro_app_question("zz", "r1", "ghost?");
+ pro_app_question("zz", "r1", "ghost?", NULL, POD_ATTN_NONE);
CHECK(!pro_app_question_open("zz"));
}
@@ -1574,10 +1574,14 @@ static void pro_app_test_voice_gate(void) {
CHECK(!strcmp(pro_app_voice_block_reason("a3"), "Link this computer in Harness."));
CHECK(!strcmp(pro_app_voice_block_reason("a4"), "Choose an agent pane."));
CHECK(pro_app_voice_block_reason("nobody") == NULL); // unknown: allowed
- pro_app_question("a1", "r1", "Which?");
+ pro_app_question("a1", "r1", "Which?", NULL, POD_ATTN_NONE);
CHECK(!strcmp(pro_app_voice_block_reason("a1"), "Answer its question first."));
pro_app_question_close("a1");
CHECK(pro_app_voice_block_reason("a1") == NULL);
+ // A Super Tab wait is not answered here: talking to the agent is how it is unblocked.
+ pro_app_question("a1", "supertab:as1:needs_human", "Which?", "Launch v2", POD_ATTN_DECISION);
+ CHECK(pro_app_voice_block_reason("a1") == NULL);
+ pro_app_question_close("a1");
// Library-only agents are matched by the machine NAME the row carries.
pro_library_row_t lib[1] = {{"far", "Far", "claude", "Box", "idle", 5}};
pro_app_library(lib, 1, 0, 1);
@@ -1609,13 +1613,21 @@ static void pro_app_test_voice_paths(void) {
CHECK(top() == POD_V_AGENT && !pod_ui_talking(&U) && U.notice_on && !strcmp(U.notice, "Can't talk right now"));
// A gate refusal never reaches the recorder
V.refuse = false;
- pro_app_question("a1", "r1", "Which?");
+ pro_app_question("a1", "r1", "Which?", NULL, POD_ATTN_NONE);
render();
CHECK(hit(POD_A_TALK, 0) == NULL); // no screen draws a Talk button; the gate still meets a stale hit
tap_stale_talk();
CHECK(R.begins == 0 && !pod_ui_talking(&U) && !strcmp(U.notice, "Answer its question first."));
- // The tick: Talk with no recording behind it ends; a sent one (waiting) ends too
+ // A Super Tab wait does not hold Talk back: talking to the agent is how it is unblocked.
pro_app_question_close("a1");
+ pro_app_question("a1", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ render();
+ tap_stale_talk();
+ CHECK(R.begins == 1 && pod_ui_talking(&U));
+ pod_ui_talk_over(&U);
+ pro_app_question_close("a1");
+ R.begins = 0;
+ // The tick: Talk with no recording behind it ends; a sent one (waiting) ends too
render();
tap(POD_A_TALK, 0);
CHECK(pod_ui_talking(&U));
@@ -1769,10 +1781,10 @@ static void side_button_discards_hands_free(void) {
static void question_needs_the_link(void) {
setup();
pro_app_link(false, NULL);
- pro_app_question("a1", "r1", "Which one?");
+ pro_app_question("a1", "r1", "Which one?", NULL, POD_ATTN_NONE);
CHECK(!pro_app_question_open("a1"));
pro_app_link(true, "mac");
- pro_app_question("a1", "r1", "Which one?");
+ pro_app_question("a1", "r1", "Which one?", NULL, POD_ATTN_NONE);
CHECK(pro_app_question_open("a1"));
}
@@ -1886,11 +1898,11 @@ static void notify_tiers(void) {
// A question is an alert; a failed turn files a failed entry as an alert.
static void notify_question_and_error(void) {
notif_room(); // a1's room, now = 5300
- pro_app_question("a3", "r1", "Which branch?");
+ pro_app_question("a3", "r1", "Which branch?", NULL, POD_ATTN_NONE);
render();
CHECK(BEEPS == 1 && banner() && !strcmp(banner()->id, "a3") && pod_model_unread_find(&U.model, "a3"));
now += 10000;
- pro_app_question("a2", "r1", "Which file?");
+ pro_app_question("a2", "r1", "Which file?", NULL, POD_ATTN_NONE);
CHECK(BEEPS == 1); // coalesced
pro_app_question_close("a3");
pro_app_question_close("a2");
@@ -1898,13 +1910,13 @@ static void notify_question_and_error(void) {
// Asleep: the question wakes the glass.
pro_app_sleep();
now += 40000;
- pro_app_question("a3", "r1", "Again?");
+ pro_app_question("a3", "r1", "Again?", NULL, POD_ATTN_NONE);
CHECK(!pro_app_asleep() && BEEPS == 2);
// Its own room: no beep, nothing filed.
pro_app_question_close("a3");
notif_setup();
pod_ui_focus(&U, "a3", now);
- pro_app_question("a3", "r1", "Here?");
+ pro_app_question("a3", "r1", "Here?", NULL, POD_ATTN_NONE);
CHECK(BEEPS == 0 && U.model.unread_count == 0);
// turn.error: a failed entry, an alert.
notif_room();
@@ -1914,22 +1926,128 @@ static void notify_question_and_error(void) {
CHECK(BEEPS == 1 && e && e->kind == POD_UNREAD_FAILED && !strcmp(e->text, "Build broke") && banner());
}
+// A Super Tab's question (pro_cable's superTab + attention): an alert like any question, whose toast stays until it is answered.
+static void notify_supertab_question_stays(void) {
+ notif_room(); // a1's room
+ pro_app_question("a3", "r1", "Staging first, or straight to prod?", "Launch v2", POD_ATTN_DECISION);
+ render();
+ const pod_agent_t *q = agent("a3");
+ CHECK(BEEPS == 1 && banner() && !strcmp(banner()->id, "a3") && q && !strcmp(q->super_tab, "Launch v2") && q->attention == POD_ATTN_DECISION);
+ now += 60000; render();
+ CHECK(banner() != NULL); // well past a plain toast's 5 s
+ pro_app_question_close("a3");
+ render();
+ CHECK(banner() == NULL && !agent("a3")->super_tab[0] && !pod_model_unread_find(&U.model, "a3"));
+ now += 40000;
+ pro_app_question("a2", "r2", "Stuck: no write access", "Launch v2", POD_ATTN_STUCK);
+ render();
+ CHECK(BEEPS == 2 && banner() && agent("a2")->attention == POD_ATTN_STUCK);
+ pro_app_question("a2", "r3", "Which file?", NULL, POD_ATTN_NONE); // a plain one replaces it: no Super Tab left on the agent
+ CHECK(!agent("a2")->super_tab[0] && agent("a2")->attention == POD_ATTN_NONE);
+}
+
+// A Super Tab's question outlives the agent's turns: only question.close ends it, and it alerts once. What the turns
+// say meanwhile neither beeps nor takes its entry or toast. An engine's question takes its place (the daemon closes the
+// wait first) and the wait comes back when the daemon asks it again.
+static void supertab_question_survives_turns(void) {
+ notif_room(); // a1's room
+ pro_app_question("a3", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ CHECK(BEEPS == 1 && pro_app_question_open("a3"));
+ now += 40000; // past the beep coalescing: only the rule can keep these quiet
+ pro_app_turn("a3", "started", "Working", 0);
+ pro_app_turn("a3", "done", "", 0);
+ pro_app_turn("a3", "started", "Working", 0);
+ pro_app_summary("a3", "Tried again, still no key.", NULL, NULL, false, POD_TIER_ALERT);
+ pro_app_turn("a3", "done", "", 0);
+ render();
+ const pod_agent_t *q = agent("a3");
+ const pod_unread_t *e = pod_model_unread_find(&U.model, "a3");
+ CHECK(pro_app_question_open("a3") && q->state == POD_ASKING && !strcmp(q->question, "Stuck: no key"));
+ CHECK(!strcmp(q->super_tab, "Launch v2") && q->attention == POD_ATTN_STUCK && e && e->ask && BEEPS == 1);
+ CHECK(banner() && !strcmp(banner()->id, "a3"));
+ // A library sweep and a send from the Pro leave it too.
+ pod_model_library_status(&U.model, "a3", "idle", now + 1);
+ pod_model_sent(&U.model, "a3", now + 2);
+ CHECK(agent("a3")->state == POD_ASKING && agent("a3")->super_tab[0]);
+ // Asked again (a resync, a relink): the same alert, no second beep.
+ pro_app_question("a3", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ CHECK(BEEPS == 1 && pro_app_question_open("a3"));
+ // An engine's question takes its place; once it closes and the wait is asked again, it is back.
+ pro_app_question_close("a3");
+ pro_app_question("a3", "tool-1", "Proceed?", NULL, POD_ATTN_NONE);
+ CHECK(pro_app_question_open("a3") && !agent("a3")->super_tab[0]);
+ pro_app_turn("a3", "started", "Working", 0); // a plain question still ends with the turn
+ CHECK(!pro_app_question_open("a3"));
+ pro_app_question("a3", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ CHECK(pro_app_question_open("a3") && agent("a3")->attention == POD_ATTN_STUCK);
+ // Only question.close ends it.
+ pro_app_question_close("a3");
+ CHECK(!pro_app_question_open("a3") && agent("a3")->state != POD_ASKING && !agent("a3")->super_tab[0]);
+}
+
+// A link drop ends a Super Tab wait as it ends any question: it becomes a plain one the next turn ends, and the daemon
+// asks it again on the next link.
+static void supertab_question_link_drop(void) {
+ notif_room();
+ pro_app_question("a3", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ pro_app_link(false, NULL);
+ pro_app_link(true, "mac");
+ CHECK(!pro_app_question_open("a3") && !agent("a3")->super_tab[0] && agent("a3")->attention == POD_ATTN_NONE);
+ pro_app_turn("a3", "started", "Working", 0);
+ CHECK(agent("a3")->state == POD_WORKING);
+ pro_app_question("a3", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ CHECK(pro_app_question_open("a3") && agent("a3")->attention == POD_ATTN_STUCK);
+}
+
+// A Super Tab wait that closes leaves the agent as its turns did, not Working; a failed turn while it waits still alerts.
+static void supertab_question_close_and_failure(void) {
+ notif_room();
+ pro_app_turn("a3", "started", "Working", 0);
+ pro_app_question("a3", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ pro_app_turn("a3", "done", "", 0);
+ CHECK(agent("a3")->state == POD_ASKING);
+ pro_app_question_close("a3");
+ CHECK(agent("a3")->state == POD_DONE && !agent("a3")->turn_started);
+ // Asked while idle and closed with no turn: idle again.
+ pro_app_question("a2", "supertab:as2:needs_human", "Ship it?", "Launch v2", POD_ATTN_DECISION);
+ pro_app_question_close("a2");
+ CHECK(agent("a2")->state != POD_WORKING && agent("a2")->state != POD_ASKING);
+ // Asked again while a turn runs, closed: that turn goes on.
+ pro_app_question("a2", "supertab:as2:needs_human", "Ship it?", "Launch v2", POD_ATTN_DECISION);
+ pro_app_turn("a2", "started", "Working", 0);
+ pro_app_question_close("a2");
+ CHECK(agent("a2")->state == POD_WORKING);
+ // A plain question still goes back to work.
+ pro_app_question("a2", "r9", "Proceed?", NULL, POD_ATTN_NONE);
+ pro_app_question_close("a2");
+ CHECK(agent("a2")->state == POD_WORKING);
+ // A crash while waiting is news.
+ now += 40000;
+ const int beeps = BEEPS;
+ pro_app_question("a3", "supertab:as1:blocked", "Stuck: no key", "Launch v2", POD_ATTN_STUCK);
+ now += 40000;
+ pro_app_turn("a3", "started", "Working", 0);
+ pro_app_turn("a3", "error", "The turn failed", 0);
+ const pod_unread_t *e = pod_model_unread_find(&U.model, "a3");
+ CHECK(BEEPS == beeps + 2 && e && e->kind == POD_UNREAD_FAILED && pro_app_question_open("a3"));
+}
+
// The daemon re-sends an open question after a link drop: the row returns, but the glass does not wake or beep again.
static void notify_question_resent_after_relink_is_quiet(void) {
notif_room();
- pro_app_question("a3", "r1", "Which branch?");
+ pro_app_question("a3", "r1", "Which branch?", NULL, POD_ATTN_NONE);
CHECK(BEEPS == 1);
pro_app_link(false, NULL);
pro_app_link(true, "mac");
pro_app_sleep();
now += 40000; // past the beep coalescing, so only the repeat check can silence it
- pro_app_question("a3", "r1", "Which branch?");
+ pro_app_question("a3", "r1", "Which branch?", NULL, POD_ATTN_NONE);
CHECK(pro_app_question_open("a3") && pod_model_unread_find(&U.model, "a3") && BEEPS == 1 && pro_app_asleep());
- pro_app_question("a3", "r2", "A different one?"); // another prompt is news
+ pro_app_question("a3", "r2", "A different one?", NULL, POD_ATTN_NONE); // another prompt is news
CHECK(BEEPS == 2 && !pro_app_asleep());
pro_app_question_close("a3");
now += 40000;
- pro_app_question("a3", "r3", "A different one?"); // answered, then asked again: news
+ pro_app_question("a3", "r3", "A different one?", NULL, POD_ATTN_NONE); // answered, then asked again: news
CHECK(BEEPS == 3);
}
@@ -1937,27 +2055,27 @@ static void notify_question_resent_after_relink_is_quiet(void) {
// Code's approvals all read "Do you want to proceed?").
static void notify_question_same_prompt_new_request_beeps(void) {
notif_room();
- pro_app_question("a3", "r1", "Do you want to proceed?");
+ pro_app_question("a3", "r1", "Do you want to proceed?", NULL, POD_ATTN_NONE);
CHECK(BEEPS == 1);
pro_app_link(false, NULL); // the close of r1 is lost with the link
pro_app_link(true, "mac");
now += 40000;
- pro_app_question("a3", "r2", "Do you want to proceed?");
+ pro_app_question("a3", "r2", "Do you want to proceed?", NULL, POD_ATTN_NONE);
CHECK(BEEPS == 2);
}
// A question's entry goes whenever the question ends: a new turn, a finished turn, a link drop.
static void notify_question_entry_ends_with_question(void) {
notif_room();
- pro_app_question("a3", "r1", "Which branch?");
+ pro_app_question("a3", "r1", "Which branch?", NULL, POD_ATTN_NONE);
CHECK(pod_model_unread_find(&U.model, "a3"));
pro_app_turn("a3", "started", "Working", 0);
CHECK(!pod_model_unread_find(&U.model, "a3"));
- pro_app_question("a2", "r1", "Which file?");
+ pro_app_question("a2", "r1", "Which file?", NULL, POD_ATTN_NONE);
CHECK(pod_model_unread_find(&U.model, "a2"));
pro_app_summary("a2", "t", "Done.", NULL, false, POD_TIER_SILENT);
CHECK(!pod_model_unread_find(&U.model, "a2")); // a silent end files nothing, and the question's entry is gone
- pro_app_question("a3", "r1", "Again?");
+ pro_app_question("a3", "r1", "Again?", NULL, POD_ATTN_NONE);
CHECK(pod_model_unread_find(&U.model, "a3"));
pro_app_link(false, NULL);
CHECK(!pod_model_unread_find(&U.model, "a3"));
@@ -2371,7 +2489,7 @@ int main(int argc, char **argv) {
{"pro_app_test_voice_paths", pro_app_test_voice_paths}, {"pro_app_test_touch_rules", pro_app_test_touch_rules},
{"pro_app_test_roster_and_swarms", pro_app_test_roster_and_swarms}, {"side_button", side_button}, {"side_button_console", side_button_console}, {"question_needs_the_link", question_needs_the_link},
{"notify_banner_beep_and_expiry", notify_banner_beep_and_expiry}, {"notify_tap_opens_and_swipe_dismisses", notify_tap_opens_and_swipe_dismisses},
- {"notify_never_over_talk", notify_never_over_talk}, {"notify_tiers", notify_tiers}, {"notify_question_and_error", notify_question_and_error}, {"notify_entries_expire", notify_entries_expire}, {"notify_question_entry_ends_with_question", notify_question_entry_ends_with_question}, {"notify_question_resent_after_relink_is_quiet", notify_question_resent_after_relink_is_quiet}, {"notify_question_same_prompt_new_request_beeps", notify_question_same_prompt_new_request_beeps}, {"notify_replace_seen_and_read", notify_replace_seen_and_read},
+ {"notify_never_over_talk", notify_never_over_talk}, {"notify_tiers", notify_tiers}, {"notify_question_and_error", notify_question_and_error}, {"notify_supertab_question_stays", notify_supertab_question_stays}, {"supertab_question_survives_turns", supertab_question_survives_turns}, {"supertab_question_link_drop", supertab_question_link_drop}, {"supertab_question_close_and_failure", supertab_question_close_and_failure}, {"notify_entries_expire", notify_entries_expire}, {"notify_question_entry_ends_with_question", notify_question_entry_ends_with_question}, {"notify_question_resent_after_relink_is_quiet", notify_question_resent_after_relink_is_quiet}, {"notify_question_same_prompt_new_request_beeps", notify_question_same_prompt_new_request_beeps}, {"notify_replace_seen_and_read", notify_replace_seen_and_read},
{"ota_screen_and_touch", ota_screen_and_touch}, {"voice_refused_while_updating", voice_refused_while_updating},
{"update_gate", update_gate}, {"ota_failed_returns", ota_failed_returns}, {"ota_keeps_awake", ota_keeps_awake},
{"ota_notifications_quiet", ota_notifications_quiet}, {"updated_notice", updated_notice},
diff --git a/devices/harness-pro/firmware/test/test_pro_cable.c b/devices/harness-pro/firmware/test/test_pro_cable.c
index 903adb6ac..6288e57ac 100644
--- a/devices/harness-pro/firmware/test/test_pro_cable.c
+++ b/devices/harness-pro/firmware/test/test_pro_cable.c
@@ -106,7 +106,10 @@ void pro_app_notif_seen(const char *id, const char *token)
{
ev_t *e = add(EV_NSEEN, id); put(e->a, token ? token : "(none)");
}
-void pro_app_question(const char *id, const char *request, const char *text) { (void)request; put(add(EV_QUESTION, id)->a, text); }
+void pro_app_question(const char *id, const char *request, const char *text, const char *super_tab, pod_attention_t attention)
+{
+ ev_t *e = add(EV_QUESTION, id); (void)request; put(e->a, text); put(e->b, super_tab); e->n1 = attention;
+}
void pro_app_question_close(const char *id) { add(EV_QCLOSE, id); }
void pro_app_focus(const char *id) { add(EV_FOCUS, id); }
void pro_app_voice_result(int kind, const char *text) { ev_t *e = add(EV_VOICE, NULL); e->n1 = kind; put(e->a, text); }
@@ -582,6 +585,30 @@ static void test_session_machines_library_voice(void)
feed("{\"t\":\"question.close\",\"agentId\":\"a\",\"id\":\"q1\"}");
feed("{\"t\":\"question.close\",\"agentId\":\"a\"}");
CHECK(nev == 3 && !strcmp(evs[0].a, "Proceed?") && !strcmp(evs[1].a, "Needs your answer") && evs[2].kind == EV_QCLOSE);
+ CHECK(!strcmp(evs[0].b, "<null>") && evs[0].n1 == POD_ATTN_NONE && !strcmp(evs[1].b, "<null>") && evs[1].n1 == POD_ATTN_NONE); // a plain question: as before
+
+ // a Super Tab's question: superTab names the project, attention says decision or stuck (an unknown one is a decision)
+ reset();
+ feed("{\"t\":\"question\",\"agentId\":\"a\",\"id\":\"q1\",\"questions\":[{\"q\":\"Staging or prod?\"}],\"superTab\":\"Launch v2\",\"attention\":\"decision\"}");
+ feed("{\"t\":\"question\",\"agentId\":\"b\",\"id\":\"q2\",\"questions\":[{\"q\":\"Stuck: no write access\"}],\"superTab\":\"Launch v2\",\"attention\":\"stuck\"}");
+ feed("{\"t\":\"question\",\"agentId\":\"c\",\"id\":\"q3\",\"questions\":[{\"q\":\"Which?\"}],\"superTab\":\"Launch v2\",\"attention\":\"blocked-ish\"}");
+ feed("{\"t\":\"question\",\"agentId\":\"d\",\"id\":\"q4\",\"questions\":[{\"q\":\"Which?\"}],\"superTab\":\"Launch v2\"}");
+ CHECK(nev == 4 && evs[0].kind == EV_QUESTION && !strcmp(evs[0].a, "Staging or prod?") && !strcmp(evs[0].b, "Launch v2") && evs[0].n1 == POD_ATTN_DECISION);
+ CHECK(!strcmp(evs[1].id, "b") && !strcmp(evs[1].a, "Stuck: no write access") && !strcmp(evs[1].b, "Launch v2") && evs[1].n1 == POD_ATTN_STUCK);
+ CHECK(evs[2].n1 == POD_ATTN_DECISION && evs[3].n1 == POD_ATTN_DECISION && !strcmp(evs[3].b, "Launch v2"));
+ reset(); // attention without a Super Tab, an empty or a non-string superTab: a plain question
+ feed("{\"t\":\"question\",\"agentId\":\"a\",\"id\":\"q1\",\"questions\":[{\"q\":\"x\"}],\"attention\":\"stuck\"}");
+ feed("{\"t\":\"question\",\"agentId\":\"a\",\"id\":\"q1\",\"questions\":[{\"q\":\"x\"}],\"superTab\":\"\",\"attention\":\"stuck\"}");
+ feed("{\"t\":\"question\",\"agentId\":\"a\",\"id\":\"q1\",\"questions\":[{\"q\":\"x\"}],\"superTab\":7,\"attention\":\"stuck\"}");
+ CHECK(nev == 3);
+ for (int i = 0; i < 3; i++) CHECK(!strcmp(evs[i].b, "<null>") && evs[i].n1 == POD_ATTN_NONE);
+ { // a long Super Tab name is cut to SUPER_TAB_MAX - 1 bytes on a UTF-8 boundary
+ char *tab = repeat("\xC3\xA9", 40);
+ reset();
+ feedf("{\"t\":\"question\",\"agentId\":\"a\",\"id\":\"q1\",\"questions\":[{\"q\":\"x\"}],\"superTab\":\"%s\",\"attention\":\"stuck\"}", tab);
+ CHECK(nev == 1 && strlen(evs[0].b) <= SUPER_TAB_MAX - 1 && strlen(evs[0].b) >= SUPER_TAB_MAX - 2 && utf8_ok(evs[0].b) && evs[0].n1 == POD_ATTN_STUCK);
+ free(tab);
+ }
// player.context is delivered (pro_app ignores it)
reset();
diff --git a/devices/harness-pro/firmware/test/test_pro_hello.py b/devices/harness-pro/firmware/test/test_pro_hello.py
index 28e2e32ef..53d946f3d 100644
--- a/devices/harness-pro/firmware/test/test_pro_hello.py
+++ b/devices/harness-pro/firmware/test/test_pro_hello.py
@@ -67,7 +67,7 @@ lines = [l for l in lines if not l.startswith("S.")]
assert lines[0] == "type=hello", lines
pairs = [tuple(x.split("=", 1)) for x in lines[1:]]
-# Exactly these keys, in this order (owner decision 7 + the activity capability).
+# Exactly these keys, in this order (owner decision 7 + the activity capability + the Super Tab wait).
assert pairs == [
("fw", "0.0.0"),
("product", "harness"),
@@ -79,6 +79,7 @@ assert pairs == [
("activity", "steps-v1"),
("stats", "turn-v1"),
("player", "library-v1"),
+ ("superTab", "wait-v1"),
("ota", "v1"),
("mac", "aa"),
("settings", "{"),
diff --git a/devices/harness-pro/firmware/test/test_pro_voice_gate.py b/devices/harness-pro/firmware/test/test_pro_voice_gate.py
index f95b3f55b..43025cc78 100644
--- a/devices/harness-pro/firmware/test/test_pro_voice_gate.py
+++ b/devices/harness-pro/firmware/test/test_pro_voice_gate.py
@@ -272,7 +272,7 @@ static void booting(void) { // no machines.end yet: the gate does not wait for
}
static void question_agent_says_why(void) {
situation(); to_agent(1);
- pro_app_question("a2", "r1", "Which one?");
+ pro_app_question("a2", "r1", "Which one?", NULL, POD_ATTN_NONE);
render();
CHECK(!hit(POD_A_TALK, 0));
press_stale();