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.

Merge batch 10-29 af: 3 reviewed round dial PRs (#2179, #2189, #2207) (#2221)

0xken15317278d6d3db
diff --git a/cli/src/cable/cableHost.spec.ts b/cli/src/cable/cableHost.spec.ts
index 3ed104af1..c2b12f856 100644
--- a/cli/src/cable/cableHost.spec.ts
+++ b/cli/src/cable/cableHost.spec.ts
@@ -967,6 +967,9 @@ describe('Swarm cards', () => {
it('keeps the list the core last handed it, and names a Swarm tab\'s Swarm on the desk row', () => {
const host = new DaemonCableHost(wiring())
+ // Not read yet is not "no Swarms": a dial told so before the core had read them left the Swarm on its face.
+ expect(host.swarmCards()).toBeNull()
+ host.setSwarmCards([])
expect(host.swarmCards()).toEqual([])
host.setSwarmCards([card])
expect(host.swarmCards()).toEqual([card])
diff --git a/cli/src/cable/cableHost.ts b/cli/src/cable/cableHost.ts
index 120828850..3eec30d57 100644
--- a/cli/src/cable/cableHost.ts
+++ b/cli/src/cable/cableHost.ts
@@ -115,7 +115,7 @@ export interface CableHostWiring {
swarmCardSide?: (tabId: string, side: CardSide) => void
/** Words for a Lead that runs here, posted as the person in its Swarm chat; not `said` when the harness leads no project,
* `refused` with the backend's reason when it refused the post. */
- swarmSay?: (harnessId: string, text: string, chat?: CardChat, chatId?: string) => Promise<SaidOnCard>
+ swarmSay?: (harnessId: string, text: string, chat?: CardChat, chatId?: string, reviewed?: boolean) => Promise<SaidOnCard>
/** A device picked a Lead: the window opens that Swarm tab and project. */
superTabSelected?: (superTabId: string, projectId: string) => void
/** A finger on the dial's glass, in pieces, while it is down; `superTabId` when it scrolls that Swarm's chat (a Pro's Lead view). */
@@ -418,13 +418,13 @@ export class DaemonCableHost implements CableHost {
}
/** The Swarm cards the core last handed the devices; a device that attaches later is shown them (superTabs/inCore/cards.ts replays). */
- private cards: SwarmCard[] = []
+ private cards: SwarmCard[] | null = null
setSwarmCards(items: SwarmCard[]): void {
this.cards = items
}
- swarmCards(): SwarmCard[] {
+ swarmCards(): SwarmCard[] | null {
return this.cards
}
@@ -444,8 +444,9 @@ export class DaemonCableHost implements CableHost {
this.wiring.swarmCardSide?.(tabId, side)
}
- swarmSay(harnessId: string, text: string, chat: CardChat = false, chatId?: string): Promise<SaidOnCard> {
- return this.wiring.swarmSay?.(harnessId, text, chat, ...(chatId ? [chatId] : [])) ?? Promise.resolve({ said: false })
+ swarmSay(harnessId: string, text: string, chat: CardChat = false, chatId?: string, reviewed = false): Promise<SaidOnCard> {
+ const pinned: [chatId?: string, reviewed?: boolean] = chatId ? (reviewed ? [chatId, true] : [chatId]) : []
+ return this.wiring.swarmSay?.(harnessId, text, chat, ...pinned) ?? Promise.resolve({ said: false })
}
superTabSelected(superTabId: string, projectId: string): void {
diff --git a/cli/src/cable/cableSession.spec.ts b/cli/src/cable/cableSession.spec.ts
index ae330a22d..921ff16a0 100644
--- a/cli/src/cable/cableSession.spec.ts
+++ b/cli/src/cable/cableSession.spec.ts
@@ -3725,7 +3725,7 @@ describe('swarm cards', () => {
swarms: rows.map((r) => ({ name: r.id, agents: 0, agentIds: [] as string[], panes: 0, ...r })) })
/** A host whose cards, desk tab and window project the test moves. */
- function cardHost(state: { cards: SwarmCard[]; desk?: ReturnType<typeof desk>; open?: { superTabId: string; projectId: string; conversationId?: string; fromDevice: boolean } | null } , over: Partial<CableHost> = {}) {
+ function cardHost(state: { cards: SwarmCard[] | null; desk?: ReturnType<typeof desk>; open?: { superTabId: string; projectId: string; conversationId?: string; fromDevice: boolean } | null } , over: Partial<CableHost> = {}) {
return makeHost({
swarmCards: () => state.cards,
listSwarms: () => state.desk ?? desk(),
@@ -3783,6 +3783,58 @@ describe('swarm cards', () => {
} finally { await session.stop() }
})
+ it('on attach before the cards were read: no supertabs at all, then the real list once it comes; an empty one read is sent', async () => {
+ // A daemon that had just started told the dial "no Swarms" before the core had read them, and the dial left the Swarm
+ // on its face for TABS; the list came 2 s later (Diego, 2026-10-29).
+ const state = { cards: null as SwarmCard[] | null }
+ const host = cardHost(state)
+ const { session, port } = await connect(host)
+ try {
+ port.say(PRO)
+ await vi.waitFor(() => expect(host.swarmCardsWanted).toHaveBeenCalledWith(true))
+ await settle(); await settle()
+ expect(ofType(port, 'supertabs')).toEqual([])
+ expect(ofType(port, 'supertab')).toEqual([])
+ state.cards = [card('st1'), card('st2')]
+ await session.syncSwarmCards()
+ await vi.waitFor(() => expect(ofType(port, 'supertab')).toHaveLength(2))
+ expect(ofType(port, 'supertabs')).toEqual([{ t: 'supertabs', ids: ['st1', 'st2'] }])
+ // Read and empty: there are no Swarms, and the dial is told so.
+ state.cards = []
+ await session.syncSwarmCards(true)
+ expect(ofType(port, 'supertabs').at(-1)).toEqual({ t: 'supertabs', ids: [] })
+ } finally { await session.stop() }
+ })
+
+ it('cards still not read 10 s after attach: the dial is told no Swarms rather than keep a list nobody vouches for', async () => {
+ // A daemon that came back signed out never reads them, and a dial that kept its link would show the old Swarms on.
+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] })
+ try {
+ const state = { cards: null as SwarmCard[] | null }
+ const { session, port } = await connect(cardHost(state))
+ port.say(PRO)
+ await vi.advanceTimersByTimeAsync(9_000)
+ expect(ofType(port, 'supertabs')).toEqual([])
+ await vi.advanceTimersByTimeAsync(1_000)
+ expect(ofType(port, 'supertabs')).toEqual([{ t: 'supertabs', ids: [] }])
+ // Read later: the real list follows.
+ state.cards = [card('st1')]
+ await session.syncSwarmCards()
+ await vi.advanceTimersByTimeAsync(300)
+ expect(ofType(port, 'supertabs').at(-1)).toEqual({ t: 'supertabs', ids: ['st1'] })
+ // Read in time: no empty list at all.
+ const fresh = { cards: null as SwarmCard[] | null }
+ const second = await connect(cardHost(fresh))
+ second.port.say(PRO)
+ await vi.advanceTimersByTimeAsync(2_000)
+ fresh.cards = [card('st1')]
+ await second.session.syncSwarmCards()
+ await vi.advanceTimersByTimeAsync(10_000)
+ expect(ofType(second.port, 'supertabs')).toEqual([{ t: 'supertabs', ids: ['st1'] }])
+ await session.stop(); await second.session.stop()
+ } finally { vi.useRealTimers() }
+ })
+
it('still sends the cards, with no tab link, when the desktop is closed', async () => {
const host = cardHost({ cards: [card('st1')] }) // listSwarms: no window
const { session, port } = await connect(host)
@@ -4175,7 +4227,7 @@ describe('swarm cards', () => {
} finally { await one.session.stop(); await two.session.stop() }
})
- it('ignores a repeat of the same recap request inside a second', async () => {
+ it('answers a repeat of the same recap request inside a second from the first read, not a second one', async () => {
const host = cardHost({ cards: [card('st1')] })
const { session, port } = await connect(host)
const now = vi.spyOn(Date, 'now')
@@ -4184,8 +4236,11 @@ describe('swarm cards', () => {
port.say(PRO)
await vi.waitFor(() => expect(ofType(port, 'supertab')).toHaveLength(1))
port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead1' }); await settle(); await settle()
+ // Dropping it left a dial that had emptied its face waiting 5 s for its own retry (Diego, 2026-10-29).
+ now.mockReturnValue(5_000_200)
port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead1' }); await settle(); await settle()
expect(host.swarmCardRecap).toHaveBeenCalledTimes(1)
+ expect(ofType(port, 'supertab.recap').map((f) => [f.tab, f.lead])).toEqual([['st1', 'lead1'], ['st1', 'lead1']])
port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead2' }); await settle(); await settle()
expect(host.swarmCardRecap).toHaveBeenCalledTimes(2)
now.mockReturnValue(5_001_100)
@@ -4194,6 +4249,51 @@ describe('swarm cards', () => {
} finally { now.mockRestore(); await session.stop() }
})
+ it('a repeat after a pushed recap is read again, never answered with the older read', async () => {
+ const recaps = vi.fn(async (tabId: string, leadId: string) => ({ tabId, leadId, text: 'A', at: 1, none: false }))
+ const host = cardHost({ cards: [card('st1')] }, { swarmCardRecap: recaps })
+ const { session, port } = await connect(host)
+ const now = vi.spyOn(Date, 'now')
+ try {
+ now.mockReturnValue(5_000_000)
+ port.say(PRO)
+ await vi.waitFor(() => expect(ofType(port, 'supertab')).toHaveLength(1))
+ port.say({ t: 'supertab.open', tab: 'st1', lead: 'lead1' })
+ port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead1' }); await settle(); await settle()
+ await session.swarmCardRecap({ tabId: 'st1', leadId: 'lead1', text: 'B', at: 2, none: false })
+ recaps.mockResolvedValueOnce({ tabId: 'st1', leadId: 'lead1', text: 'B', at: 2, none: false })
+ now.mockReturnValue(5_000_200)
+ port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead1' }); await settle(); await settle()
+ expect(recaps).toHaveBeenCalledTimes(2)
+ expect(ofType(port, 'supertab.recap').map((f) => f.text)).toEqual(['A', 'B', 'B'])
+ } finally { now.mockRestore(); await session.stop() }
+ })
+
+ it('reads a repeat again once the Lead left the cards, and a read that throws answers nothing', async () => {
+ const state = { cards: [card('st1')] }
+ const recaps = vi.fn(async (tabId: string, leadId: string) => ({ tabId, leadId, text: 'Shipped it.', at: 1792560000, none: false }))
+ const host = cardHost(state, { swarmCardRecap: recaps })
+ const { session, port } = await connect(host)
+ const now = vi.spyOn(Date, 'now')
+ try {
+ now.mockReturnValue(5_000_000)
+ port.say(PRO)
+ await vi.waitFor(() => expect(ofType(port, 'supertab')).toHaveLength(1))
+ port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead1' }); await settle(); await settle()
+ // Access went inside the second: the first answer is not handed out again, the host is asked and refuses.
+ state.cards = []
+ recaps.mockResolvedValueOnce(null as never)
+ now.mockReturnValue(5_000_200)
+ port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead1' }); await settle(); await settle()
+ expect(recaps).toHaveBeenCalledTimes(2)
+ expect(ofType(port, 'supertab.recap')).toHaveLength(1)
+ recaps.mockImplementationOnce(() => { throw new Error('boom') })
+ port.say({ t: 'supertab.recap.get', tab: 'st1', lead: 'lead2' }); await settle(); await settle()
+ expect(ofType(port, 'supertab.recap')).toHaveLength(1)
+ expect(port.isOpen).toBe(true)
+ } finally { now.mockRestore(); await session.stop() }
+ })
+
it('shortens a recap on a character until its frame is within 6 KB', async () => {
const big = '日'.repeat(500) + '"\n'.repeat(1500) // escapes make the JSON far bigger than the text
const host = cardHost({ cards: [card('st1')] }, { swarmCardRecap: vi.fn(async (tabId: string, leadId: string) => ({ tabId, leadId, text: big, at: 5, none: false })) })
@@ -4485,9 +4585,22 @@ describe('swarm cards', () => {
// Buddies off: exactly a swarmChat dial's Lead.
{ ...base(3) },
])
+ // The Swarm's side, which the dial follows as the daemon's: 'pm' unless the cards keep the Buddy side.
+ expect(ofType(port, 'supertab')[0].side).toBe('pm')
} finally { await session.stop() }
})
+ it('a swarmBuddy dial hears the Swarm\'s Buddy side; a swarmChat dial never hears a side', async () => {
+ for (const [hello, side] of [[BUDDY, 'buddy'], [ROUND, undefined]] as const) {
+ const { session, port } = await connect(cardHost({ cards: [card('st1', [withBuddy()], { side: 'buddy' })] }))
+ try {
+ port.say(hello)
+ await vi.waitFor(() => expect(ofType(port, 'supertab')).toHaveLength(1))
+ expect(ofType(port, 'supertab')[0].side).toBe(side)
+ } finally { await session.stop() }
+ }
+ })
+
it('a swarmChat dial without swarmBuddy gets today\'s frame, byte for byte, whatever the Buddy fields', async () => {
const run = async (leads: () => SwarmLead[]) => {
const state = { cards: [card('st1', leads())] }
@@ -4660,6 +4773,89 @@ describe('swarm cards', () => {
} finally { await session.stop() }
})
+ // ── Review before posting (device voice in the Swarm chat): words for a chat everyone in the Swarm reads are shown with
+ // the chat's name, then Send or Discard. Without this, a held recording on a Swarm face was a draft typed into the
+ // Lead's terminal.
+ const reviewed = async (hello: Record<string, unknown>, leads: SwarmLead[], swarmSay: CableHost['swarmSay'], op: 'send' | 'discard',
+ over: Partial<CableHost> = {}) => {
+ const host = cardHost({ cards: [card('st1', leads)] }, { transcribe: vi.fn(async () => 'ship it'), route: vi.fn(), swarmSay, ...over })
+ const { session, port } = await connect(host)
+ try {
+ port.say(hello)
+ await vi.waitFor(() => expect(ofType(port, 'supertab')).toHaveLength(1))
+ port.say({ t: 'voice.begin', uploadId: 'u-h1', agentId: 'h1' })
+ port.pcm(Buffer.alloc(3200)); port.say({ t: 'voice.end', uploadId: 'u-h1', review: true })
+ await vi.waitFor(() => expect(port.sent.some(m => m.t === 'voice.draft' || m.t === 'voice.error')).toBe(true))
+ const draft = ofType(port, 'voice.draft')[0]
+ const calledBefore = swarmSay ? vi.mocked(swarmSay).mock.calls.length : 0
+ if (draft) port.say({ t: 'draft.command', draftId: draft.id, revision: draft.revision, requestId: 'r1', op })
+ if (draft) await vi.waitFor(() => expect(port.sent.some(m => m.t === 'draft.state' && m.requestId === 'r1')).toBe(true))
+ return { draft, calledBefore, state: ofType(port, 'draft.state')[0], turns: vi.mocked(host.sendTurn).mock.calls }
+ } finally { await session.stop() }
+ }
+
+ it('words reviewed on a Swarm face are a draft named for that chat, posted there by Send and never typed into a terminal', async () => {
+ const swarmSay = vi.fn(async (): Promise<SaidOnCard> => ({ said: true }))
+ const r = await reviewed(BUDDY, [withBuddy({ local: 'h1' })], swarmSay, 'send')
+ expect(r.draft).toMatchObject({ t: 'voice.draft', active: true, name: "Project 1 · diego's Buddy", context: 'Swarm chat', text: 'ship it' })
+ expect(r.calledBefore).toBe(0)
+ // Reviewed: the chat it was reviewed for, even if the window moved since (SwarmCards.say checks it is still the Lead's).
+ expect(swarmSay.mock.calls).toEqual([['h1', 'ship it', 'buddy', 'pm1', true]])
+ expect(r.state).toMatchObject({ ok: true, sent: true })
+ expect(r.turns).toEqual([])
+ })
+
+ it('a pane focused in the window at capture does not take Swarm-face words: they are reviewed for the face\'s chat', async () => {
+ const swarmSay = vi.fn(async (): Promise<SaidOnCard> => ({ said: true }))
+ const r = await reviewed(BUDDY, [withBuddy({ local: 'h1' })], swarmSay, 'send', { appFocus: () => ({ machineId: 'm1', agentId: 'a2' }) })
+ expect(r.draft).toMatchObject({ name: "Project 1 · diego's Buddy", agentId: 'h1' })
+ expect(swarmSay.mock.calls).toEqual([['h1', 'ship it', 'buddy', 'pm1', true]])
+ expect(r.turns).toEqual([])
+ })
+
+ it('reviewed Swarm-face words with no way to post them in a Swarm are refused, never drafted for a terminal', async () => {
+ const r = await reviewed(BUDDY, [withBuddy({ local: 'h1' })], undefined, 'send')
+ expect(r.draft).toBeUndefined()
+ expect(r.turns).toEqual([])
+ })
+
+ it('Discard posts nothing', async () => {
+ const swarmSay = vi.fn(async (): Promise<SaidOnCard> => ({ said: true }))
+ const lead = { kind: 'lead' as const, id: 'lead-c1', name: 'Lead', working: false }
+ const r = await reviewed(ROUND, [withBuddy({ local: 'h1', chat: lead })], swarmSay, 'discard')
+ expect(r.draft).toMatchObject({ name: 'Project 1 · Lead' })
+ expect(r.state).toMatchObject({ ok: true, active: false })
+ expect(swarmSay).not.toHaveBeenCalled()
+ expect(r.turns).toEqual([])
+ })
+
+ it('a reviewed post the Swarm refuses or cannot take stays a draft with the reason, and nothing is typed', async () => {
+ const lead = { kind: 'lead' as const, id: 'lead-c1', name: 'Lead', working: false }
+ const refusing = await reviewed(ROUND, [withBuddy({ local: 'h1', chat: lead })], vi.fn(async () => refused), 'send')
+ expect(refusing.state).toMatchObject({ ok: false, active: true, error: 'Chat with PM is read-only.' })
+ expect(refusing.turns).toEqual([])
+ const offline = vi.fn(async (): Promise<SaidOnCard> => { throw new Error('offline') })
+ const unreachable = await reviewed(ROUND, [withBuddy({ local: 'h1', chat: lead })], offline, 'send')
+ expect(unreachable.state).toMatchObject({ ok: false, active: true, error: 'Could not reach the Swarm. Try again.' })
+ expect(unreachable.turns).toEqual([])
+ })
+
+ it('says it reviews Swarm chat words, and refuses unreviewed ones from a dial that promised to review them', async () => {
+ const swarmSay = vi.fn(async (): Promise<SaidOnCard> => ({ said: true }))
+ const transcribe = vi.fn(async () => 'ship it')
+ const host = cardHost({ cards: [card('st1', [withBuddy({ local: 'h1' })])] }, { transcribe, route: vi.fn(), swarmSay })
+ const { session, port } = await connect(host)
+ try {
+ port.say({ ...BUDDY, swarmReview: 'v1' })
+ await vi.waitFor(() => expect(ofType(port, 'supertab')).toHaveLength(1))
+ expect(ofType(port, 'welcome')[0].features).toContain('swarm.review')
+ voice(port, 'h1')
+ await vi.waitFor(() => expect(ofType(port, 'voice.error')).toHaveLength(1))
+ expect(ofType(port, 'voice.error')[0].message).toBe('Review the words before they are posted.')
+ expect(transcribe).not.toHaveBeenCalled(); expect(swarmSay).not.toHaveBeenCalled(); expect(host.sendTurn).not.toHaveBeenCalled()
+ } finally { await session.stop() }
+ })
+
/** 13 Leads (12 are sent), every name at its 48-byte cut, each working in a group with a Buddy; `id(kind, l)` names the ids. */
const fullCards = (id: (kind: string, l: number) => string) => {
const wide = 'é'.repeat(24) // 48 bytes
diff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.ts
index 07a82fc22..0b54cd4a2 100644
--- a/cli/src/cable/cableSession.ts
+++ b/cli/src/cable/cableSession.ts
@@ -167,6 +167,8 @@ const RECAP_FRAME_MAX = 6 * 1024
/** Repeats of one Lead's recap request inside this are ignored; a device that picks another stale announce within this is not followed. */
const RECAP_REPEAT_MS = 1000
const PICK_ECHO_MS = 2000
+/** Cards still not read this long after attach: the dial is told there are none, not left on a list nobody vouches for. */
+const CARDS_UNREAD_MS = 10_000
/** The recap frame, its text shortened (on a character) until the whole JSON fits what the Pro reads. A chat's recap names
* its chat (`chatId`), for a round dial that speaks swarmChat; any other is today's frame. */
export function recapFrame(r: LeadRecap): Message {
@@ -383,8 +385,8 @@ export interface CableHost {
listSwarms(): { selected: string; swarms: CableSwarm[]; tiles: CableTile[] }
/** The dial picked a swarm. Relayed to the window, which switches and re-describes its desk. */
selectSwarm(swarmId: string): void
- /** The Swarm cards the core last told the devices (superTabs/inCore/cards.ts); empty until it has. */
- swarmCards?(): SwarmCard[]
+ /** The Swarm cards the core last told the devices (superTabs/inCore/cards.ts); null until it has, which is not "no Swarms". */
+ swarmCards?(): SwarmCard[] | null
/** A device that speaks `swarmCard: 'v1'` is attached (true) or gone (false): the core starts or stops reading the Swarms. */
swarmCardsWanted?(on: boolean): void
/** One Lead's last message, read on request; null when it could not be read. */
@@ -396,7 +398,7 @@ export interface CableHost {
/** Words for a Lead that runs here: posted as the person in its Swarm chat. Not `said`: not a Lead, send the turn as before;
* `refused`: the backend refused the post, whose words are never typed anywhere instead. `chatId`: the chat they were
* spoken to, the only one they may be posted in. */
- swarmSay?(harnessId: string, text: string, chat?: CardChat, chatId?: string): Promise<SaidOnCard>
+ swarmSay?(harnessId: string, text: string, chat?: CardChat, chatId?: string, reviewed?: boolean): Promise<SaidOnCard>
/** A device picked a Lead: the window opens that Swarm tab and project. */
superTabSelected?(superTabId: string, projectId: string): void
/** The Swarm tab the window has on screen and the project open in it ('' when none is); null when the active tab is not a Swarm or there is no window. */
@@ -596,6 +598,9 @@ export interface DialStatus {
devices?: DialStatus[]
}
+/** The chat on a dial's face as the person began to speak, and the project it belongs to (a review names both). */
+type SwarmFace = SwarmChat & { project: string }
+
interface Message {
t: string
[key: string]: unknown
@@ -723,6 +728,9 @@ export class CableSession {
* (`supertab.side`), each Lead carries `buddies` and the reader's Buddy, and the Buddy's word is a quiet notice. A
* swarmChat dial without it gets today's frames byte for byte. */
private swarmBuddy = false
+ /** `swarmReview: 'v1'` beside swarmChat (docs/device-voice-swarm-chat.md): the dial reviews every word for a Swarm chat
+ * before it is posted, so one that comes unreviewed is refused before it is transcribed. */
+ private swarmReview = false
private playerOffset = 0
private playerRequest = 0
private playerLibraryKey = ''
@@ -736,14 +744,14 @@ 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', this.superTabWaits && 'superTab', this.swarmCard && 'swarmCard', this.swarmChat && 'swarmChat', this.swarmBuddy && 'swarmBuddy']
+ const named = [this.swarmMembers && 'swarms', this.longRecap && 'recap', this.stepsActivity && 'activity', this.statsTurn && 'stats', this.playerCapable && 'player', this.superTabWaits && 'superTab', this.swarmCard && 'swarmCard', this.swarmChat && 'swarmChat', this.swarmBuddy && 'swarmBuddy', this.swarmReview && 'swarmReview']
.filter(Boolean)
return named.length ? ` caps ${named.join(',')}` : ''
}
private resetCapabilities(): void {
this.swarmMembers = this.longRecap = this.stepsActivity = this.statsTurn = this.playerCapable = this.superTabWaits = false
- this.swarmCard = this.swarmChat = this.swarmBuddy = false
+ this.swarmCard = this.swarmChat = this.swarmBuddy = this.swarmReview = false
this.dropCards()
this.seqOn = false
this.seq = 0
@@ -866,7 +874,7 @@ export class CableSession {
form?: { command?: FormCommand; pin: Promise<FormResult> };
/** The chat on this dial's face for that agent's Swarm project as the person began to speak: the words go there or
* nowhere, and a Buddy chat's never reach a terminal (review of #2146). */
- swarmFace?: SwarmChat } | null = null
+ swarmFace?: SwarmFace } | null = null
private voiceSearch?: SelectionCommand
private voiceForm?: FormCommand
private voiceCarryId?: string
@@ -1310,6 +1318,7 @@ export class CableSession {
this.swarmCard = str('swarmCard') === 'v1'
this.swarmChat = this.swarmCard && str('swarmChat') === 'v1'
this.swarmBuddy = this.swarmChat && str('swarmBuddy') === 'v1'
+ this.swarmReview = this.swarmChat && str('swarmReview') === 'v1'
this.wantCards(this.swarmCard)
this.seqOn = str('board') === 'pro'
this.seq = 0
@@ -1338,6 +1347,9 @@ export class CableSession {
...(this.host.selectPassage ? ['selection'] : []),
...(this.host.visit ? ['visit'] : []),
...(this.host.answerReviewed ? ['question.review'] : []),
+ // Words reviewed on a Swarm face are posted in its chat by Send. A dial asks for review there only when it sees
+ // this: an older daemon would type the reviewed words into the Lead's terminal.
+ ...(this.host.swarmSay ? ['swarm.review'] : []),
// The desktop will carry this device's preferences. A device that does not see this keeps
// its own settings screens and never reports.
'settings',
@@ -1711,10 +1723,12 @@ export class CableSession {
// The dial can still name the previous pane while a focus frame is in flight, or after the
// devices process restarted. Ordinary dictation belongs to the window's selection at capture
// start. Quoted text, carried text, questions and edits already have their own pinned targets.
- const focused = str('agentId') && !formVoice && !searchVoice && !draftVoice && !questionVoice &&
- !carryVoice && !('selectionId' in msg) ? this.host.appFocus?.() : undefined
+ // Except words for a Swarm face's chat: the dial shows that chat, so a pane focused in the window never takes them.
+ const plain = str('agentId') && !formVoice && !searchVoice && !draftVoice && !questionVoice && !carryVoice && !('selectionId' in msg)
+ const dialFace = plain ? this.swarmFaceOf(str('agentId')!) : undefined
+ const focused = plain && !dialFace ? this.host.appFocus?.() : undefined
const agentId = focused?.agentId ?? str('agentId')
- const swarmFace = agentId ? this.swarmFaceOf(agentId) : undefined
+ const swarmFace = dialFace ?? (agentId ? this.swarmFaceOf(agentId) : undefined)
this.voice = {
agentId,
...(swarmFace ? { swarmFace } : {}),
@@ -2188,6 +2202,10 @@ export class CableSession {
return
}
+ if (this.swarmReview && turn.swarmFace && !review) {
+ await reply({ t: 'voice.error', message: 'Review the words before they are posted.' }); return
+ }
+
const seconds = turn.bytes / (turn.rate * 2)
this.log(`cable: voice ${seconds.toFixed(1)}s (${Math.round(turn.bytes / 1024)} KB) → stt`)
@@ -2321,6 +2339,23 @@ export class CableSession {
await reply({ t: 'voice.error', message: 'That recipient is no longer available. Choose it again.' })
return
}
+ // Reviewed on a Swarm face: Send posts the words in the chat that was on the face, as the person, and never in a terminal.
+ if (review && turn.swarmFace && !carried && !selection?.ok) {
+ if (!this.host.swarmSay) { await reply({ t: 'voice.error', message: 'Could not reach the Swarm. Try again.' }); return }
+ const face = turn.swarmFace, say = this.host.swarmSay.bind(this.host), recipient = agentId
+ const state = this.voiceDraft.create({ agentId: recipient, name: `${face.project} · ${face.name}`, text: transcript,
+ context: 'Swarm chat',
+ submit: async words => {
+ const [chat] = this.sayArgs(face)
+ const said = await say(recipient, turn.cmd ? `/${turn.cmd} ${words}` : words, chat, face.id, true)
+ .catch((): SaidOnCard => ({ said: false }))
+ if (said.said) return { ok: true }
+ return { ok: false, error: said.refused?.message ?? (face.kind === 'buddy' ? 'Could not reach your Buddy. Try again.' : 'Could not reach the Swarm. Try again.') }
+ } })
+ if (!state.ok) { await reply({ t: 'voice.error', message: state.error }); return }
+ this.voiceDraftCreation = { uploadId, id: state.id }
+ await reply({ t: 'voice.draft', ...state }); return
+ }
if (review) {
const recipient = agentId
const state = this.voiceDraft.create({ agentId: recipient, name: agentName || 'Harness', text: transcript,
@@ -2683,6 +2718,7 @@ export class CableSession {
/** Each Swarm's `supertab` frame as the Pro was last sent it, and the ids list: only a difference is sent again. */
private readonly cardKeys = new Map<string, string>()
private cardIdsKey = ''
+ private cardsUnread: ReturnType<typeof setTimeout> | null = null
private cardTimer: ReturnType<typeof setTimeout> | null = null
/** The Lead whose recap the Pro has open: the only one a changed text is pushed for. */
private openLead: { tabId: string; leadId: string } | null = null
@@ -2694,7 +2730,7 @@ export class CableSession {
private readonly cardSession = `c${++nextCardSession}`
/** The project this Pro itself picked last and when: the desktop's announce of it is no news, and a stale one of another is held off. */
private picked: { key: string; at: number } | null = null
- private lastRecapGet: { key: string; at: number } | null = null
+ private lastRecapGet: { key: string; at: number; read: Promise<LeadRecap | null> } | null = null
/** A swarmChat dial's alerts (`${tab}:${lead}`): the notice it was last given or shown as already there, and whether it
* was read on the desktop since. A notice is sent once, never on an attach or resync (it was there before), never for
* the chat the desktop has open; `notice.read` once when the desktop opens the chat of one that was sent. */
@@ -2705,17 +2741,18 @@ export class CableSession {
private noticesReplay = true
/** The chat on this dial's face for the Lead that runs as `harnessId` here; none for a device without chats. */
- private swarmFaceOf(harnessId: string): SwarmChat | undefined {
+ private swarmFaceOf(harnessId: string): SwarmFace | undefined {
if (!this.swarmChat) return undefined
for (const card of this.host.swarmCards?.() ?? []) {
const lead = card.leads.find((l) => l.local === harnessId)
- if (lead) return this.swarmBuddy ? lead.sideChat ?? lead.chat : lead.chat
+ const face = lead && (this.swarmBuddy ? lead.sideChat ?? lead.chat : lead.chat)
+ if (lead) return face && { ...face, project: lead.project }
}
return undefined
}
/** The extra arguments of words spoken to a Swarm Lead: the dial's chat flag, and the chat they were spoken to. */
- private sayArgs(face: SwarmChat | undefined): [chat?: CardChat, chatId?: string] {
+ private sayArgs(face: SwarmFace | undefined): [chat?: CardChat, chatId?: string] {
const [chat] = this.chatFlag()
if (chat === undefined) return []
return face ? [chat, face.id] : [chat]
@@ -2736,6 +2773,8 @@ export class CableSession {
private dropCards(): void {
if (this.cardTimer) clearTimeout(this.cardTimer)
this.cardTimer = null
+ if (this.cardsUnread) clearTimeout(this.cardsUnread)
+ this.cardsUnread = null
this.cardKeys.clear()
this.cardIdsKey = ''
this.focusedKey = ''
@@ -2773,7 +2812,26 @@ export class CableSession {
private async pushSwarmCards(force: boolean): Promise<void> {
if (!this.swarmCard) return
if (force) { this.cardKeys.clear(); this.cardIdsKey = ''; this.focusedKey = '' }
- const cards = (this.host.swarmCards?.() ?? []).slice(0, SWARM_CARDS_MAX)
+ // Nothing until the core has read them: an empty list on a daemon that had just started sent the dial off the Swarm on
+ // its face, onto TABS, 2 s before the real list came (Diego, 2026-10-29). Empty only ever means no Swarms, as it does for
+ // a host with no cards at all.
+ const read = this.host.swarmCards ? this.host.swarmCards() : []
+ if (!read) {
+ // Bounded: a daemon that came back signed out never reads them, and a dial that kept its link would show the old
+ // Swarms on. After CARDS_UNREAD_MS it is told there are none; the real list replaces that whenever it comes.
+ if (force && !this.cardsUnread) {
+ this.cardsUnread = setTimeout(() => {
+ this.cardsUnread = null
+ if (this.host.swarmCards?.() || this.cardIdsKey) return
+ this.cardIdsKey = '[]'
+ this.queued(async () => { await this.send({ t: 'supertabs', ids: [] }) }).catch((err) => this.log(`cable: swarm cards failed (${(err as Error).message})`))
+ }, CARDS_UNREAD_MS)
+ this.cardsUnread.unref?.()
+ }
+ return
+ }
+ if (this.cardsUnread) { clearTimeout(this.cardsUnread); this.cardsUnread = null }
+ const cards = read.slice(0, SWARM_CARDS_MAX)
const desk = this.host.listSwarms().swarms
const ids = JSON.stringify(cards.map((c) => c.id))
if (ids !== this.cardIdsKey) {
@@ -2784,7 +2842,8 @@ export class CableSession {
for (const card of cards) {
// The desk tab of the same Swarm, when the window has one: empty when it is closed or never opened it.
const tab = desk.find((s) => s.superTabId === card.id)?.id ?? ''
- const frame = { t: 'supertab', id: card.id, tab, name: card.name, count: card.count,
+ // A swarmBuddy dial follows the Swarm's side as the daemon's (review of #2218); no other device hears one.
+ const frame = { t: 'supertab', id: card.id, tab, name: card.name, count: card.count, ...(this.swarmBuddy ? { side: card.side ?? 'pm' } : {}),
leads: card.leads.slice(0, SWARM_LEADS_MAX).map((l) => this.swarmBuddy ? buddyLead(l) : this.swarmChat ? chatLead(l) : { id: l.id, projectId: l.projectId, project: l.project,
engine: l.engine, owner: l.owner, local: l.local, state: l.state, order: l.order, ...(l.since === undefined ? {} : { since: l.since }) }) }
fitFrame(frame)
@@ -2862,7 +2921,7 @@ export class CableSession {
return
}
// Not in the list yet: asked again when it arrives.
- const card = this.host.swarmCards?.().find((c) => c.id === open.superTabId)
+ const card = this.host.swarmCards?.()?.find((c) => c.id === open.superTabId)
if (!card) { this.logFocus(`cable: swarm focus ${named} · held: no such Swarm in the list`); return }
const lead = open.projectId ? card.leads.find((l) => l.projectId === open.projectId) : undefined
if (open.projectId && !lead) { this.logFocus(`cable: swarm focus ${named} · held: no Lead for that project`); return }
@@ -2881,6 +2940,8 @@ export class CableSession {
/** A Lead's changed text, for the Pro that has that Lead's recap open. */
async swarmCardRecap(recap: LeadRecap): Promise<void> {
+ // A newer text than the read a repeat request would be answered from: that read is not handed out again.
+ if (this.lastRecapGet?.key === `${recap.tabId}/${recap.leadId}`) this.lastRecapGet = null
if (!this.swarmCard || this.openLead?.tabId !== recap.tabId || this.openLead.leadId !== recap.leadId) return
// The service pushes a Lead's recap and each dial's face chat's apart: each device takes only the kind it asked for.
if (this.swarmChat !== (recap.chatId !== undefined) || this.swarmBuddy !== (recap.buddy === true)) return
@@ -2903,7 +2964,7 @@ export class CableSession {
return
}
if (type === 'supertab.select') {
- const projectId = this.host.swarmCards?.().find((c) => c.id === tab)?.leads.find((l) => l.id === lead)?.projectId
+ const projectId = this.host.swarmCards?.()?.find((c) => c.id === tab)?.leads.find((l) => l.id === lead)?.projectId
if (!projectId) { this.log(`cable: ignored pick of unknown Lead ${lead}`); return }
// Remembered before the window answers, so its announce of this very project is not sent back as a focus.
this.focusedKey = `${tab}/${projectId}`
@@ -2911,12 +2972,18 @@ export class CableSession {
this.host.superTabSelected?.(tab, projectId)
return
}
- // A repeat for the same Lead inside a second is ignored: the first answer is on its way.
+ // A repeat for the same Lead inside a second is answered from the first read, not read again. Dropping it left a dial
+ // that had emptied its face on the resting pet until its own 5 s retry (Diego, 2026-10-29).
+ // Only while the Lead is still in the cards: one whose access went is read again, and the host refuses it.
const asked = `${tab}/${lead}`, now = Date.now()
- if (this.lastRecapGet?.key === asked && now - this.lastRecapGet.at < RECAP_REPEAT_MS) return
- this.lastRecapGet = { key: asked, at: now }
- let recap: LeadRecap | null = null
- try { recap = await this.host.swarmCardRecap?.(tab, lead, ...this.chatFlag()) ?? null } catch (err) { this.log(`cable: recap for ${lead} failed (${(err as Error).message})`) }
+ const listed = this.host.swarmCards?.()?.find((c) => c.id === tab)?.leads.some((l) => l.id === lead) ?? false
+ if (this.lastRecapGet?.key !== asked || now - this.lastRecapGet.at >= RECAP_REPEAT_MS || !listed) {
+ const read = Promise.resolve()
+ .then(() => this.host.swarmCardRecap?.(tab, lead, ...this.chatFlag()) ?? null)
+ .catch((err) => { this.log(`cable: recap for ${lead} failed (${(err as Error).message})`); return null })
+ this.lastRecapGet = { key: asked, at: now, read }
+ }
+ const recap = await this.lastRecapGet.read
// Nothing on a failure: the Pro keeps its "…" and asks again on the next open.
if (recap) await this.queued(async () => { await this.send(recapFrame(recap)) })
}
diff --git a/cli/src/core/api.ts b/cli/src/core/api.ts
index 00f06afa5..457723b83 100644
--- a/cli/src/core/api.ts
+++ b/cli/src/core/api.ts
@@ -1235,7 +1235,9 @@ export interface SwarmLead {
buddyNotice?: LeadNotice
}
/** One Swarm this account is in, as a Harness Pro's card: its Leads, most urgent first. */
-export interface SwarmCard { id: string; name: string; count: number; leads: SwarmLead[] }
+/** `side` 'buddy' while a swarmBuddy dial keeps the Swarm on its Buddy side (spec 2026-10-29-round-dial-pm-buddy): the dial
+ * follows it as the daemon's, which a face alone cannot tell where no project has a Buddy chat (review of #2218). */
+export interface SwarmCard { id: string; name: string; count: number; leads: SwarmLead[]; side?: 'buddy' }
/** A Lead's last message, for its card; `chatId` when it is the last message of the chat on the round dial's face, and
* `buddy` when that face is a swarmBuddy dial's (`CardChat` 'buddy'), so each dial takes only the recaps it asked for. */
export interface LeadRecap { tabId: string; leadId: string; text: string; at: number; none: boolean; chatId?: string; buddy?: true }
@@ -1262,7 +1264,9 @@ export type CardChat = boolean | 'buddy'
* refused by the backend with its code and message, which must never become a terminal turn instead. */
export type SaidOnCard = { said: true } | { said: false; refused?: { code: string; message: string } }
/** The conversation the window has open in a Swarm tab. */
-export interface CardFocus { tabId: string; conversationId: string }
+/** `fromDevice`: the window moved there because a device picked it (a dial's swipe to the next project), so the move is
+ * that device's own and keeps the side it keeps (spec 2026-10-29-round-dial-pm-buddy, newest wins). */
+export interface CardFocus { tabId: string; conversationId: string; fromDevice?: true }
/** The Super Tab service's door into the core (superTabs/inCore/attention.ts): the waits of its members here. */
export interface SuperTabsCore {
diff --git a/cli/src/core/devicesLink.spec.ts b/cli/src/core/devicesLink.spec.ts
index e1f5a2ae0..061875f2c 100644
--- a/cli/src/core/devicesLink.spec.ts
+++ b/cli/src/core/devicesLink.spec.ts
@@ -261,6 +261,8 @@ describe('the devices\' Swarm card requests to the Super Tab service', () => {
expect((await devices.answer('super_tabs', { action: 'cardRecap', tabId: 't1', leadId: 'l1', chat: 'buddy' })).echoed).toEqual({ action: 'cardRecap', tabId: 't1', leadId: 'l1', chat: 'buddy' })
expect((await devices.answer('super_tabs', { action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy' })).echoed).toEqual({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy' })
expect((await devices.answer('super_tabs', { action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1' })).echoed).toEqual({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1' })
+ expect((await devices.answer('super_tabs', { action: 'cardSay', harnessId: 'h1', text: 'ship it', chatId: 'pm1', reviewed: true })).echoed).toEqual({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chatId: 'pm1', reviewed: true })
+ expect((await devices.answer('super_tabs', { action: 'cardSay', harnessId: 'h1', text: 'ship it', chatId: 'pm1', reviewed: 'yes' })).echoed).toEqual({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chatId: 'pm1' })
expect((await devices.answer('super_tabs', { action: 'cardSay', harnessId: 'h1', text: 'ship it', chatId: 7 })).echoed).toEqual({ action: 'cardSay', harnessId: 'h1', text: 'ship it' })
expect((await devices.answer('super_tabs', { action: 'cardSide', tabId: 't1', side: 'buddy', leadId: 'l1', text: 'x' })).echoed).toEqual({ action: 'cardSide', tabId: 't1', side: 'buddy' })
})
diff --git a/cli/src/core/devicesLink.ts b/cli/src/core/devicesLink.ts
index d6018fe77..78b0232a8 100644
--- a/cli/src/core/devicesLink.ts
+++ b/cli/src/core/devicesLink.ts
@@ -130,7 +130,8 @@ export function createDevicesLink(deps: DevicesLinkDeps) {
// window's open conversation rides with the wish (superTabs/inCore/cards.ts checks them); absent, the request is today's.
const chat = payload.chat === true || payload.chat === 'buddy' ? { chat: payload.chat } : {}
return core.superTabRequest(action === 'cardsWanted' ? { action, on: on === true, include, ...(focus !== undefined ? { focus } : {}) }
- : action === 'cardSay' ? { action, harnessId, text, ...chat, ...(typeof payload.chatId === 'string' ? { chatId: payload.chatId } : {}) }
+ : action === 'cardSay' ? { action, harnessId, text, ...chat, ...(typeof payload.chatId === 'string' ? { chatId: payload.chatId } : {}),
+ ...(payload.reviewed === true ? { reviewed: true } : {}) }
: action === 'cardWorker' ? { action, machineId, harnessId }
: action === 'cardSide' ? { action, tabId, side }
: { action, tabId, leadId, session, ...chat })
diff --git a/cli/src/services/devices.spec.ts b/cli/src/services/devices.spec.ts
index 75091117e..f13b1a82b 100644
--- a/cli/src/services/devices.spec.ts
+++ b/cli/src/services/devices.spec.ts
@@ -630,6 +630,9 @@ describe('what the windows say, reaching the dial', () => {
expect(superTabRequest).toHaveBeenLastCalledWith({ action: 'cardsWanted', on: true, include: ['st1'] })
port.swarms(open('tab-st1'))
expect(superTabRequest).toHaveBeenCalledTimes(3)
+ // The window followed a device's own pick: the focus says so, for the cards to keep the dial's side.
+ port.swarms({ ...open('tab-st1', 'g2'), fromDevice: true })
+ expect(superTabRequest).toHaveBeenLastCalledWith({ action: 'cardsWanted', on: true, include: ['st1'], focus: { tabId: 'st1', conversationId: 'g2', fromDevice: true } })
port.swarms(open('tab-st1', 'g1'))
superTabRequest.mockClear()
reconnected.forEach((run) => run())
@@ -680,6 +683,9 @@ describe('what the windows say, reaching the dial', () => {
expect(await seen.host.swarmCardRecap!('st1', 'lead1', 'buddy')).toBeNull()
expect(await seen.host.swarmSay!('h1', 'ship it', 'buddy', 'pm1')).toEqual({ said: true })
expect(superTabRequest).toHaveBeenLastCalledWith({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1' })
+ answers.unshift({ ok: true, said: true })
+ expect(await seen.host.swarmSay!('h1', 'ship it', 'buddy', 'pm1', true)).toEqual({ said: true })
+ expect(superTabRequest).toHaveBeenLastCalledWith({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1', reviewed: true })
seen.host.swarmCardOpen!('c1', 'st1', 'lead1', 'buddy')
expect(superTabRequest).toHaveBeenLastCalledWith({ action: 'cardOpen', session: 'c1', tabId: 'st1', leadId: 'lead1', chat: 'buddy' })
seen.host.swarmCardSide!('st1', 'buddy')
diff --git a/cli/src/services/devices.ts b/cli/src/services/devices.ts
index 2cdc474f6..c43fcbf2a 100644
--- a/cli/src/services/devices.ts
+++ b/cli/src/services/devices.ts
@@ -192,7 +192,7 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)
let cardInclude: string[] = []
// The conversation the window has open in its active Swarm tab, which the round dial's face follows (design
// 2026-10-28-round-dial-swarm-chat): said with the wish, and left out when there is none, as before.
- let cardFocus: { tabId: string; conversationId: string } | null = null
+ let cardFocus: { tabId: string; conversationId: string; fromDevice?: true } | null = null
const tellCards = (): void => {
const on = cardDevices > 0
void askCards({ action: 'cardsWanted', on, include: on ? cardInclude : [], ...(on && cardFocus ? { focus: cardFocus } : {}) })
@@ -264,7 +264,8 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)
swarmCardOpen: (session, tabId, leadId, chat) => { void askCards({ action: 'cardOpen', session, tabId, leadId, ...chatFlag(chat) }) },
swarmCardSide: (tabId, side) => { void askCards({ action: 'cardSide', tabId, side }) },
// An error (no service, a refused post) is not `said`: the words go to the harness instead, never lost.
- swarmSay: async (harnessId, text, chat, chatId) => saidOf(await askCards({ action: 'cardSay', harnessId, text, ...chatFlag(chat), ...(chatId ? { chatId } : {}) })),
+ swarmSay: async (harnessId, text, chat, chatId, reviewed) => saidOf(await askCards({ action: 'cardSay', harnessId, text, ...chatFlag(chat),
+ ...(chatId ? { chatId, ...(reviewed ? { reviewed: true } : {}) } : {}) })),
// The Pro picked a Lead: the window opens that Swarm tab and project. Harmless with no window.
superTabSelected: (superTabId, projectId) => core.clients.sendLocal({ type: 'dial_super_tab', payload: { superTabId, projectId } }),
scrolled: (phase, dy, velocity, superTabId) => core.clients.sendLocal({ type: 'dial_scroll', payload: { phase, dy, velocity, ...(superTabId ? { superTabId } : {}) } }),
@@ -573,7 +574,9 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)
// The Swarms the window has tabs for are read first; said again to the core only when they change.
const include = [...new Set((swarms?.swarms ?? []).map((s) => s.superTabId).filter((id): id is string => !!id))].slice(0, 16)
const open = cableHost.activeSwarmProject()
- const focus = open?.conversationId ? { tabId: open.superTabId, conversationId: open.conversationId } : null
+ // `fromDevice`: the window followed a device's own pick, which the cards keep a dial's side through.
+ const focus = open?.conversationId
+ ? { tabId: open.superTabId, conversationId: open.conversationId, ...(open.fromDevice ? { fromDevice: true as const } : {}) } : null
const refocused = `${focus?.tabId}/${focus?.conversationId}` !== `${cardFocus?.tabId}/${cardFocus?.conversationId}`
if (include.join(',') !== cardInclude.join(',') || refocused) { cardInclude = include; cardFocus = focus; if (cardDevices > 0) tellCards() }
void cable.syncSwarms()
diff --git a/cli/src/superTabs/cards.spec.ts b/cli/src/superTabs/cards.spec.ts
index d499ed363..ef833a484 100644
--- a/cli/src/superTabs/cards.spec.ts
+++ b/cli/src/superTabs/cards.spec.ts
@@ -986,6 +986,56 @@ describe('SwarmCards Buddy side', () => {
t.cards.want(false)
})
+ it('keeps the side through a desktop focus the dial itself caused, and clears it on the desktop\'s own next one', async () => {
+ const t = chatSwarm({}, true)
+ t.cards.want(true, [], null)
+ await vi.waitFor(() => expect(t.seen).toHaveLength(1))
+ t.cards.side('t1', 'buddy')
+ // The dial swiped to the next project: its select moved the desktop there, and that announce says so.
+ t.cards.want(true, [], { tabId: 't1', conversationId: 'lead-web', fromDevice: true })
+ expect(t.webLead()?.sideChat).toMatchObject({ kind: 'buddy' })
+ // The person then opens another conversation on the desktop: newest wins, the side goes and the face follows it.
+ t.cards.want(true, [], { tabId: 't1', conversationId: 'g-web' })
+ expect(t.webLead()?.sideChat).toMatchObject({ kind: 'group', id: 'g-web' })
+ t.cards.want(false)
+ })
+
+ it('says the Swarm\'s side on its card, so a dial follows the daemon\'s side even where no face changes', async () => {
+ // No Buddy chat in the Swarm: a side changes no face, and the card alone tells the dial (review of #2218).
+ const t = chatSwarm({})
+ t.cards.want(true, [], null)
+ await vi.waitFor(() => expect(t.seen).toHaveLength(1))
+ expect(t.seen.at(-1)?.[0].side).toBeUndefined()
+ t.cards.side('t1', 'buddy')
+ expect(t.seen.at(-1)?.[0].side).toBe('buddy')
+ // The desktop opens a group: the side goes, and the card says so.
+ t.cards.want(true, [], { tabId: 't1', conversationId: 'g-web' })
+ expect(t.seen.at(-1)?.[0].side).toBeUndefined()
+ t.cards.want(false)
+ })
+
+ it('says the Buddy side when the desktop opens the Buddy chat, so the side and the face agree', async () => {
+ // Re-check of #2216: the face followed the desktop to the Buddy chat while the card said the PM side, and the dial
+ // (#2218) showed the PM screen without the Buddy's recap.
+ const t = chatSwarm({ 'pm-web': [said(2, 'y1', { text: 'from the Buddy' })] }, true)
+ t.cards.want(true, [], null)
+ await vi.waitFor(() => expect(t.seen).toHaveLength(1))
+ t.cards.want(true, [], { tabId: 't1', conversationId: 'pm-web' })
+ expect(t.seen.at(-1)?.[0].side).toBe('buddy')
+ expect(t.webLead()?.sideChat).toMatchObject({ kind: 'buddy', id: 'pm-web' })
+ expect(await t.cards.recap('t1', 'a1', 'buddy')).toMatchObject({ chatId: 'pm-web', text: 'from the Buddy' })
+ // A swipe down wins over that focus: both say the PM side.
+ t.cards.side('t1', 'pm')
+ expect(t.seen.at(-1)?.[0].side).toBeUndefined()
+ expect(t.webLead()?.sideChat).toMatchObject({ kind: 'lead' })
+ expect(await t.cards.recap('t1', 'a1', 'buddy')).toMatchObject({ chatId: 'lead-web' })
+ // The desktop moving to a group clears both.
+ t.cards.want(true, [], { tabId: 't1', conversationId: 'g-web' })
+ expect(t.seen.at(-1)?.[0].side).toBeUndefined()
+ expect(t.webLead()?.sideChat).toMatchObject({ kind: 'group' })
+ t.cards.want(false)
+ })
+
it('keeps the side per Swarm, refuses a bad tab or side, and forgets every side when the devices go', async () => {
const t = chatSwarm({}, true)
t.cards.want(true, [], null)
@@ -1055,6 +1105,24 @@ describe('SwarmCards Buddy side', () => {
expect(posts).toEqual(['pm-web'])
t.cards.want(false)
})
+
+ it('reviewed words go to the chat they were reviewed for after the face moved, and never to a chat outside the Lead\'s project', async () => {
+ const t = chatSwarm({}, true)
+ t.cards.want(true, [], null)
+ await vi.waitFor(() => expect(t.seen).toHaveLength(1))
+ t.cards.side('t1', 'buddy')
+ // The person reviewed the words for their Buddy chat; the window opened the Lead before they pressed Send.
+ t.cards.want(true, [], { tabId: 't1', conversationId: 'lead-web' })
+ expect(await t.cards.say('h-a1', 'reviewed for my Buddy', 'buddy', 'pm-web', true)).toEqual({ said: true })
+ // Another project's chat, or one this reader cannot see, is not where this Lead's words go.
+ for (const chatId of ['lead-mobile', 'gone']) {
+ expect(await t.cards.say('h-a1', 'not here', 'buddy', chatId, true)).toEqual({ said: false,
+ refused: { code: 'CHAT_MOVED', message: 'That chat is no longer on the dial. Say it again.' } })
+ }
+ const posts = t.call.mock.calls.filter(c => c[0] === 'POST').map(c => (c[2] as { command: { conversationId: string } }).command.conversationId)
+ expect(posts).toEqual(['pm-web'])
+ t.cards.want(false)
+ })
})
// Privacy edges reviews keep finding (Lead, 10-29): an answer read for one reader, or while access lasted, is never given
diff --git a/cli/src/superTabs/cards.ts b/cli/src/superTabs/cards.ts
index 2214cd681..e7e94302d 100644
--- a/cli/src/superTabs/cards.ts
+++ b/cli/src/superTabs/cards.ts
@@ -277,10 +277,12 @@ export class SwarmCards {
const wanted = include.filter(cardId).slice(0, MAX_CARDS)
const moved = wanted.join(',') !== this.include.join(',')
this.include = wanted
- const next = focus && cardId(focus.tabId) && cardId(focus.conversationId) ? { tabId: focus.tabId, conversationId: focus.conversationId } : null
+ const next = focus && cardId(focus.tabId) && cardId(focus.conversationId)
+ ? { tabId: focus.tabId, conversationId: focus.conversationId, ...(focus.fromDevice === true ? { fromDevice: true as const } : {}) } : null
const refocused = `${next?.tabId}/${next?.conversationId}` !== `${this.focus?.tabId}/${this.focus?.conversationId}`
this.focus = next
- if (refocused) this.sides.clear()
+ // The desktop's own move clears the dial's side; the move a dial's pick caused is the dial's, and keeps it.
+ if (refocused && !next?.fromDevice) this.sides.clear()
if (this.timer) {
if (refocused && this.live) { this.emit(); void this.pushOpen() }
if (moved) void this.tick()
@@ -291,6 +293,19 @@ export class SwarmCards {
void this.tick()
}
+ /**
+ * The side a swarmBuddy dial is shown for a Swarm, which its faces, recaps and card all follow: the one it swiped to, else
+ * the Buddy side while the window has the reader's Buddy chat open there (spec 2026-10-29: opening it on the desktop
+ * shows the Buddy screen). Taken from the swipes alone, the card said the PM side over a Buddy face (re-check of #2216).
+ */
+ private sideOf(tabId: string, state: Json): CardSide | undefined {
+ const swiped = this.sides.get(tabId)
+ if (swiped) return swiped
+ const focus = this.focus?.tabId === tabId ? this.focus.conversationId : undefined
+ return focus !== undefined && state.buddies === true &&
+ list(state.conversations).some(c => c.id === focus && isReadersBuddyChat(c, this.me) && c.archived !== true) ? 'buddy' : undefined
+ }
+
/** A swarmBuddy dial swiped to a side of a Swarm (spec 2026-10-29): every project of it shows that side until the window
* opens another conversation. The cards are rebuilt at once from the last reads, as a focus change does. */
side(tabId: string, side: CardSide): void {
@@ -396,12 +411,14 @@ export class SwarmCards {
const tab = this.tabs.get(row.id)
if (!tab) continue
const focus = this.focus?.tabId === row.id ? this.focus.conversationId : undefined
- const { count, leads } = leadsOf(tab.state, this.machineId, live, this.me, focus, this.sides.get(row.id))
+ const side = this.sideOf(row.id, tab.state)
+ const { count, leads } = leadsOf(tab.state, this.machineId, live, this.me, focus, side)
const noticed = leads.map(lead => {
const notice = this.notices.get(recapKey(row.id, lead.id)), buddyNotice = this.buddyNotices.get(recapKey(row.id, lead.id))
return { ...lead, ...(notice ? { notice } : {}), ...(buddyNotice ? { buddyNotice } : {}) }
})
- cards.push({ id: row.id, name: cut(String(tab.state.name ?? row.name ?? ''), NAME_BYTES), count, leads: noticed })
+ cards.push({ id: row.id, name: cut(String(tab.state.name ?? row.name ?? ''), NAME_BYTES), count, leads: noticed,
+ ...(side === 'buddy' ? { side: 'buddy' as const } : {}) })
}
// `since` moves every poll while a turn runs and the Pro counts on by itself, so it alone never re-sends the list.
// Nor does a clock that keeps its turn; one whose turn changed (the Lead's ended, a worker's goes on) does. The start is
@@ -500,7 +517,7 @@ export class SwarmCards {
if (!chat) return { id: found.lead.id, sequence: sequenceOf(found.lead), voices: new Set([leadId]) }
const focus = this.focus?.tabId === tabId ? this.focus.conversationId : undefined
const conversations = list(state.conversations), projectId = projectKey(found.project), buddies = state.buddies === true
- const face = chat === 'buddy' && buddies ? sideFaceOf(conversations, projectId, found.lead, focus, this.me, this.sides.get(tabId))
+ const face = chat === 'buddy' && buddies ? sideFaceOf(conversations, projectId, found.lead, focus, this.me, this.sideOf(tabId, state))
: faceOf(conversations, projectId, found.lead, focus, this.me, buddies)
if (!face) return null
const id = face.conversation.id as string
@@ -550,16 +567,20 @@ export class SwarmCards {
* PM, Buddies off, a Buddy chat not the reader's), whose words must never become a terminal turn instead (spec 2026-10-29
* Voice). Any other failure (the network, a 5xx) throws as before. `chatId`: the chat on the dial's face when the words
* were spoken; they go there or nowhere, so words for the reader's Buddy never land in the project's chat because the
- * window moved on while they were said (review of #2146). */
- async say(harnessId: string, text: string, chat: CardChat = false, chatId?: string): Promise<SaidOnCard> {
+ * window moved on while they were said (review of #2146). `reviewed`: the person saw that chat named and pressed Send,
+ * so the words go there even if the face moved since, while it is still a chat of the Lead's project this reader may
+ * see (docs/device-voice-swarm-chat.md); the backend checks the post as for typing. */
+ async say(harnessId: string, text: string, chat: CardChat = false, chatId?: string, reviewed = false): Promise<SaidOnCard> {
for (const [tabId, { state }] of this.tabs) {
const agent = list(state.agents).find(a => a.machineId === this.machineId && a.harnessId === harnessId)
const found = agent && cardId(agent.id) ? this.target(tabId, agent.id, chat) : null
if (!found) continue
- if (chatId !== undefined && found.id !== chatId) return { said: false, refused: { code: 'CHAT_MOVED', message: 'That chat is no longer on the dial. Say it again.' } }
+ const to = chatId === undefined || found.id === chatId ? found.id
+ : reviewed && this.chatOfLead(state, agent!.id as string, chatId) ? chatId : null
+ if (!to) return { said: false, refused: { code: 'CHAT_MOVED', message: 'That chat is no longer on the dial. Say it again.' } }
try {
await backend(this.core, 'POST', `/api/super-tabs/${tabId}/commands`, { operationId: `pro-voice-${randomUUID()}`,
- command: { type: 'message.send', conversationId: found.id, text, replyTo: null, recipientIds: [] } })
+ command: { type: 'message.send', conversationId: to, text, replyTo: null, recipientIds: [] } })
} catch (error) {
if (error instanceof SuperTabHostError && error.status >= 400 && error.status < 500) return { said: false, refused: { code: error.code, message: error.message } }
throw error
@@ -569,6 +590,16 @@ export class SwarmCards {
return { said: false }
}
+ /** Whether `chatId` is, as last read, a chat that could be on this Lead's face: its Lead conversation, or an open chat of its
+ * project that is not another person's Buddy chat. */
+ private chatOfLead(state: Json, leadId: string, chatId: string): boolean {
+ const found = leadProjects(state).find(p => p.leadId === leadId)
+ if (!found) return false
+ if (found.lead.id === chatId) return true
+ const c = list(state.conversations).find(c => c.id === chatId)
+ return !!c && cardId(c.id) && inProject(c, projectKey(found.project)) && c.archived !== true && (!isBuddyChat(c) || isReadersBuddyChat(c, this.me))
+ }
+
/** Remembered recaps are kept only for Leads that are still in a tab, and a chat's only while it is on the face. */
private prune(): void {
for (const [key, held] of this.recaps) {
diff --git a/cli/src/superTabs/inCore/cards.spec.ts b/cli/src/superTabs/inCore/cards.spec.ts
index 60cc3a5dc..a780f6b88 100644
--- a/cli/src/superTabs/inCore/cards.spec.ts
+++ b/cli/src/superTabs/inCore/cards.spec.ts
@@ -33,6 +33,14 @@ describe('the Swarm cards on the devices', () => {
expect(swarmCards).toHaveBeenCalledWith([])
})
+ it('passes a Swarm\'s Buddy side on, and nothing else as a side', () => {
+ const { cards, swarmCards } = setup()
+ cards.cards([card('t1', [lead('l1')], { side: 'buddy' }), card('t2', [lead('l2')], { side: 'pm' }), card('t3', [lead('l3')], { side: true })])
+ const sent = swarmCards.mock.calls.at(-1)?.[0] as Array<Record<string, unknown>>
+ expect(sent.map((c) => c.side)).toEqual(['buddy', undefined, undefined])
+ expect('side' in sent[1]).toBe(false)
+ })
+
it('checks ids, counts and strings, and drops a malformed list whole, keeping the last good one', () => {
const { cards, swarmCards, log } = setup()
cards.cards([card('t1')])
@@ -239,6 +247,11 @@ describe('whether the Swarm cards are wanted, which the core owns', () => {
cards.want(true, ['t1'], bad)
expect(request.mock.calls).toEqual([[{ action: 'cardsWanted', on: true, include: ['t1'] }]])
}
+ // A focus the device's own pick caused says so, as a change of its own; anything but true is not that.
+ cards.want(true, ['t1'], { ...focus, fromDevice: true })
+ expect(request).toHaveBeenLastCalledWith({ action: 'cardsWanted', on: true, include: ['t1'], focus: { ...focus, fromDevice: true } })
+ cards.want(true, ['t1'], { ...focus, fromDevice: 1 })
+ expect(request).toHaveBeenLastCalledWith({ action: 'cardsWanted', on: true, include: ['t1'], focus })
// The devices gone take the focus with them.
cards.want(true, ['t1'], focus)
cards.devicesGone()
@@ -265,9 +278,11 @@ describe('whether the Swarm cards are wanted, which the core owns', () => {
expect(await cards.ask({ action: 'cardSide', tabId: 't1', side: 'buddy', extra: 1 })).toEqual({ ok: true })
await cards.ask({ action: 'cardSide', tabId: 't1', side: 'pm' })
await cards.ask({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: true, chatId: 'bad id' })
+ await cards.ask({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1', reviewed: true })
expect(request.mock.calls).toEqual([[{ action: 'cardRecap', tabId: 't1', leadId: 'l1', chat: 'buddy' }], [{ action: 'cardOpen', session: 's1', tabId: 't1', leadId: 'l1', chat: 'buddy' }],
[{ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1' }], [{ action: 'cardSide', tabId: 't1', side: 'buddy' }], [{ action: 'cardSide', tabId: 't1', side: 'pm' }],
- [{ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: true }]])
+ [{ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: true }],
+ [{ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1', reviewed: true }]])
request.mockClear()
for (const side of ['up', null, undefined, true]) expect(await cards.ask({ action: 'cardSide', tabId: 't1', side })).toEqual({ error: 'INVALID_REQUEST' })
expect(request).not.toHaveBeenCalled()
diff --git a/cli/src/superTabs/inCore/cards.ts b/cli/src/superTabs/inCore/cards.ts
index 03afb136c..ba1242846 100644
--- a/cli/src/superTabs/inCore/cards.ts
+++ b/cli/src/superTabs/inCore/cards.ts
@@ -111,7 +111,7 @@ function cardIn(value: unknown): SwarmCard | null {
if (!lead) return null
leads.push(lead)
}
- return { id: card.id, name: cut(card.name, NAME_BYTES), count: card.count, leads }
+ return { id: card.id, name: cut(card.name, NAME_BYTES), count: card.count, leads, ...(card.side === 'buddy' ? { side: 'buddy' as const } : {}) }
}
/** A recap the service sent, checked and cut; null when it is not one. */
@@ -129,7 +129,7 @@ export function createSuperTabCards({ swarmCards, swarmCardRecap, request, log =
let last: SwarmCard[] | null = null
/** Whether any capable device wants cards, the Swarms to read first, and the conversation the window has open in a Swarm tab. */
let wanted = false, include: string[] = []
- let focus: { tabId: string; conversationId: string } | null = null
+ let focus: { tabId: string; conversationId: string; fromDevice?: true } | null = null
const route = async (payload: Record<string, unknown>): Promise<Record<string, unknown>> => {
try {
const answer = await request?.(payload)
@@ -143,8 +143,10 @@ export function createSuperTabCards({ swarmCards, swarmCardRecap, request, log =
want(on: boolean, swarms: unknown, open?: unknown): void {
const next = on && Array.isArray(swarms) ? [...new Set(swarms.filter(id))].slice(0, MAX_CARDS) : []
const asked = object(open)
- const nextFocus = on && id(asked.tabId) && id(asked.conversationId) ? { tabId: asked.tabId, conversationId: asked.conversationId } : null
- if (on === wanted && next.join(',') === include.join(',') && `${nextFocus?.tabId}/${nextFocus?.conversationId}` === `${focus?.tabId}/${focus?.conversationId}`) return
+ const nextFocus = on && id(asked.tabId) && id(asked.conversationId)
+ ? { tabId: asked.tabId, conversationId: asked.conversationId, ...(asked.fromDevice === true ? { fromDevice: true as const } : {}) } : null
+ const key = (f: typeof focus) => `${f?.tabId}/${f?.conversationId}/${f?.fromDevice === true}`
+ if (on === wanted && next.join(',') === include.join(',') && key(nextFocus) === key(focus)) return
wanted = on
include = next
focus = nextFocus
@@ -198,7 +200,9 @@ export function createSuperTabCards({ swarmCards, swarmCardRecap, request, log =
}
if (payload.action === 'cardRecap') return route({ action: 'cardRecap', tabId: payload.tabId, leadId: payload.leadId, ...chat })
// The chat on the dial's face when the words were spoken, which they may be posted in and no other.
- if (payload.action === 'cardSay') return route({ action: 'cardSay', harnessId: payload.harnessId, text: payload.text, ...chat, ...(id(payload.chatId) ? { chatId: payload.chatId } : {}) })
+ // `reviewed`: the person saw that chat named on the dial and pressed Send.
+ if (payload.action === 'cardSay') return route({ action: 'cardSay', harnessId: payload.harnessId, text: payload.text, ...chat,
+ ...(id(payload.chatId) ? { chatId: payload.chatId, ...(payload.reviewed === true ? { reviewed: true } : {}) } : {}) })
if (payload.action === 'cardOpen') return route({ action: 'cardOpen', session: payload.session, tabId: payload.tabId, leadId: payload.leadId, ...chat })
// A card's failure from another computer: whether its agent is a Swarm's worker (services/devices.ts asks; it decides).
if (payload.action === 'cardWorker') return route({ action: 'cardWorker', machineId: payload.machineId, harnessId: payload.harnessId })
diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.ts
index 5264ea5b7..6a57c8655 100644
--- a/cli/src/superTabs/service.spec.ts
+++ b/cli/src/superTabs/service.spec.ts
@@ -815,6 +815,11 @@ describe('the Swarm cards the devices ask for', () => {
const t = withCards()
await t.ask({ action: 'cardsWanted', on: true, include: ['s1'], focus: { tabId: 's1', conversationId: 'g1', extra: 1 } }, owner)
expect(t.cards.want).toHaveBeenLastCalledWith(true, ['s1'], { tabId: 's1', conversationId: 'g1' })
+ // A focus the device's own pick caused says so; anything but true is not that.
+ await t.ask({ action: 'cardsWanted', on: true, include: ['s1'], focus: { tabId: 's1', conversationId: 'g1', fromDevice: true } }, owner)
+ expect(t.cards.want).toHaveBeenLastCalledWith(true, ['s1'], { tabId: 's1', conversationId: 'g1', fromDevice: true })
+ await t.ask({ action: 'cardsWanted', on: true, include: ['s1'], focus: { tabId: 's1', conversationId: 'g1', fromDevice: 'yes' } }, owner)
+ expect(t.cards.want).toHaveBeenLastCalledWith(true, ['s1'], { tabId: 's1', conversationId: 'g1' })
// A focus that is not two ids is none.
for (const focus of [{ tabId: 'bad id', conversationId: 'g1' }, { tabId: 's1', conversationId: 'x'.repeat(48) }, { tabId: 's1' }, 'g1']) {
await t.ask({ action: 'cardsWanted', on: true, include: ['s1'], focus }, owner)
@@ -854,6 +859,11 @@ describe('the Swarm cards the devices ask for', () => {
expect(t.cards.say).toHaveBeenLastCalledWith('h1', 'ship it', 'buddy', 'pm1')
await t.ask({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'bad id' }, owner)
expect(t.cards.say).toHaveBeenLastCalledWith('h1', 'ship it', 'buddy')
+ // Reviewed on the dial: only with the chat it was reviewed for.
+ await t.ask({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', chatId: 'pm1', reviewed: true }, owner)
+ expect(t.cards.say).toHaveBeenLastCalledWith('h1', 'ship it', 'buddy', 'pm1', true)
+ await t.ask({ action: 'cardSay', harnessId: 'h1', text: 'ship it', chat: 'buddy', reviewed: true }, owner)
+ expect(t.cards.say).toHaveBeenLastCalledWith('h1', 'ship it', 'buddy')
})
it('cardSay passes a refused post\'s code and message on, and says nothing of a refusal otherwise', async () => {
const t = withCards()
diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.ts
index d28da76df..60d15c052 100644
--- a/cli/src/superTabs/service.ts
+++ b/cli/src/superTabs/service.ts
@@ -421,13 +421,16 @@ export function superTabService(core: CoreApi, options: SuperTabServiceOptions =
if (payload.action === 'cardsWanted') {
const include = Array.isArray(payload.include) ? payload.include.filter(cardId) : []
const asked = payload.focus && typeof payload.focus === 'object' ? payload.focus as Record<string, unknown> : {}
- const focus = cardId(asked.tabId) && cardId(asked.conversationId) ? { tabId: asked.tabId, conversationId: asked.conversationId } : null
+ const focus = cardId(asked.tabId) && cardId(asked.conversationId)
+ ? { tabId: asked.tabId, conversationId: asked.conversationId, ...(asked.fromDevice === true ? { fromDevice: true as const } : {}) } : null
cards().want(payload.on === true, include, focus)
return { ok: true }
}
if (payload.action === 'cardRecap' && cardId(payload.tabId) && cardId(payload.leadId)) return { ok: true, ...await cards().recap(payload.tabId, payload.leadId, chat) }
if (payload.action === 'cardSay' && cardId(payload.harnessId) && typeof payload.text === 'string' && payload.text.trim() && payload.text.length <= 32_000) {
- const result = await cards().say(payload.harnessId, payload.text.trim(), chat, ...(cardId(payload.chatId) ? [payload.chatId] : []))
+ const pinned: [chatId?: string, reviewed?: boolean] = !cardId(payload.chatId) ? []
+ : payload.reviewed === true ? [payload.chatId, true] : [payload.chatId]
+ const result = await cards().say(payload.harnessId, payload.text.trim(), chat, ...pinned)
// A refusal travels with its code and message, which the dial shows instead of typing the words anywhere.
return { ok: true, said: result.said, ...(!result.said && result.refused ? { refused: result.refused } : {}) }
}
diff --git a/devices/harness-device/firmware/dependencies.lock b/devices/harness-device/firmware/dependencies.lock
index 7b1c7d871..227891226 100644
--- a/devices/harness-device/firmware/dependencies.lock
+++ b/devices/harness-device/firmware/dependencies.lock
@@ -70,7 +70,7 @@ dependencies:
idf:
source:
type: idf
- version: 5.5.0
+ version: 5.5.4
waveshare/esp_lcd_touch_cst9217:
component_hash: f755f8e3ae61df23413256a6a447e367a4b844538229c183ff0e89dbbdc15319
dependencies:
diff --git a/devices/harness-device/firmware/main/cable_client.c b/devices/harness-device/firmware/main/cable_client.c
index e7c6a3b30..776cb37cc 100644
--- a/devices/harness-device/firmware/main/cable_client.c
+++ b/devices/harness-device/firmware/main/cable_client.c
@@ -324,6 +324,12 @@ static void send_hello(void)
// Each Lead's face is the chat the desktop has open, and the alerts are the Lead's new messages (handle_supertab_notice;
// design 2026-10-28-round-dial-swarm-chat). A daemon that predates it ignores the field and sends today's frames.
msg_string(&root, "swarmChat", "v1");
+ // A PM and a Buddy side per Swarm (spec 2026-10-29-round-dial-pm-buddy): each Lead's `buddies` and the reader's
+ // Buddy, a face that may be the Buddy chat, its quiet notice, and `supertab.side` back. Older daemons ignore it.
+ msg_string(&root, "swarmBuddy", "v1");
+ // Words for a Swarm chat are always reviewed here (Send or Discard) before they are posted, as everyone in the Swarm
+ // reads them; the daemon refuses any that come unreviewed (docs/device-voice-swarm-chat.md).
+ msg_string(&root, "swarmReview", "v1");
// Which of the two dials this is (board.h) — informational, so a log or a bug report can say. A
// daemon that predates the field ignores it.
msg_string(&root, "hw", board()->name);
@@ -393,6 +399,15 @@ void cable_client_supertab_send(const char *t, const char *tab, const char *lead
send_json(root);
}
+void cable_client_supertab_side(const char *tab, bool buddy)
+{
+ if (!tab || !tab[0] || strlen(tab) >= ID_MAX) return;
+ cJSON *root = msg("supertab.side");
+ msg_string(&root, "tab", tab);
+ msg_string(&root, "side", buddy ? "buddy" : "pm");
+ send_json(root);
+}
+
void cable_client_send_turn(const char *agent_id, const char *text)
{
@@ -943,15 +958,20 @@ static void handle_supertabs(const cJSON *p)
}
static void handle_supertab(const cJSON *p)
{
- static EXT_RAM_BSS_ATTR ht_supertab_t card; // 3.4 KB: too large for the reader task's stack
+ static EXT_RAM_BSS_ATTR ht_supertab_t card; // 6 KB: too large for the reader task's stack
const char *tab = str_of(p, "tab");
if (tab && strlen(tab) >= ID_MAX) tab = ""; // a desk tab id that cannot be held links to nothing
if (!ht_supertab_init(&card, str_of(p, "id"), tab, str_of(p, "name"), 0)) return;
+ // The Swarm's side, from a swarmBuddy daemon (review of #2218): the dial follows it. Anything else is none.
+ const char *side = str_of(p, "side");
+ card.side = !side ? HT_SIDE_NONE : !strcmp(side, "buddy") ? HT_SIDE_BUDDY : !strcmp(side, "pm") ? HT_SIDE_PM : HT_SIDE_NONE;
const cJSON *l = NULL;
cJSON_ArrayForEach(l, cJSON_GetObjectItemCaseSensitive(p, "leads")) {
if (card.lead_n >= HT_SUPERTAB_LEADS_MAX) break;
if (!cJSON_IsObject(l)) continue;
const cJSON *order = cJSON_GetObjectItemCaseSensitive(l, "order"), *since = cJSON_GetObjectItemCaseSensitive(l, "since");
+ const cJSON *buddy = cJSON_GetObjectItemCaseSensitive(l, "buddy");
+ const cJSON *cells = cJSON_IsObject(buddy) ? cJSON_GetObjectItemCaseSensitive(buddy, "cells") : NULL;
ht_lead_in_t in = {
.id = str_of(l, "id"), .project_id = str_of(l, "projectId"), .project = str_of(l, "project"),
.engine = str_of(l, "engine"), .owner = str_of(l, "owner"), .local = str_of(l, "local"), .state = str_of(l, "state"),
@@ -960,6 +980,12 @@ static void handle_supertab(const cJSON *p)
.since = cJSON_IsNumber(since) && since->valuedouble >= 0 ? (since->valuedouble > 2592000 ? 2592000 : (long)since->valuedouble) : -1,
// The chat on the face; absent from a daemon without swarmChat, which reads as the Lead chat.
.chat = str_of(l, "chat"), .chat_id = str_of(l, "chatId"), .chat_name = str_of(l, "chatName"),
+ // The reader's Buddy, from a swarmBuddy daemon while Buddies are on; supertab.c drops a block it cannot draw.
+ .buddies = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(l, "buddies")),
+ .buddy = {.present = cJSON_IsObject(buddy), .chat_id = str_of(buddy, "chatId"), .name = str_of(buddy, "name"),
+ .engine = str_of(buddy, "engine"), .color = str_of(buddy, "color"),
+ .cells = cJSON_IsNumber(cells) && cells->valuedouble >= 0 && cells->valuedouble < 65536 ? (long)cells->valuedouble : -1,
+ .live = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(buddy, "live"))},
};
ht_supertab_lead_add(&card, &in);
}
@@ -982,16 +1008,18 @@ static void handle_supertab_recap(const cJSON *p)
ui_supertab_recap(tab, lead, chat_id ? chat_id : "", none || !text ? "" : text, secs > 4294967295.0 ? 0xFFFFFFFFu : (uint32_t)secs, none);
}
// `supertab.notice` {tab, lead, chat, chatId, id, text, at}: the Lead's new message in its Lead conversation or Chat with
-// PM, the one thing that alerts with a swarmChat daemon. The daemon sends each once; the UI decides the beep.
+// PM, the one thing that alerts with a swarmChat daemon, or the Buddy's in its chat (chat "buddy", a quiet one). The daemon
+// sends each once; the UI decides the beep.
static void handle_supertab_notice(const cJSON *p)
{
const char *tab = str_of(p, "tab"), *lead = str_of(p, "lead"), *chat = str_of(p, "chat"), *chat_id = str_of(p, "chatId");
const char *id = str_of(p, "id"), *text = str_of(p, "text");
if (!id_fits(tab) || !id_fits(lead) || !id_fits(chat_id) || !id_fits(id) || !text || !chat) return;
- if (strcmp(chat, "lead") && strcmp(chat, "pm")) return; // groups never alert
+ if (strcmp(chat, "lead") && strcmp(chat, "pm") && strcmp(chat, "buddy")) return; // groups never alert
const cJSON *at = cJSON_GetObjectItemCaseSensitive(p, "at");
const double secs = cJSON_IsNumber(at) && at->valuedouble > 0 ? at->valuedouble : 0;
- if (ui_supertab_notice(tab, lead, strcmp(chat, "pm") ? HT_CHAT_LEAD : HT_CHAT_PM, chat_id, text,
+ ht_chat_kind_t kind = !strcmp(chat, "pm") ? HT_CHAT_PM : !strcmp(chat, "buddy") ? HT_CHAT_BUDDY : HT_CHAT_LEAD;
+ if (ui_supertab_notice(tab, lead, kind, chat_id, text,
secs > 4294967295.0 ? 0xFFFFFFFFu : (uint32_t)secs))
audio_notify_done();
}
diff --git a/devices/harness-device/firmware/main/cable_client.h b/devices/harness-device/firmware/main/cable_client.h
index 25a9c4e38..63dfa7b51 100644
--- a/devices/harness-device/firmware/main/cable_client.h
+++ b/devices/harness-device/firmware/main/cable_client.h
@@ -233,6 +233,9 @@ void cable_client_list_swarms(void);
// A Lead id is not an agent id: it never goes into focus, agent.open or voice.begin. Only its `local` harness id does.
// `t` is one of the three requests; `lead` is "" only for an open (the dial left the Swarm).
void cable_client_supertab_send(const char *t, const char *tab, const char *lead);
+// `supertab.side` {tab, side}: the dial swiped that Swarm to its Buddy side (true) or its PM side (spec
+// 2026-10-29-round-dial-pm-buddy). A tab id it cannot hold sends nothing.
+void cable_client_supertab_side(const char *tab, bool buddy);
// Send what the user asked for, into `agent_id`. Fire-and-forget: everything after this arrives back as
// `turn.started` / `turn.done`, or as `turn.error` in words a person can act on.
diff --git a/devices/harness-device/firmware/main/cable_features.c b/devices/harness-device/firmware/main/cable_features.c
index a977d52bb..3c9873a1b 100644
--- a/devices/harness-device/firmware/main/cable_features.c
+++ b/devices/harness-device/firmware/main/cable_features.c
@@ -11,7 +11,7 @@ uint32_t cable_features_parse(const cJSON *welcome)
{"visit", CABLE_FEATURE_VISIT}, {"voice.draft", CABLE_FEATURE_DRAFT},
{"question.review", CABLE_FEATURE_QUESTIONS},
{"agents.refresh", CABLE_FEATURE_AGENTS_REFRESH},
- {"settings", CABLE_FEATURE_SETTINGS},
+ {"settings", CABLE_FEATURE_SETTINGS}, {"swarm.review", CABLE_FEATURE_SWARM_REVIEW},
};
uint32_t result = 0;
const cJSON *item;
diff --git a/devices/harness-device/firmware/main/cable_features.h b/devices/harness-device/firmware/main/cable_features.h
index e5dcde734..5adf033d1 100644
--- a/devices/harness-device/firmware/main/cable_features.h
+++ b/devices/harness-device/firmware/main/cable_features.h
@@ -13,6 +13,9 @@ enum {
// device that does not see it keeps its own settings screens; nothing here is load-bearing for a
// session, so an older daemon simply never asks.
CABLE_FEATURE_SETTINGS = 1u << 6,
+ // Words reviewed on a Swarm face are posted in its chat by Send. Without it a reviewed draft would be typed into the
+ // Lead's terminal, so a Swarm face never asks an older daemon for review.
+ CABLE_FEATURE_SWARM_REVIEW = 1u << 7,
};
// Optional welcome field. Older daemons omit it and retain the core voice,
diff --git a/devices/harness-device/firmware/main/ui/habitat/supertab.c b/devices/harness-device/firmware/main/ui/habitat/supertab.c
index 0ea21deb2..b3bb577e7 100644
--- a/devices/harness-device/firmware/main/ui/habitat/supertab.c
+++ b/devices/harness-device/firmware/main/ui/habitat/supertab.c
@@ -20,6 +20,20 @@ static bool put_id(char *dst, const char *src, bool required)
put_text(dst, ID_MAX, src);
return true;
}
+// "#rrggbb", either case, as 0xRRGGBB; false for anything else.
+static bool hex_color(const char *s, uint32_t *out)
+{
+ if (!s || s[0] != '#' || strlen(s) != 7) return false;
+ uint32_t v = 0;
+ for (int i = 1; i < 7; i++) {
+ char c = s[i];
+ int d = c >= '0' && c <= '9' ? c - '0' : c >= 'a' && c <= 'f' ? c - 'a' + 10 : c >= 'A' && c <= 'F' ? c - 'A' + 10 : -1;
+ if (d < 0) return false;
+ v = v << 4 | (uint32_t)d;
+ }
+ *out = v;
+ return true;
+}
static bool asking(ht_lead_state_t s)
{
return s == HT_LEAD_ASK || s == HT_LEAD_STUCK;
@@ -60,10 +74,24 @@ bool ht_supertab_lead_add(ht_supertab_t *t, const ht_lead_in_t *in)
// The chat on the face. One this dial cannot name (an unknown kind, an id it cannot hold) is the Lead chat with no
// id: the Lead stays, and no chat's recap is taken for it.
const char *c = in->chat ? in->chat : "";
- l->chat = !strcmp(c, "group") ? HT_CHAT_GROUP : !strcmp(c, "pm") ? HT_CHAT_PM : HT_CHAT_LEAD;
- bool named = (!strcmp(c, "group") || !strcmp(c, "pm") || !strcmp(c, "lead")) && put_id(l->chat_id, in->chat_id, true);
+ l->chat = !strcmp(c, "group") ? HT_CHAT_GROUP : !strcmp(c, "pm") ? HT_CHAT_PM : !strcmp(c, "buddy") ? HT_CHAT_BUDDY : HT_CHAT_LEAD;
+ bool named = (!strcmp(c, "group") || !strcmp(c, "pm") || !strcmp(c, "lead") || !strcmp(c, "buddy")) &&
+ put_id(l->chat_id, in->chat_id, true);
if (named) put_text(l->chat_name, sizeof l->chat_name, in->chat_name);
else { l->chat = HT_CHAT_LEAD; l->chat_id[0] = 0; l->chat_name[0] = 0; }
+ // The reader's Buddy, only while Buddies are on. One the dial cannot draw is no Buddy; the Lead stays.
+ l->buddies = in->buddies;
+ const ht_buddy_in_t *b = &in->buddy;
+ uint32_t color = 0;
+ if (in->buddies && b->present && b->cells >= 0 && b->cells <= 0x7fff && hex_color(b->color, &color) &&
+ put_id(l->buddy.chat_id, b->chat_id, true)) {
+ l->buddy.has = true;
+ l->buddy.live = b->live;
+ l->buddy.cells = (uint16_t)b->cells;
+ l->buddy.color = color;
+ put_text(l->buddy.name, sizeof l->buddy.name, b->name);
+ put_text(l->buddy.engine, sizeof l->buddy.engine, b->engine);
+ } else memset(&l->buddy, 0, sizeof l->buddy);
t->lead_n++;
return true;
}
@@ -168,6 +196,17 @@ int ht_supertabs_put(ht_supertabs_t *s, const ht_supertab_t *in, uint32_t now_ms
void ht_supertabs_recap_open(ht_supertabs_t *s, const char *tab, const char *lead, uint32_t now_ms)
{
bool open = lead && *lead && tab && *tab;
+ // The Lead already on the face keeps what it shows until a new recap replaces it: emptying it left the resting pet
+ // for the 5 s retry on every reopen (Diego, 2026-10-29). Only while the face's chat is still the one it was for.
+ // A kept recap is not LOADING, so its refresh has no 5 s retry: one lost on the way waits for the next push.
+ if (open && (s->recap.state == HT_RECAP_LOADED || s->recap.state == HT_RECAP_EMPTY) && !strcmp(s->recap.tab, tab) && !strcmp(s->recap.lead, lead)) {
+ const ht_supertab_t *t = ht_supertabs_find(s, tab);
+ for (int i = 0; t && i < t->lead_n; i++)
+ if (!strcmp(t->leads[i].id, lead) && !strcmp(t->leads[i].chat_id, s->recap.chat_id)) {
+ s->recap.asked_ms = now_ms;
+ return;
+ }
+ }
put_text(s->recap.tab, sizeof s->recap.tab, open ? tab : "");
put_text(s->recap.lead, sizeof s->recap.lead, open ? lead : "");
s->recap.chat_id[0] = 0;
diff --git a/devices/harness-device/firmware/main/ui/habitat/supertab.h b/devices/harness-device/firmware/main/ui/habitat/supertab.h
index 0a6019aec..d5101333c 100644
--- a/devices/harness-device/firmware/main/ui/habitat/supertab.h
+++ b/devices/harness-device/firmware/main/ui/habitat/supertab.h
@@ -12,8 +12,9 @@
enum { HT_SUPERTABS_MAX = 16, HT_SUPERTAB_LEADS_MAX = 12, HT_SUPERTAB_NAME = 49, HT_SUPERTAB_TEXT = 1501 };
typedef enum { HT_LEAD_DONE, HT_LEAD_WORK, HT_LEAD_ASK, HT_LEAD_STUCK } ht_lead_state_t;
// The chat on a Lead's face (design 2026-10-28-round-dial-swarm-chat): its project's Lead conversation, the reader's Chat
-// with PM, or a group. A daemon without `swarmChat` sends none, which reads as the Lead chat with no id.
-typedef enum { HT_CHAT_LEAD, HT_CHAT_PM, HT_CHAT_GROUP } ht_chat_kind_t;
+// with PM, a group, or the reader's own Buddy chat (spec 2026-10-29-round-dial-pm-buddy, a swarmBuddy daemon only). A
+// daemon without `swarmChat` sends none, which reads as the Lead chat with no id.
+typedef enum { HT_CHAT_LEAD, HT_CHAT_PM, HT_CHAT_GROUP, HT_CHAT_BUDDY } ht_chat_kind_t;
typedef struct {
char id[ID_MAX], project_id[ID_MAX], project[HT_SUPERTAB_NAME], engine[12], owner[HT_SUPERTAB_NAME], local[ID_MAX];
ht_lead_state_t state;
@@ -22,10 +23,17 @@ typedef struct {
uint32_t since_at_ms; // the dial's clock when since_s arrived
ht_chat_kind_t chat;
char chat_id[ID_MAX], chat_name[HT_SUPERTAB_NAME]; // "" from a daemon without swarmChat
+ // The Swarm has Buddies on, and the reader's own Buddy in this project: its chat, name, engine, the 15 half bits of
+ // Desktop's avatar pattern (bit i = half cell i) and its colour 0xRRGGBB. `live` false while the Buddy is down.
+ bool buddies;
+ struct { bool has, live; char chat_id[ID_MAX], name[HT_SUPERTAB_NAME], engine[16]; uint16_t cells; uint32_t color; } buddy;
} ht_lead_t;
+// The side a swarmBuddy daemon says the Swarm is on (its cards' side, which the dial follows); NONE from an older daemon.
+typedef enum { HT_SIDE_NONE, HT_SIDE_PM, HT_SIDE_BUDDY } ht_side_t;
typedef struct {
char id[ID_MAX], tab[ID_MAX], name[HT_SUPERTAB_NAME];
uint16_t count; // the Swarm's real project count; at most 12 Leads come
+ ht_side_t side;
uint8_t lead_n;
ht_lead_t leads[HT_SUPERTAB_LEADS_MAX];
} ht_supertab_t;
@@ -43,7 +51,10 @@ typedef enum { HT_LEAD_RAISED_ASK, HT_LEAD_RAISED_STUCK, HT_LEAD_CLEARED } ht_le
typedef struct { ht_lead_event_kind_t kind; char tab[ID_MAX], lead[ID_MAX]; } ht_lead_event_t;
// One Lead of a frame, as read off the wire. NULL strings are absent fields.
-typedef struct { const char *id, *project_id, *project, *engine, *owner, *local, *state; int order; long since; const char *chat, *chat_id, *chat_name; } ht_lead_in_t;
+// `color` is "#rrggbb"; a block that does not read (no chat id, a bad colour, cells past 15 bits) is dropped, not the Lead.
+typedef struct { bool present, live; const char *chat_id, *name, *engine, *color; long cells; } ht_buddy_in_t;
+typedef struct { const char *id, *project_id, *project, *engine, *owner, *local, *state; int order; long since; const char *chat, *chat_id, *chat_name;
+ bool buddies; ht_buddy_in_t buddy; } ht_lead_in_t;
// false: an empty or overlong id or tab. Names are cut on a UTF-8 boundary.
bool ht_supertab_init(ht_supertab_t *, const char *id, const char *tab, const char *name, int count);
// false: the Lead is malformed or repeats an id (skipped, not the frame), or the record already holds 12.
diff --git a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
index 483198412..fad1e5d0b 100644
--- a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
+++ b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
@@ -231,7 +231,7 @@ static EXT_RAM_BSS_ATTR struct {
int brightness;
uint32_t voice_started;
bool voice_open, voice_start_pending, voice_waiting, voice_carry;
- bool voice_review, voice_review_preview, voice_draft_append, voice_search;
+ bool voice_review, voice_review_preview, voice_draft_append, voice_search, voice_swarm;
uint32_t voice_draft_revision;
int draft_drag;
uint32_t voice_generation, voice_question_revision;
@@ -588,7 +588,7 @@ static int workspace_index(const char *id)
* where the dial is in it. A Lead id is not an agent id: it reaches the cable only in supertab.* requests (A_SUPERTAB),
* never in focus, agent.open or voice.begin. Voice goes to the Lead's `local` harness id.
*/
-enum { SUPERTAB_RECAP_GET, SUPERTAB_OPEN, SUPERTAB_SELECT };
+enum { SUPERTAB_RECAP_GET, SUPERTAB_OPEN, SUPERTAB_SELECT, SUPERTAB_SIDE }; // SIDE: id "buddy" or "pm"
#define SWARM_WAITS 16
#define SWARM_SAID 24 // one per inbox entry the Lead messages can fill (NOTICES)
static EXT_RAM_BSS_ATTR ht_supertabs_t swarm;
@@ -599,10 +599,21 @@ static EXT_RAM_BSS_ATTR struct {
bool retried; // its recap was asked for a second time
struct { char tab[ID_MAX], lead[ID_MAX]; } focus[HT_SUPERTABS_MAX]; // the Lead the desktop last showed, per Swarm
char pending[ID_MAX]; // a Swarm the desktop opened before its `swarms` frame said so (ui_supertab_focus)
+ // The Swarm and Lead an emptied list took off the face, not the person, and when: it comes back if the Swarm does.
+ struct { char tab[ID_MAX], lead[ID_MAX]; uint32_t at; } lost;
+ bool auto_tabs; // TABS opened by the dial itself, not touched since: it browses no desk tab
// Super Tab waits from this machine's harnesses, shown only through the Lead whose `local` names the harness.
struct { char agent[ID_MAX], request[80], swarm[HT_SUPERTAB_NAME], text[240]; bool stuck, shown; } waits[SWARM_WAITS];
// The chat each Lead's message entry (`swarm` 3) came from, so `supertab.notice.read` removes only that one.
struct { char lead[ID_MAX], chat[ID_MAX]; } said[SWARM_SAID];
+ // The side each Swarm is on (spec 2026-10-29-round-dial-pm-buddy): its PM's or the reader's Buddy's, kept across its
+ // projects. A swipe sets it, and so does the daemon when a face turns to or from its Buddy chat (newest wins).
+ struct { char tab[ID_MAX]; bool buddy; } side[HT_SUPERTABS_MAX];
+ // A Buddy's word not yet seen on the dial, per Lead, and the chat it came in: the PM side's quiet badge.
+ struct { char lead[ID_MAX], chat[ID_MAX]; } heard[SWARM_SAID];
+ // The voice turn on the face was started on the Buddy side: its ring and "Sending to your Buddy", pinned at the start as
+ // its chat and engine are, so a side change while it records or sends never says another chat (batch check, #2207).
+ bool voice_buddy;
} sw;
static bool swarm_mode(void)
{
@@ -649,6 +660,65 @@ static void swarm_send(int op, const char *tab, const char *lead)
COPY(a.text, tab); COPY(a.id, lead);
queue(a);
}
+static int swarm_side_slot(const char *tab, bool make)
+{
+ for (int i = 0; tab && i < HT_SUPERTABS_MAX; i++) if (sw.side[i].tab[0] && !strcmp(sw.side[i].tab, tab)) return i;
+ if (!make) return -1;
+ for (int i = 0; i < HT_SUPERTABS_MAX; i++) if (!sw.side[i].tab[0] || !ht_supertabs_find(&swarm, sw.side[i].tab)) return i;
+ return 0; // ponytail: sixteen Swarms is the most the dial holds; a seventeenth takes the first slot
+}
+static bool swarm_side_buddy(const char *tab)
+{
+ int i = swarm_side_slot(tab, false);
+ return i >= 0 && sw.side[i].buddy;
+}
+static void swarm_side_put(const char *tab, bool buddy)
+{
+ int i = swarm_side_slot(tab, true);
+ COPY(sw.side[i].tab, tab); sw.side[i].buddy = buddy;
+}
+static void swarm_side_send(const char *tab)
+{
+ swarm_send(SUPERTAB_SIDE, tab, swarm_side_buddy(tab) ? "buddy" : "pm");
+}
+// The face shows the Buddy side: the Swarm on the face has Buddies on and is on that side.
+static bool swarm_on_buddy(const ht_lead_t *l)
+{
+ return l && l->buddies && swarm_mode() && swarm_side_buddy(sw.tab);
+}
+// Whose engine a voice turn to the face's Lead listens with: the Buddy's on its side.
+static const char *swarm_voice_engine(const ht_lead_t *l)
+{
+ return swarm_on_buddy(l) && l->buddy.has ? l->buddy.engine : l->engine;
+}
+static int swarm_heard_of(const char *lead)
+{
+ for (int i = 0; lead && i < SWARM_SAID; i++) if (sw.heard[i].lead[0] && !strcmp(sw.heard[i].lead, lead)) return i;
+ return -1;
+}
+// Showing the Buddy side reads its quiet badge.
+static void swarm_buddy_seen(void)
+{
+ const ht_lead_t *l = swarm_lead();
+ int i = swarm_on_buddy(l) ? swarm_heard_of(l->id) : -1;
+ if (i >= 0) sw.heard[i].lead[0] = 0;
+}
+// Swipe up opens the Buddy side, down the PM side again (spec 2026-10-29 Switching); true when the swipe was the side's.
+// Down on the PM side is not: it still pulls the inbox. Without Buddies neither is.
+static bool swarm_side_swipe(int dy)
+{
+ const ht_lead_t *l = swarm_lead();
+ if (!l || !l->buddies || !s.connected) return false;
+ bool buddy = swarm_side_buddy(sw.tab), up = dy < 0;
+ if (!up && !buddy) return false;
+ if (up != buddy) {
+ swarm_side_put(sw.tab, up);
+ swarm_side_send(sw.tab);
+ swarm_buddy_seen();
+ change();
+ }
+ return true;
+}
// The Lead at `i` comes onto the face: its recap is asked for afresh. `select` moves the desktop there too; a
// supertab.focus does not need it, the desktop is already there.
static void swarm_show(const ht_supertab_t *t, int i, bool select)
@@ -660,7 +730,12 @@ static void swarm_show(const ht_supertab_t *t, int i, bool select)
}
COPY(sw.lead, t->leads[i].id); sw.at = i; sw.retried = false;
ht_supertabs_recap_open(&swarm, t->id, sw.lead, ms());
- if (select) swarm_send(SUPERTAB_SELECT, t->id, sw.lead);
+ if (select) {
+ swarm_send(SUPERTAB_SELECT, t->id, sw.lead);
+ // The person moved here on the dial, which is newer than the desktop: the Swarm keeps the side the dial is on.
+ if (t->leads[i].buddies) swarm_side_send(t->id);
+ }
+ swarm_buddy_seen();
swarm_send(SUPERTAB_OPEN, t->id, sw.lead);
swarm_send(SUPERTAB_RECAP_GET, t->id, sw.lead);
change();
@@ -736,6 +811,7 @@ static int tab_index_here(void)
}
static void tabs_open(void)
{
+ sw.auto_tabs = false;
view(TABS);
if (s.view != TABS) return;
ht_tab_carousel_reset(&tab_carousel, tabs_total(), tab_index_here());
@@ -771,6 +847,8 @@ static void tab_request(const char *id, bool browsing)
static void tabs_sync(void)
{
if (s.view!=TABS || (s.touch_down && s.touch_cancelled)) return;
+ // The list moving under a TABS nobody asked for switched the desktop's tab by itself (Diego, 2026-10-29).
+ if (sw.auto_tabs) return;
int index=ht_tab_carousel_index(&tab_carousel);
// A Swarm's page waits for Done: it is entered with no workspace handshake.
if (index>=0 && index<s.tab_count && !tab_swarm(index)) tab_request(s.tabs[index].id,true);
@@ -1165,7 +1243,7 @@ static void surface_tick(uint32_t now)
change();
}
if (home_caption_tick(now)) change();
- // A recap lost on the way is asked for once more after 5 s; the daemon ignores a repeat within 1 s.
+ // A recap lost on the way is asked for once more after 5 s; the daemon answers a repeat within 1 s from its first read.
if (swarm_mode() && swarm.recap.state == HT_RECAP_LOADING && !sw.retried &&
(int32_t)(now - swarm.recap.asked_ms) >= 5000) {
sw.retried = true;
@@ -1185,6 +1263,7 @@ static void surface_tick(uint32_t now)
visible && s.view == VOICE && s.voice_open && !s.voice_search &&
!s.voice_waiting && !s.voice_start_pending && audio_client_recording() &&
(s.voice_return == HOME || s.voice_return == AGENT || s.voice_return == SELECTION) &&
+ (!s.voice_swarm || cable_client_supports(CABLE_FEATURE_SWARM_REVIEW)) &&
s.touch_down && !s.touch_cancelled && gesture.live && !gesture.moved && !gesture.guarded &&
pressed_action.kind == A_PET && held >= 650 && held <= 1800;
if (review_preview != s.voice_review_preview) { s.voice_review_preview = review_preview; change(); }
@@ -1284,6 +1363,69 @@ static void focus_bell(ht_scene_t *f, unsigned count, int bell_y)
ht_text(f, x + BELL_PAD_H + bw + BELL_GAP, bell_y + (h - cf->height) / 2, cw, cf, ink, blue, text);
}
static void render_focus_panes(ht_scene_t *f);
+/*
+ * THE BUDDY SIDE (spec 2026-10-29-round-dial-pm-buddy, mockup option A): the lilac ring at the glass edge, the Buddy's
+ * avatar where the pet stands, and the two dots at the right edge, which every face of a Swarm with Buddies carries.
+ * Colours are mixed over the black glass.
+ */
+#define BUDDY_LILAC 0xc49bffu
+static unsigned mix_black(unsigned rgb, unsigned pct)
+{
+ unsigned out = 0;
+ for (int k = 0; k < 24; k += 8) out |= (((rgb >> k & 255u) * pct + 50) / 100) << k;
+ return out;
+}
+static void face_buddy_disc(ht_scene_t *f, int cx, int cy, int d, unsigned rgb)
+{
+ ht_box(f, cx - d / 2, cy - d / 2, d, d, d / 2, color(rgb), color(rgb));
+}
+static void face_buddy_ring(ht_scene_t *f)
+{
+ ht_ring_arc(f, 233 * 16, 233 * 16, 230 * 16, 3 * 16, 90, 180, color(mix_black(BUDDY_LILAC, 32)));
+}
+// The upper dot lit on the PM side, the lower one (lilac) on the Buddy side.
+static void face_buddy_dots(ht_scene_t *f, bool buddy)
+{
+ face_buddy_disc(f, 442, 218, buddy ? 9 : 12, buddy ? 0x55565fu : 0xeaeaf0u);
+ face_buddy_disc(f, 442, 248, buddy ? 12 : 9, buddy ? BUDDY_LILAC : 0x55565fu);
+}
+/*
+ * Desktop's agent pattern (avatar_art.dart superTabAgentPattern; the daemon sends its 15 half bits and colour): mirrored on
+ * 5 x 5 cells of 10 px, each with its corner pixels cut for the rounding, as one 50 px sprite. Two frames in turn:
+ * ht_damage compares a sprite by its cells, so a new pattern goes into the frame the last scene did not use.
+ */
+static const ht_cell_frame_t *face_buddy_avatar(uint16_t bits, uint32_t rgb)
+{
+ static EXT_RAM_BSS_ATTR struct { uint8_t cells[50 * 50]; uint16_t palette[2]; ht_cell_frame_t frame; uint16_t bits; uint32_t rgb; bool made; } art[2];
+ static int last;
+ static const int mirror[5] = {0, 1, 2, 1, 0};
+ if (!(bits & 0x7fff)) bits = 1u << 7; // as Desktop: never an empty pattern
+ for (int k = 0; k < 2; k++) if (art[k].made && art[k].bits == bits && art[k].rgb == rgb) return &art[last = k].frame;
+ int k = last = !last;
+ for (int y = 0; y < 50; y++) for (int x = 0; x < 50; x++) {
+ int px = x % 10, py = y % 10;
+ bool on = (bits >> ((y / 10) * 3 + mirror[x / 10])) & 1, corner = (px == 0 || px == 9) && (py == 0 || py == 9);
+ art[k].cells[y * 50 + x] = on && !corner;
+ }
+ uint16_t c = color(rgb);
+ art[k].palette[0] = 0; art[k].palette[1] = (uint16_t)(c << 8 | c >> 8); // panel order
+ art[k].frame = (ht_cell_frame_t){.cols = 50, .rows = 50, .cell = 1, .palette = art[k].palette, .cells = art[k].cells};
+ art[k].bits = bits; art[k].rgb = rgb; art[k].made = true;
+ return &art[k].frame;
+}
+// The Buddy side of a project with no Buddy: a dashed circle with "+", and where to add one. Nothing here talks.
+static void render_buddy_empty(ht_scene_t *f, const ht_lead_t *l)
+{
+ ht_arc_title_face(f, FG, l->project[0] ? l->project : "Untitled", &ht_arc_inter_prop);
+ for (int k = 0; k < 12; k++) ht_ring_arc(f, 233 * 16, 168 * 16, 44 * 16, 3 * 16, k * 30, 7, color(0x3a3b44));
+ const ht_font_t *plus = &ht_lv_inter_44.base;
+ focus_put(f, 63, 168 - plus->height / 2, 340, plus, color(0x55565f), BG, "+", true);
+ focus_put(f, 63, 238, 340, &ht_lv_inter_28.base, color(0x8a8a99), BG, "No Buddy here yet", true);
+ focus_put(f, 63, 280, 340, &ht_lv_inter_20.base, color(0x6b6d78), BG, "Add one in the Harness app.", true);
+ face_buddy_ring(f);
+ face_buddy_dots(f, true);
+ s.hits[s.hit_count++] = (hit_t){{83, 0, 300, 66}, A_AGENTS, 0, true};
+}
/*
* A SWARM PANE'S FACE (spec §4): the agent face, built from the Lead. The project on the upper arc; working: the pet
* and the time since `since` (none for a remote Lead); asking or stuck: the asking pose and, in the recap's place, the
@@ -1294,13 +1436,17 @@ static void render_swarm_face(ht_scene_t *f)
{
const ht_lead_t *l = swarm_lead();
if (!l) { render_focus_panes(f); return; }
+ // The Buddy side: the Buddy's chat on the face, never working (spec 2026-10-29-round-dial-pm-buddy).
+ bool buddy = swarm_on_buddy(l);
+ if (buddy && !l->buddy.has) { render_buddy_empty(f, l); return; }
const char *wait = swarm_wait_text(l);
bool asking = l->state == HT_LEAD_ASK || l->state == HT_LEAD_STUCK || wait;
- bool working = l->state == HT_LEAD_WORK && !wait;
+ bool working = l->state == HT_LEAD_WORK && !wait && !buddy;
// A swarmChat daemon's recap is that of the chat on the face: one read for a chat the desktop has since left is not
// shown (design 2026-10-28-round-dial-swarm-chat §3). An older daemon names no chat on either side.
const char *recap = wait ? wait : !working && swarm.recap.state == HT_RECAP_LOADED &&
- !strcmp(swarm.recap.lead, l->id) && !strcmp(swarm.recap.chat_id, l->chat_id) && !s.nap ? swarm.recap.text : NULL;
+ !strcmp(swarm.recap.lead, l->id) && !strcmp(swarm.recap.chat_id, l->chat_id) && (l->chat == HT_CHAT_BUDDY) == buddy &&
+ !s.nap ? swarm.recap.text : NULL;
uint32_t since_ms = working && l->since_s >= 0 ? (uint32_t)l->since_s * 1000u + (ms() - l->since_at_ms) : 0;
uint32_t since = since_ms / 1000;
s.timer_at = 0;
@@ -1316,8 +1462,8 @@ static void render_swarm_face(ht_scene_t *f)
s.bell_unread = unread;
const ht_supertab_t *t = swarm_here();
ht_character_face_t f_ = {.recipient = l->project[0] ? l->project : "Untitled", .status = "", .hint = "",
- .tab = t ? t->name : "", .engine = l->engine, .activity = working && !s.nap ? "Working" : "",
- .chat = l->chat != HT_CHAT_LEAD ? l->chat_name : NULL,
+ .tab = t ? t->name : "", .engine = buddy ? "" : l->engine, .activity = working && !s.nap ? "Working" : "",
+ .chat = !buddy && l->chat != HT_CHAT_LEAD && l->chat != HT_CHAT_BUDDY ? l->chat_name : NULL,
.elapsed = since, .detail = "", .mood = character_mood(), .pose = character.motion.reaction.pose,
.asking = asking,
.clock_ms = (s.quiet || display_is_asleep()) ? 0 : clock,
@@ -1339,6 +1485,29 @@ static void render_swarm_face(ht_scene_t *f)
if (focus_face) focus_bell(f, unread, bell_y);
else ht_notification_bell(f, unread, f_.ink);
}
+ if (buddy) {
+ // The avatar stands where the pet does on Focus, at 233, 158 or higher: 8 px clear of the recap's card, which keeps
+ // today's place (it rises with its lines). A creature skin keeps its creature.
+ if (focus_face) {
+ int cy = 158;
+ for (int i = 0; i < f->count; i++)
+ if (f->runs[i].box.h && f->runs[i].w >= 300 && f->runs[i].y - 8 - 46 < cy) cy = f->runs[i].y - 8 - 46;
+ face_buddy_disc(f, 233, cy, 92, mix_black(l->buddy.color, 16));
+ ht_cell_sprite(f, 208, cy - 25, face_buddy_avatar(l->buddy.cells, l->buddy.color));
+ }
+ face_buddy_ring(f);
+ }
+ if (l->buddies) {
+ // The PM side's quiet badge for the Buddy's word: on the lower dot, and a line on the lower arc unless the bell or
+ // the face has it. Empty runs in their place otherwise, so the count never moves.
+ face_buddy_dots(f, buddy);
+ bool heard = !buddy && swarm_heard_of(l->id) >= 0, lower = bell && !told;
+ for (int i = 0; i < f->count; i++) lower |= f->runs[i].arc == 2 && f->runs[i].text[0];
+ if (heard) { face_buddy_disc(f, 449, 241, 14, 0x000000u); face_buddy_disc(f, 449, 241, 10, BUDDY_LILAC); }
+ else { ht_box(f, 0, 0, 1, 1, 0, BG, BG); ht_box(f, 0, 0, 1, 1, 0, BG, BG); }
+ if (heard && !lower) ht_arc_status_face(f, color(BUDDY_LILAC), "Your Buddy replied", &ht_arc_inter_lower);
+ else ht_text(f, 0, 0, 1, &ht_lv_inter_20.base, BG, BG, "");
+ }
// The same targets as a pane's face: the name opens PANES, the bell the inbox, the rest talks (to a local Lead).
s.hits[s.hit_count++] = (hit_t){{83, 0, 300, 66}, A_AGENTS, 0, true};
for (int i = 0; i < f->count; i++) if (f->runs[i].arc == 1) {
@@ -2205,6 +2374,13 @@ static void render_voice(ht_scene_t *f)
.carrying = s.voice_carry, .voice = true};
f_.focus = f_.detail && *f_.detail;
ht_character_face(f, &character, &f_, ACCENT, NULL);
+ // Speaking to the Buddy side: the ring stays, and sending says to whom (spec 2026-10-29 Voice). The turn's side, not the
+ // Swarm's now: the words go where the turn started.
+ if (sw.voice_buddy) {
+ face_buddy_ring(f);
+ if (s.voice_waiting) ht_arc_status_face(f, color(BUDDY_LILAC), "Sending to your Buddy", &ht_arc_inter_lower);
+ else ht_text(f, 0, 0, 1, &ht_lv_inter_20.base, BG, BG, "");
+ }
s.pet_next_ms = character.id == HT_CHARACTER_FOCUS ? ht_focus_pet_next_ms(&f_, NULL) : 0;
s.status_phase = status_animated() ? ht_shimmer_phase(ms() * status_speed()) : 0;
for (int i = 0; i < f->count; i++)
@@ -2921,6 +3097,7 @@ static void dispatch(action_t a)
s.voice_return = s.view;
int target = find(a.id);
const ht_lead_t *lead = voice_lead(a.id, a.value);
+ s.voice_swarm = lead != NULL;
if (lead) target = -1;
if (a.value == 2) snprintf(s.voice_target, sizeof s.voice_target, "Find %.48s",
!strcmp(form.page.title, "Find Harness") ? "Harness" :
@@ -2928,7 +3105,8 @@ static void dispatch(action_t a)
else if (a.value == 7) COPY(s.voice_target, "Find in output");
else if (a.value == 5 || a.value == 6) COPY(s.voice_target, draft.page.name);
else COPY(s.voice_target, lead ? lead->project : target >= 0 ? s.agents[target].name : "harness");
- COPY(s.voice_engine, lead ? lead->engine : target >= 0 && a.value != 2 && a.value != 5 && a.value != 6 && a.value != 7 ?
+ sw.voice_buddy = lead && swarm_on_buddy(lead) && lead->buddy.has;
+ COPY(s.voice_engine, lead ? swarm_voice_engine(lead) : target >= 0 && a.value != 2 && a.value != 5 && a.value != 6 && a.value != 7 ?
s.agents[target].engine : "");
s.voice_started = ms();
view(VOICE);
@@ -2937,7 +3115,10 @@ static void dispatch(action_t a)
break;
case A_VOICE_STOP:
if (s.voice_open && !s.voice_start_pending && !s.voice_waiting && audio_client_recording()) {
- if (a.value == 1 && cable_client_supports(CABLE_FEATURE_DRAFT) && !s.voice_search && (s.voice_return == HOME || s.voice_return == AGENT || s.voice_return == SELECTION)) {
+ // Words for a Swarm chat are always reviewed, by a daemon that posts the draft there; an older one would type
+ // it into the Lead's terminal, so a Swarm face is never held to review with it.
+ bool swarm_review = cable_client_supports(CABLE_FEATURE_DRAFT | CABLE_FEATURE_SWARM_REVIEW);
+ if (s.voice_swarm ? swarm_review : a.value == 1 && cable_client_supports(CABLE_FEATURE_DRAFT) && !s.voice_search && (s.voice_return == HOME || s.voice_return == AGENT || s.voice_return == SELECTION)) {
s.voice_review = true; audio_client_request_review();
}
audio_client_stop();
@@ -3161,6 +3342,7 @@ static void worker(void *unused)
case A_SUPERTAB: {
static const char *ops[] = {"supertab.recap.get", "supertab.open", "supertab.select"};
if (a.value >= SUPERTAB_RECAP_GET && a.value <= SUPERTAB_SELECT) cable_client_supertab_send(ops[a.value], a.text, a.id);
+ else if (a.value == SUPERTAB_SIDE) cable_client_supertab_side(a.text, !strcmp(a.id, "buddy"));
break;
}
case A_NOTICE_READ:
@@ -3301,6 +3483,7 @@ void habitat_touch(bool down, int x, int y, uint32_t now)
}
surface = s.view == HOME || s.view == AGENT;
if (down && !s.touch_down) {
+ sw.auto_tabs = false; sw.lost.tab[0] = 0; // the person's TABS from here on, and no Swarm comes back over it
s.touch_cancelled = false;
s.touch_brake = s.coasting && (int32_t)(now - s.coast_until) < 0;
s.coasting = false;
@@ -3513,6 +3696,8 @@ void habitat_touch(bool down, int x, int y, uint32_t now)
// Reading/choosing consumed this contact; motion cannot submit an answer.
} else if (s.view == SELECTION) {
// Its bounded reading cursor already consumed this vertical drag.
+ } else if (surface && swarm_mode() && swarm_side_swipe(dy)) {
+ // A Swarm project's PM side and Buddy side (spec 2026-10-29-round-dial-pm-buddy): up and back down.
} else if (surface && character.id == HT_CHARACTER_FOCUS && dy > 0 && notice_unread(face_id())) {
// Pull down from the badge. The creature skins keep this drag inert — their footer
// badge is a target you tap — but on Focus the badge sits at the top edge and a pull
@@ -3553,8 +3738,9 @@ void habitat_touch(bool down, int x, int y, uint32_t now)
s.offset = (s.offset + (dx < 0 ? 1 : s.notice_count - 1)) % s.notice_count;
else if (surface && swarm_here() && swarm_here()->lead_n && s.connected) {
// A Swarm's next or previous project, by `order`, wrapping as the panes do (never `focus`).
- int n = swarm_here()->lead_n;
- swarm_show(swarm_here(), (sw.at + (dx < 0 ? 1 : n - 1)) % n, true);
+ // One project wraps onto itself: nothing to pick, ask or reopen on the desktop (Diego, 2026-10-29).
+ int n = swarm_here()->lead_n, i = (sw.at + (dx < 0 ? 1 : n - 1)) % n;
+ if (i != sw.at) swarm_show(swarm_here(), i, true);
} else if (surface && swarm_mode()) {
// A Swarm with no projects has nowhere to swipe to.
} else if (surface && s.count && s.connected && !s.loading) {
@@ -4387,7 +4573,8 @@ bool ui_picker_is_open(void) { return s.view == MODELS || s.view == MACHINES ||
bool ui_switch_is_open(void) { return s.view == TABS; }
bool ui_scroll_reportable(void)
{
- return s.ready && s.connected && !s.loading && (s.view == HOME || s.view == AGENT) && active() &&
+ // Not on a Swarm's face: it is no pane's terminal, and the pane still active behind it is not on the glass.
+ return s.ready && s.connected && !s.loading && (s.view == HOME || s.view == AGENT) && active() && !swarm_mode() &&
!display_is_asleep() && !s.voice_open && !audio_client_active();
}
int ui_notif_pull_zone_px(void) { return 0; }
@@ -4965,6 +5152,20 @@ static void swarm_tabs_changed(void)
int index = tab_index_of(focused);
ht_tab_carousel_reset(&tab_carousel, tabs_total(), index >= 0 ? index : tab_index_here());
}
+// A daemon that had just started said "no Swarms" before it had read them, and the real list came 2 s later (Diego's dial,
+// 2026-10-29): the Swarm the list took off the face comes back on the Lead it showed, with no pick sent, as long as the
+// person has not moved on. Only that Swarm, within 10 s; one that really went stays gone.
+static bool swarm_regain(const ht_supertab_t *t)
+{
+ if (!t || !sw.lost.tab[0] || swarm_mode() || strcmp(t->id, sw.lost.tab)) return false;
+ bool fresh = (int32_t)(ms() - sw.lost.at) < 10000;
+ bool untouched = s.view == TABS ? sw.auto_tabs : swarm_may_follow();
+ if (!fresh || !untouched) { sw.lost.tab[0] = 0; return false; }
+ char lead[ID_MAX]; COPY(lead, sw.lost.lead);
+ sw.lost.tab[0] = 0;
+ swarm_enter(t, lead, false);
+ return true;
+}
void ui_supertabs_ids(const char ids[][ID_MAX], int n)
{
static EXT_RAM_BSS_ATTR ht_lead_event_t ev[HT_SUPERTABS_MAX * HT_SUPERTAB_LEADS_MAX]; // static: off the reader task's stack
@@ -4972,10 +5173,11 @@ void ui_supertabs_ids(const char ids[][ID_MAX], int n)
int count = ht_supertabs_ids(&swarm, ids, n, ev, (int)(sizeof ev / sizeof ev[0]));
swarm_events(ev, count);
if (swarm_mode() && !swarm_here()) {
- // The Swarm on the face is gone: back to the list.
+ // The Swarm on the face is gone: back to the list. Remembered, for a list that came empty before the real one.
+ COPY(sw.lost.tab, sw.tab); COPY(sw.lost.lead, sw.lead); sw.lost.at = ms();
sw.tab[0] = sw.lead[0] = sw.desk[0] = 0;
ht_supertabs_recap_open(&swarm, "", "", ms());
- if (s.view == HOME || s.view == AGENT || s.view == AGENTS) tabs_open();
+ if (s.view == HOME || s.view == AGENT || s.view == AGENTS) { tabs_open(); sw.auto_tabs = s.view == TABS; }
}
swarms_apply();
swarm_tabs_changed();
@@ -4988,7 +5190,26 @@ bool ui_supertab(const ht_supertab_t *in)
if (!in) return false;
display_lock();
bool linked = in->tab[0] && !ht_supertabs_for_desk(&swarm, in->tab);
+ // The side follows the daemon, newest wins (spec 2026-10-29 Switching): a face that turns to its Buddy chat (a swipe
+ // the daemon took, the desktop opening it) is the Buddy side, one that turns away (the desktop opened another
+ // conversation) the PM side. Without Buddies there is no Buddy side.
+ const ht_supertab_t *was = ht_supertabs_find(&swarm, in->id);
+ int turn = 0;
+ bool buddies = false;
+ for (int k = 0; k < in->lead_n; k++) {
+ const ht_lead_t *l = &in->leads[k];
+ int j = swarm_lead_index(was, l->id);
+ bool before = j >= 0 && was->leads[j].chat == HT_CHAT_BUDDY, now = l->chat == HT_CHAT_BUDDY;
+ buddies |= l->buddies;
+ if (now && !before) turn = 1;
+ else if (before && !now && !turn) turn = -1;
+ }
int n = ht_supertabs_put(&swarm, in, ms(), ev, (int)(sizeof ev / sizeof ev[0]));
+ // A daemon that says the side is the truth: a face alone cannot tell it where no project has a Buddy chat (review of
+ // #2218). An older one says none, and the faces' turns tell it.
+ if (in->side != HT_SIDE_NONE) swarm_side_put(in->id, buddies && in->side == HT_SIDE_BUDDY);
+ else if ((!buddies || turn < 0) && swarm_side_buddy(in->id)) swarm_side_put(in->id, false);
+ else if (buddies && turn > 0) swarm_side_put(in->id, true);
bool beep = swarm_events(ev, n);
// A wait that came before any Lead named its harness shows now, once.
for (int w = 0; w < SWARM_WAITS; w++) {
@@ -4997,6 +5218,7 @@ bool ui_supertab(const ht_supertab_t *in)
ht_supertabs_lead_by_local(&swarm, sw.waits[w].agent, &t) : NULL;
if (l) beep |= swarm_notice_raise(t, l, sw.waits[w].stuck);
}
+ swarm_regain(ht_supertabs_find(&swarm, in->id));
const ht_supertab_t *t = swarm_here();
if (t && !strcmp(t->id, in->id)) {
// The face keeps its Lead; a Lead that went leaves the face on the one now at its place.
@@ -5004,6 +5226,7 @@ bool ui_supertab(const ht_supertab_t *in)
if (i >= 0) sw.at = i;
else if (t->lead_n) swarm_show(t, sw.at < t->lead_n ? sw.at : t->lead_n - 1, false);
else swarm_show(t, -1, false);
+ swarm_buddy_seen();
}
if (linked) swarms_apply();
swarm_tabs_changed();
@@ -5032,6 +5255,7 @@ void ui_supertab_focus(const char *tab, const char *lead)
// As `focus` today: never while talking, nor over a question or a form.
bool free = !s.voice_open && !question_view(s.view) && s.view != FORM && s.view != DRAFT && s.view != DRAFT_OPTIONS;
sw.pending[0] = 0;
+ if (swarm_regain(t)) { change(); display_unlock(); return; }
if (t && (i >= 0 || !lead[0]) && free) {
if (swarm_mode() && !strcmp(sw.tab, tab)) {
if (i >= 0 && strcmp(sw.lead, lead)) swarm_show(t, i, false);
@@ -5066,6 +5290,18 @@ bool ui_supertab_notice(const char *tab, const char *lead, ht_chat_kind_t chat,
int i = swarm_lead_index(t, lead);
if (i < 0) { display_unlock(); return false; }
const ht_lead_t *l = &t->leads[i];
+ if (chat == HT_CHAT_BUDDY) {
+ // The Buddy's word is quiet (spec 2026-10-29 Alerts): no beep, no inbox entry, no wake. Read at once when its side
+ // is on the face, else the PM side's badge until that side is opened.
+ int k = swarm_heard_of(l->id);
+ for (int m = 0; m < SWARM_SAID && k < 0; m++) if (!sw.heard[m].lead[0]) k = m;
+ if (k < 0) k = 0; // ponytail: 24 unseen Buddy words at once; the first slot gives way
+ COPY(sw.heard[k].lead, l->id); COPY(sw.heard[k].chat, chat_id);
+ if (on_face(l->id)) swarm_buddy_seen();
+ change();
+ display_unlock();
+ return false;
+ }
char grey[HT_SUPERTAB_NAME + 8];
snprintf(grey, sizeof grey, "%s%s", t->name, chat == HT_CHAT_PM ? " \xc2\xb7 PM" : "");
notice_forget_read(l->id);
@@ -5088,6 +5324,8 @@ void ui_supertab_notice_read(const char *tab, const char *lead, const char *chat
{
if (!tab || !lead || !chat_id) return;
display_lock();
+ int h = swarm_heard_of(lead);
+ if (h >= 0 && !strcmp(sw.heard[h].chat, chat_id)) { sw.heard[h].lead[0] = 0; change(); }
int e = swarm_notice(lead), k = swarm_said_of(lead);
if (e >= 0 && s.notice[e].swarm == 3 && k >= 0 && !strcmp(sw.said[k].chat, chat_id)) {
sw.said[k].lead[0] = 0;
diff --git a/devices/harness-device/firmware/test/test_cable_features.c b/devices/harness-device/firmware/test/test_cable_features.c
index 30d647e53..50ee2eadb 100644
--- a/devices/harness-device/firmware/test/test_cable_features.c
+++ b/devices/harness-device/firmware/test/test_cable_features.c
@@ -31,6 +31,7 @@ int main(void)
check("{\"features\":[\"form\",{}]}", 0);
check("{\"features\":[\"form\",[\"visit\"]]}", 0);
check("{\"features\":[\"agents.refresh\"]}", CABLE_FEATURE_AGENTS_REFRESH);
+ check("{\"features\":[\"swarm.review\"]}", CABLE_FEATURE_SWARM_REVIEW);
static const char *names[] = {"form", "selection", "visit", "voice.draft", "question.review", "agents.refresh"};
for (unsigned mask=0; mask<64; mask++) {
cJSON *root=cJSON_CreateObject(), *array=cJSON_AddArrayToObject(root,"features");
diff --git a/devices/harness-device/firmware/test/test_cable_supertab.py b/devices/harness-device/firmware/test/test_cable_supertab.py
index 1d9030308..c4e966deb 100644
--- a/devices/harness-device/firmware/test/test_cable_supertab.py
+++ b/devices/harness-device/firmware/test/test_cable_supertab.py
@@ -95,7 +95,7 @@ static void ui_question_close(const char *a,const char *r) { (void)a;(void)r;qcl
for name in ['str_of', 'msg', 'msg_check', 'msg_string', 'msg_number', 'msg_array', 'send_hello', 'id_fits',
'handle_supertabs', 'handle_supertab', 'handle_supertab_recap', 'handle_supertab_focus',
'handle_supertab_notice', 'handle_supertab_notice_read',
- 'handle_question', 'handle_question_close', 'cable_client_supertab_send']:
+ 'handle_question', 'handle_question_close', 'cable_client_supertab_send', 'cable_client_supertab_side']:
code += function(name)
code += r'''
static cJSON *parse(const char *json) { cJSON *p=cJSON_Parse(json);assert(p);return p; }
@@ -115,6 +115,10 @@ int main(void) {
assert(!strcmp(field(wire[0],"product"),"harness"));
// hello says swarmChat v1: the daemon sends the chat on each face and the Lead/PM notices.
assert(!strcmp(field(wire[0],"swarmChat"),"v1"));
+ // and swarmBuddy v1: each Lead's Buddy block, a Buddy face and the Buddy's quiet notice.
+ assert(!strcmp(field(wire[0],"swarmBuddy"),"v1"));
+ // hello says swarmReview v1: words for a Swarm chat are always reviewed here, so the daemon refuses any that are not.
+ assert(!strcmp(field(wire[0],"swarmReview"),"v1"));
// supertabs: ids in order, the bad and the repeated skipped, at most 16.
feed(handle_supertabs,"{\"ids\":[\"s1\",\"\",7,\"s2\",\"s1\",\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"]}");
@@ -163,6 +167,40 @@ int main(void) {
assert(got_card.leads[1].chat==HT_CHAT_PM && !strcmp(got_card.leads[1].chat_id,"pm1") && !strcmp(got_card.leads[1].chat_name,"PM"));
assert(got_card.leads[2].chat==HT_CHAT_LEAD && !got_card.leads[2].chat_id[0]);
+ // supertab from a swarmBuddy daemon: `buddies`, the Buddy block (#rrggbb colour, 15-bit cells) and a Buddy face.
+ feed(handle_supertab,"{\"id\":\"s1\",\"name\":\"openharness\",\"leads\":["
+ "{\"id\":\"L1\",\"state\":\"done\",\"order\":0,\"chat\":\"buddy\",\"chatId\":\"b1\",\"chatName\":\"diego's Buddy\",\"buddies\":true,"
+ "\"buddy\":{\"chatId\":\"b1\",\"name\":\"diego's Buddy\",\"engine\":\"codex\",\"cells\":25513,\"color\":\"#d6a79a\",\"live\":true}},"
+ "{\"id\":\"L2\",\"state\":\"done\",\"order\":1,\"chat\":\"lead\",\"chatId\":\"lead-docs\",\"chatName\":\"Lead\",\"buddies\":true},"
+ "{\"id\":\"L3\",\"state\":\"done\",\"order\":2,\"buddies\":true,"
+ "\"buddy\":{\"chatId\":\"b3\",\"name\":\"x\",\"engine\":\"claude\",\"cells\":32768,\"color\":\"#d6a79a\",\"live\":true}},"
+ "{\"id\":\"L4\",\"state\":\"done\",\"order\":3,\"buddies\":true,"
+ "\"buddy\":{\"chatId\":\"b4\",\"name\":\"x\",\"engine\":\"claude\",\"cells\":7,\"color\":\"red\",\"live\":false}},"
+ "{\"id\":\"L5\",\"state\":\"done\",\"order\":4,\"buddies\":true,"
+ "\"buddy\":{\"chatId\":\"b5\",\"name\":\"x\",\"engine\":\"claude\",\"cells\":\"7\",\"color\":\"#000000\"}},"
+ "{\"id\":\"L6\",\"state\":\"done\",\"order\":5,\"buddies\":true,\"buddy\":\"b6\"}]}");
+ assert(got_card.lead_n==6);
+ l=&got_card.leads[0];
+ assert(l->chat==HT_CHAT_BUDDY && !strcmp(l->chat_id,"b1") && l->buddies && l->buddy.has && l->buddy.live);
+ assert(l->buddy.cells==25513 && l->buddy.color==0xd6a79a && !strcmp(l->buddy.engine,"codex") && !strcmp(l->buddy.name,"diego's Buddy"));
+ assert(got_card.leads[1].buddies && !got_card.leads[1].buddy.has && got_card.leads[1].chat==HT_CHAT_LEAD);
+ // Cells past 15 bits, a colour that is not #rrggbb, cells that are not a number, a block that is not an object: no Buddy.
+ for (int i=2;i<6;i++) assert(got_card.leads[i].buddies && !got_card.leads[i].buddy.has);
+ // `live` absent is a down Buddy only when the block is drawn at all; a swarmChat frame has no Buddies.
+ assert(!got_card.leads[1].buddy.live);
+ feed(handle_supertab,"{\"id\":\"s1\",\"name\":\"openharness\",\"leads\":[{\"id\":\"L1\",\"state\":\"done\",\"chat\":\"lead\",\"chatId\":\"c\"}]}");
+ assert(!got_card.leads[0].buddies && !got_card.leads[0].buddy.has);
+ // The Swarm's side, which a swarmBuddy daemon says on every frame: none from an older one or an unknown value.
+ assert(got_card.side == HT_SIDE_NONE);
+ feed(handle_supertab,"{\"id\":\"s1\",\"name\":\"n\",\"side\":\"buddy\",\"leads\":[]}");
+ assert(got_card.side == HT_SIDE_BUDDY);
+ feed(handle_supertab,"{\"id\":\"s1\",\"name\":\"n\",\"side\":\"pm\",\"leads\":[]}");
+ assert(got_card.side == HT_SIDE_PM);
+ feed(handle_supertab,"{\"id\":\"s1\",\"name\":\"n\",\"side\":\"left\",\"leads\":[]}");
+ assert(got_card.side == HT_SIDE_NONE);
+ feed(handle_supertab,"{\"id\":\"s1\",\"name\":\"n\",\"side\":1,\"leads\":[]}");
+ assert(got_card.side == HT_SIDE_NONE);
+
// supertab.notice and supertab.notice.read reach the ui calls with their fields; the UI decides the beep.
const unsigned beeps_before=beeps;
beep_next=true;
@@ -172,6 +210,10 @@ int main(void) {
assert(!strcmp(got_chat_id,"pm1") && !strcmp(got_text,"Ready to ship.") && got_at==1792560000u);
feed(handle_supertab_notice,"{\"tab\":\"s1\",\"lead\":\"L1\",\"chat\":\"lead\",\"chatId\":\"lead-web\",\"id\":\"m10\",\"text\":\"Done.\",\"at\":5}");
assert(notice_calls==2 && got_chat==HT_CHAT_LEAD && beeps==beeps_before+1);
+ // The Buddy's word: chat "buddy" reaches the UI as HT_CHAT_BUDDY; the UI says it is quiet.
+ feed(handle_supertab_notice,"{\"tab\":\"s1\",\"lead\":\"L1\",\"chat\":\"buddy\",\"chatId\":\"b1\",\"id\":\"m11\",\"text\":\"Cache it.\",\"at\":6}");
+ assert(notice_calls==3 && got_chat==HT_CHAT_BUDDY && !strcmp(got_chat_id,"b1") && !strcmp(got_text,"Cache it.") && beeps==beeps_before+1);
+ notice_calls=2;
feed(handle_supertab_notice_read,"{\"tab\":\"s1\",\"lead\":\"L2\",\"chatId\":\"pm1\"}");
assert(read_calls==1 && !strcmp(got_tab,"s1") && !strcmp(got_lead,"L2") && !strcmp(got_chat_id,"pm1"));
// a notice with a non-id chatId or no lead is ignored, and so is one of a group, with no id, or no text.
@@ -254,7 +296,18 @@ int main(void) {
cable_client_supertab_send("focus","s1","L1");
cable_client_supertab_send(NULL,"s1","L1");
assert(sends==3);
- puts("Swarm frames: hello capabilities, supertabs/supertab/recap/focus parsing, chats and Lead/PM notices, malformed Leads skipped, Super Tab waits kept off the question screen, exact requests PASS");
+ // supertab.side: the side the dial swiped to, for a Swarm id it can hold.
+ sends=0;
+ cable_client_supertab_side("t1",true);
+ cable_client_supertab_side("t1",false);
+ assert(sends==2);
+ assert(!strcmp(wire[0],"{\"t\":\"supertab.side\",\"tab\":\"t1\",\"side\":\"buddy\"}"));
+ assert(!strcmp(wire[1],"{\"t\":\"supertab.side\",\"tab\":\"t1\",\"side\":\"pm\"}"));
+ cable_client_supertab_side(longer,true);
+ cable_client_supertab_side("",true);
+ cable_client_supertab_side(NULL,false);
+ assert(sends==2);
+ puts("Swarm frames: hello capabilities, supertabs/supertab/recap/focus parsing, chats, Buddies and Lead/PM/Buddy notices, supertab.side, malformed Leads skipped, Super Tab waits kept off the question screen, exact requests PASS");
}
'''
with tempfile.TemporaryDirectory(prefix='harness-supertab-') as folder:
diff --git a/devices/harness-device/firmware/test/test_supertab.c b/devices/harness-device/firmware/test/test_supertab.c
index d219f1c4a..a9c915296 100644
--- a/devices/harness-device/firmware/test/test_supertab.c
+++ b/devices/harness-device/firmware/test/test_supertab.c
@@ -235,10 +235,80 @@ static void chats(void)
// An old daemon's Lead (no chat) takes the recap that names none, as before.
ht_supertabs_recap_open(&model, "s1", "L2", 200);
assert(ht_supertabs_recap_put(&model, "s1", "L2", "", "Shipped.", 3, false) && !model.recap.chat_id[0]);
+ // Opening the Lead already on the face keeps its recap until a new one arrives; one still on its way is asked anew.
+ ht_supertabs_recap_open(&model, "s1", "L0", 250);
+ assert(ht_supertabs_recap_put(&model, "s1", "L0", "g1", "Tests green.", 2, false));
+ ht_supertabs_recap_open(&model, "s1", "L0", 260);
+ assert(model.recap.state == HT_RECAP_LOADED && !strcmp(model.recap.text, "Tests green.") && model.recap.asked_ms == 260);
+ assert(ht_supertabs_recap_put(&model, "s1", "L0", "g1", "Deployed.", 4, false) && !strcmp(model.recap.text, "Deployed."));
+ ht_supertabs_recap_open(&model, "s1", "L2", 270); ht_supertabs_recap_open(&model, "s1", "L2", 280);
+ assert(model.recap.state == HT_RECAP_LOADING && model.recap.asked_ms == 280);
+ // The face's chat moved on: what it holds is another chat's, and is not kept.
+ ht_supertabs_recap_open(&model, "s1", "L0", 290);
+ assert(ht_supertabs_recap_put(&model, "s1", "L0", "g1", "Tests green.", 2, false));
+ t.leads[0].chat_id[0] = 'h'; ht_supertabs_put(&model, &t, 0, NULL, 0);
+ ht_supertabs_recap_open(&model, "s1", "L0", 295);
+ assert(model.recap.state == HT_RECAP_LOADING && !model.recap.text[0] && !model.recap.chat_id[0]);
// Opening another Lead forgets the chat the last recap was for.
ht_supertabs_recap_open(&model, "s1", "L1", 300);
assert(!model.recap.chat_id[0]);
- puts("supertab: chat kind/id/name, old Leads as the Lead chat, recap only for the face's chat PASS");
+ puts("supertab: chat kind/id/name, old Leads as the Lead chat, recap only for the face's chat, the face's own reopen keeps it PASS");
+}
+
+// The reader's own Buddy in each project (spec 2026-10-29-round-dial-pm-buddy): `buddies` while the Swarm has them on,
+// the Buddy block with its avatar's 15 half bits and colour, and a face that may be its chat.
+static void buddies(void)
+{
+ static ht_supertab_t t;
+ assert(ht_supertab_init(&t, "s1", "", "openharness", 3));
+ ht_lead_in_t b = lead("L0", "done", 0); b.chat = "buddy"; b.chat_id = "b1"; b.chat_name = "diego's Buddy"; b.buddies = true;
+ b.buddy = (ht_buddy_in_t){.present = true, .chat_id = "b1", .name = "diego's Buddy", .engine = "codex", .color = "#d6a79a",
+ .cells = 25513, .live = true};
+ // Buddies on, no Buddy in this project; and an older daemon, which sends neither.
+ ht_lead_in_t none = lead("L1", "done", 1); none.buddies = true;
+ ht_lead_in_t old = lead("L2", "done", 2);
+ assert(ht_supertab_lead_add(&t, &b) && ht_supertab_lead_add(&t, &none) && ht_supertab_lead_add(&t, &old));
+ const ht_lead_t *l = &t.leads[0];
+ assert(l->buddies && l->buddy.has && l->buddy.live && l->buddy.cells == 25513 && l->buddy.color == 0xd6a79a);
+ assert(!strcmp(l->buddy.chat_id, "b1") && !strcmp(l->buddy.name, "diego's Buddy") && !strcmp(l->buddy.engine, "codex"));
+ assert(l->chat == HT_CHAT_BUDDY && !strcmp(l->chat_id, "b1") && !strcmp(l->chat_name, "diego's Buddy"));
+ assert(t.leads[1].buddies && !t.leads[1].buddy.has);
+ assert(!t.leads[2].buddies && !t.leads[2].buddy.has && t.leads[2].chat == HT_CHAT_LEAD);
+ // A down Buddy is still drawn, not live.
+ assert(ht_supertab_init(&t, "s1", "", "openharness", 1));
+ b.buddy.live = false; assert(ht_supertab_lead_add(&t, &b) && t.leads[0].buddy.has && !t.leads[0].buddy.live);
+ // A block this dial cannot draw is dropped and the Lead kept: a colour that is not #rrggbb, cells past 15 bits or
+ // negative, no chat id or one too long to hold. Buddies stay on.
+ char longer[ID_MAX + 1]; memset(longer, 'b', ID_MAX); longer[ID_MAX] = 0;
+ const char *colors[] = {"d6a79a", "#d6a79", "#d6a79a0", "#d6a7zz", "", NULL};
+ for (int i = 0; i < 6; i++) {
+ ht_lead_in_t bad = b; bad.buddy.color = colors[i];
+ assert(ht_supertab_init(&t, "s1", "", "n", 1) && ht_supertab_lead_add(&t, &bad));
+ assert(t.leads[0].buddies && !t.leads[0].buddy.has);
+ }
+ const long cells[] = {32768, -1};
+ for (int i = 0; i < 2; i++) {
+ ht_lead_in_t bad = b; bad.buddy.cells = cells[i];
+ assert(ht_supertab_init(&t, "s1", "", "n", 1) && ht_supertab_lead_add(&t, &bad) && !t.leads[0].buddy.has);
+ }
+ const char *ids[] = {"", NULL, longer};
+ for (int i = 0; i < 3; i++) {
+ ht_lead_in_t bad = b; bad.buddy.chat_id = ids[i];
+ assert(ht_supertab_init(&t, "s1", "", "n", 1) && ht_supertab_lead_add(&t, &bad) && !t.leads[0].buddy.has);
+ }
+ // The upper case and the edges hold: 0 and 32767 cells, #FFFFFF.
+ ht_lead_in_t edge = b; edge.buddy.color = "#FFFFFF"; edge.buddy.cells = 32767;
+ assert(ht_supertab_init(&t, "s1", "", "n", 1) && ht_supertab_lead_add(&t, &edge));
+ assert(t.leads[0].buddy.has && t.leads[0].buddy.color == 0xffffff && t.leads[0].buddy.cells == 32767);
+ edge.buddy.cells = 0;
+ assert(ht_supertab_init(&t, "s1", "", "n", 1) && ht_supertab_lead_add(&t, &edge) && t.leads[0].buddy.has && !t.leads[0].buddy.cells);
+ // A Buddy block without `buddies` (never from the daemon) is not drawn.
+ ht_lead_in_t off = b; off.buddies = false;
+ assert(ht_supertab_init(&t, "s1", "", "n", 1) && ht_supertab_lead_add(&t, &off) && !t.leads[0].buddy.has);
+ // A Buddy face whose chat id cannot be held is the Lead chat, as any other.
+ ht_lead_in_t wide = b; wide.chat_id = longer;
+ assert(ht_supertab_init(&t, "s1", "", "n", 1) && ht_supertab_lead_add(&t, &wide) && t.leads[0].chat == HT_CHAT_LEAD);
+ puts("supertab: Buddies on, the Buddy block and its avatar, a Buddy face, bad blocks dropped with the Lead kept PASS");
}
int main(void)
@@ -247,5 +317,6 @@ int main(void)
transitions();
lookups_and_recap();
chats();
+ buddies();
return 0;
}
diff --git a/devices/harness-device/firmware/test/test_touch_ui.py b/devices/harness-device/firmware/test/test_touch_ui.py
index 44f4630d2..cb629b7c9 100644
--- a/devices/harness-device/firmware/test/test_touch_ui.py
+++ b/devices/harness-device/firmware/test/test_touch_ui.py
@@ -47,7 +47,7 @@ code = r'''
# Keep real protocol capacities: a larger fake buffer can hide target truncation.
code += defines('CABLE_READ_TOKEN_MAX','ID_MAX','CABLE_NAME_MAX','SWARM_ID_MAX','SWARMS_MAX','CABLE_MAX_AGENTS','MAX_PROJECTS')
code += defines('NOTICES','QUESTION_MAX','OPTION_MAX','PANE_MEMORY_MAX','UI_FONT','Q_ROWS','DRAFT_ROWS',source=source)
-code += defines('FACE_CX', source=source)
+code += defines('FACE_CX', 'BUDDY_LILAC', source=source)
code += '#define NOTICE_TTL_MS 21600000u\n#define ERROR_VIEW_MS 8000u\nstatic void ui_cable_toast(const char *message) { (void)message; }\n'
if '#define PANE_RESULT_BYTES ' in source:
code += defines('PANE_RESULT_BYTES', source=source)
@@ -56,7 +56,7 @@ code += source[source.index('typedef enum {'):source.index('static EXT_RAM_BSS_A
code += typedef('cable_swarm_t') + typedef('cable_notif_t')
code += r'''
static struct {
- bool ready, connected, loading, voice_open, voice_start_pending, voice_waiting, voice_carry, voice_review, voice_draft_append, voice_review_preview, voice_search;
+ bool ready, connected, loading, voice_open, voice_start_pending, voice_waiting, voice_carry, voice_review, voice_draft_append, voice_review_preview, voice_search, voice_swarm;
bool coasting, touch_brake, touch_down, touch_cancelled, quiet, nap, focus_face, straight_title, muted;
ht_rect_t pressed_rect;
int brightness;
@@ -202,7 +202,7 @@ static bool queue(action_t a) {
if (a.kind==A_NOTICE_READ) { notice_reads_sent++; notice_read_queued=a; }
if (a.kind==A_DESKTOP) { desktop_opens++; COPY(opened_agent,a.id); }
if (a.kind==A_SUPERTAB && swarm_sent<64) {
- static const char *ops[]={"recap.get","open","select"};
+ static const char *ops[]={"recap.get","open","select","side"};
snprintf(swarm_wire[swarm_sent++],sizeof swarm_wire[0],"%s %s %s",ops[a.value],a.text,a.id);
}
if (a.kind==A_STOP_YES) COPY(stopped_agent,a.id);
@@ -228,14 +228,14 @@ swarm_parts = {
# with the last `swarms` list it keeps beside it
'swarms_apply': source[source.index('// The last `swarms` list as it came'):source.index('void ui_swarms_replace(')],
}
-for name in ['copy', 'recap_preview', 'notice_unread', 'notice_was_read', 'notice_forget_read', 'notice_flush_reads', 'notice_mark_read', 'habitat_scene_receipt', 'habitat_scene_presented', 'pane_memory', 'pane_memory_apply', 'dismiss_result', 'activity_text', 'ensure', 'input_cancel', 'view', 'notice_open', 'workspace_index', 'swarm_core', 'voice_lead', 'tabs_open', 'workspace_failed', 'tab_request', 'tabs_sync', 'ui_scroll_reportable', 'focus_skin', 'focus_face_for', 'focus_chord', 'focus_put', 'focus_span', 'focus_take', 'focus_rows', 'ui_rows', 'ui_can_display', 'ui_wrap', 'text_in', 'control', 'home_footer', 'footer_control', 'text', 'center', 'render_brand', 'heading', 'question_view', 'question_rows', 'question_move', 'question_text', 'render_question', 'render_choices', 'render_answer_review', 'question_answer', 'send_answer', 'make_action', 'character_mood', 'voice_status', 'home_caption_rotates', 'home_caption_tick', 'status_animated', 'status_speed', 'status_wake_ms', 'surface_tick', 'command_face', 'render_workspace_preview', 'question_prompt', 'focus_bell', 'render_swarm_face', 'render_home', 'render_voice', 'render_selection', 'render_form', 'draft_move', 'render_draft', 'render_draft_options', 'swarms_apply', 'ui_swarms_replace', 'ui_workspace_applied', 'ui_land_after_reload']:
+for name in ['copy', 'recap_preview', 'notice_unread', 'notice_was_read', 'notice_forget_read', 'notice_flush_reads', 'notice_mark_read', 'habitat_scene_receipt', 'habitat_scene_presented', 'pane_memory', 'pane_memory_apply', 'dismiss_result', 'activity_text', 'ensure', 'input_cancel', 'view', 'notice_open', 'workspace_index', 'swarm_core', 'voice_lead', 'tabs_open', 'workspace_failed', 'tab_request', 'tabs_sync', 'ui_scroll_reportable', 'focus_skin', 'focus_face_for', 'focus_chord', 'focus_put', 'focus_span', 'focus_take', 'focus_rows', 'ui_rows', 'ui_can_display', 'ui_wrap', 'text_in', 'control', 'home_footer', 'footer_control', 'text', 'center', 'render_brand', 'heading', 'question_view', 'question_rows', 'question_move', 'question_text', 'render_question', 'render_choices', 'render_answer_review', 'question_answer', 'send_answer', 'make_action', 'character_mood', 'voice_status', 'home_caption_rotates', 'home_caption_tick', 'status_animated', 'status_speed', 'status_wake_ms', 'surface_tick', 'command_face', 'render_workspace_preview', 'question_prompt', 'focus_bell', 'mix_black', 'face_buddy_disc', 'face_buddy_ring', 'face_buddy_dots', 'face_buddy_avatar', 'render_buddy_empty', 'render_swarm_face', 'render_home', 'render_voice', 'render_selection', 'render_form', 'draft_move', 'render_draft', 'render_draft_options', 'swarms_apply', 'ui_swarms_replace', 'ui_workspace_applied', 'ui_land_after_reload']:
code += swarm_parts[name] if name in swarm_parts else function(name)
code += function('render_settings') + function('ui_visit_state')
code += function('ui_project_known') + function('ui_focus_project') + function('ui_apply_pending_focus')
code += function('focus_centred') + function('focus_header') + function('focus_clipped') + function('tabs_move') + function('tab_name') + function('tab_split') + function('tab_fade') + function('tab_neighbour') + function('focus_carousel') + function('tab_label') + function('render_focus_tabs') + function('pane_label') + function('render_focus_panes') + function('render_agents') + function('render_tabs') + function('page_controls') + function('render_notice') + function('css_line') + function('inbox_line') + function('inbox_page') + function('render_focus_inbox') + function('render_list')
for name in ['notice_remove', 'notice_sync_view', 'notice_selection', 'notice_restore_selection', 'notice_add', 'notice_expire', 'on_face', 'notice_read_now', 'ui_notify_summary', 'ui_turn_error', 'ui_notif_seen', 'ui_notif_read', 'ui_notif_replace', 'ui_notif_open', 'ui_question_close', 'ui_answer_receipt',
'utf8_trim', 'swarm_notice', 'swarm_notice_mark', 'swarm_notice_raise', 'swarm_notice_drop', 'swarm_events',
- 'swarm_tabs_changed', 'ui_supertabs_ids', 'ui_supertab', 'ui_supertab_recap', 'ui_supertab_focus',
+ 'swarm_tabs_changed', 'swarm_regain', 'ui_supertabs_ids', 'ui_supertab', 'ui_supertab_recap', 'ui_supertab_focus',
'ui_supertab_wait', 'ui_supertab_wait_close', 'ui_supertabs_clear', 'swarm_said_of', 'ui_supertab_notice', 'ui_supertab_notice_read']:
code += function(name)
code += '#define ui_notify_task_done(a,b,c,d) ui_notify_summary(a,b,c,d,"alert",false,false)\n'
@@ -281,7 +281,8 @@ static void dispatch(action_t a) {
s.voice_engine[0]=0; // as the real dispatch: the recipient's engine, none for Find / form / draft voice
for (int i=0;i<s.count;i++) if (a.value!=2 && a.value!=5 && a.value!=6 && a.value!=7 && !strcmp(s.agents[i].id,a.id)) COPY(s.voice_engine,s.agents[i].engine);
const ht_lead_t *lead = voice_lead(a.id, a.value); // and a Swarm's Lead's, by its harness
- if (lead) { COPY(s.voice_engine, lead->engine); COPY(s.voice_target, lead->project); }
+ if (lead) { COPY(s.voice_engine, swarm_voice_engine(lead)); COPY(s.voice_target, lead->project); }
+ sw.voice_buddy = lead && swarm_on_buddy(lead) && lead->buddy.has; // as the real dispatch: pinned at the start
s.voice_carry=a.value==3; s.voice_search=a.value==7; COPY(voice_context,a.text);
s.voice_return=s.view; s.voice_open = recording = true; view(VOICE);
} else if (a.kind == A_VOICE_STOP) { stops++; if(a.value==1)reviews++; recording = false; }
@@ -1594,6 +1595,21 @@ static void swarm_pane_checks(const char *dir) {
swarm_sent = 0; surface_tick(fake_ms + 4999); assert(!swarm_sent);
surface_tick(fake_ms + 5000); assert(swarm_sent == 1 && !strcmp(swarm_wire[0], "recap.get s1 L4"));
surface_tick(fake_ms + 11000); assert(swarm_sent == 1);
+ // A swipe on a Swarm of one project lands on the project already on the face: nothing happens. It used to empty
+ // the recap for 5 s and pick the project again, which reopened its Lead chat on the desktop (Diego, 2026-10-29).
+ swarm_setup(); enter_at("s2", "P0");
+ ui_supertab_recap("s2", "P0", "", "Sandbox rebuilt.", 1792560000u, false); scene_take();
+ assert(swarm.recap.state == HT_RECAP_LOADED); swarm_sent = 0;
+ habitat_touch(true, 320, 220, fake_ms); habitat_touch(false, 150, 220, fake_ms + 120); scene_take();
+ habitat_touch(true, 150, 220, fake_ms + 1000); habitat_touch(false, 320, 220, fake_ms + 1120); scene_take();
+ assert(!strcmp(sw.lead, "P0") && swarm.recap.state == HT_RECAP_LOADED && !strcmp(swarm.recap.text, "Sandbox rebuilt."));
+ assert(!swarm_sent);
+ // Two projects still move, both ways.
+ enter_at("s3", "K0"); swarm_sent = 0;
+ habitat_touch(true, 320, 220, fake_ms + 2000); habitat_touch(false, 150, 220, fake_ms + 2120);
+ assert(!strcmp(sw.lead, "K1") && swarm_sent == 3 && !strcmp(swarm_wire[0], "select s3 K1"));
+ habitat_touch(true, 320, 220, fake_ms + 3000); habitat_touch(false, 150, 220, fake_ms + 3120);
+ assert(!strcmp(sw.lead, "K0") && swarm_sent == 6 && !strcmp(swarm_wire[3], "select s3 K0"));
// PANES (tap the name): one page per Lead in order, opened on the one on the face; a long name on two lines with
// "…"; Done picks with the swipe's messages.
swarm_setup(); enter_at("s1", "L2"); tap(fake_ms, 233, 30);
@@ -1639,6 +1655,40 @@ static void swarm_pane_checks(const char *dir) {
// The Swarm gone from the list: back to TABS.
{ const char ids[2][ID_MAX] = {"s3", "s2"}; ui_supertabs_ids(ids, 2); }
assert(!swarm_mode() && s.view == TABS);
+ // Diego's dial, 2026-10-29: after a reconnect the list came empty, then whole 2 s later. The Swarm on the face comes
+ // back on the Lead it showed, with no pick sent, and the TABS the dial opened by itself switched no desk tab meanwhile.
+ {
+ const char none[1][ID_MAX] = {""}, ids[3][ID_MAX] = {"s1", "s3", "s2"};
+ swarm_setup(); enter_at("s1", "L2"); s.view = HOME; swarm_sent = 0; int switched = tab_switches;
+ ui_supertabs_ids(none, 0); assert(!swarm_mode() && s.view == TABS);
+ int plain = tab_index_of("t2"); assert(plain >= 0 && !tab_swarm(plain));
+ ht_tab_carousel_reset(&tab_carousel, tabs_total(), plain); tabs_sync(); assert(tab_switches == switched);
+ fake_ms += 2000; ui_supertabs_ids(ids, 3); openharness_card(); card_send();
+ assert(swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L2") && s.view == HOME);
+ ui_supertab_focus("s1", "L2"); assert(!strcmp(sw.lead, "L2") && s.view == HOME);
+ assert(!wire_has(0, "select s1 L2") && tab_switches == switched);
+ // The focus alone brings it back too, when it comes before the card.
+ ui_supertabs_ids(none, 0); assert(s.view == TABS);
+ ui_supertabs_ids(ids, 3); openharness_card(); ht_supertabs_put(&swarm, &card, ms(), NULL, 0);
+ ui_supertab_focus("s1", "L2"); assert(swarm_mode() && !strcmp(sw.lead, "L2") && s.view == HOME);
+ // A Swarm that really went, back only after 10 s: TABS stays, and the person's touch browses as before.
+ ui_supertabs_ids(none, 0); fake_ms += 10000; ui_supertabs_ids(ids, 3); card_send();
+ assert(!swarm_mode() && s.view == TABS);
+ habitat_touch(true, 233, 233, fake_ms);
+ ht_tab_carousel_reset(&tab_carousel, tabs_total(), tab_index_of("t2")); tabs_sync(); assert(tab_switches == switched + 1);
+ habitat_touch_cancel();
+ // The person on TABS already, browsing: a Swarm coming back does not pull the dial off it.
+ swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
+ ui_supertabs_ids(none, 0); habitat_touch(true, 233, 233, fake_ms); habitat_touch_cancel();
+ ui_supertabs_ids(ids, 3); openharness_card(); card_send(); assert(!swarm_mode() && s.view == TABS);
+ // The person touched TABS, chose a plain tab with Done and went HOME: the Swarm back within 10 s stays off the face.
+ swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
+ ui_supertabs_ids(none, 0); habitat_touch(true, 233, 233, fake_ms); habitat_touch_cancel();
+ ht_tab_carousel_reset(&tab_carousel, tabs_total(), tab_index_of("t2")); dispatch((action_t){.kind = A_TAB_DONE});
+ dispatch((action_t){.kind = A_HOME}); assert(s.view == HOME);
+ fake_ms += 2000; ui_supertabs_ids(ids, 3); openharness_card(); card_send();
+ ui_supertab_focus("s1", "L2"); assert(!swarm_mode() && s.view == HOME);
+ }
// Diego's dial, 2026-10-28: the window on a Swarm tab with no project open (its Chat with PM, a DM) names no Lead.
// The dial still goes into that Swarm, on the Lead the desktop last showed there, else the first by order; a dial
// already in it keeps its face.
@@ -1934,6 +1984,277 @@ static void swarm_chat_checks(const char *dir) {
ui_supertab_wait_close("h1", "supertab:w1"); assert(swarm_entry("C1") < 0);
puts("Swarm chats: work only for a working group, the face chat's recap, Lead/PM notices read on their face or unread with a beep, one entry per Lead, news across a snapshot, notice.read, Lead waits still alert PASS");
}
+/*
+ * A DAEMON THAT SPEAKS swarmBuddy (docs/superpowers/specs/2026-10-29-round-dial-pm-buddy-spec.md): each project has a PM
+ * side (today's face, plus two dots) and a Buddy side (the reader's Buddy's avatar, a lilac ring, its last message).
+ * Swipe up for the Buddy, down for the PM; the side is kept per Swarm; the Buddy's word is a quiet badge.
+ */
+static void buddy_lead(const char *id, const char *project, const char *local, const char *chat, const char *chat_id,
+ const char *buddy_chat, const char *buddy_engine) {
+ ht_lead_in_t in = {.id = id, .project = project, .engine = "claude", .local = local, .state = "done", .order = card.lead_n, .since = -1,
+ .chat = chat, .chat_id = chat_id, .chat_name = !strcmp(chat, "buddy") ? "diego's Buddy" : "Lead", .buddies = true,
+ .buddy = {.present = buddy_chat != NULL, .chat_id = buddy_chat, .name = "diego's Buddy", .engine = buddy_engine,
+ .color = "#d6a79a", .cells = 25513, .live = true}};
+ assert(ht_supertab_lead_add(&card, &in));
+}
+// web-api (B0, a Codex Buddy) and firmware (B1, a Claude Buddy) have Buddies, docs (B2) none. `face` is B0's chat kind.
+static void buddy_card(const char *face) {
+ card_begin("s1", "t1", "openharness");
+ buddy_lead("B0", "web-api", "h0", face, !strcmp(face, "buddy") ? "b0" : "lead-web", "b0", "codex");
+ buddy_lead("B1", "firmware", "h1", "lead", "lead-fw", "b1", "claude");
+ buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL);
+ assert(!card_send());
+}
+static void buddy_setup(void) {
+ reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
+ desk_open();
+ const char ids[1][ID_MAX] = {"s1"};
+ ui_supertabs_ids(ids, 1);
+ buddy_card("lead");
+ enter_at("s1", "B0"); swarm_sent = 0;
+}
+static void swipe_v(int from_y, int to_y) {
+ fake_ms += 1000; habitat_touch(true, 233, from_y, fake_ms); habitat_touch(false, 233, to_y, fake_ms + 120); scene_take();
+}
+static void swipe_up(void) { swipe_v(330, 150); }
+static void swipe_down(void) { swipe_v(150, 330); }
+static void swipe_next(void) {
+ fake_ms += 1000; habitat_touch(true, 320, 220, fake_ms); habitat_touch(false, 150, 220, fake_ms + 120); scene_take();
+}
+// A box run by its centre, diameter and fill.
+static bool disc_at(int cx, int cy, int d, unsigned rgb) {
+ for (int i = 0; i < scene.count; i++) {
+ const ht_run_t *r = &scene.runs[i];
+ if (r->box.h == d && r->x == cx - d / 2 && r->y == cy - d / 2 && r->box.fill == ht_rgb(rgb)) return true;
+ }
+ return false;
+}
+// The lilac ring at the glass edge: r 230, 3 px, #c49bff at 32 % over black.
+static bool lilac_ring(void) {
+ for (int i = 0; i < scene.count; i++) {
+ const ht_run_t *r = &scene.runs[i];
+ if (r->ring.set && r->ring.w16 == 3 * 16 && r->ring.r16 == 230 * 16 && r->ring.colour == ht_rgb(0x3f3252)) return true;
+ }
+ return false;
+}
+// The avatar: a 50 px sprite of the pattern, centred on its disc (the colour at 16 % over black, r 46) at x 233, at y 158
+// or higher, so it stands at least 8 px clear of the recap's card.
+static const ht_run_t *avatar_sprite(void) {
+ for (int i = 0; i < scene.count; i++) {
+ const ht_run_t *r = &scene.runs[i];
+ if (r->sprite.width == 50 && r->x == 208 && r->y <= 133) return r;
+ }
+ return NULL;
+}
+static int card_top(void) {
+ for (int i = 0; i < scene.count; i++) if (scene.runs[i].box.h && scene.runs[i].w >= 300) return scene.runs[i].y;
+ return 0;
+}
+static bool avatar(void) {
+ const ht_run_t *a = avatar_sprite();
+ if (!a || !disc_at(233, a->y + 25, 92, 0x221b19)) return false;
+ return !card_top() || a->y + 25 + 46 + 8 <= card_top();
+}
+static bool pm_dots(void) { return disc_at(442, 218, 12, 0xeaeaf0) && disc_at(442, 248, 9, 0x55565f); }
+static bool buddy_dots(void) { return disc_at(442, 218, 9, 0x55565f) && disc_at(442, 248, 12, 0xc49bff); }
+static bool any_dot(void) { return disc_at(442, 218, 12, 0xeaeaf0) || disc_at(442, 218, 9, 0x55565f); }
+static bool badge(void) { return disc_at(449, 241, 14, 0x000000) && disc_at(449, 241, 10, 0xc49bff); }
+static void swarm_buddy_checks(const char *dir) {
+ // 7a the PM side: today's face and two dots, the upper one lit.
+ buddy_setup();
+ assert(title_is("web-api") && pm_dots() && !lilac_ring() && !avatar());
+ FOCUS_PAGE("buddy-7a");
+ int pm_runs = scene.count;
+ // 7b swipe up: the dial says so, and draws the Buddy side at once: the ring, the avatar, the lower dot lit.
+ swipe_up();
+ // A Swarm's face is no pane's terminal: the drag scrolls nothing (it used to scroll the pane still active behind it).
+ assert(!down_reports && !moves && !ups);
+ assert(swarm_sent == 1 && !strcmp(swarm_wire[0], "side s1 buddy"));
+ assert(s.view == HOME && title_is("web-api") && lilac_ring() && avatar() && buddy_dots());
+ // The daemon puts the Buddy chat on the face; its recap is the Buddy's last message.
+ buddy_card("buddy");
+ ui_supertab_recap("s1", "B0", "b0", "Two ways: cache the read, or move it to the host. I'd cache it.", 1792560000u, false); scene_take();
+ assert(scene_says("Two ways") && lilac_ring() && avatar());
+ // Without a recap it stands at 233, 158 exactly.
+ { const ht_run_t *a = avatar_sprite(); assert(a); }
+ {
+ // A four-line recap: the card rises, the avatar with it.
+ ui_supertab_recap("s1", "B0", "b0", "Two ways: cache the read, or move it to the host. I'd cache it. Want me to write it up and send it to the PM?", 1792560000u, false);
+ scene_take(); assert(avatar() && card_top());
+ // With the bell too (an unread notice off the face) every run still fits the scene.
+ assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "Flashed.", 1792560001u));
+ scene_take(); assert(avatar() && scene.count < HT_RUNS);
+ ui_supertab_recap("s1", "B0", "b0", "", 1792560000u, true); scene_take();
+ assert(avatar() && avatar_sprite()->y == 133);
+ ui_supertab_recap("s1", "B0", "b0", "Two ways: cache the read, or move it to the host. I'd cache it.", 1792560000u, false); scene_take();
+ }
+ FOCUS_PAGE("buddy-7b");
+ {
+ // The pattern: 25513's half bits mirrored on 5 x 5 cells of 10 px, each with its corner pixel cut.
+ const ht_run_t *a = avatar_sprite();
+ assert(a->sprite.height == 50 && a->sprite.cell == 1 && !a->sprite.row_at && a->sprite.palette[1]);
+ #define AV(x, y) a->sprite.cells[(y) * 50 + (x)]
+ static const int cols[5] = {0, 1, 2, 1, 0};
+ for (int r = 0; r < 5; r++) for (int c = 0; c < 5; c++) {
+ bool on = (25513 >> (r * 3 + cols[c])) & 1;
+ assert((AV(c * 10 + 5, r * 10 + 5) != 0) == on);
+ if (on) assert(!AV(c * 10, r * 10) && AV(c * 10 + 1, r * 10) && !AV(c * 10 + 9, r * 10 + 9));
+ }
+ #undef AV
+ }
+ // Swipe up on the Buddy side does nothing.
+ swipe_up(); assert(swarm_sent == 1 && lilac_ring());
+ // The next project keeps the side, and the dial says it again with the move.
+ swipe_next();
+ assert(!strcmp(sw.lead, "B1") && title_is("firmware") && lilac_ring() && avatar() && wire_has(1, "side s1 buddy") && wire_has(1, "select s1 B1"));
+ // 7c a project with no Buddy: the empty state, and a tap there starts no voice.
+ swipe_next();
+ assert(!strcmp(sw.lead, "B2") && title_is("docs") && lilac_ring() && buddy_dots() && !avatar());
+ assert(scene_says("No Buddy here yet") && scene_says("Add one in the Harness app."));
+ FOCUS_PAGE("buddy-7c");
+ { int before = starts; tap(fake_ms + 2000, 233, 260); assert(starts == before && s.view == HOME); }
+ // Swipe down: back to the PM side.
+ int sent = swarm_sent; swipe_down();
+ assert(swarm_sent == sent + 1 && !strcmp(swarm_wire[sent], "side s1 pm") && pm_dots() && !lilac_ring() && !scene_says("No Buddy"));
+ // On the PM side an unread Lead notice still opens the inbox on a pull down.
+ assert(ui_supertab_notice("s1", "B0", HT_CHAT_LEAD, "lead-web", "Web is merged.", 1792560001u));
+ scene_take(); sent = swarm_sent; swipe_down();
+ assert(s.view == INBOX && swarm_sent == sent);
+ dispatch((action_t){.kind = A_HOME}); scene_take();
+
+ // The side follows the daemon, newest wins: a face that turns to its Buddy chat (the desktop opened it) is the Buddy
+ // side; one that turns away (the desktop moved on) is the PM side again. The dial does not answer either.
+ buddy_setup(); buddy_card("buddy");
+ scene_take(); assert(lilac_ring() && avatar() && swarm_sent == 0);
+ buddy_card("lead"); scene_take(); assert(!lilac_ring() && pm_dots() && swarm_sent == 0);
+ // A desktop focus moves the face without saying a side; only the person's own move does.
+ swipe_up(); assert(swarm_sent == 1);
+ ui_supertab_focus("s1", "B1"); scene_take(); assert(!strcmp(sw.lead, "B1") && !wire_has(1, "side s1 buddy") && !wire_has(1, "side s1 pm"));
+ // The dial follows the daemon even right after its own move: the daemon keeps the side through the desktop move its
+ // select causes, so a turn away is always a newer desktop focus.
+ buddy_setup(); swipe_up(); buddy_card("buddy"); swipe_next();
+ assert(!strcmp(sw.lead, "B1") && lilac_ring() && wire_has(0, "side s1 buddy"));
+ sent = swarm_sent; buddy_card("lead"); scene_take();
+ assert(!lilac_ring() && pm_dots() && swarm_sent == sent);
+
+ // The daemon's side is the truth where it says one (review of #2218): Buddies on and no Buddy anywhere, the person
+ // swipes up to the empty Buddy side, then opens a group on the desktop. No face turns to or from a Buddy chat, and the
+ // frame says the PM side: the dial follows the desktop's group.
+ {
+ reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000; desk_open();
+ const char ids[1][ID_MAX] = {"s1"}; ui_supertabs_ids(ids, 1);
+ card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL); card.side = HT_SIDE_PM; card_send();
+ enter_at("s1", "B2"); swarm_sent = 0;
+ swipe_up(); assert(scene_says("No Buddy here yet") && swarm_sent == 1);
+ // The daemon took the swipe: its frame says the Buddy side, and the empty screen stays.
+ card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL); card.side = HT_SIDE_BUDDY; card_send();
+ scene_take(); assert(scene_says("No Buddy here yet"));
+ // The desktop opens a group: the daemon drops the side.
+ card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "group", "g-docs", NULL, NULL); card.side = HT_SIDE_PM; card_send();
+ scene_take(); assert(!scene_says("No Buddy here yet") && !lilac_ring() && pm_dots() && swarm_sent == 1);
+ // And the daemon's Buddy side shows it, with no swipe here (another dial, or the side said again).
+ card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL); card.side = HT_SIDE_BUDDY; card_send();
+ scene_take(); assert(scene_says("No Buddy here yet") && lilac_ring());
+ }
+ // Buddies off: no dots, swipe up is inert, and the face is exactly a face from a daemon without Buddies.
+ buddy_setup();
+ card_begin("s1", "t1", "openharness");
+ chat_lead("B0", "web-api", "h0", "done", 0, -1, "lead", "lead-web", "Lead");
+ card_send(); scene_take();
+ assert(!any_dot() && !lilac_ring());
+ swipe_up(); assert(swarm_sent == 0 && !lilac_ring() && !any_dot() && s.view == HOME);
+ static ht_scene_t off; off = scene;
+ {
+ ht_lead_in_t in = {.id = "B0", .project = "web-api", .engine = "claude", .local = "h0", .state = "done", .order = 0, .since = -1,
+ .chat = "lead", .chat_id = "lead-web", .chat_name = "Lead"};
+ card_begin("s1", "t1", "openharness"); assert(ht_supertab_lead_add(&card, &in)); card_send(); scene_take();
+ assert(scene.count == off.count && !memcmp(&scene, &off, sizeof scene));
+ }
+ // Buddies turned off while on the Buddy side: the PM face, no dots.
+ buddy_setup(); swipe_up(); assert(lilac_ring());
+ card_begin("s1", "t1", "openharness"); chat_lead("B0", "web-api", "h0", "done", 0, -1, "lead", "lead-web", "Lead"); card_send();
+ scene_take(); assert(!lilac_ring() && !any_dot() && !avatar());
+ // A Buddy removed while its side is open (Buddies still on, no block): the empty state, no voice.
+ buddy_setup(); swipe_up();
+ card_begin("s1", "t1", "openharness"); buddy_lead("B0", "web-api", "h0", "lead", "lead-web", NULL, NULL); card_send(); scene_take();
+ assert(scene_says("No Buddy here yet") && lilac_ring());
+ { int before = starts; tap(fake_ms + 2000, 233, 260); assert(starts == before); }
+
+ // 7d the quiet notice: on the PM side the Buddy's word is a lilac badge and a line on the lower arc, with no beep, no
+ // inbox entry and no wake. The run count holds.
+ buddy_setup();
+ ui_supertab_recap("s1", "B0", "lead-web", "Assigned #2083 to web-api. I'll post here when the PR is up.", 1792560000u, false);
+ scene_take(); pm_runs = scene.count;
+ assert(!badge() && !scene_says("Your Buddy replied"));
+ int entries = s.notice_count; int woke = wakes;
+ assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "Cache it.", 1792560002u));
+ scene_take();
+ assert(s.notice_count == entries && wakes == woke && badge() && scene_says("Your Buddy replied") && scene.count == pm_runs);
+ FOCUS_PAGE("buddy-7d");
+ // Another project shows none; back on web-api it is still there.
+ swipe_next(); assert(!badge() && !scene_says("Your Buddy replied"));
+ swarm_show(ht_supertabs_find(&swarm, "s1"), 0, true); scene_take(); assert(badge());
+ // Opening the Buddy side reads it.
+ swipe_up(); assert(!badge()); swipe_down(); assert(!badge() && !scene_says("Your Buddy replied"));
+ // The resting face keeps its own line on the lower arc: there the badge alone tells it.
+ ui_supertab_recap("s1", "B0", "lead-web", "", 1792560000u, true);
+ assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "Later.", 1792560002u));
+ scene_take(); assert(badge() && !scene_says("Your Buddy replied"));
+ swipe_up(); swipe_down(); assert(!badge());
+ // A Buddy word while its side is open is read there; the desktop opening the Buddy chat reads one too.
+ swipe_up(); buddy_card("buddy");
+ assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "Done.", 1792560003u));
+ swipe_down(); assert(!badge());
+ assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "Again.", 1792560004u)); scene_take(); assert(badge());
+ ui_supertab_notice_read("s1", "B0", "other"); scene_take(); assert(badge());
+ ui_supertab_notice_read("s1", "B0", "b0"); scene_take(); assert(!badge());
+ // A Lead notice is unchanged: an entry, and a beep off the face.
+ assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "Flashed.", 1792560005u) && s.notice_count == entries + 1);
+
+ // 7e-7g voice on the Buddy side: the Buddy's engine's pet, the ring kept, and "Sending to your Buddy".
+ buddy_setup(); swipe_up(); buddy_card("buddy"); scene_take();
+ tap(fake_ms + 2000, 233, 260);
+ assert(s.view == VOICE && !strcmp(target, "h0") && !strcmp(s.voice_engine, "codex") && lilac_ring());
+ FOCUS_PAGE("buddy-7e");
+ s.voice_waiting = true; recording = false; scene_take();
+ assert(lilac_ring() && scene_says("Sending to your Buddy"));
+ FOCUS_PAGE("buddy-7f");
+ dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false; scene_take();
+ assert(s.view == HOME && lilac_ring());
+ // A Claude Buddy listens with Claude's pet.
+ swipe_next(); tap(fake_ms + 2000, 233, 260);
+ assert(s.view == VOICE && !strcmp(target, "h1") && !strcmp(s.voice_engine, "claude"));
+ FOCUS_PAGE("buddy-7g");
+ dispatch((action_t){.kind = A_VOICE_ABORT}); scene_take();
+ // On the PM side voice is today's: the Lead's engine, no ring, no Buddy line.
+ swipe_down(); tap(fake_ms + 2000, 233, 260);
+ assert(s.view == VOICE && !strcmp(target, "h1") && !strcmp(s.voice_engine, "claude") && !lilac_ring());
+ s.voice_waiting = true; recording = false; scene_take(); assert(!scene_says("Sending to your Buddy"));
+ dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false;
+ // The ring and "Sending to your Buddy" belong to the turn: pinned when it starts, as its chat is (the batch's check of
+ // #2218 with #2207). The side changing under a recording, or while it is sent, moves neither, either way.
+ for (int waiting = 0; waiting < 2; waiting++) {
+ // Started on the PM side; the desktop then opens the Buddy chat.
+ buddy_setup(); tap(fake_ms + 2000, 233, 260);
+ assert(s.view == VOICE && !lilac_ring());
+ if (waiting) { s.voice_waiting = true; recording = false; }
+ buddy_card("buddy"); scene_take();
+ assert(swarm_side_buddy("s1") && s.view == VOICE && !lilac_ring() && !scene_says("Sending to your Buddy"));
+ s.voice_waiting = true; recording = false; scene_take();
+ assert(!lilac_ring() && !scene_says("Sending to your Buddy"));
+ dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false;
+ // Started on the Buddy side; the desktop then opens another conversation.
+ buddy_setup(); swipe_up(); buddy_card("buddy"); scene_take(); tap(fake_ms + 2000, 233, 260);
+ assert(s.view == VOICE && lilac_ring());
+ if (waiting) { s.voice_waiting = true; recording = false; }
+ buddy_card("lead"); scene_take();
+ assert(!swarm_side_buddy("s1") && s.view == VOICE && lilac_ring());
+ s.voice_waiting = true; recording = false; scene_take();
+ assert(lilac_ring() && scene_says("Sending to your Buddy"));
+ dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false;
+ }
+ puts("Swarm Buddies: swipe up for the Buddy (ring, avatar, dots, its recap), down for the PM, side kept across projects and following the daemon, the empty state, Buddies off unchanged, the quiet badge, voice with the Buddy's engine PASS");
+}
int main(int argc, char **argv) {
test_character = getenv("HABITAT_TEST_TUX") ? HT_CHARACTER_TUX : HT_CHARACTER_TIM;
notification_read_checks(argc>1 ? argv[1] : NULL);
@@ -3121,6 +3442,9 @@ int main(int argc, char **argv) {
reset(); tap(1000,233,220); scene_take();
habitat_touch(true,233,220,2000); surface_tick(4000); habitat_touch(false,233,220,4100);
assert(!stops && !reviews); // Resting a hand is not review.
+ // On a Swarm face an older daemon takes no review: the hold does not promise one.
+ reset(); tap(1000,233,220); scene_take(); s.voice_swarm=true;
+ habitat_touch(true,233,220,2000); surface_tick(2675); assert(!s.voice_review_preview);
reset(); s.view=DRAFT;
ht_draft_page_t draft_page={.active=true,.revision=1,.can_send=true,.id="draft-one",.agent="a",.name="Parser helper",
.text="Keep the public API.\n\nOnly change the parser.\nPreserve existing tests.\nAdd Unicode coverage.\nDo not rename exports.\nKeep async behavior.\nKeep all exported types.",.position=1,.total=2};
@@ -3487,6 +3811,7 @@ int main(int argc, char **argv) {
puts("touch UI: PASS (production contacts/renderers; voice start/finish/discard, target pinning, sensor cancellation, immediate scroll, swipes, round trips, congestion and holds)");
// Last, so every face above renders exactly as it did before chats: the faces are compared byte for byte.
swarm_chat_checks(argc>1 ? argv[1] : NULL);
+ swarm_buddy_checks(argc>1 ? argv[1] : NULL);
}
'''
extra_sources = []
diff --git a/devices/harness-device/firmware/test/test_voice_ui.py b/devices/harness-device/firmware/test/test_voice_ui.py
index 0afadac27..6c681da68 100644
--- a/devices/harness-device/firmware/test/test_voice_ui.py
+++ b/devices/harness-device/firmware/test/test_voice_ui.py
@@ -58,7 +58,7 @@ static void select_companion(void) {}
static ht_tab_carousel_t tab_carousel;
#define PANE_PITCH 60
static struct {
- bool quick_open, coasting, ready, connected, loading, nap, voice_open, voice_start_pending, voice_waiting, voice_carry, voice_review, voice_review_preview, voice_draft_append, voice_search, touch_down, touch_cancelled;
+ bool quick_open, coasting, ready, connected, loading, nap, voice_open, voice_start_pending, voice_waiting, voice_carry, voice_review, voice_review_preview, voice_draft_append, voice_search, voice_swarm, touch_down, touch_cancelled;
int pet_pose, view, voice_return, offset, pressed, active, pane_pos;
uint32_t error_until;
uint32_t pet_until, nap_until, voice_retry_until, voice_started, voice_wait_until, voice_generation, voice_question_revision, voice_draft_revision;
@@ -122,6 +122,9 @@ bool queue(action_t action) { if (queue_full) return false; queued = action; ret
# The Swarm's data and lookups, for the Lead a face voice turn goes to.
harness += source[source.index('enum { SUPERTAB_RECAP_GET'):source.index('static const char *swarm_fixed_text(')]
harness += function('voice_lead')
+# and whose engine it listens with: the Buddy's on a Swarm's Buddy side.
+for name in ['swarm_side_slot', 'swarm_side_buddy', 'swarm_on_buddy', 'swarm_voice_engine']:
+ harness += function(name)
harness += function('question_view') + function('copy') + function('input_cancel') + function('view') + function('voice_close') + function('workspace_failed')
dispatch = source.split('case A_VOICE:\n', 1)[1].split('case A_PET:', 1)[0]
harness += 'static void dispatch(action_t a) { switch (a.kind) { case A_VOICE:\n' + dispatch + '} }\n'
@@ -162,9 +165,39 @@ int main(void) {
strcpy(sw.tab, "s1"); strcpy(sw.lead, "L1");
dispatch((action_t){.kind = A_VOICE, .id = "h1"}); work(queued);
assert(recording && s.view == VOICE && !strcmp(started_for, "h1"));
- assert(!strcmp(s.voice_engine, "codex") && !strcmp(s.voice_target, "mobile"));
+ assert(!strcmp(s.voice_engine, "codex") && !strcmp(s.voice_target, "mobile") && !sw.voice_buddy);
done(); finish_audio(); ui_voice_routed(true, false, "", "h1", "mobile", 1);
assert(s.view == AGENT && !s.voice_open && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L1"));
+ // Words for the Swarm chat are always reviewed, a plain tap included, by a daemon that posts a reviewed draft there.
+ reset(); host_features = 31 | CABLE_FEATURE_SWARM_REVIEW; strcpy(sw.tab, "s1"); strcpy(sw.lead, "L1");
+ dispatch((action_t){.kind = A_VOICE, .id = "h1"}); work(queued); done();
+ assert(reviews == 1 && s.voice_review && s.voice_waiting);
+ discard(); finish_audio();
+ // On the Buddy side the turn is pinned to it when it starts, with the Buddy's engine; a later side change moves neither.
+ {
+ static ht_supertab_t buddy_card;
+ ht_lead_in_t b = {.id = "L1", .project = "mobile", .engine = "codex", .local = "h1", .state = "done", .order = 0, .since = -1,
+ .buddies = true, .buddy = {.present = true, .chat_id = "b1", .name = "diego's Buddy", .engine = "claude",
+ .color = "#d6a79a", .cells = 25513, .live = true}};
+ assert(ht_supertab_init(&buddy_card, "s1", "", "openharness", 1) && ht_supertab_lead_add(&buddy_card, &b));
+ ht_supertabs_put(&swarm, &buddy_card, now, ev, 4);
+ reset(); strcpy(sw.tab, "s1"); strcpy(sw.lead, "L1"); strcpy(sw.side[0].tab, "s1"); sw.side[0].buddy = true;
+ dispatch((action_t){.kind = A_VOICE, .id = "h1"}); work(queued);
+ assert(s.voice_open && sw.voice_buddy && !strcmp(s.voice_engine, "claude"));
+ sw.side[0].buddy = false;
+ assert(sw.voice_buddy);
+ discard(); finish_audio();
+ reset(); strcpy(sw.tab, "s1"); strcpy(sw.lead, "L1"); sw.side[0].buddy = false;
+ dispatch((action_t){.kind = A_VOICE, .id = "h1"}); work(queued);
+ assert(s.voice_open && !sw.voice_buddy && !strcmp(s.voice_engine, "codex"));
+ discard(); finish_audio();
+ ht_supertabs_put(&swarm, &card, now, ev, 4); memset(sw.side, 0, sizeof sw.side);
+ }
+ // An older daemon would type a reviewed draft into the Lead's terminal: no review on the face, even when held.
+ reset(); strcpy(sw.tab, "s1"); strcpy(sw.lead, "L1");
+ dispatch((action_t){.kind = A_VOICE, .id = "h1"}); work(queued); dispatch((action_t){.kind = A_VOICE_STOP, .value = 1});
+ assert(!reviews && !s.voice_review && s.voice_waiting);
+ discard(); finish_audio();
// A desk pane's id while a Lead is on the face is no Lead's harness: the pane's own engine.
strcpy(s.agents[0].engine, "claude"); begin();
assert(!strcmp(started_for, "agent") && !strcmp(s.voice_engine, "claude"));
diff --git a/docs/device-voice-swarm-chat.md b/docs/device-voice-swarm-chat.md
new file mode 100644
index 000000000..8dced24fa
--- /dev/null
+++ b/docs/device-voice-swarm-chat.md
@@ -0,0 +1,54 @@
+# Device voice in the Swarm chat: review before posting
+
+Builds on [the round dial's Swarm chats](superpowers/specs/2026-10-28-round-dial-swarm-chat-design.md) and
+[its PM and Buddy screens](superpowers/specs/2026-10-29-round-dial-pm-buddy-spec.md): the face shows the chat the desktop
+has open, and words spoken on it go to that chat as the person. Everyone in the Swarm reads that chat, so the dial now
+shows the words first (device owner's choice 2a, 2026-10-27).
+
+## Behaviour
+
+- Tap the Swarm face, speak, tap again. The dial shows the words with the project and chat it will post to
+ (`openharness · Lead`, `openharness · PM`, a group's title or the Buddy's name), then **Send** or **Discard**.
+- Send posts them in that chat as the person, with the same command typing uses and the same access check. Discard posts
+ nothing.
+- The chat is the one on the face when the person began to speak, even if the desktop moves while they speak or review.
+- A refused post (a read-only Chat with PM, someone else's chat) or an unreachable Swarm keeps the draft with the reason.
+ Nothing is typed into the Lead's terminal.
+
+## Cable
+
+| Direction | Field | Meaning |
+|---|---|---|
+| daemon → device | `welcome.features` has `swarm.review` | Words reviewed on a Swarm face are posted in its chat by Send |
+| device → daemon | `hello.swarmReview: "v1"` | This dial reviews every word for a Swarm chat |
+| device → daemon | `voice.end.review: true` | As for any draft; then `voice.draft` with `name` and `context: "Swarm chat"` |
+
+- A dial asks for review on a Swarm face only from a daemon that lists `swarm.review`. An older daemon would type the
+ reviewed draft into the Lead's terminal, so with one the face posts at once, as before, and a hold does not offer review.
+- Words begun on a Swarm face keep the face's Lead as their recipient: a pane focused in the window never takes them.
+- Send passes `reviewed` with the chat: `SwarmCards.say` posts there while it is still the Lead conversation or an open chat
+ of that Lead's project this reader may see, even if the face moved since. Unreviewed words keep today's rule (refused
+ once the face moved).
+- A daemon that saw `swarmReview` refuses unreviewed words for a Swarm face before they are transcribed:
+ `Review the words before they are posted.`
+
+## Not in this version
+
+- Reading the reply aloud (choice 4a: later, only in the person's own chat and only when they turn it on).
+- A light or screen for what waits on the person (choice 5a), and the Harness Pro, which has no Swarm chat face.
+
+## Design (docs/feature-design-rules.md)
+
+1. **Growth:** one draft per device session in memory (`VoiceDraft`), cleared on send, discard or detach. Nothing stored.
+2. **Concurrency:** the draft is claimed before its post. A second Send returns the first one's receipt, so one Send is
+ one message.
+3. **Read cost:** no new reads. The face is read from the cards the daemon already holds.
+4. **Scale:** one post per Send, as typing. At 10× the first warning is the backend's refusal rate in the cable log.
+5. **Compatibility:** gated both ways (`swarm.review`, `swarmReview`). New firmware with an old daemon, or old firmware
+ with a new daemon, behaves as today.
+6. **Migration and rollback:** none to migrate. Rolling back either side returns to posting at once.
+7. **Audience:** the post is the backend's `message.send` as the signed-in person, which enforces who may post. A Buddy
+ chat's words never reach a terminal.
+8. **Identity:** the signed-in person's, never the machine owner's login, as for every card post.
+9. **Failure:** a refused or unconfirmed post leaves the draft with its reason; nothing is retried on its own.
+10. **Platforms:** the round dial on macOS, Linux and Windows daemons alike. No platform-specific code.
diff --git a/docs/swarms.md b/docs/swarms.md
index 605e65cac..9f8caa807 100644
--- a/docs/swarms.md
+++ b/docs/swarms.md
@@ -180,6 +180,15 @@ Buddies are on in every Swarm; there is no setting. They replaced Chat with PM (
⇧⌘K opens the current project's. A row with new lines shows its name in bold, with no count; the Swarm tab counts
them. A chat with no Buddy running offers **Start**: one of the person's own machines and Claude Code, already
chosen, or Codex.
+- **On the round dial.** Each project has two screens. The PM screen is the project's face as before, with two dots at
+ the right edge. Swipe up for the Buddy screen: a lilac ring, the Buddy's avatar (Desktop's pattern and colour) and
+ its last message. Swipe down to return to the PM screen. A swipe down on the PM screen still opens the inbox when
+ something is unread. The dial keeps the screen per Swarm as you move between projects; opening another conversation
+ on the desktop puts the dial back on what the desktop shows. A project without a Buddy shows "No Buddy here yet". Tap
+ to talk works on both screens: on the Buddy screen the words go to the Buddy chat, with the Buddy's engine
+ listening, and a refused post shows as an error on the dial, never as words in a terminal. A new line from the
+ Buddy is quiet: no beep and no inbox entry, only a lilac badge on the lower dot and "Your Buddy replied", until you
+ open the Buddy screen.
- **The product manager's lines to one person.** What the product manager tells one person directly goes to that
person's Buddy chat in the project (a line it sends with `person.tell`, and the line saying what it chose for a
decision left to it). The chat opens for the line if the person has none yet, so no line drops. Such a line reads