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 11-02 at: #2648 #2633 #2630 #2646 #2650 (#2654)

0xken15f3fa5d6e1a3e
diff --git a/backend/integration/superTabProfile.test.ts b/backend/integration/superTabProfile.test.ts
index e033d18b6..2a698618b 100644
--- a/backend/integration/superTabProfile.test.ts
+++ b/backend/integration/superTabProfile.test.ts
@@ -452,7 +452,8 @@ describe('reactions', () => {
describe('the ship moment', () => {
const config = { engine: 'claude', model: 'opus', effort: 'high', contextWindow: null, engineVersion: null }
- it('posts one celebration in the project chat when linked work is Done, waking nobody', async () => {
+ // The task's own line says it shipped, in place of the Shipped line (taskLine.ts; Quiet Swarm, Dee, 11-02).
+ it('edits the task\'s one line in the project chat to shipped when its merge is recorded, once on a retry, waking nobody', async () => {
const tab = await swarm()
await run(tab, { type: 'agent.add', conversationId: 'lead', machineId: 'host', harnessId: randomUUID(), name: 'River', configuration: config, lead: true })
const group = (await run(tab, { type: 'conversation.create', title: 'Avatars', brief: 'Add avatars.',
@@ -466,13 +467,18 @@ describe('the ship moment', () => {
evidence: 'npm test: 12 passed' }, owner, builder)
const operationId = randomUUID()
const done: Command = { type: 'work.status', conversationId: group, assignmentId: work.assignment!.id, status: 'done',
- result: 'Merged https://github.com/example/app/pull/7' }
+ result: 'Review passed: https://github.com/example/app/pull/7' }
await run(tab, done, owner, builder, operationId)
await run(tab, done, owner, builder, operationId)
+ const merged: Command = { type: 'conversation.merged', conversationId: group, pullRequestUrl: 'https://github.com/example/app/pull/7' }
+ const mergeId = randomUUID()
+ await run(tab, merged, owner, undefined, mergeId)
+ await run(tab, merged, owner, undefined, mergeId)
const rows = await db.superTabMessage.findMany({ where: { tabId: tab, conversationId: 'lead' } })
- const ships = rows.filter(m => (m.source as { kind?: string } | null)?.kind === 'ship')
- expect(ships).toHaveLength(1)
- expect(ships[0]).toMatchObject({ text: '🎉 Shipped: Avatars, requested by owner, built by Kai. https://github.com/example/app/pull/7', recipientIds: [] })
- expect(await db.superTabDelivery.count({ where: { tabId: tab, messageId: ships[0]!.id } })).toBe(0)
+ expect(rows.filter(m => (m.source as { kind?: string } | null)?.kind === 'ship')).toEqual([])
+ const lines = rows.filter(m => (m.source as { kind?: string } | null)?.kind === 'task-line')
+ expect(lines).toHaveLength(1)
+ expect(lines[0]).toMatchObject({ text: 'Avatars · shipped', recipientIds: [], source: { taskId: group, state: 'shipped', builderId: builder } })
+ expect(await db.superTabDelivery.count({ where: { tabId: tab, messageId: lines[0]!.id } })).toBe(0)
})
})
diff --git a/backend/integration/superTabRead.test.ts b/backend/integration/superTabRead.test.ts
index baa4c8be1..86bc6de38 100644
--- a/backend/integration/superTabRead.test.ts
+++ b/backend/integration/superTabRead.test.ts
@@ -676,8 +676,10 @@ describe('a real command through the store by parts (design 4.7)', () => {
expect(written.version).toBeGreaterThan(R)
clock = Date.now()
const seen = (await get(`/api/super-tabs/${s.tabId}/changes?cursor=${cursor}`, peer)).body.data
+ // The task's line in its project chat takes the new name too (taskLine.ts): that chat is written in the same commit.
+ expect(reply.parts.filter(p => p.kind === 'group').map(p => [p.key, p.version]).sort()).toEqual([['lead', written.version], [s.web, written.version]].sort())
expect(seen.groups.map((g: { key: string; version: number; data: { title: string } }) => [g.key, g.version, g.data.title]))
- .toEqual([[s.web, written.version, 'Renamed for real']])
+ .toEqual([['lead', written.version, 'Lead'], [s.web, written.version, 'Renamed for real']])
expect(seen.lastChangedAt).toBe(reply.lastChangedAt)
})
})
diff --git a/backend/integration/superTabTaskLines.test.ts b/backend/integration/superTabTaskLines.test.ts
new file mode 100644
index 000000000..8b7ee3b75
--- /dev/null
+++ b/backend/integration/superTabTaskLines.test.ts
@@ -0,0 +1,138 @@
+import { randomUUID } from 'node:crypto'
+import { execFile } from 'node:child_process'
+import { promisify } from 'node:util'
+import { join } from 'node:path'
+import { tmpdir } from 'node:os'
+import { afterAll, beforeAll, describe, expect, it } from 'vitest'
+import { MongoMemoryReplSet } from 'mongodb-memory-server-core'
+import { PrismaClient } from '@prisma/client'
+import type { AuthUser } from '../src/lib/ssoAuth.js'
+import { SuperTabStore } from '../src/superTabs/store.js'
+import type { Command } from '../src/superTabs/commands.js'
+
+// Quiet Swarm 2/6 (task #2191; docs/plans/2026-11-02-quiet-swarm-task-line-plan.md): each task with an Engineer is one
+// message in its project chat, edited in place as the task moves, none for its steps, and a private project's line only
+// for that project's readers. Through the store and a fresh loopback replica set, as the people's apps read it.
+let replica: MongoMemoryReplSet
+let db: PrismaClient
+let store: SuperTabStore
+const owner: AuthUser = { sub: '150000000000000000000001', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }
+const peer: AuthUser = { sub: '150000000000000000000002', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }
+const host: AuthUser = { sub: '150000000000000000000003', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }
+const config = { engine: 'codex', model: 'fixture-model', effort: 'high', contextWindow: 200000, engineVersion: 'fixture' }
+const run = (tab: string, command: Command, user = owner, asAgentId?: string) =>
+ store.execute(user, tab, { operationId: randomUUID(), command }, asAgentId)
+
+beforeAll(async () => {
+ replica = await MongoMemoryReplSet.create({ binary: { version: '7.0.24', downloadDir: join(tmpdir(), 'harness-super-tab-mongodb-binaries') },
+ replSet: { count: 1, ip: '127.0.0.1', storageEngine: 'wiredTiger' } })
+ const uri = replica.getUri(`task_lines_test_${randomUUID().replaceAll('-', '_')}`)
+ await promisify(execFile)(join(process.cwd(), 'node_modules/.bin/prisma'), ['db', 'push', '--skip-generate'], {
+ env: { ...process.env, DATABASE_URL: uri }, timeout: 60000,
+ })
+ db = new PrismaClient({ datasources: { db: { url: uri } } })
+ store = new SuperTabStore(db)
+ for (const user of [owner, peer, host]) await db.user.create({ data: { id: user.sub, externalId: `fixture-${user.sub}`,
+ email: user.email, autonomousEnv: user.autonomousEnv } })
+ await db.machine.create({ data: { machineId: 'test-host', userId: host.sub, apiKey: 'fixture-only', managerId: 'fixture',
+ autonomousEnv: 'prod', authMode: 'remote' } })
+ await db.machineShare.create({ data: { machineId: 'test-host', ownerId: host.sub, autonomousEnv: 'prod', emails: [owner.email] } })
+})
+afterAll(async () => {
+ await db?.$disconnect()
+ await replica?.stop()
+})
+
+type Row = { id: string; text: string; source?: Record<string, unknown> | null; recipientIds?: string[] }
+async function swarm() {
+ const tab = (await store.create(owner, randomUUID(), 'Quiet')).id
+ const invitation = await run(tab, { type: 'invite.create', email: peer.email, role: 'collaborator', conversationId: 'lead' })
+ await run(tab, { type: 'invite.accept', inviteId: invitation.result.inviteId as string }, peer)
+ const add = async (name: string, conversationId: string, lead = false) => String((await run(tab, { type: 'agent.add', conversationId,
+ machineId: 'test-host', harnessId: randomUUID(), name, configuration: config, lead })).result.agentId)
+ const as = (agentId: string) => (command: Command) => run(tab, command, host, agentId)
+ /** The task lines a person's app reads on a chat's newest page, and the page's reaction counter. */
+ const page = async (conversationId: string, user = owner) => {
+ const answer = await store.messages(user, tab, conversationId, {}) as unknown as { messages: Row[]; reactionSeq: number }
+ return { lines: answer.messages.filter(m => m.source?.kind === 'task-line'), reactionSeq: answer.reactionSeq }
+ }
+ return { tab, add, as, page }
+}
+
+describe('a task\'s one message in its project chat', () => {
+ it('posts one message per task with an Engineer and edits it through each state', async () => {
+ const s = await swarm()
+ const P = await s.add('Coordinator', 'lead', true)
+ const T = String((await s.as(P)({ type: 'conversation.create', title: 'Offline drafts', brief: 'Keep drafts.', checks: [] })).result.conversationId)
+ const E = await s.add('Engineer', T)
+ const assignmentId = String((await s.as(P)({ type: 'work.assign', conversationId: T, agentId: E })).result.assignmentId)
+ const status = (value: 'working' | 'needs_human' | 'review' | 'done', result: string | null, extra: Record<string, unknown> = {}) =>
+ s.as(E)({ type: 'work.status', conversationId: T, assignmentId, status: value, result, ...extra } as Command)
+
+ const first = await s.page('lead')
+ expect(first.lines).toEqual([expect.objectContaining({ text: 'Offline drafts · planned', recipientIds: [],
+ source: expect.objectContaining({ kind: 'task-line', taskId: T, title: 'Offline drafts', state: 'planned', builderId: E }) })])
+ const lineId = first.lines[0]!.id
+ expect(await db.superTabDelivery.count({ where: { tabId: s.tab, messageId: lineId } })).toBe(0)
+
+ let seq = first.reactionSeq
+ const steps: Array<[Parameters<typeof status>[0], string | null, Record<string, unknown>, string, Record<string, unknown>]> = [
+ ['working', 'Started.', {}, 'Offline drafts · working', { state: 'working' }],
+ ['needs_human', 'Keep drafts after a restart?', { ask: { personId: peer.sub, options: ['Keep', 'Drop'], recommended: 0, unblocks: 'The release' } },
+ 'Offline drafts · waiting on peer', { state: 'waiting', answerFor: peer.sub }],
+ ['review', 'Ready: https://github.com/example/app/pull/7 at abc1234.', {}, 'Offline drafts · in review', { state: 'review' }],
+ ['done', 'Review passed: https://github.com/example/app/pull/7.', {}, 'Offline drafts · ready', { state: 'ready' }],
+ ]
+ for (const [value, result, extra, text, source] of steps) {
+ await status(value, result, extra)
+ const now = await s.page('lead')
+ expect(now.lines).toEqual([expect.objectContaining({ id: lineId, text, source: expect.objectContaining({ taskId: T, ...source }) })])
+ if (!('answerFor' in source)) expect(now.lines[0]!.source).not.toHaveProperty('answerFor')
+ // The page a reader already shows changed: its counter moved, so the app reads it again.
+ expect(now.reactionSeq).toBeGreaterThan(seq)
+ seq = now.reactionSeq
+ }
+ // Shipped once the merge is recorded (PM, review of #2633).
+ await s.as(P)({ type: 'conversation.merged', conversationId: T, pullRequestUrl: 'https://github.com/example/app/pull/7' })
+ const shipped = await s.page('lead')
+ expect(shipped.lines).toEqual([expect.objectContaining({ id: lineId, text: 'Offline drafts · shipped', source: expect.objectContaining({ state: 'shipped' }) })])
+ expect(shipped.reactionSeq).toBeGreaterThan(seq)
+ // The Shipped line is gone: its line says it.
+ expect((await store.messages(owner, s.tab, 'lead', {}) as unknown as { messages: Row[] }).messages.filter(m => m.source?.kind === 'ship')).toEqual([])
+ })
+
+ it('posts none for a task\'s steps', async () => {
+ const s = await swarm()
+ const P = await s.add('Coordinator', 'lead', true)
+ const T = String((await s.as(P)({ type: 'conversation.create', title: 'Offline drafts', brief: 'Keep drafts.', checks: [] })).result.conversationId)
+ const E = await s.add('Engineer', T)
+ const assignmentId = String((await s.as(P)({ type: 'work.assign', conversationId: T, agentId: E })).result.assignmentId)
+ await s.as(E)({ type: 'work.status', conversationId: T, assignmentId, status: 'review', result: 'Ready.' })
+ const R = String((await s.as(E)({ type: 'conversation.create', title: 'Review', step: 'Review', reviewOf: T, brief: 'Review it.', checks: [] }))
+ .result.conversationId)
+ const V = await s.add('Reviewer', R)
+ const reviewing = String((await s.as(E)({ type: 'work.assign', conversationId: R, agentId: V })).result.assignmentId)
+ await s.as(V)({ type: 'work.status', conversationId: R, assignmentId: reviewing, status: 'done', result: 'Ready to merge: Yes.' })
+ const { lines } = await s.page('lead')
+ expect(lines.map(l => [l.source?.taskId, l.source?.state])).toEqual([[T, 'review']])
+ })
+
+ it('shows a private project\'s task line only to that project\'s readers', async () => {
+ const s = await swarm()
+ const created = (await run(s.tab, { type: 'project.create', name: 'Secret', visibility: 'private', brief: '' })).result as { projectId: string; conversationId: string }
+ const P = await s.add('Coordinator', created.conversationId, true)
+ const T = String((await s.as(P)({ type: 'conversation.create', title: 'Hidden work', brief: 'Quietly.', checks: [] })).result.conversationId)
+ const E = await s.add('Engineer', T)
+ const assignmentId = String((await s.as(P)({ type: 'work.assign', conversationId: T, agentId: E })).result.assignmentId)
+ await s.as(E)({ type: 'work.status', conversationId: T, assignmentId, status: 'working', result: 'Started.' })
+
+ const mine = await s.page(created.conversationId)
+ expect(mine.lines.map(l => [l.source?.taskId, l.source?.state])).toEqual([[T, 'working']])
+ const lineId = mine.lines[0]!.id
+ // A Swarm member outside the project: no line on the chats they read, and neither the private chat nor the line by id.
+ expect((await s.page('lead', peer)).lines).toEqual([])
+ await expect(store.messages(peer, s.tab, created.conversationId, {})).rejects.toThrow()
+ await expect(store.messages(peer, s.tab, created.conversationId, { messageId: lineId })).rejects.toThrow()
+ await expect(store.messages(peer, s.tab, 'lead', { messageId: lineId })).resolves.toMatchObject({ messages: [] })
+ })
+})
diff --git a/backend/src/superTabs/buddyNews.test.ts b/backend/src/superTabs/buddyNews.test.ts
index 59a47ee23..c89d22e68 100644
--- a/backend/src/superTabs/buddyNews.test.ts
+++ b/backend/src/superTabs/buddyNews.test.ts
@@ -4,6 +4,7 @@ import { createSuperTab, forRecipients, type Actor, type Conversation, type Mess
import { buddyChatId } from './buddies.js'
import { assignedNotice, buddiesTold } from './buddyNews.js'
import { SHIP_KIND } from './ship.js'
+import { TASK_LINE_KIND } from './taskLine.js'
import { leaderboard } from './leaderboard/stats.js'
import { weekStart } from './leaderboard/week.js'
@@ -146,6 +147,19 @@ describe('the assignment notice a Buddy gets for work its person requested', ()
expect(assignedNotice(f.state, task, { kind: 'agent', id: f.pm, name: 'pm', membershipGeneration: 'first' }, 'op')).toBeNull()
})
+ // The Shipped line's rule, kept for the news (ship.test.ts before #2633): work Done without a pull request never shipped.
+ it('says nothing has shipped for work Done without a pull request, or Done before its merge', () => {
+ for (const result of ['Ready to merge: Yes.', 'Review passed: https://github.com/o/r/pull/7']) {
+ const { f, group, assign } = requested()
+ assign()
+ const task = f.state.conversations.find(c => c.id === group)!
+ const worker = task.assignment!.agentId
+ const done = f.run({ type: 'work.status', conversationId: group, assignmentId: task.assignment!.id, status: 'done', result },
+ agentActor(worker))
+ expect(notices(done.messages)).toEqual([])
+ }
+ })
+
it('is not sent when its person cannot read the task, when nobody requested it, or when another person did', () => {
const hidden = requested()
hidden.f.state.projects!.find(p => p.id === hidden.f.app.projectId)!.visibility = 'private'
@@ -177,10 +191,19 @@ describe('work the PM opens from a Buddy\'s proposal without naming anyone (grou
.toEqual([expect.objectContaining({ conversationId: group, recipients: ['buddy'], source: { kind: 'agent-only' } })])
const assignmentId = find().assignment!.id
for (const check of find().checks) f.run({ type: 'work.check', conversationId: group, assignmentId, checkId: check.id, passed: true, evidence: 'ok' })
- const done = f.run({ type: 'work.status', conversationId: group, assignmentId, status: 'done', result: 'Merged https://github.com/o/r/pull/7' },
- agentActor(worker)).messages.find(m => m.source?.kind === SHIP_KIND)!
- expect(done).toMatchObject({ conversationId: f.app.conversationId, source: { requesterId: 'peer' }, buddyRecipients: ['buddy'] })
- expect(done.text).toContain('requested by peer')
+ // Done with its pull request reads ready and is no news yet; its recorded merge ships it (taskLine.ts; PM, review of #2633),
+ // and their Buddy hears it inside the task, once.
+ const done = f.run({ type: 'work.status', conversationId: group, assignmentId, status: 'done', result: 'Review passed: https://github.com/o/r/pull/7' },
+ agentActor(worker))
+ expect(done.edits).toEqual([expect.objectContaining({ conversationId: f.app.conversationId, source: expect.objectContaining({ kind: TASK_LINE_KIND,
+ state: 'ready', requesterId: 'peer' }) })])
+ expect(done.messages.filter(m => m.recipients.includes('buddy'))).toEqual([])
+ const merged = f.run({ type: 'conversation.merged', conversationId: group, pullRequestUrl: 'https://github.com/o/r/pull/7' }, agentActor(worker))
+ expect(merged.edits).toEqual([expect.objectContaining({ source: expect.objectContaining({ state: 'shipped' }) })])
+ expect(merged.messages.filter(m => m.recipients.includes('buddy'))).toEqual([expect.objectContaining({ conversationId: group,
+ source: { kind: 'agent-only' }, text: expect.stringContaining('which they requested, shipped') })])
+ expect(f.run({ type: 'conversation.merged', conversationId: group, pullRequestUrl: 'https://github.com/o/r/pull/7' }, agentActor(worker))
+ .messages.filter(m => m.recipients.includes('buddy'))).toEqual([])
const board = leaderboard({ state: f.state, groups: f.state.conversations, machines: [], projectId: f.app.projectId, week: weekStart(1000), now: 1000 })
expect(board.people.find(p => p.personId === 'peer')).toMatchObject({ points: 3, shipped: { count: 1 } })
})
diff --git a/backend/src/superTabs/buddyNews.ts b/backend/src/superTabs/buddyNews.ts
index 542a7a86c..89a6eb27c 100644
--- a/backend/src/superTabs/buddyNews.ts
+++ b/backend/src/superTabs/buddyNews.ts
@@ -54,6 +54,15 @@ export function assignedNotice(state: SuperTabState, group: Conversation, author
text: `News for your owner: #${group.number} "${group.title}", which they requested, is assigned and ${group.assignment.status}.` }
}
+/** Work [group]'s requester asked for just shipped: the news the Shipped line brought their Buddy, now that the task's line
+ * says it (taskLine.ts), as one line for their Buddy alone inside the task, like the assignment's. */
+export function shippedNotice(state: SuperTabState, group: Conversation, author: Author, operationId: string): MessageDraft | null {
+ const buddy = group.requesterId ? listeningBuddy(state, group.requesterId, group) : undefined
+ if (!buddy) return null
+ return { id: stableId(operationId, 'buddy-news', 'shipped'), conversationId: group.id, author, replyTo: null, recipients: [buddy.id], source: AGENT_ONLY,
+ text: `News for your owner: #${group.number} "${group.title}", which they requested, shipped.` }
+}
+
/** The Buddies [messages] bring news to outside their own chat: what they were told relied on their person still reading
* there, so a write that sends news guards on those people and Buddies (parts/touches.ts). */
export function buddiesHearing(state: SuperTabState, messages: readonly MessageDraft[]): Agent[] {
diff --git a/backend/src/superTabs/cards.ts b/backend/src/superTabs/cards.ts
index ff400e9e0..11f435cf1 100644
--- a/backend/src/superTabs/cards.ts
+++ b/backend/src/superTabs/cards.ts
@@ -12,6 +12,8 @@ export interface GroupCards {
task?: string
/** Each linked pull request's card: the first main-chat message that linked it, and when a merge was recorded. */
pullRequests?: PullRequestCard[]
+ /** Its one line in its project chat and what it last showed (taskLine.ts). */
+ line?: import('./taskLine.js').TaskLine
}
export interface PullRequestCard { url: string; messageId: string; mergedAt?: number }
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index ac26f44c9..8afe87e04 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -33,7 +33,8 @@ import { fixedOriginal, LEDGER_WEEKS, PULL_REQUEST_URL, recordAsked, recordFix,
recordReportedModel, recordVerdict } from './leaderboard/record.js'
import { WEEK_MS } from './leaderboard/week.js'
import { react, reactionSchema, type ReactionTarget } from './reactions.js'
-import { shipNotice, shippedAt } from './ship.js'
+import { shippedAt } from './ship.js'
+import { syncTaskLines } from './taskLine.js'
import { assignedNotice, tellBuddies } from './buddyNews.js'
import { bindPullRequestCards, bindTaskCard, pullRequestCard, recordCardMerged } from './cards.js'
import { avatarChoice, setAgentAvatar, setMemberAvatar, setStatus, statusSchema, type AvatarUpload } from './profile.js'
@@ -716,7 +717,19 @@ function open(state: SuperTabState, conversationId: string) {
}
/** Pure policy/state transition. The store commits its state, messages and delivery records in one transaction. */
+/** One command, then each task's line brought up to date (taskLine.ts), whichever way the command returned. */
export function applyCommand(original: SuperTabState, actor: Actor, input: Command, context: CommandContext): CommandEffects {
+ const effects = applyCommandOnce(original, actor, input, context)
+ // Who moved the task, for a line its project's coordinator cannot sign and for the Buddy's news; nobody when the actor is
+ // no longer a member (a command that removed them).
+ let sender: Author | undefined
+ try { sender = author(effects.state, actor) } catch { sender = undefined }
+ syncTaskLines(original, effects, input.type === 'work.status' ? input.conversationId : undefined, sender,
+ stableId(original.id, actorKey(actor), context.operationId))
+ return effects
+}
+
+function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command, context: CommandContext): CommandEffects {
// A credential someone pasted, or an agent echoed from its terminal, is gone before anything is stored or delivered
// (Oct 2026: a Harness access token in a shared Lead chat). The sender's result says what went.
const removed: CredentialKind[] = []
@@ -3071,11 +3084,9 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
if (short) effects.messages.push({ id: stableId(operationId, 'review-capacity', short.source.engine), conversationId: short.conversationId, author: sender,
text: short.text, replyTo: null, recipients: coordinator ? [coordinator] : [], source: short.source,
...(!coordinator && short.mentions.length ? { mentions: short.mentions } : {}) })
- // Shipped before this command: the leaderboard marks this Done as shipped just above (recordStatus).
+ // The task's line says it shipped (taskLine.ts), in place of the Shipped line; its links are kept as that line's were.
if (command.status === 'done' && shippedAt(conversation(original, group.id)) == null) {
appendPullRequestUrls(group, [command.result, ...group.checks.map(check => check.evidence)])
- const shipped = shipNotice(state, group, sender, operationId)
- if (shipped) effects.messages.push(shipped)
}
}
if (actor.kind === 'agent') renewOwnTask(state, group, actor.agentId, context.now)
diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.ts
index 6dc656049..010fdaf5f 100644
--- a/backend/src/superTabs/model.ts
+++ b/backend/src/superTabs/model.ts
@@ -551,6 +551,8 @@ export const NOTICE_READERS = {
'note-removed': 'recipients',
'project-report': 'people', route: 'people', 'route-override': 'people', 'buddy-proposal': 'people', 'buddy-proposal-sent': 'people', 'buddy-session-ended': 'people',
'decision-delegated': 'people', 'machine-removed': 'people', 'machine-left': 'people', ship: 'people',
+ // A task's one line in its project chat, edited as it moves (taskLine.ts): people read a task's state there.
+ 'task-line': 'people',
// A project PM's private line in a person's one Buddy chat, marked with its project (commands.ts person.tell): its person
// reads it, as they read the line in their older project chat.
'pm-line': 'people',
@@ -637,6 +639,8 @@ export interface CommandEffects {
instructions?: import('./instructions.js').InstructionsWrite
/** A coordinator's note kept or a note removed, written outside the tab state by the store (instructions.ts). */
notes?: import('./instructions.js').NotesWrite
+ /** Stored messages given new words: a task's line as the task moves (taskLine.ts). */
+ edits?: import('./taskLine.js').MessageEdit[]
}
/** `details` go to the caller with the code: what it needs to act on the refusal (a stale save's current text). */
export class SuperTabError extends Error {
diff --git a/backend/src/superTabs/notices.test.ts b/backend/src/superTabs/notices.test.ts
index 9060c788f..c10b43529 100644
--- a/backend/src/superTabs/notices.test.ts
+++ b/backend/src/superTabs/notices.test.ts
@@ -76,15 +76,16 @@ describe('the notices the Swarm writes into a chat', () => {
const written = writtenKinds()
it('finds the notices it is known to write, so a change in how they are written cannot empty this check', () => {
- expect([...written.keys()]).toEqual(expect.arrayContaining(['system', 'instructions', 'agent-only', 'idle', 'review-failed', 'work-lost', 'terminal-alert', 'native', 'ship']))
+ expect([...written.keys()]).toEqual(expect.arrayContaining(['system', 'instructions', 'agent-only', 'idle', 'review-failed', 'work-lost', 'terminal-alert', 'native', 'task-line']))
})
it('classifies every kind it writes, and only those', () => {
const unclassified = [...written].filter(([kind]) => !Object.hasOwn(NOTICE_READERS, kind)).map(([kind, files]) => `${kind} (${files.join(', ')})`)
expect(unclassified, 'add each to NOTICE_READERS in model.ts: who reads it?').toEqual([])
// A kind no longer written keeps its readers for the rows stored before: the server's idle stop (project instructions,
- // phase 4) told only the Lead; the coordinator's progress post, now the project's status card (Dee, 2026-10-31), people.
- const retired = ['idle-stop', 'project-report']
+ // phase 4) told only the Lead; the coordinator's progress post, now the project's status card (Dee, 2026-10-31), people;
+ // the Shipped line, now the task's own line (taskLine.ts; Quiet Swarm, Dee, 2026-11-02), people.
+ const retired = ['idle-stop', 'project-report', 'ship']
expect(Object.keys(NOTICE_READERS).filter(kind => !written.has(kind) && !retired.includes(kind))).toEqual([])
expect(retired.filter(kind => written.has(kind))).toEqual([])
})
diff --git a/backend/src/superTabs/read/contract.ts b/backend/src/superTabs/read/contract.ts
index 1934f0cb9..00d6f8d27 100644
--- a/backend/src/superTabs/read/contract.ts
+++ b/backend/src/superTabs/read/contract.ts
@@ -34,7 +34,10 @@ export type AgentView = Omit<Agent, 'downNamed' | 'downSince' | 'limitedUntil' |
export interface Audience { people: Array<{ id: string; generation: string }> }
/** A conversation with its own message counter (`lastMessageSequence` and message sequences compare within one group).
* `dormant` is set only on a dormant group fetched on demand; `audience` only on a private conversation. */
-export type GroupView = Omit<Conversation, 'messageSeq' | 'reportSeq' | 'dormant' | 'lastActivityAt' | 'audience' | 'ledger' | 'proposals'>
+export type GroupView = Omit<Conversation, 'messageSeq' | 'reportSeq' | 'dormant' | 'lastActivityAt' | 'audience' | 'ledger' | 'proposals'> & {
+ /** When it shipped (ms): its first Done; absent until it has. Nothing else of its ledger is sent. */
+ shippedAt?: number
+}
& { messageSeq: number; dormant?: true; audience?: Audience
/** A Buddy chat's owner, in place of its audience (read/views.ts groupView). */
buddyOwnerId?: string }
diff --git a/backend/src/superTabs/read/views.test.ts b/backend/src/superTabs/read/views.test.ts
index 8ab409b4e..79e0ba2e3 100644
--- a/backend/src/superTabs/read/views.test.ts
+++ b/backend/src/superTabs/read/views.test.ts
@@ -79,6 +79,19 @@ describe('reader view of the parts (design 4.1, 4.3)', () => {
for (const hidden of ['reportSeq', 'lastActivityAt', 'dormant', 'audience']) expect(web.data).not.toHaveProperty(hidden)
})
+ it('tells readers when a group shipped, and nothing else of its ledger', () => {
+ const { s } = scene()
+ const shipped = (ledger?: Record<string, unknown>) => {
+ s.edit(state => { const group = state.conversations.find(c => c.id === s.web)!; if (ledger) group.ledger = ledger as never; else delete group.ledger })
+ const parts = store.split(s.state, { tabId: 'tab', version: R, now: NOW })
+ return readerView(parts, peer, NOW, { teamMachines: [] }).parts.groups.find(g => g.key === s.web)!.data
+ }
+ expect(shipped({ shippedAt: NOW - 50 })).toMatchObject({ shippedAt: NOW - 50 })
+ expect(shipped({})).not.toHaveProperty('shippedAt')
+ expect(shipped()).not.toHaveProperty('shippedAt')
+ expect(shipped({ shippedAt: NOW - 50 })).not.toHaveProperty('ledger')
+ })
+
it('shows an older Swarm\'s stored Leads conversation to nobody, its id neither (model.ts leadsRemoved)', () => {
const s = richSwarm()
s.edit(state => { storeOldLeads(state, [s.lead]) })
diff --git a/backend/src/superTabs/read/views.ts b/backend/src/superTabs/read/views.ts
index 69cf9e513..4cd245ec9 100644
--- a/backend/src/superTabs/read/views.ts
+++ b/backend/src/superTabs/read/views.ts
@@ -59,13 +59,14 @@ export const envelope = <T>(part: Pick<Part, 'key' | 'version' | 'changedAt'>, d
({ key: part.key, version: part.version, changedAt: part.changedAt, data })
/** A group as readers get it: its message counter, a dormant flag only when dormant, never the store's bookkeeping or the
- * leaderboard's (the leaderboard read sums it). */
+ * leaderboard's (the leaderboard read sums it), except when it shipped. */
export function groupView(group: Conversation, seenMachines: ReadonlySet<string>): GroupView {
- const { messageSeq, reportSeq: _report, lastActivityAt: _activity, ledger: _ledger, proposals: _proposals, dormant, audience, ...rest } = withSeenRequirement(group, seenMachines)
+ const { messageSeq, reportSeq: _report, lastActivityAt: _activity, ledger, proposals: _proposals, dormant, audience, ...rest } = withSeenRequirement(group, seenMachines)
// A Buddy chat names its owner instead of an audience: an app from before Buddies takes a private chat of the reader
// alone for their Chat with PM, and would send what they write for the PM to their Buddy instead (buddies.ts).
const readers = isBuddyChat(group) ? { buddyOwnerId: audience!.people[0]!.id } : audience ? { audience } : {}
- return { ...rest, messageSeq: messageSeq ?? 0, ...(dormant ? { dormant: true as const } : {}), ...readers }
+ const shippedAt = ledger?.shippedAt
+ return { ...rest, messageSeq: messageSeq ?? 0, ...(dormant ? { dormant: true as const } : {}), ...(shippedAt === undefined ? {} : { shippedAt }), ...readers }
}
/** A conversation's whole data as the reader may see it: a task's requirement lists only the machines they see. */
diff --git a/backend/src/superTabs/ship.test.ts b/backend/src/superTabs/ship.test.ts
deleted file mode 100644
index 93471f2f6..000000000
--- a/backend/src/superTabs/ship.test.ts
+++ /dev/null
@@ -1,123 +0,0 @@
-import { describe, expect, it } from 'vitest'
-import { applyCommand, type Command, type CommandContext } from './commands.js'
-import { createSuperTab, type Actor, type AgentConfiguration } from './model.js'
-import { SHIP_KIND } from './ship.js'
-
-const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }
-const config: AgentConfiguration = { engine: 'claude', model: 'opus', effort: 'high', contextWindow: null, engineVersion: null }
-const PR = 'https://github.com/example/app/pull/7'
-
-function fixture() {
- let state = createSuperTab('tab', 'Office', { id: 'owner', email: owner.email }, 'prod')
- let sequence = 0
- const run = (command: Command, actor: Actor = owner, context: Partial<CommandContext> = {}) => {
- const effects = applyCommand(state, actor, command, { now: 1000, operationId: `op-${++sequence}`, ...context })
- state = effects.state
- return effects
- }
- const add = (name: string, group: string, lead = false) => run({ type: 'agent.add', conversationId: group, machineId: 'host', harnessId: name,
- name, configuration: config, lead }, owner, { contribution: { machineOwnerId: 'host-owner', contributorId: 'owner' } }).result.agentId as string
- const lead = add('River', 'lead', true)
- const as = (agentId: string): Actor => ({ kind: 'agent', agentId, machineOwnerId: 'host-owner' })
- const group = (title = 'Avatars', extra: Record<string, unknown> = {}) => run({ type: 'conversation.create', title, brief: 'Add avatars.',
- checks: [{ description: 'Tests pass', independent: false }], ...extra } as Command).result.conversationId as string
- /** Passes the task's first check as [passer] (its worker by default), then marks it Done as its worker. */
- const finish = (id: string, worker: string, result = `Merged ${PR}`, passer = worker) => {
- const work = state.conversations.find(c => c.id === id)!
- const assignment = work.assignment!.id
- run({ type: 'work.check', conversationId: id, assignmentId: assignment, checkId: work.checks[0]!.id, passed: true, evidence: 'npm test: 12 passed' }, as(passer))
- return run({ type: 'work.status', conversationId: id, assignmentId: assignment, status: 'done', result }, as(worker))
- }
- const ships = (effects: ReturnType<typeof run>) => effects.messages.filter(m => m.source?.kind === SHIP_KIND)
- return { run, add, as, group, finish, ships, lead, get state() { return state } }
-}
-
-describe('the ship moment', () => {
- it('posts one celebration in the project chat naming the requester, builder and reviewers', () => {
- const f = fixture()
- const id = f.group()
- const builder = f.add('Kai', id)
- const reviewer = f.add('Ivy', id)
- f.state.agents.find(a => a.id === reviewer)!.role = 'reviewer'
- f.run({ type: 'work.assign', conversationId: id, agentId: builder }, owner)
- const [line, ...more] = f.ships(f.finish(id, builder, undefined, reviewer))
- expect(more).toEqual([])
- expect(line).toMatchObject({ conversationId: 'lead', recipients: [],
- source: { kind: SHIP_KIND, conversationId: id, title: 'Avatars', pullRequests: [PR], requesterId: 'owner', builderIds: [builder], reviewerIds: [reviewer] } })
- expect(line!.text).toBe(`🎉 Shipped: Avatars, requested by dee, built by Kai, reviewed by Ivy. ${PR}`)
- })
-
- it('leaves out who asked when nobody is recorded, and counts who passed a linked task\'s check', () => {
- const f = fixture()
- const id = f.group()
- delete f.state.conversations.find(c => c.id === id)!.requesterId
- const builder = f.add('Kai', id)
- const review = f.run({ type: 'conversation.create', title: 'Review avatars', brief: 'Review.', reviewOf: id, checks: [{ description: 'Verdict', independent: false }] })
- .result.conversationId as string
- const reviewer = f.add('Ivy', review)
- f.run({ type: 'work.assign', conversationId: id, agentId: builder }, owner)
- f.run({ type: 'work.assign', conversationId: review, agentId: reviewer }, owner)
- const verdict = f.state.conversations.find(c => c.id === review)!
- f.run({ type: 'work.check', conversationId: review, assignmentId: verdict.assignment!.id, checkId: verdict.checks[0]!.id, passed: true, evidence: 'Ready: yes' }, f.as(reviewer))
- const [line] = f.ships(f.finish(id, builder))
- expect(line!.source).not.toHaveProperty('requesterId')
- expect(line!.text).toBe(`🎉 Shipped: Avatars, built by Kai, reviewed by Ivy. ${PR}`)
- })
-
- // Review credit goes to whoever passed a check on another agent's task (project instructions, phase 4), never by role.
- it('names who passed its checks as reviewers, whatever their role', () => {
- const f = fixture()
- const id = f.group('Avatars', { checks: [{ description: 'Tests pass', independent: false }, { description: 'Reviewed', independent: false }] })
- const builder = f.add('Kai', id), checker = f.add('Max', id), bystander = f.add('Lee', id)
- f.state.agents.find(a => a.id === bystander)!.role = 'reviewer'
- const review = f.run({ type: 'conversation.create', title: 'Test avatars', brief: 'Test.', reviewOf: id, checks: [{ description: 'Tested', independent: false }] })
- .result.conversationId as string
- const tester = f.add('Ivy', review)
- f.run({ type: 'work.assign', conversationId: id, agentId: builder }, owner)
- f.run({ type: 'work.assign', conversationId: review, agentId: tester }, owner)
- const linked = f.state.conversations.find(c => c.id === review)!
- f.run({ type: 'work.check', conversationId: review, assignmentId: linked.assignment!.id, checkId: linked.checks[0]!.id, passed: true, evidence: 'Tested' }, f.as(tester))
- const work = f.state.conversations.find(c => c.id === id)!
- f.run({ type: 'work.check', conversationId: id, assignmentId: work.assignment!.id, checkId: work.checks[1]!.id, passed: true, evidence: 'Looks right' }, f.as(checker))
- // The assignee passes its own first check: never its own reviewer.
- const [line] = f.ships(f.finish(id, builder))
- expect(line!.source).toMatchObject({ builderIds: [builder], reviewerIds: [checker, tester] })
- expect(line!.text).toBe(`🎉 Shipped: Avatars, requested by dee, built by Kai, reviewed by Max and Ivy. ${PR}`)
- })
-
- it('celebrates a group once: reassigned and Done again, it stays quiet', () => {
- const f = fixture()
- const id = f.group()
- const builder = f.add('Kai', id)
- f.run({ type: 'work.assign', conversationId: id, agentId: builder }, owner)
- expect(f.ships(f.finish(id, builder))).toHaveLength(1)
- const again = f.add('Ivy', id)
- f.run({ type: 'agent.release', agentId: builder, decision: 'keep' }, f.as(f.lead))
- f.run({ type: 'work.assign', conversationId: id, agentId: again }, owner)
- expect(f.ships(f.finish(id, again, 'Follow-up merged https://github.com/example/app/pull/8'))).toEqual([])
- })
-
- it('stays quiet without a linked pull request, for a review group, and for other statuses', () => {
- const f = fixture()
- const id = f.group()
- const builder = f.add('Kai', id)
- f.run({ type: 'work.assign', conversationId: id, agentId: builder }, owner)
- const assignment = f.state.conversations.find(c => c.id === id)!.assignment!.id
- expect(f.ships(f.run({ type: 'work.status', conversationId: id, assignmentId: assignment, status: 'review', result: PR }, f.as(builder)))).toEqual([])
- expect(f.ships(f.finish(id, builder, 'Done, nothing to merge.'))).toEqual([])
- })
-
- it('never names a private conversation, its words or its link', () => {
- const f = fixture()
- const id = f.group('Secret plan')
- const builder = f.add('Kai', id)
- f.run({ type: 'work.assign', conversationId: id, agentId: builder }, owner)
- const work = f.state.conversations.find(c => c.id === id)!
- f.run({ type: 'work.check', conversationId: id, assignmentId: work.assignment!.id, checkId: work.checks[0]!.id, passed: true, evidence: 'ok' }, f.as(builder))
- // A private conversation (a Buddy chat) is chat only today; were one ever to carry work, its celebration still says nothing of it.
- Object.assign(f.state.conversations.find(c => c.id === id)!, { kind: 'buddy', audience: { people: [{ id: 'owner', generation: 'tab' }] } })
- const done = f.run({ type: 'work.status', conversationId: id, assignmentId: work.assignment!.id, status: 'done', result: `Merged ${PR}` })
- expect(f.ships(done)).toEqual([])
- expect(JSON.stringify(done.messages.filter(m => m.conversationId !== id))).not.toContain('Secret plan')
- })
-})
diff --git a/backend/src/superTabs/ship.ts b/backend/src/superTabs/ship.ts
index 8b3dcbfe5..3f16b5d67 100644
--- a/backend/src/superTabs/ship.ts
+++ b/backend/src/superTabs/ship.ts
@@ -1,36 +1,8 @@
-import { isLeads, stableId, type Author, type Conversation, type MessageDraft, type SuperTabState } from './model.js'
-import { agentDisplayName } from './agentNames.js'
-import { groupProject } from './projects.js'
+import type { Conversation } from './model.js'
-/** The source of the celebration row Desktop draws with confetti. */
+/** The source of the celebration row Desktop draws with confetti. No longer written: a task's line says it shipped
+ * (taskLine.ts); older rows still read as people's, and their requester's Buddy heard them (buddyNews.ts). */
export const SHIP_KIND = 'ship'
-/** How a check's `passedBy` names an agent (model.ts actorKey). */
-const AGENT_KEY = 'agent:'
/** When the group first shipped, as the leaderboard records it (leaderboard/record.ts `recordStatus`: once, on the first Done). */
export const shippedAt = (group: Conversation): number | undefined => group.ledger?.shippedAt
-
-/** Work just became Done. When it links a pull request, the project chat gets one line naming who asked, who built it and
- * who reviewed it ("Done with a linked PR" is shipped: Leads mark Done after the merge). A private conversation is never
- * celebrated: its title, words and link are its own. No agent is woken by it. A group is one request: only its first ship is
- * celebrated, not a later attempt's Done (the caller checks `shippedAt` from before the command). */
-export function shipNotice(state: SuperTabState, group: Conversation, author: Author, operationId: string): MessageDraft | null {
- const pullRequests = group.pullRequestUrls ?? []
- if (!pullRequests.length || group.audience || group.reviewOf || isLeads(group) || !group.assignment) return null
- const project = groupProject(state, group)
- const agentName = (id: string) => agentDisplayName(state.agents, id) ?? state.agents.find(a => a.id === id)?.name
- const builderIds = [group.assignment.agentId].filter(id => agentName(id))
- // Reviewed by whoever passed a check on it or on a task linked to it, whatever its role, but never by its own assignee
- // (project instructions, phase 4).
- const passers = [group, ...state.conversations.filter(c => c.reviewOf === group.id)].flatMap(c => c.checks)
- .flatMap(c => c.passedBy?.startsWith(AGENT_KEY) ? [c.passedBy.slice(AGENT_KEY.length)] : [])
- const reviewerIds = [...new Set(passers)].filter(id => id !== group.assignment!.agentId && agentName(id))
- const requester = state.people.find(p => p.id === group.requesterId)
- const names = (ids: string[]) => ids.map(agentName).join(' and ')
- const credits = [requester && `requested by ${requester.email.split('@')[0]}`, builderIds.length && `built by ${names(builderIds)}`,
- reviewerIds.length && `reviewed by ${names(reviewerIds)}`].filter(Boolean)
- return { id: stableId(operationId, SHIP_KIND), conversationId: project.leadConversationId, author, replyTo: null, recipients: [],
- text: `🎉 Shipped: ${group.title}${credits.length ? `, ${credits.join(', ')}` : ''}. ${pullRequests.join(' ')}`,
- source: { kind: SHIP_KIND, conversationId: group.id, title: group.title, pullRequests, ...(requester ? { requesterId: requester.id } : {}),
- builderIds, reviewerIds } }
-}
diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.ts
index 1c8200730..ff70f697f 100644
--- a/backend/src/superTabs/store.ts
+++ b/backend/src/superTabs/store.ts
@@ -1716,6 +1716,10 @@ export class SuperTabStore {
}
await recordEvidence(tx, tabId, original, effects.state, context.now)
await this.writeMessages(tx, tabId, effects.state, effects.messages, sequences)
+ // A task's line takes its new words in place, keeping its id, place and author (taskLine.ts).
+ for (const edit of effects.edits ?? []) {
+ await tx.superTabMessage.updateMany({ where: { tabId, conversationId: edit.conversationId, id: edit.id }, data: { text: edit.text, source: json(edit.source) } })
+ }
if (effects.lateDeliveries?.length) await this.writeLateDeliveries(tx, tabId, effects.state, effects.lateDeliveries)
if (command.type === 'message.send' && actor.kind === 'person') await resolveByReply(tx, tabId, command.conversationId, actor.userId, context.now)
if (command.type === 'work.assign') await resolveWhenWorked(tx, tabId, command.conversationId, context.now)
diff --git a/backend/src/superTabs/taskLine.test.ts b/backend/src/superTabs/taskLine.test.ts
new file mode 100644
index 000000000..7ec3418a2
--- /dev/null
+++ b/backend/src/superTabs/taskLine.test.ts
@@ -0,0 +1,172 @@
+import { describe, expect, it } from 'vitest'
+import { applyCommand, type Command, type CommandContext } from './commands.js'
+import { createSuperTab, type Actor, type AgentConfiguration, type CommandEffects } from './model.js'
+import { SHIP_KIND } from './ship.js'
+import { TASK_LINE_KIND } from './taskLine.js'
+
+const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }
+const config: AgentConfiguration = { engine: 'claude', model: 'opus', effort: 'high', contextWindow: null, engineVersion: null }
+const PR = 'https://github.com/example/app/pull/7'
+
+function fixture() {
+ let state = createSuperTab('tab', 'Office', { id: 'owner', email: owner.email }, 'prod')
+ let sequence = 0
+ const run = (command: Command, actor: Actor = owner, context: Partial<CommandContext> = {}) => {
+ const effects = applyCommand(state, actor, command, { now: 1000 + sequence, operationId: `op-${++sequence}`, ...context })
+ state = effects.state
+ return effects
+ }
+ const add = (name: string, group: string, lead = false) => run({ type: 'agent.add', conversationId: group, machineId: 'host', harnessId: name,
+ name, configuration: config, lead }, owner, { contribution: { machineOwnerId: 'host-owner', contributorId: 'owner' } }).result.agentId as string
+ const pm = add('River', 'lead', true)
+ const as = (agentId: string): Actor => ({ kind: 'agent', agentId, machineOwnerId: 'host-owner' })
+ const group = (title = 'Offline drafts', extra: Record<string, unknown> = {}) => run({ type: 'conversation.create', title, brief: 'Keep drafts.',
+ checks: [], ...extra } as Command).result.conversationId as string
+ const task = (id: string) => state.conversations.find(c => c.id === id)!
+ const status = (id: string, worker: string, value: 'working' | 'needs_human' | 'blocked' | 'review' | 'done' | 'stopped', result: string | null = null,
+ extra: Record<string, unknown> = {}) =>
+ run({ type: 'work.status', conversationId: id, assignmentId: task(id).assignment!.id, status: value, result, ...extra } as Command, as(worker))
+ const lines = (effects: CommandEffects) => effects.messages.filter(m => m.source?.kind === TASK_LINE_KIND)
+ return { run, add, as, group, task, status, lines, pm, get state() { return state } }
+}
+
+describe('a task\'s one line in its project chat', () => {
+ it('posts one line in the project chat when a task is assigned', () => {
+ const f = fixture()
+ const id = f.group()
+ const builder = f.add('Kai', id)
+ const effects = f.run({ type: 'work.assign', conversationId: id, agentId: builder })
+ const [line, ...more] = f.lines(effects)
+ expect(more).toEqual([])
+ expect(line).toMatchObject({ conversationId: 'lead', recipients: [], replyTo: null, text: 'Offline drafts · planned',
+ author: { kind: 'agent', id: f.pm },
+ source: { kind: TASK_LINE_KIND, taskId: id, number: f.task(id).number, title: 'Offline drafts', state: 'planned', builderId: builder, requesterId: 'owner' } })
+ expect(line!.source).not.toHaveProperty('answerFor')
+ expect(f.task(id).cards?.line).toMatchObject({ messageId: line!.id, state: 'planned' })
+ })
+
+ it('edits the same line through working, waiting, review, ready and shipped', () => {
+ const f = fixture()
+ const id = f.group()
+ const builder = f.add('Kai', id)
+ const lineId = f.lines(f.run({ type: 'work.assign', conversationId: id, agentId: builder }))[0]!.id
+ const seq = () => f.state.conversations.find(c => c.id === 'lead')!.reactionSeq ?? 0
+ const steps: Array<[Parameters<typeof f.status>[2], string, Record<string, unknown>, Record<string, unknown>]> = [
+ ['working', 'Offline drafts · working', { state: 'working' }, {}],
+ ['needs_human', 'Offline drafts · waiting on dee', { state: 'waiting', answerFor: 'owner' },
+ { ask: { personId: 'owner', options: ['Keep', 'Drop'], recommended: 0, unblocks: 'The release' } }],
+ ['review', 'Offline drafts · in review', { state: 'review' }, {}],
+ // Done with its pull request, not merged yet: ready, never shipped (PM, review of #2633).
+ ['done', 'Offline drafts · ready', { state: 'ready' }, {}],
+ ]
+ for (const [value, text, source, extra] of steps) {
+ const before = seq()
+ const effects = f.status(id, builder, value, value === 'needs_human' ? 'Keep drafts after a restart?' : value === 'done' ? `Review passed: ${PR}` : null, extra)
+ expect(f.lines(effects)).toEqual([])
+ expect(effects.edits).toEqual([expect.objectContaining({ id: lineId, conversationId: 'lead', text,
+ source: expect.objectContaining({ kind: TASK_LINE_KIND, taskId: id, ...source }) })])
+ if (!('answerFor' in source)) expect(effects.edits![0]!.source).not.toHaveProperty('answerFor')
+ expect(seq()).toBe(before + 1)
+ }
+ // Shipped once its merge is recorded, and only then.
+ const merged = f.run({ type: 'conversation.merged', conversationId: id, pullRequestUrl: PR })
+ expect(merged.edits).toEqual([expect.objectContaining({ id: lineId, text: 'Offline drafts · shipped', source: expect.objectContaining({ state: 'shipped' }) })])
+ expect(f.run({ type: 'conversation.merged', conversationId: id, pullRequestUrl: PR }).edits ?? []).toEqual([])
+ })
+
+ it('reads done, never shipped, for work Done with no pull request', () => {
+ const f = fixture()
+ const id = f.group('Review: PR #2632')
+ const builder = f.add('Kai', id)
+ const lineId = f.lines(f.run({ type: 'work.assign', conversationId: id, agentId: builder }))[0]!.id
+ const done = f.status(id, builder, 'done', 'Ready to merge: Yes.')
+ expect(done.edits).toEqual([expect.objectContaining({ id: lineId, text: 'Review: PR #2632 · done', source: expect.objectContaining({ state: 'done' }) })])
+ })
+
+ it('writes no Shipped line for a task with a line', () => {
+ const f = fixture()
+ const id = f.group()
+ const builder = f.add('Kai', id)
+ f.run({ type: 'work.assign', conversationId: id, agentId: builder })
+ const effects = f.status(id, builder, 'done', `Merged ${PR}`)
+ expect(effects.messages.filter(m => m.source?.kind === SHIP_KIND)).toEqual([])
+ })
+
+ it('does not edit for a repeated status or a plain message', () => {
+ const f = fixture()
+ const id = f.group()
+ const builder = f.add('Kai', id)
+ f.run({ type: 'work.assign', conversationId: id, agentId: builder })
+ f.status(id, builder, 'working', 'Started.')
+ const seq = f.state.conversations.find(c => c.id === 'lead')!.reactionSeq
+ expect(f.status(id, builder, 'working', 'Halfway.').edits ?? []).toEqual([])
+ expect(f.status(id, builder, 'blocked', 'Waiting on CI.').edits ?? []).toEqual([])
+ expect(f.run({ type: 'message.send', conversationId: id, text: 'Pushed.', replyTo: null, recipientIds: [] }, f.as(builder)).edits ?? []).toEqual([])
+ expect(f.state.conversations.find(c => c.id === 'lead')!.reactionSeq).toBe(seq)
+ })
+
+ it('gives a step no line and leaves its task\'s line alone', () => {
+ const f = fixture()
+ const id = f.group()
+ const builder = f.add('Kai', id)
+ f.run({ type: 'work.assign', conversationId: id, agentId: builder })
+ f.status(id, builder, 'review', 'Ready.')
+ const step = f.run({ type: 'conversation.create', title: 'Review', step: 'Review', reviewOf: id, brief: 'Review it.', checks: [] }, f.as(builder))
+ .result.conversationId as string
+ const reviewer = f.add('Ivy', step)
+ const assigned = f.run({ type: 'work.assign', conversationId: step, agentId: reviewer }, f.as(builder))
+ const finished = f.status(step, reviewer, 'done', 'Ready to merge: Yes.')
+ for (const effects of [assigned, finished]) {
+ expect(f.lines(effects)).toEqual([])
+ expect(effects.edits ?? []).toEqual([])
+ }
+ expect(f.task(step).cards?.line).toBeUndefined()
+ expect(f.task(id).cards?.line?.state).toBe('review')
+ })
+
+ it('keeps one line through a task stopped and reassigned', () => {
+ const f = fixture()
+ const id = f.group()
+ const first = f.add('Kai', id), second = f.add('Max', id)
+ const lineId = f.lines(f.run({ type: 'work.assign', conversationId: id, agentId: first }))[0]!.id
+ f.status(id, first, 'working', 'Started.')
+ const stopped = f.run({ type: 'work.cancel', conversationId: id, assignmentId: f.task(id).assignment!.id, reason: 'Moving it on.' }, f.as(f.pm))
+ expect(stopped.edits).toEqual([expect.objectContaining({ id: lineId, text: 'Offline drafts · stopped', source: expect.objectContaining({ state: 'stopped' }) })])
+ const again = f.run({ type: 'work.assign', conversationId: id, agentId: second }, f.as(f.pm))
+ expect(f.lines(again)).toEqual([])
+ expect(again.edits).toEqual([expect.objectContaining({ id: lineId, source: expect.objectContaining({ state: 'planned', builderId: second }) })])
+ })
+
+ it('follows a rename of the task', () => {
+ const f = fixture()
+ const id = f.group()
+ const builder = f.add('Kai', id)
+ const lineId = f.lines(f.run({ type: 'work.assign', conversationId: id, agentId: builder }))[0]!.id
+ const renamed = f.run({ type: 'conversation.rename', conversationId: id, title: 'Drafts survive a restart' })
+ expect(renamed.edits).toEqual([expect.objectContaining({ id: lineId, text: 'Drafts survive a restart · planned',
+ source: expect.objectContaining({ title: 'Drafts survive a restart' }) })])
+ })
+
+ it('posts a private project\'s task line in that project\'s own chat', () => {
+ const f = fixture()
+ const project = f.run({ type: 'project.create', name: 'Secret', visibility: 'private', brief: '' }).result.projectId as string
+ const chat = f.state.projects!.find(p => p.id === project)!.leadConversationId
+ const id = f.group('Hidden work', { projectId: project })
+ const builder = f.add('Kai', id)
+ const [line] = f.lines(f.run({ type: 'work.assign', conversationId: id, agentId: builder }))
+ expect(line!.conversationId).toBe(chat)
+ expect(line!.conversationId).not.toBe('lead')
+ })
+
+ it('posts nothing for a task that existed before lines until it changes, and nothing for a finished one', () => {
+ const f = fixture()
+ const id = f.group()
+ const builder = f.add('Kai', id)
+ f.run({ type: 'work.assign', conversationId: id, agentId: builder })
+ // As stored before this release: assigned, with no line.
+ delete f.task(id).cards
+ expect(f.lines(f.run({ type: 'message.send', conversationId: 'lead', text: 'Hello.', replyTo: null, recipientIds: [] }))).toEqual([])
+ const [line] = f.lines(f.status(id, builder, 'review', 'Ready.'))
+ expect(line).toMatchObject({ text: 'Offline drafts · in review', source: { state: 'review' } })
+ })
+})
diff --git a/backend/src/superTabs/taskLine.ts b/backend/src/superTabs/taskLine.ts
new file mode 100644
index 000000000..d1d0529f1
--- /dev/null
+++ b/backend/src/superTabs/taskLine.ts
@@ -0,0 +1,110 @@
+import { agentDisplayName } from './agentNames.js'
+import { isBuddyChat } from './buddies.js'
+import { shippedNotice } from './buddyNews.js'
+import { isLeads, stableId, type Author, type CommandEffects, type Conversation, type MessageDraft, type SuperTabState, type WorkStatus } from './model.js'
+import { groupProject, projectsOf } from './projects.js'
+import { isStep } from './steps.js'
+import { usernameOf } from './usernames.js'
+
+/**
+ * A task's one message in its project chat (Quiet Swarm, Dee, 11-02; docs/plans/2026-11-02-quiet-swarm-task-line-plan.md):
+ * like a Slack bot's long job, one message that keeps itself current until it ships, its thread the task's own
+ * conversation. It replaces the Shipped line. The server posts it when a task first has an Engineer and edits it in place
+ * as the task moves, only when its words change; Desktop and the phone draw it from its source, an older client from its
+ * text. It wakes nobody.
+ */
+export const TASK_LINE_KIND = 'task-line'
+/** `ready`: Done with its pull request, not merged yet; `shipped`: a merge of it recorded; `done`: Done with no pull request,
+ * such as a review (PM, review of #2633). */
+export type TaskLineState = 'planned' | 'working' | 'waiting' | 'review' | 'ready' | 'shipped' | 'done' | 'stopped'
+/** What the line last showed, kept on its task (cards.ts GroupCards.line). `reported`: the assignment whose agent has sent a
+ * status, so the line reads planned until then. */
+export interface TaskLine { messageId: string; conversationId: string; state: TaskLineState; title: string; builderId: string; answerFor?: string; reported?: string }
+/** A stored message's new words, written by the store over the row with that id (store.ts). */
+export interface MessageEdit { id: string; conversationId: string; text: string; source: Record<string, unknown> }
+
+const WORDS: Record<Exclude<TaskLineState, 'waiting'>, string> = { planned: 'planned', working: 'working', review: 'in review', ready: 'ready',
+ shipped: 'shipped', done: 'done', stopped: 'stopped' }
+const MOVING: ReadonlySet<WorkStatus> = new Set(['working', 'blocked', 'reconciling', 'lost'])
+
+/** A task of a project with work of its own: never a step, the project chat, a Buddy chat, the Leads chat, or a private
+ * conversation (chat only: it holds no work, and its words are its own). */
+function lined(chats: ReadonlySet<string>, group: Conversation): boolean {
+ return !group.kind && !isLeads(group) && !isBuddyChat(group) && !isStep(group) && !group.audience && !chats.has(group.id)
+}
+
+/** What [group]'s line shows now. [reported]: its agent sent a status in this command. */
+function drawn(group: Conversation, line: TaskLine | undefined, reported: boolean): Omit<TaskLine, 'messageId' | 'conversationId'> {
+ const assignment = group.assignment!
+ const status = assignment.status
+ const heard = reported || line?.reported === assignment.id
+ // Shipped only once a merge is recorded (conversation.merged), never on Done alone: the batch merges after the review passed.
+ const state: TaskLineState = status === 'working' && !heard ? 'planned' : MOVING.has(status) ? 'working'
+ : status === 'needs_human' ? 'waiting' : group.ledger?.mergedAt != null ? 'shipped' : status === 'review' ? 'review'
+ : status === 'done' ? group.pullRequestUrls?.length ? 'ready' : 'done' : 'stopped'
+ return { state, title: group.title, builderId: assignment.agentId, ...(state === 'waiting' && assignment.askedOf ? { answerFor: assignment.askedOf } : {}),
+ ...(heard ? { reported: assignment.id } : {}) }
+}
+
+const same = (a: Omit<TaskLine, 'messageId' | 'conversationId'>, b: TaskLine) => a.state === b.state && a.title === b.title
+ && a.builderId === b.builderId && a.answerFor === b.answerFor
+
+function words(state: SuperTabState, line: Omit<TaskLine, 'messageId' | 'conversationId'>): string {
+ const asked = line.answerFor && usernameOf(state, line.answerFor)
+ return `${line.title} · ${line.state === 'waiting' ? asked ? `waiting on ${asked}` : 'waiting' : WORDS[line.state]}`
+}
+
+/** The line's source, but for its kind (written beside each `source` as TASK_LINE_KIND, notices.test.ts reads it there). */
+function fields(group: Conversation, line: Omit<TaskLine, 'messageId' | 'conversationId'>): Record<string, unknown> {
+ return { taskId: group.id, ...(group.number != null ? { number: group.number } : {}), title: line.title, state: line.state,
+ ...(line.answerFor ? { answerFor: line.answerFor } : {}), builderId: line.builderId, ...(group.requesterId ? { requesterId: group.requesterId } : {}) }
+}
+
+/** The line's author: its project's coordinator, as the server's other notices in that chat are (tidy.ts), else whoever moved
+ * the task. */
+function lineAuthor(state: SuperTabState, chat: Conversation, sender: Author | undefined): Author | undefined {
+ const coordinator = chat.leadId ? state.agents.find(a => a.id === chat.leadId) : undefined
+ return coordinator ? { kind: 'agent', id: coordinator.id, name: coordinator.name, displayName: agentDisplayName(state.agents, coordinator.id),
+ membershipGeneration: coordinator.membershipGeneration } : sender
+}
+
+/** After a command: each task whose line's words changed has it posted (the first time its assignment changes) or edited,
+ * and the chat's reaction counter moves for each edit, so a reader polling it reads the page shown again (reactions.ts).
+ * A task that had work before lines gets its line at its next change; one that never changes again, none. */
+export function syncTaskLines(before: SuperTabState, effects: CommandEffects, reported: string | undefined, sender: Author | undefined, operationId: string): void {
+ const state = effects.state
+ let earlier: Map<string, Conversation> | undefined
+ const was = (id: string) => (earlier ??= new Map(before.conversations.map(c => [c.id, c]))).get(id)
+ const chats = new Set(projectsOf(state).map(p => p.leadConversationId))
+ for (const group of state.conversations) {
+ if (!group.assignment || !lined(chats, group)) continue
+ const line = group.cards?.line
+ const now = drawn(group, line, reported === group.id)
+ if (line) {
+ if (same(now, line)) {
+ if (now.reported !== line.reported) group.cards = { ...group.cards, line: { ...line, ...now } }
+ continue
+ }
+ const chat = state.conversations.find(c => c.id === line.conversationId)
+ if (!chat) continue
+ effects.edits = [...effects.edits ?? [], { id: line.messageId, conversationId: chat.id, text: words(state, now), source: { kind: TASK_LINE_KIND, ...fields(group, now) } }]
+ chat.reactionSeq = (chat.reactionSeq ?? 0) + 1
+ group.cards = { ...group.cards, line: { messageId: line.messageId, conversationId: chat.id, ...now } }
+ } else {
+ const previous = was(group.id)?.assignment
+ if (previous && previous.id === group.assignment.id && previous.status === group.assignment.status && previous.askedOf === group.assignment.askedOf) continue
+ const chat = state.conversations.find(c => c.id === groupProject(state, group).leadConversationId)
+ const author = chat && lineAuthor(state, chat, sender)
+ if (!chat || !author) continue
+ const message: MessageDraft = { id: stableId(operationId, TASK_LINE_KIND, group.id), conversationId: chat.id, author, text: words(state, now),
+ replyTo: null, recipients: [], source: { kind: TASK_LINE_KIND, ...fields(group, now) } }
+ effects.messages.push(message)
+ group.cards = { ...group.cards, line: { messageId: message.id, conversationId: chat.id, ...now } }
+ }
+ // Only its first recorded merge is news, as the Shipped line was: a merge recorded again tells nobody again.
+ if (now.state === 'shipped' && was(group.id)?.ledger?.mergedAt == null) {
+ const news = sender && shippedNotice(state, group, sender, operationId)
+ if (news) effects.messages.push(news)
+ }
+ }
+}
diff --git a/backend/vitest.super-tabs.config.ts b/backend/vitest.super-tabs.config.ts
index fbf154152..aca32dbc4 100644
--- a/backend/vitest.super-tabs.config.ts
+++ b/backend/vitest.super-tabs.config.ts
@@ -8,5 +8,5 @@ export default defineConfig({ test: { include: ['integration/superTabs.test.ts',
'integration/superTabBuddyProbes.test.ts', 'integration/superTabBuddySessions.test.ts', 'integration/superTabSwarmBuddy.test.ts', 'integration/superTabCosts.test.ts', 'integration/harnessSharesList.test.ts', 'integration/atlasSnapshot.test.ts', 'integration/queryStats.test.ts',
'integration/superTabEvidence.test.ts', 'integration/superTabAttemptModels.test.ts', 'integration/superTabNamedReads.test.ts', 'integration/swarmSweepPlans.test.ts', 'integration/workerIndexPlans.test.ts', 'integration/superTabReflection.test.ts',
'integration/superTabMessagePages.test.ts', 'integration/superTabDeliveryCompaction.test.ts', 'integration/superTabNoticeDigest.test.ts', 'integration/superTabCommandLoads.test.ts', 'integration/superTabThreads.test.ts', 'integration/superTabMachineRemovals.test.ts',
- 'integration/superTabInstructions.test.ts', 'integration/superTabWorkflow.test.ts', 'integration/superTabDeletion.test.ts'], hookTimeout: 120000, testTimeout: 30000, setupFiles: ['integration/cacheOn.test-support.ts', 'src/lib/noRedis.test-support.ts'],
+ 'integration/superTabInstructions.test.ts', 'integration/superTabWorkflow.test.ts', 'integration/superTabTaskLines.test.ts', 'integration/superTabDeletion.test.ts'], hookTimeout: 120000, testTimeout: 30000, setupFiles: ['integration/cacheOn.test-support.ts', 'src/lib/noRedis.test-support.ts'],
fileParallelism: false, env: { NODE_ENV: 'test', HARNESS_CREDENTIAL_ENCRYPTION_KEY: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' } } })
diff --git a/cli/src/cable/machineFleet.ts b/cli/src/cable/machineFleet.ts
index fb358d688..430cfa008 100644
--- a/cli/src/cable/machineFleet.ts
+++ b/cli/src/cable/machineFleet.ts
@@ -10,6 +10,7 @@ import type { ReviewedAnswer } from './questionInbox.js'
// round trip, a failure mode and an audience — for nothing.
import type { CableAgent } from './cableSession.js'
import type { RecentTurn } from './cableHost.js'
+import type { Tier } from '../lib/notifyTier.js'
/** One of the owner's machines, as the fleet knows it. The local row is added by the host, not here. */
/**
@@ -43,7 +44,9 @@ export class FleetError extends Error {
/** A card from an attached machine, already translated into the dial's four kinds. */
export type FleetEvent =
- | { machineId: string; kind: 'processing' | 'done' | 'summary' | 'error'; agentId: string; text: string; recap: string; subagent?: boolean; update?: string }
+ | { machineId: string; kind: 'processing' | 'done' | 'summary' | 'error'; agentId: string; text: string; recap: string; subagent?: boolean; update?: string
+ /** A summary's tier, as that machine's recaps decided it (services/recaps.ts): the dial follows it. */
+ tier?: Tier }
| { machineId: string; kind: 'question'; agentId: string; requestId: string; questions: unknown }
| { machineId: string; kind: 'questionClosed'; agentId: string; requestId: string }
| { machineId: string; kind: 'state'; state: FleetMachine['state'] }
diff --git a/cli/src/core/api.ts b/cli/src/core/api.ts
index 7c8fad9b6..51c1d135e 100644
--- a/cli/src/core/api.ts
+++ b/cli/src/core/api.ts
@@ -941,6 +941,10 @@ export interface RecapSession {
* where a turn ends, a cancel or a forget (reading it reads the orchestrator); absent, the recaps keep
* what they were last told. */
subagent?: boolean
+ /** Its finished turns are silent on the devices (the dial, the phone): its news reaches people another way. The core
+ * only carries this; who says it is outside the core (a Swarm agent's, through the Swarm's door: superTabs/inCore.ts).
+ * Said with every event, since the recaps in their own process have no agent list to look it up in (#2540's review). */
+ quietOnDevices?: boolean
}
/** Who watches this machine's turn cards: a device at all (through the backend or on the cable), and one
diff --git a/cli/src/core/main.ts b/cli/src/core/main.ts
index 87eb5d962..87ed4349f 100644
--- a/cli/src/core/main.ts
+++ b/cli/src/core/main.ts
@@ -201,7 +201,6 @@ import { createGuestCreate } from './agents/guestCreate.js'
import { createStoreLink } from './storeLink.js'
import { createModelsLink } from './modelsLink.js'
import { createRecapsLink } from './recapsLink.js'
-import { HOSTED_JEV_PATH } from '../lib/jev/jevClient.js'
import { createAgentCleanupLink } from './agentCleanupLink.js'
import { AGENT_CLEANUP_FALLBACKS, RECAPS_FALLBACKS, TERMINALS_OFF } from './api.js'
import { answerAgentQuery } from './agentQueries.js'
@@ -1477,6 +1476,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
bySession: (sessionId) => registry.bySession(sessionId), resolve: (id) => registry.resolve(id), live: () => registry.list(),
stopped: (agentId) => stoppedAgents.get(agentId),
orchestratorRoleOf: (agentId) => ports.orchestrator?.roleOf(agentId) ?? null,
+ quietOnDevices: (session) => swarm?.quietOnDevices(session) ?? false,
})
asking.hearQuestions(recaps.question) // a turn waiting on the person is not announced as done
const isSubagentSession = recaps.isSubagentSession
@@ -1583,8 +1583,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
if (outOfProcess.has('wifi')) ports.wifi = wifiLink.port
// What the core tells the recaps in their own process, and reads back from what they said (core/recapsLink.ts).
const recapsLink = createRecapsLink({ notify: (frame, opts) => serviceLinks.notify('recaps', frame, opts), buffered: () => serviceLinks.buffered('recaps'),
- call: (type, payload) => serviceLinks.call('recaps', type, payload), clients: coreApi.clients, lastTurn: coreApi.transcripts.lastTurn,
- jev: (body) => proxyBackend('POST', HOSTED_JEV_PATH, body) })
+ call: (type, payload) => serviceLinks.call('recaps', type, payload), clients: coreApi.clients, lastTurn: coreApi.transcripts.lastTurn })
// What the core tells the agent cleanup in its own process, and answers it (core/agentCleanupLink.ts).
const agentCleanupLink = createAgentCleanupLink(coreApi, (frame, opts) => serviceLinks.notify('agentCleanup', frame, opts))
const usageLink = createUsageLink({ call: payload => ports.usage?.read(payload.target as AgentUsageTarget) ?? Promise.resolve({}), changed: agentEvents.onTokenUsageChanged })
diff --git a/cli/src/core/recapsLink.spec.ts b/cli/src/core/recapsLink.spec.ts
index c0f6e5cf3..2aca9bfe4 100644
--- a/cli/src/core/recapsLink.spec.ts
+++ b/cli/src/core/recapsLink.spec.ts
@@ -13,7 +13,6 @@ function setup() {
call: vi.fn(async (_type: string, _payload: Record<string, unknown>): Promise<Record<string, unknown>> => ({ cards: [] })),
clients: { turnCard: vi.fn(), turnSummary: vi.fn() },
lastTurn: vi.fn(async (sessionId: string) => (sessionId === 's1' ? { assistantText: 'done', userMessage: 'go' } : null)),
- jev: vi.fn(async (_body: unknown): Promise<{ status: number; body: Record<string, unknown> }> => ({ status: 200, body: { data: { answers: {} } } })),
log: vi.fn(),
now: () => clock,
}
@@ -86,13 +85,11 @@ describe('the recaps in their own process, as the core sees them', () => {
expect(await link.answer('agents', {})).toEqual({ error: 'UNKNOWN_QUERY' })
})
- it('asks Harness\'s Jev for the process, signed by the core, and answers as the backend did', async () => {
- const { deps, link } = setup()
- const body = { state: { recap: 'Deployed' }, questions: {} }
- expect(await link.answer('jev', { body })).toEqual({ status: 200, body: { data: { answers: {} } } })
- expect(deps.jev).toHaveBeenCalledWith(body)
- deps.jev.mockResolvedValueOnce({ status: 402, body: { error: { code: 'JEV_CREDITS' } } })
- expect(await link.answer('jev', { body })).toEqual({ status: 402, body: { error: { code: 'JEV_CREDITS' } } })
+ // #2540 took Jev out of the tier, and its review (Orion) found the route left behind: a way from that process to the
+ // account's backend that nothing asks for. A question for Jev is now one the core does not know.
+ it('answers no question for Jev: the process has no way to the account\'s backend', async () => {
+ const { link } = setup()
+ expect(await link.answer('jev', { body: { state: { recap: 'Deployed' }, questions: {} } })).toEqual({ error: 'UNKNOWN_QUERY' })
})
it('asks the process for the cards of every turn still at work, and takes none it cannot read', async () => {
@@ -117,7 +114,7 @@ describe('the recaps in their own process, as the core sees them', () => {
it('says it to the daemon\'s log unless told otherwise', () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
- const link = createRecapsLink({ notify: vi.fn(() => true), buffered: () => RECAPS_BUFFER_LIMIT + 1, call: vi.fn(), clients: { turnCard: vi.fn(), turnSummary: vi.fn() }, lastTurn: vi.fn(), jev: vi.fn() })
+ const link = createRecapsLink({ notify: vi.fn(() => true), buffered: () => RECAPS_BUFFER_LIMIT + 1, call: vi.fn(), clients: { turnCard: vi.fn(), turnSummary: vi.fn() }, lastTurn: vi.fn() })
link.port.lifecycle({ kind: 'stopped', sessionId: 's1' }, watchers)
expect(warn).toHaveBeenCalledTimes(1)
warn.mockRestore()
diff --git a/cli/src/core/recapsLink.ts b/cli/src/core/recapsLink.ts
index 615243cc6..c8746191f 100644
--- a/cli/src/core/recapsLink.ts
+++ b/cli/src/core/recapsLink.ts
@@ -35,9 +35,6 @@ export interface RecapsLinkDeps {
/** Where its cards and recaps go: the core API checks each frame's type. */
clients: Pick<CoreApi['clients'], 'turnCard' | 'turnSummary'>
lastTurn: CoreApi['transcripts']['lastTurn']
- /** Harness's Jev, asked for how loudly a turn ends (lib/notifyTier.ts): the process holds no credential, so
- * this one route is all of the account's backend it may reach, signed by the core. */
- jev: (body: unknown) => Promise<{ status: number; body: Record<string, unknown> }>
log?: (line: string) => void
now?: () => number
}
@@ -103,7 +100,6 @@ export function createRecapsLink(deps: RecapsLinkDeps) {
/** The core's answers to the process's questions (core/serviceLinks.ts `answer`, for `recaps`). */
async answer(query: string, payload: Record<string, unknown>): Promise<Record<string, unknown>> {
if (query === 'lastTurn' && typeof payload.sessionId === 'string') return { turn: await deps.lastTurn(payload.sessionId) }
- if (query === 'jev') return { ...await deps.jev(payload.body) }
return { error: 'UNKNOWN_QUERY' }
},
/** The process went: no card of it is busy any more, and the core's heartbeats stop with their turns. */
diff --git a/cli/src/core/turns/recaps.spec.ts b/cli/src/core/turns/recaps.spec.ts
index 4595a3d4d..cfd4f2c2e 100644
--- a/cli/src/core/turns/recaps.spec.ts
+++ b/cli/src/core/turns/recaps.spec.ts
@@ -27,6 +27,7 @@ function setup(over: Partial<RecapDeps> = {}) {
live: () => [live, bare, { agentId: 'a3', sessionId: '' } as RegisteredSession],
sessionTurnOpen: vi.fn((sessionId: string) => sessionId === 's1'),
orchestratorRoleOf: vi.fn(() => null),
+ quietOnDevices: vi.fn(() => false),
...over,
}
const recaps = createRecaps(deps)
@@ -60,6 +61,19 @@ describe('recaps, as the core keeps them', () => {
expect(recaps.isSubagentSession('s1')).toBe(false)
})
+ // #2540's review: the recaps in the edge host have no agent list, so whether a session's turns are quiet on the devices
+ // goes with the session. The core only carries the fact; who says it (the Swarm, through its door) is outside the core.
+ it('says a session is quiet on devices when it is told so, and says nothing of it otherwise', () => {
+ const quietOnDevices = vi.fn((row: RegisteredSession) => row.agentId === 'a1')
+ const { recaps, port } = setup({ quietOnDevices })
+ recaps.mirror.ingest([started], 's1')
+ recaps.mirror.ingest([started], 's2')
+ recaps.mirror.ingest([started], 'unbound')
+ expect(port.lifecycle.mock.calls.map(([event]) => (event as { session: { quietOnDevices?: boolean } }).session.quietOnDevices))
+ .toEqual([true, undefined, undefined])
+ expect(quietOnDevices.mock.calls.map(([row]) => row.agentId)).toEqual(['a1', 'a2'])
+ })
+
it('tells the recaps each batch, addressed as the core knows the session, and whether it is a sub-agent\'s only where a turn ends', () => {
const { deps, recaps, port, live } = setup()
recaps.mirror.ingest([started], 's1')
diff --git a/cli/src/core/turns/recaps.ts b/cli/src/core/turns/recaps.ts
index 94b2de36c..0dbe79de0 100644
--- a/cli/src/core/turns/recaps.ts
+++ b/cli/src/core/turns/recaps.ts
@@ -37,6 +37,8 @@ export interface RecapDeps {
sessionTurnOpen: (sessionId: string) => boolean
/** The orchestrator's role for an agent: a specialist, or the director. */
orchestratorRoleOf: OrchestratorService['roleOf']
+ /** Whether an agent's finished turns are silent on the devices, as someone outside the core says (RecapSession). */
+ quietOnDevices: (session: RegisteredSession) => boolean
}
/** The calls the core makes about a turn's recap. */
@@ -64,7 +66,7 @@ export interface TurnRecaps {
export function createRecaps({
port, turnActivity, clients, deviceIsWatching, cableWatchingLocal, remoteApp, bySession, resolve, stopped, live, sessionTurnOpen,
- orchestratorRoleOf,
+ orchestratorRoleOf, quietOnDevices,
}: RecapDeps) {
/**
* A turn that belongs to a SUB-AGENT: an Orchestrator specialist, or its Director while specialists
@@ -99,6 +101,7 @@ export function createRecaps({
...(known?.engine ? { engine: known.engine } : {}),
...(known?.transcriptPath ? { transcriptPath: known.transcriptPath } : {}),
...(subagent === undefined ? {} : { subagent }),
+ ...(known && quietOnDevices(known) ? { quietOnDevices: true } : {}),
}
}
const tell = (event: TurnLifecycle): void => { port()?.lifecycle(event, watchers()) }
diff --git a/cli/src/device/deviceFleet.spec.ts b/cli/src/device/deviceFleet.spec.ts
index 7e1143071..e85fa6559 100644
--- a/cli/src/device/deviceFleet.spec.ts
+++ b/cli/src/device/deviceFleet.spec.ts
@@ -298,6 +298,18 @@ describe('DeviceFleet', () => {
})
+ // #2648's review (Orion): the emit dropped the tier the other machine's recaps decided, so the dial decided again here
+ // with no agent list for that machine, and a Swarm agent on another of the person's Macs alerted.
+ it('carries the tier the other machine decided on its summary card, and only a real one', () => {
+ const { fleet, say } = make()
+ const seen: FleetEvent[] = []
+ fleet.onEvent((e) => seen.push(e))
+ say({ type: 'commander_event', machineId: 'm1', agentId: 'a1', payload: { kind: 'summary', recap: 'Built.', text: 'done', tier: 'silent' } })
+ say({ type: 'commander_event', machineId: 'm1', agentId: 'a1', payload: { kind: 'summary', recap: 'Built.', text: 'done', tier: 'loud' } })
+ say({ type: 'commander_event', machineId: 'm1', agentId: 'a1', payload: { kind: 'processing', text: 'go', tier: 'alert' } })
+ expect(seen.map((e) => (e as { tier?: string }).tier)).toEqual(['silent', undefined, undefined])
+ })
+
it('ignores card kinds the dial has no use for', () => {
const { fleet, say } = make()
const seen: FleetEvent[] = []
diff --git a/cli/src/device/deviceFleet.ts b/cli/src/device/deviceFleet.ts
index 9067e9392..5c858cb7b 100644
--- a/cli/src/device/deviceFleet.ts
+++ b/cli/src/device/deviceFleet.ts
@@ -6,6 +6,7 @@ import type { ReviewedAnswer } from '../cable/questionInbox.js'
// the LANE costs a cloud socket and only exists while the user is actually looking at another machine. A
// dial parked on the local machine — which is where it sits most of the time — holds no socket at all.
import { isTerminalEngine } from '../engines/types.js'
+import { isTier } from '../lib/notifyTier.js'
import { FleetError, type FleetEvent, type FleetMachine, type MachineFleet } from '../cable/machineFleet.js'
import type { CableAgent } from '../cable/cableSession.js'
import type { RecentTurn } from '../cable/cableHost.js'
@@ -426,6 +427,9 @@ export class DeviceFleet implements MachineFleet {
...(kind === 'processing' && typeof payload.update === 'string' ? { update: payload.update } : {}),
// A specialist on another Mac is as silent here as one on this one.
...(payload.subagent === true ? { subagent: true } : {}),
+ // How loudly it ends, decided by that machine's recaps, which know its agents: this dial has no list of them, and
+ // decided again here a Swarm agent on another of the person's Macs alerted (#2648's review).
+ ...(kind === 'summary' && isTier(payload.tier) ? { tier: payload.tier } : {}),
})
return
}
diff --git a/cli/src/lib/authSession.ts b/cli/src/lib/authSession.ts
index 9489beffb..925173ecb 100644
--- a/cli/src/lib/authSession.ts
+++ b/cli/src/lib/authSession.ts
@@ -89,8 +89,8 @@ function parse(raw: string): AuthSession | null {
* made (ms) — the device key log lets a sign-in start its file over only shortly after it was made. */
export const newSignInEpoch = (now = Date.now()): string => `${randomBytes(16).toString('hex')}@${now}`
-/** How a `signInEpoch` given to a session from before epochs existed starts: nobody saw that sign-in
- * being made here, so the device key log may take its file over for it but never starts one over. */
+/** How a `signInEpoch` given to a session from before epochs existed starts, and a Team sign-in's ([teamSignInEpoch]): nobody
+ * saw that sign-in made by hand here, so the device key log may take its file over for it but never starts one over. */
export const ADOPTED_SIGN_IN = 'adopted:'
/** A Team sign-in's epoch, made as it signs in. Adopted, so the device key log treats it as it always has (a Team session was
diff --git a/cli/src/lib/commander.ts b/cli/src/lib/commander.ts
index f770122af..3007b58bf 100644
--- a/cli/src/lib/commander.ts
+++ b/cli/src/lib/commander.ts
@@ -717,7 +717,7 @@ export class CommanderMirror {
}
/**
- * [tell] once `decideTier` answers (it waits at most its own budget, 1 s). A newer turn, a cancel or a forget
+ * [tell] once `decideTier` answers (by fixed rules, at once: lib/notifyTier.ts). A newer turn, a cancel or a forget
* waits for nothing: the recap goes out at once at the fallback's tier, from inside the abort, so it still
* lands before the next turn's first card — the dial would otherwise draw the old recap over "Working…".
*/
diff --git a/cli/src/lib/e2ee/deviceLogSyncer.ts b/cli/src/lib/e2ee/deviceLogSyncer.ts
index 6c9b93758..31702559b 100644
--- a/cli/src/lib/e2ee/deviceLogSyncer.ts
+++ b/cli/src/lib/e2ee/deviceLogSyncer.ts
@@ -40,8 +40,8 @@ export type DeviceLogAppendAnswer = { head: DevLogHead } | { error: string; head
export interface DevLogSignIn {
/** Which sign-in it is. */
epoch: string
- /** Given to a session from before sign-ins were recorded: nobody saw it being made here, so it never
- * starts the log over (it may take a file over). */
+ /** Given to a session from before sign-ins were recorded, or a Team sign-in's (authSession `teamSignInEpoch`):
+ * nobody saw it being made by hand here, so it never starts the log over (it may take a file over). */
adopted: boolean
/** When it was made (ms); null when not known — then it never starts the log over either. */
at: number | null
diff --git a/cli/src/services/devices.spec.ts b/cli/src/services/devices.spec.ts
index d360e434b..f48a8f73b 100644
--- a/cli/src/services/devices.spec.ts
+++ b/cli/src/services/devices.spec.ts
@@ -427,6 +427,29 @@ describe('what the windows say, reaching the dial', () => {
void port
})
+ // #2540's review (Orion): a card that carries a tier was followed before its machine was looked at, so a Team machine's
+ // agent could alert. A Team machine runs Swarm work only.
+ it('decides a Team machine\'s agent by the Team rule even when its card brings a tier, and follows any other card\'s', async () => {
+ const core = fakeCore({ dataDir })
+ const { port } = start({ core, decideTier: null })
+ await teamAccount(core)
+ const card = (event: FleetEvent) => seen.fleet!.events!(event)
+ card({ machineId: 'team-mac', kind: 'summary', agentId: 'reviewer', text: 'done', recap: 'Reviewed.', tier: 'alert' })
+ card({ machineId: 'mac-mini', kind: 'summary', agentId: 'far', text: 'done', recap: 'Done far.', tier: 'list' })
+ await vi.waitFor(() => expect(calls('summary')).toHaveLength(2))
+ // The one followed lands first; the one decided here waits for the decider.
+ expect(new Map(calls('summary').map((c) => [c[0], c[3]]))).toEqual(new Map([['reviewer', 'silent'], ['far', 'list']]))
+ expect(logs).toContainEqual(expect.stringMatching(/silent · rule:swarm · swarm/))
+ void port
+ })
+
+ it('follows the tier another of the person\'s machines decided: a Swarm agent there is silent on this dial', async () => {
+ const { port } = start({ decideTier: null })
+ seen.fleet!.events!({ machineId: 'mac-mini', kind: 'summary', agentId: 'far-pm', text: 'done', recap: 'Planned.', tier: 'silent' })
+ await vi.waitFor(() => expect(calls('summary')).toEqual([['far-pm', 'Planned.', 'done', 'silent', undefined, false]]))
+ void port
+ })
+
it('still decides a remote card that came without a tier, and never throws', async () => {
const { port } = start({ decideTier: null })
expect(() => seen.fleet!.events!({ machineId: 'mac-mini', kind: 'summary', agentId: 'far', text: 'done', recap: '' })).not.toThrow()
diff --git a/cli/src/services/devices.ts b/cli/src/services/devices.ts
index 53e0a3c36..df89b437e 100644
--- a/cli/src/services/devices.ts
+++ b/cli/src/services/devices.ts
@@ -380,8 +380,9 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)
ended.delete(agentId)
const who = cableHost.describe(agentId)
// Decided once already, by the recaps (services/recaps.ts), for the phone as well: the dial follows it and
- // nobody is asked again. A card without one (a cloud agent's, a recaps from before) is decided here.
- if (event.tier) {
+ // nobody is asked again. A card without one (a cloud agent's, a recaps from before) is decided here, and so is
+ // a Team machine's, whatever its card says: it runs Swarm work only (#2540's review: its own tier alerted).
+ if (event.tier && !onTeamMachine(event)) {
tally(who?.name ?? '', event.tier, 'recaps', 'decided upstream', 0)
void cable.summary(agentId, recap, event.text, event.tier, event.fullText, false)
return
@@ -421,12 +422,14 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)
const swarmWorker = (event: DialEvent): boolean => {
const session = event.machineId ? undefined : core.agents.byAgent(event.agentId)
const role = session?.startedBy === 'agent' ? session.swarmSkill?.role : undefined
- return role === 'agent' || (!!event.machineId && teamMachines.has(event.machineId))
+ return role === 'agent' || onTeamMachine(event)
}
+ /** An agent on one of the account's Harness Team machines, which run Swarm work only. */
+ const onTeamMachine = (event: DialEvent): boolean => !!event.machineId && teamMachines.has(event.machineId)
/** Any Swarm agent, whatever its role (PM, Buddy, Builder, Reviewer, Tester): its registry row carries `swarmSkill`, or it runs
* on a Harness Team account. Its news reaches the dial through the Swarm's cards, so its finished turn is silent. */
const swarmAgent = (event: DialEvent): boolean =>
- (!event.machineId && !!core.agents.byAgent(event.agentId)?.swarmSkill) || (!!event.machineId && teamMachines.has(event.machineId))
+ (!event.machineId && !!core.agents.byAgent(event.agentId)?.swarmSkill) || onTeamMachine(event)
/** Whether an agent on another machine is a Swarm's Builder or Reviewer, as the Swarm service read it last
* (superTabs/cards.ts `worker`). Asked once a minute at most per agent: a failing worker fails every 1-2 s. */
const WORKER_ANSWER_MS = 60_000
diff --git a/cli/src/services/recaps.spec.ts b/cli/src/services/recaps.spec.ts
index be1de2e89..4561ac33c 100644
--- a/cli/src/services/recaps.spec.ts
+++ b/cli/src/services/recaps.spec.ts
@@ -245,10 +245,11 @@ describe('the recaps', () => {
})
describe('a finished turn\'s tier', () => {
- const turn = async (tell: (event: TurnLifecycle, seen?: typeof watching) => void, seen: typeof watching & { remote?: boolean }) => {
- // The core says the engine with every event (core/turns/recaps.ts `session`).
- tell({ kind: 'events', session: { ...s1, engine: 'codex' }, events: [started()], replay: false }, seen)
- tell({ kind: 'events', session: { ...s1, engine: 'codex' }, events: [ended], replay: false }, seen)
+ const turn = async (tell: (event: TurnLifecycle, seen?: typeof watching) => void, seen: typeof watching & { remote?: boolean }, quiet?: boolean) => {
+ // The core says the engine, and whether the session is quiet on devices, with every event (core/turns/recaps.ts `session`).
+ const session = { ...s1, engine: 'codex', ...(quiet === undefined ? {} : { quietOnDevices: quiet }) }
+ tell({ kind: 'events', session, events: [started()], replay: false }, seen)
+ tell({ kind: 'events', session, events: [ended], replay: false }, seen)
}
it('is decided once, with the agent and its engine, for the dial and the apps while a device listens', async () => {
@@ -278,30 +279,31 @@ describe('the recaps', () => {
expect(vi.mocked(alone.core.clients.turnSummary).mock.calls[0][0].payload).not.toHaveProperty('tier')
})
- const decidedWith = async (row: object | undefined) => {
+ const decidedWith = async (quiet: boolean | undefined) => {
const log = vi.spyOn(console, 'log').mockImplementation(() => {})
const backend = vi.fn()
- const core = fakeCore({ dataDir: temp(), account: { backend }, agents: { byAgent: vi.fn(() => row as never) } })
+ // A row in the agent list says nothing: the session says it (in the edge host there is no agent list).
+ const core = fakeCore({ dataDir: temp(), account: { backend }, agents: { byAgent: vi.fn(() => ({ agentId: 'a1', swarmSkill: { role: 'lead', key: 'k' } }) as never) } })
const { tell } = setup({ decideTier: undefined }, core)
- await turn(tell, watching)
+ await turn(tell, watching, quiet)
await vi.waitFor(() => expect(core.clients.turnSummary).toHaveBeenCalled())
expect(backend).not.toHaveBeenCalled()
return { tier: (vi.mocked(core.clients.turnSummary).mock.calls[0][0].payload as { tier?: string }).tier, log }
}
it('decides a harness agent\'s turn alert, with no Jev call', async () => {
- const { tier, log } = await decidedWith({ agentId: 'a1' })
+ const { tier, log } = await decidedWith(false)
expect(tier).toBe('alert')
expect(log).toHaveBeenCalledWith(expect.stringMatching(/^\[recap\] notify · app · alert · rule:turn · turn · \d+ms$/))
})
- it.each(['lead', 'buddy', 'agent'])('decides a Swarm agent\'s turn silent, whatever its role (%s)', async (role) => {
- const { tier, log } = await decidedWith({ agentId: 'a1', swarmSkill: { role, key: 'k' } })
+ it('decides the turn of a session the core says is quiet on devices silent', async () => {
+ const { tier, log } = await decidedWith(true)
expect(tier).toBe('silent')
expect(log).toHaveBeenCalledWith(expect.stringMatching(/rule:swarm/))
})
- it('decides a turn alert when the agent has no row', async () => {
+ it('decides a turn alert when the core says nothing of it', async () => {
expect((await decidedWith(undefined)).tier).toBe('alert')
})
})
diff --git a/cli/src/services/recaps.ts b/cli/src/services/recaps.ts
index 5e9a8ed41..3e8b28558 100644
--- a/cli/src/services/recaps.ts
+++ b/cli/src/services/recaps.ts
@@ -103,8 +103,9 @@ export function createRecaps(core: CoreApi, options: RecapsOptions = {}): Recaps
decideTier: async (turn) => {
if (!watchers.device && !watchers.remote) return null
const session = sessions.get(turn.sessionId)
- // A Swarm agent tells its news through the Swarm's chat cards, so its turn is silent on the devices.
- const swarm = !!(session && core.agents.byAgent(session.agentId)?.swarmSkill)
+ // A Swarm agent tells its news through the Swarm's chat cards, so its turn is silent on the devices. The core says so
+ // with the session: in the edge host this core API has no agent list to look it up in (#2540's review).
+ const swarm = session?.quietOnDevices === true
const decision = await tierOf({ agent: session?.name ?? '', engine: session?.engine ?? '', recap: turn.recap,
durationS: turn.durationS, stats: turn.stats, subagent: false, onScreen: false, failed: false, swarm })
return decision.tier
diff --git a/cli/src/services/recapsProcess.spec.ts b/cli/src/services/recapsProcess.spec.ts
index 4ed9862b9..c5a8255a8 100644
--- a/cli/src/services/recapsProcess.spec.ts
+++ b/cli/src/services/recapsProcess.spec.ts
@@ -122,38 +122,42 @@ describe('the recaps in their own process', () => {
expect(() => api.clients.turnSummary({ type: 'turn_summary' })).not.toThrow()
})
- it('runs on a core API that reaches the core only through these four ways, and holds no credential', async () => {
- const jev = vi.fn(async () => ({ status: 200, body: { data: {} } }))
- const ways = { turnCard: vi.fn(), turnSummary: vi.fn(), lastTurn: vi.fn(async () => null), jev }
+ // #2540's review (Orion): the recaps run here, in the edge host, on a core API with no agent list, so a Swarm agent was
+ // never found and every one of its finished turns alerted on the dial and the phone. The core says it with the session.
+ it('decides a finished turn on this core API: a session the core says is quiet on devices is silent, any other alerts', async () => {
+ vi.spyOn(console, 'log').mockImplementation(() => {})
+ const tier = async (session: typeof s1 & { quietOnDevices?: boolean }) => {
+ const { options } = setup({ create: (core, opts) => createRecaps(core, { recapForce: false, recapWithoutDevice: () => true, ...opts }) })
+ const core = connection()
+ options.onConnected!(core.core)
+ options.onEvent!(lifecycle({ kind: 'events', session, events: [started], replay: false }))
+ options.onEvent!(lifecycle({ kind: 'events', session, events: [ended], replay: false }))
+ await vi.waitFor(() => expect(core.said('summary')).toHaveLength(1))
+ return (core.said('summary')[0] as { frame: { payload: { tier?: string } } }).frame.payload.tier
+ }
+ expect(await tier({ ...s1, quietOnDevices: true })).toBe('silent')
+ expect(await tier(s1)).toBe('alert')
+ })
+
+ it('runs on a core API that reaches the core only through these three ways, and holds no credential', async () => {
+ const ways = { turnCard: vi.fn(), turnSummary: vi.fn(), lastTurn: vi.fn(async () => null) }
const api = recapsCoreApi('/data', ways)
expect(api.dataDir).toBe('/data')
expect(api.transcripts.lastTurn).toBe(ways.lastTurn)
expect(api.clients.turnCard).toBe(ways.turnCard)
expect(api.clients.turnSummary).toBe(ways.turnSummary)
await expect(api.account.accessToken()).rejects.toThrow('recaps holds no credential')
- // Of the account's backend, Jev's route alone: anything else answers as no core to ask.
- expect(await api.account.backend('POST', '/api/route/jev', { state: {} })).toEqual({ status: 200, body: { data: {} } })
- expect(jev).toHaveBeenCalledWith({ state: {} })
- expect(await api.account.backend('GET', '/api/route/jev')).toMatchObject({ status: 503 })
+ // None of the account's backend, Jev's old route included (#2540's review): each answers as no core to ask.
+ expect(await api.account.backend('POST', '/api/route/jev', { state: {} })).toMatchObject({ status: 503 })
expect(await api.account.backend('POST', '/api/machines', {})).toMatchObject({ status: 503 })
- expect(jev).toHaveBeenCalledTimes(1)
})
- it('asks the core for Jev, and reads any answer that is not the backend\'s as unavailable', async () => {
+ it('never asks the core for Jev', async () => {
const { options, api } = setup()
- const unavailable = { status: 503, body: { error: 'SERVICE_UNAVAILABLE' } }
- expect(await api.account.backend('POST', '/api/route/jev', { state: 1 })).toEqual(unavailable)
const core = connection()
options.onConnected!(core.core)
- core.query.mockResolvedValueOnce({ status: 200, body: { data: { answers: {} } } })
- expect(await api.account.backend('POST', '/api/route/jev', { state: 1 })).toEqual({ status: 200, body: { data: { answers: {} } } })
- expect(core.query).toHaveBeenLastCalledWith('jev', { body: { state: 1 } })
- core.query.mockResolvedValueOnce({ error: 'UNKNOWN_QUERY' })
- expect(await api.account.backend('POST', '/api/route/jev', {})).toEqual(unavailable)
- core.query.mockResolvedValueOnce({ status: 200, body: 'not an object' })
- expect(await api.account.backend('POST', '/api/route/jev', {})).toEqual(unavailable)
- core.query.mockRejectedValueOnce(new Error('the core went away'))
- expect(await api.account.backend('POST', '/api/route/jev', {})).toEqual(unavailable)
+ expect(await api.account.backend('POST', '/api/route/jev', { state: 1 })).toMatchObject({ status: 503 })
+ expect(core.query).not.toHaveBeenCalled()
})
it('runs on the real service process unless told otherwise', async () => {
diff --git a/cli/src/services/recapsProcess.ts b/cli/src/services/recapsProcess.ts
index b9e0d444f..2f3bf95c0 100644
--- a/cli/src/services/recapsProcess.ts
+++ b/cli/src/services/recapsProcess.ts
@@ -14,7 +14,6 @@
* them each time it connects: a core that restarted holds nothing until then (core/recapsLink.ts).
*/
import type { CoreApi, TurnCardFrame, TurnLifecycle, TurnSummaryFrame, RecapWatchers } from '../core/api.js'
-import { HOSTED_JEV_PATH } from '../lib/jev/jevClient.js'
import type { LastTurnText } from '../lib/normalize.js'
import { processCoreApi } from './processCoreApi.js'
import { runServiceProcess, type CoreConnection, type ServiceProcess } from './process.js'
@@ -36,32 +35,20 @@ export interface RecapsCoreWays {
turnCard(frame: TurnCardFrame): void
turnSummary(frame: TurnSummaryFrame): void
lastTurn(sessionId: string): Promise<LastTurnText | null>
- /** Harness's Jev, for how loudly a turn ends: asked of the core, which signs it (core/recapsLink.ts). */
- jev(body: unknown): Promise<{ status: number; body: Record<string, unknown> }>
}
/** The core API the recaps run on in their own process: the light services' (processCoreApi.ts), with
- * the ways the recaps reach the core. Of the account's backend, only Jev's route: the rest answers as
- * every light service's does. */
+ * the ways the recaps reach the core. None of the account's backend: it answers as every light service's does
+ * (the tier has asked no model since #2540, and its review found Jev's route left behind). */
export function recapsCoreApi(dataDir: string, ways: RecapsCoreWays): CoreApi {
const api = processCoreApi(dataDir, 'recaps')
return {
...api,
- account: {
- ...api.account,
- backend: (method, path, body) => (method === 'POST' && path === HOSTED_JEV_PATH ? ways.jev(body) : api.account.backend(method, path, body)),
- },
transcripts: { ...api.transcripts, lastTurn: ways.lastTurn },
clients: { ...api.clients, turnCard: ways.turnCard, turnSummary: ways.turnSummary },
}
}
-/** The core's answer to `jev`, as the backend's: a status and an object, or unavailable. */
-const backendAnswer = (answer: Record<string, unknown> | null): { status: number; body: Record<string, unknown> } =>
- answer && typeof answer.status === 'number' && answer.body && typeof answer.body === 'object'
- ? { status: answer.status, body: answer.body as Record<string, unknown> }
- : { status: 503, body: { error: 'SERVICE_UNAVAILABLE' } }
-
/** Whether what the core sent reads as a lifecycle event: its kind, and the watchers beside it. */
const isLifecycle = (payload: Record<string, unknown>): payload is { event: TurnLifecycle; watchers: RecapWatchers } =>
!!payload.event && typeof payload.event === 'object' && typeof (payload.event as { kind?: unknown }).kind === 'string'
@@ -91,8 +78,6 @@ export function runRecapsService(options: RecapsServiceOptions): ServiceProcess
const answer = await core.query('lastTurn', { sessionId })
return answer.turn && typeof answer.turn === 'object' ? answer.turn as LastTurnText : null
},
- // Unavailable with no core: the tier then falls back to its rule (lib/notifyTier.ts).
- jev: async (body) => backendAnswer(core ? await core.query('jev', { body }).catch(() => null) : null),
}), { changed: tell })
const run = options.run ?? runServiceProcess
diff --git a/cli/src/superTabs/inCore.ts b/cli/src/superTabs/inCore.ts
index 5ed4a920d..141bddcaa 100644
--- a/cli/src/superTabs/inCore.ts
+++ b/cli/src/superTabs/inCore.ts
@@ -14,6 +14,7 @@ export { createSuperTabAttention } from './inCore/attention.js'
export { createSuperTabCards } from './inCore/cards.js'
export { createSuperTabTerminal } from './inCore/terminal.js'
export { swarmRoleThrough } from './inCore/role.js'
+export { quietOnDevices } from './inCore/devices.js'
export { createSwarmSkillAdoption } from './inCore/adoption.js'
export { createSwarmAgents } from './inCore/agents.js'
export { SWARM_LAUNCH } from './inCore/launch.js'
diff --git a/cli/src/superTabs/inCore/devices.spec.ts b/cli/src/superTabs/inCore/devices.spec.ts
new file mode 100644
index 000000000..233987562
--- /dev/null
+++ b/cli/src/superTabs/inCore/devices.spec.ts
@@ -0,0 +1,15 @@
+import { describe, expect, it } from 'vitest'
+import type { RegisteredSession } from '../../lib/registry.js'
+import { quietOnDevices } from './devices.js'
+
+describe('a Swarm agent on the devices', () => {
+ // #2540: a Swarm agent tells its news through the Swarm's chat cards, so its finished turns are silent on the dial and
+ // the phone. The core carries only the fact (core/turns/recaps.ts); this is where it is said.
+ it.each(['lead', 'buddy', 'agent'] as const)('is quiet on devices whatever its role (%s)', (role) => {
+ expect(quietOnDevices({ agentId: 'a1', swarmSkill: { role, key: 'k' } } as RegisteredSession)).toBe(true)
+ })
+
+ it('leaves any other agent to its own tier', () => {
+ expect(quietOnDevices({ agentId: 'a1' } as RegisteredSession)).toBe(false)
+ })
+})
diff --git a/cli/src/superTabs/inCore/devices.ts b/cli/src/superTabs/inCore/devices.ts
new file mode 100644
index 000000000..d5e634a5f
--- /dev/null
+++ b/cli/src/superTabs/inCore/devices.ts
@@ -0,0 +1,9 @@
+/**
+ * A Swarm agent on the devices: it tells its news through the Swarm's chat cards, so its finished turns are silent on the
+ * dial and the phone (#2540). The core carries the fact with each session it tells the recaps (core/api.ts RecapSession);
+ * whether an agent is a Swarm agent is said here, through the Swarm's door, and only while the Swarm is on.
+ */
+import type { RegisteredSession } from '../../lib/registry.js'
+
+/** Whether an agent's finished turns are silent on the devices: one launched with its Swarm skill, whatever its role. */
+export const quietOnDevices = (session: RegisteredSession): boolean => !!session.swarmSkill
diff --git a/desktop/lib/super_tabs/activity.dart b/desktop/lib/super_tabs/activity.dart
index 608200e63..5d1ce39f3 100644
--- a/desktop/lib/super_tabs/activity.dart
+++ b/desktop/lib/super_tabs/activity.dart
@@ -1,94 +1,63 @@
import 'dart:async';
+import 'package:clock/clock.dart';
import 'package:flutter/widgets.dart';
+import 'attention.dart';
import 'controller.dart';
import 'decisions.dart';
import 'model.dart';
import 'notifications.dart';
-/// One reply to the reader's message, or one reaction to it, as the server
-/// lists it (backend superTabs/activity.ts).
-class SuperTabActivityItem {
- SuperTabActivityItem.fromJson(Map<String, dynamic> row)
- : id = row['id'] as String,
- kind = row['kind'] == 'reaction'
- ? SuperTabActivityKind.reaction
- : SuperTabActivityKind.reply,
- conversationId = row['conversationId'] as String,
- conversationTitle = row['conversationTitle'] as String? ?? '',
- projectName = row['projectName'] as String? ?? '',
- messageId = row['messageId'] as String,
- messageSequence = (row['messageSequence'] as num?)?.toInt() ?? 0,
- threadId = row['threadId'] as String?,
- actor = superTabMap(row['actor']),
- emoji = row['emoji'] as String?,
- text = row['text'] as String? ?? '',
- createdAt = DateTime.tryParse(row['createdAt'] as String? ?? ''),
- read = row['read'] == true;
-
- final String id, conversationId, conversationTitle, projectName, messageId;
- final SuperTabActivityKind kind;
- final int messageSequence;
-
- /// The thread a reply that lives only there is in; null in the main stream.
- final String? threadId;
-
- /// `kind` (person | agent), `id` and `name`, named by the server.
- final Map<String, dynamic> actor;
-
- /// The reaction (`thumbs_up`, `check`, …); null for a reply.
- final String? emoji;
-
- /// The reply's text, or the reacted message's.
- final String text;
- final DateTime? createdAt;
- final bool read;
-
- String get actorName => actor['name'] as String? ?? 'Someone';
- String? get actorId => actor['id'] as String?;
- bool get byAgent => actor['kind'] == 'agent';
-
- SuperTabActivityItem _asRead() =>
- SuperTabActivityItem.fromJson({..._json, 'read': true});
-
- Map<String, dynamic> get _json => {
- 'id': id,
- 'kind': kind.name,
- 'conversationId': conversationId,
- 'conversationTitle': conversationTitle,
- 'projectName': projectName,
- 'messageId': messageId,
- 'messageSequence': messageSequence,
- 'threadId': threadId,
- 'actor': actor,
- 'emoji': emoji,
- 'text': text,
- 'createdAt': createdAt?.toIso8601String(),
- 'read': read,
- };
+/// What one row of Needs you is.
+enum SuperTabNeedKind { decision, agent, mention }
+
+/// One row of Needs you: a decision asked of the reader, an agent waiting on
+/// them, or a tag of them.
+class SuperTabNeed {
+ const SuperTabNeed({
+ required this.kind,
+ required this.id,
+ required this.title,
+ required this.conversationId,
+ this.at,
+ this.decision,
+ this.mention,
+ });
+ final SuperTabNeedKind kind;
+
+ /// Stable across reads: `decision:<id>`, `agent:<group>`, `mention:<id>`.
+ final String id;
+
+ /// What the row says: the question, `<agent> is waiting on you`, or
+ /// `<author> mentioned you in # <project>`.
+ final String title;
+ final String conversationId;
+ final DateTime? at;
+ final SuperTabDecision? decision;
+ final SuperTabMention? mention;
}
-enum SuperTabActivityKind { reply, reaction }
-
-/// What the Activity view lists, as Slack's tabs: everything, or one kind.
-enum SuperTabActivityFilter { all, decisions, mentions, replies, reactions }
-
-/// The reader's Activity in one Swarm (Slack's Activity): decisions asked of
-/// them and their tags ([SuperTabDecisions], [SuperTabMentions]), with the
-/// replies to their messages and the reactions to them, read from the server
-/// when its digest moves or the view opens — never on a timer. Rows the view
-/// showed are marked read on every device when it is left, as the Threads
-/// view reads what it shows. One per controller.
+/// The reader's Activity in one Swarm: the one place for everything new for
+/// them (Quiet Swarm design, screens 6 and 11b). Three lists over what the
+/// Swarm already holds, no feed of its own:
+///
+/// * Needs you: decisions asked of them, agents waiting on them and their
+/// tags. Its length is Activity's number.
+/// * New replies: the followed threads with replies they have not read.
+/// * Done today: tasks that shipped today.
+///
+/// Leaving the view marks nothing read: it shows no reply or reaction row,
+/// and a thread is read when it is opened. One per controller.
class SuperTabActivity extends ChangeNotifier {
SuperTabActivity._(this.controller)
: mentions = SuperTabMentions.of(controller),
- decisions = SuperTabDecisions.of(controller) {
- controller.addListener(_changed);
+ decisions = SuperTabDecisions.of(controller),
+ attention = SuperTabAttention.of(controller) {
+ controller.addListener(notifyListeners);
controller.onDispose(dispose);
mentions.addListener(notifyListeners);
decisions.addListener(notifyListeners);
- _changed();
}
@visibleForTesting
@@ -102,275 +71,184 @@ class SuperTabActivity extends ChangeNotifier {
final SuperTabController controller;
final SuperTabMentions mentions;
final SuperTabDecisions decisions;
+ final SuperTabAttention attention;
+ bool _open = false, _disposed = false;
+
+ SuperTabSnapshot? get _snapshot =>
+ controller.accessRevoked ? null : controller.snapshot;
+
+ /// Decisions asked of the reader, then agents waiting on them, then their
+ /// tags; each newest first.
+ List<SuperTabNeed> get needsYou {
+ final snapshot = _snapshot;
+ if (snapshot == null) return const [];
+ final epoch = DateTime.fromMillisecondsSinceEpoch(0);
+ final asked = decisions.open;
+ final decided = {for (final d in asked) d.conversationId};
+ final people = {for (final p in snapshot.people) p.id: p};
+ return [
+ for (final d in [
+ ...asked,
+ ]..sort((a, b) => (b.createdAt ?? epoch).compareTo(a.createdAt ?? epoch)))
+ SuperTabNeed(
+ kind: SuperTabNeedKind.decision,
+ id: 'decision:${d.id}',
+ title: d.question,
+ conversationId: d.conversationId,
+ at: d.createdAt,
+ decision: d,
+ ),
+ for (final group in snapshot.conversations)
+ if (_waiting(snapshot, group, decided))
+ SuperTabNeed(
+ kind: SuperTabNeedKind.agent,
+ id: 'agent:${group.id}',
+ title:
+ '${_agentName(snapshot, group.assignment!['agentId'] as String)} is waiting on you',
+ conversationId: group.id,
+ ),
+ for (final m in [
+ ..._tags,
+ ]..sort((a, b) => (b.createdAt ?? epoch).compareTo(a.createdAt ?? epoch)))
+ SuperTabNeed(
+ kind: SuperTabNeedKind.mention,
+ id: 'mention:${m.id}',
+ title:
+ '${people[m.leadId]?.username ?? m.leadName} mentioned you in # ${m.projectName}',
+ conversationId: m.conversationId,
+ at: m.createdAt,
+ mention: m,
+ ),
+ ];
+ }
- /// Replies and reactions, newest first, in chats this Swarm still lists.
- List<SuperTabActivityItem> items = const [];
- bool loaded = false, more = false;
- String? error;
-
- /// False on a server before Activity (it answered 404): replies and
- /// reactions are not listed, and nothing is asked again.
- bool supported = true;
+ /// A tag from a server that does not say where it is: it counts until
+ /// answered, past any read mark. Not `1 << 52`: a shift is 32 bits on the web.
+ static const _unknown = 9007199254740991;
+
+ /// The tags that need the reader: not read past (the number clears by
+ /// reading). One in a thread that New replies lists is shown there instead;
+ /// a tag in a thread the reader does not follow still needs them.
+ Iterable<SuperTabMention> get _tags {
+ final listed = {
+ for (final t in newReplies) '${t.conversationId}/${t.rootId}',
+ };
+ return mentions.waiting.where(
+ (m) =>
+ mentionUnread(m) &&
+ (m.threadId == null ||
+ !listed.contains('${m.conversationId}/${m.threadId}')),
+ );
+ }
- SuperTabActivityFilter filter = SuperTabActivityFilter.all;
- bool _open = false;
+ /// A task whose agent waits on the reader (it needs a decision, or is
+ /// stuck) and has not already asked it as a decision.
+ bool _waiting(
+ SuperTabSnapshot snapshot,
+ SuperTabConversation group,
+ Set<String> decided,
+ ) {
+ final work = group.assignment;
+ if (work == null ||
+ group.closed ||
+ group.isBuddyChat ||
+ decided.contains(group.id) ||
+ !superTabWorkWaits(work['status']) ||
+ snapshot.agent(work['agentId'] as String? ?? '') == null) {
+ return false;
+ }
+ // Whoever it asked, else whoever asked for the task, else the Swarm's
+ // owner: a task waiting on nobody named is for no other reader.
+ final forThem =
+ work['askedOf'] as String? ?? group.requesterId ?? snapshot.ownerId;
+ return forThem == controller.accountId;
+ }
- /// Rows shown as unread in this visit: they stay bold until the view is
- /// left, though reading them on another device cleared them.
- final Set<String> _newThisVisit = {};
+ String _agentName(SuperTabSnapshot snapshot, String agentId) {
+ final agent = snapshot.agent(agentId);
+ return agent?.displayName ?? agent?.name ?? 'An agent';
+ }
- String? _digest;
- int? _epoch;
- Future<void>? _loading;
- bool _dirty = false, _disposed = false;
- int _asked = 0, _shown = 0;
- DateTime? _waitUntil;
- Timer? _retry;
-
- String get _path =>
- '/api/super-tabs/${Uri.encodeComponent(controller.tabId)}';
-
- /// Whether the filter lists [item]. Decisions and Mentions list neither kind.
- bool shows(SuperTabActivityItem item) => switch (filter) {
- SuperTabActivityFilter.all => true,
- SuperTabActivityFilter.replies => item.kind == SuperTabActivityKind.reply,
- SuperTabActivityFilter.reactions =>
- item.kind == SuperTabActivityKind.reaction,
- _ => false,
- };
-
- /// Whether [item] shows bold.
- bool isUnread(SuperTabActivityItem item) =>
- !item.read || _newThisVisit.contains(item.id);
-
- /// Whether [mention] shows bold: waiting and not read past, as its chat's
- /// red number counts it (attention.dart).
+ /// Whether [mention] shows bold: not read past, as its chat's red number
+ /// counts it (attention.dart).
bool mentionUnread(SuperTabMention mention) =>
mention.resolvedBy == null &&
- (mention.messageSequence ?? (1 << 52)) >
+ (mention.messageSequence ?? _unknown) >
(mention.threadId == null
? controller.readMark(mention.conversationId)
: controller.threadReadMark(mention.threadId!));
- /// The Activity row's red number: what is the reader's own to answer, as
- /// Notifications counted it (their tags and decisions), and replies to them
- /// not yet seen. Reactions only make the row bold, as in Slack.
+ /// The followed threads with replies the reader has not read, newest reply
+ /// first; one read during this visit stays, bold, until the view is left.
+ List<SuperTabFollowedThread> get newReplies => [
+ for (final t in attention.shown)
+ if (attention.isNew(t)) t,
+ ];
+
+ /// Tasks that shipped today (the reader's day), newest first: no review or
+ /// test step, no Buddy chat.
+ List<SuperTabConversation> get doneToday {
+ final snapshot = _snapshot;
+ if (snapshot == null) return const [];
+ final now = clock.now();
+ bool today(DateTime at) =>
+ at.year == now.year && at.month == now.month && at.day == now.day;
+ return [
+ for (final g in snapshot.conversations)
+ if (g.shippedAt case final at? when today(at.toLocal()))
+ if (g.reviewOf == null && !g.isBuddyChat) g,
+ ]..sort((a, b) => b.shippedAt!.compareTo(a.shippedAt!));
+ }
+
+ /// The Activity row's red number: what needs the reader, and nothing else.
+ /// A tag counts until it is read, a decision or an agent waiting until it
+ /// is answered. Before the tags are read the server's count stands in.
int get count {
- final snapshot = controller.snapshot;
- if (controller.accessRevoked || snapshot == null) return 0;
- return snapshot.mentionsWaiting +
+ final snapshot = _snapshot;
+ if (snapshot == null) return 0;
+ final decided = {for (final d in decisions.open) d.conversationId};
+ final tags = mentions.waiting.isEmpty && snapshot.mentionsWaiting > 0
+ ? snapshot.mentionsWaiting
+ : _tags.length;
+ return tags +
snapshot.decisionsWaiting +
- items
- .where((i) => i.kind == SuperTabActivityKind.reply && !i.read)
+ snapshot.conversations
+ .where((g) => _waiting(snapshot, g, decided))
.length;
}
- /// Whether the Activity row is bold: anything unread in it.
- bool get unread => count > 0 || items.any((i) => !i.read);
+ /// Whether the Activity row is bold: something needs the reader, or a thread
+ /// they follow has replies they have not read.
+ bool get unread => count > 0 || attention.threadsUnread;
- /// The view opened: reads now; what is unread stays bold until [closed].
+ /// The view opened: reads what it lists now; what is new stays bold until
+ /// [closed].
void opened() {
_open = true;
- _newThisVisit
- ..clear()
- ..addAll(items.where((i) => !i.read).map((i) => i.id));
- unawaited(load());
+ attention.opened();
unawaited(mentions.load());
+ unawaited(decisions.load());
}
- /// The view was left: what its list showed then is read on every device, and
- /// the next visit starts on All unless it asks for a list (Diego, 2026-11-02).
- /// Rows only passed by on the way to another list stay unread, which loses
- /// nothing; marking a row nobody read would.
+ /// The view was left. It marks nothing read: it showed no reply or reaction
+ /// row, and a thread is read when it is opened.
void closed() {
if (!_open) return;
_open = false;
- _newThisVisit.clear();
- final shown = {for (final i in items.where(shows)) i.id};
- filter = SuperTabActivityFilter.all;
// The view is going away while this runs (its dispose): what listens is
// told after the frame's teardown, never during it.
scheduleMicrotask(() {
if (_disposed) return;
- unawaited(_markShownRead(shown));
+ attention.closed();
notifyListeners();
});
}
- void setFilter(SuperTabActivityFilter value) {
- if (filter == value) return;
- filter = value;
- notifyListeners();
- }
-
- /// The mark is by time, whatever the kind (backend activity.ts
- /// markActivityRead): it stops before the oldest unread row [shown] lacks, or
- /// that row would be read on every device unseen. A shown row newer than it
- /// stays unread for now, which loses nothing.
- Future<void> _markShownRead(Set<String> shown) async {
- final unread = items.where((i) => !i.read && i.createdAt != null).toList();
- final unseen = unread
- .where((i) => !shown.contains(i.id))
- .map((i) => i.createdAt!)
- .fold<DateTime?>(null, (a, b) => a == null || b.isBefore(a) ? b : a);
- final newest = unread
- .where(
- (i) =>
- shown.contains(i.id) &&
- (unseen == null || i.createdAt!.isBefore(unseen)),
- )
- .map((i) => i.createdAt!)
- .fold<DateTime?>(null, (a, b) => a == null || b.isAfter(a) ? b : a);
- if (newest == null || !supported || controller.accessRevoked) return;
- final epoch = controller.visibilityEpoch;
- // Shown read at once; the server's answer is the next read's.
- items = [
- for (final i in items)
- if (!i.read && !i.createdAt!.isAfter(newest)) i._asRead() else i,
- ];
- notifyListeners();
- try {
- await controller.request(
- 'POST',
- '$_path/activity/read',
- body: {'through': newest.toUtc().toIso8601String()},
- );
- } catch (_) {
- // Unread again on the next read; nothing else to do.
- if (!_disposed && controller.visibilityEpoch == epoch) {
- _digest = null;
- }
- }
- }
-
- void _clear() {
- items = const [];
- loaded = false;
- more = false;
- error = null;
- _newThisVisit.clear();
- _retry?.cancel();
- _retry = null;
- }
-
- void _changed() {
- if (_disposed) return;
- if (controller.accessRevoked) {
- if (loaded || items.isNotEmpty || error != null) {
- _clear();
- // An answer on its way belongs to the access that is gone.
- _shown = ++_asked;
- _digest = null;
- notifyListeners();
- }
- return;
- }
- final snapshot = controller.snapshot;
- if (snapshot == null) return;
- final epoch = controller.visibilityEpoch;
- if (epoch != null && epoch != _epoch) {
- final moved = _epoch != null;
- _epoch = epoch;
- if (moved) {
- // Who may read what changed: nothing read before shows until read
- // again.
- _clear();
- _shown = ++_asked;
- _digest = null;
- notifyListeners();
- }
- }
- // A server before Activity sends no digest: nothing to read.
- final digest = snapshot.activityDigest;
- if (digest == null || !supported) return;
- if (digest == _digest && loaded) return;
- _digest = digest;
- unawaited(load());
- }
-
- /// Joins a read under way, and has it read once more when asked again.
- Future<void> load() {
- if (_disposed || !supported) return Future.value();
- if (_loading case final running?) {
- _dirty = true;
- return running;
- }
- return _loading = () async {
- do {
- _dirty = false;
- await _read();
- } while (_dirty && !_disposed);
- }().whenComplete(() => _loading = null);
- }
-
- Future<void> _read() async {
- if (controller.accessRevoked || controller.snapshot == null) return;
- if (_waitUntil case final wait? when DateTime.now().isBefore(wait)) {
- // Asked too often: one read when the wait is over, no more.
- _retry ??= Timer(wait.difference(DateTime.now()), () {
- _retry = null;
- unawaited(load());
- });
- return;
- }
- final asked = ++_asked;
- final epoch = controller.visibilityEpoch;
- bool current() =>
- !_disposed &&
- !controller.accessRevoked &&
- asked > _shown &&
- controller.visibilityEpoch == epoch;
- try {
- final answer = await controller.request('GET', '$_path/activity');
- if (!current()) return;
- _shown = asked;
- final readable = {
- for (final g in controller.snapshot?.conversations ?? const []) g.id,
- };
- items = [
- for (final row in answer['items'] as List? ?? const [])
- if (SuperTabActivityItem.fromJson(superTabMap(row)) case final i
- // Only chats this reader still has; a chat lost since is not
- // shown on the server's word alone.
- when readable.contains(i.conversationId))
- i,
- ];
- more = answer['more'] == true;
- loaded = true;
- error = null;
- _waitUntil = null;
- if (_open) {
- _newThisVisit.addAll(items.where((i) => !i.read).map((i) => i.id));
- }
- notifyListeners();
- } catch (failure) {
- if (!current()) return;
- _shown = asked;
- if (failure is SuperTabFailure && failure.statusCode == 404) {
- // A server before Activity: tags and decisions still show.
- supported = false;
- loaded = true;
- error = null;
- notifyListeners();
- return;
- }
- if (failure is SuperTabFailure && failure.statusCode == 429) {
- _waitUntil = DateTime.now().add(const Duration(seconds: 5));
- }
- // The digest is read again on its next move, or by Retry.
- _digest = null;
- loaded = true;
- error = 'Could not load activity.';
- notifyListeners();
- }
- }
-
@override
void dispose() {
if (_disposed) return;
_disposed = true;
- _retry?.cancel();
- controller.removeListener(_changed);
+ controller.removeListener(notifyListeners);
mentions.removeListener(notifyListeners);
decisions.removeListener(notifyListeners);
super.dispose();
@@ -425,10 +303,20 @@ class SuperTabChatNotices {
if (controller.notifyOf(group.id) != SuperTabNotify.all) continue;
if (controller.selectedId == group.id && _openChatRead) continue;
if (top <= controller.readMark(group.id)) continue;
- onMessage?.call(group, top);
+ unawaited(_tell(group, before, top));
}
}
+ /// Tells of [group] unless all it gained is the person's own, which the state doesn't say. By the
+ /// time that's read, the person may have read the chat or lost it.
+ Future<void> _tell(SuperTabConversation group, int before, int top) async {
+ final epoch = _epoch;
+ if (await controller.onlyOwnSince(group.id, before)) return;
+ if (_disposed || controller.accessRevoked || _epoch != epoch) return;
+ if (top <= controller.readMark(group.id)) return;
+ onMessage?.call(group, top);
+ }
+
/// Whether the open chat is being read now. The view on screen knows; with none up, this falls
/// back to the Swarm showing and the app in front.
bool get _openChatRead {
diff --git a/desktop/lib/super_tabs/activity_view.dart b/desktop/lib/super_tabs/activity_view.dart
index 08f788d81..cec5335d3 100644
--- a/desktop/lib/super_tabs/activity_view.dart
+++ b/desktop/lib/super_tabs/activity_view.dart
@@ -4,47 +4,45 @@ import 'package:flutter/material.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../widgets/desktop_chrome.dart';
+import '../widgets/laid_out_list.dart';
import 'activity.dart';
+import 'attention.dart';
import 'decisions_view.dart';
-import 'identity.dart';
-import 'machine_status.dart' show superTabAgo;
+import 'machine_status.dart' show superTabAgoShort;
+import 'model.dart';
import 'notifications.dart';
-import 'profile_model.dart';
import 'section_heading.dart';
-import '../widgets/laid_out_list.dart';
-/// Slack's Activity, where Notifications was (Lead, 10-31): decisions asked
-/// of the reader first, then one list, newest first, of their tags, the
-/// replies to their messages and the reactions to them. Unread rows are bold;
-/// a click opens the message where it is. Filters show one kind.
+/// Activity, the one place for everything new for the reader (Quiet Swarm
+/// design, screens 6 and 11b): Needs you, New replies, Done today. One line
+/// to a row, bold when it is new, no filters. A click opens the thing where
+/// it is; a decision opens its card to answer.
class SuperTabActivityView extends StatefulWidget {
const SuperTabActivityView({
super.key,
required this.activity,
required this.onOpenMention,
- required this.onOpenMessage,
+ required this.onOpenThread,
+ required this.onOpenConversation,
this.now = DateTime.now,
});
final SuperTabActivity activity;
final ValueChanged<SuperTabMention> onOpenMention;
- /// Opens a reply or the reacted message: chat, message.
- final void Function(String conversationId, String messageId) onOpenMessage;
+ /// Opens a followed thread in its chat: chat, the thread's root message.
+ final void Function(String conversationId, String rootId) onOpenThread;
+
+ /// Opens the chat of an agent waiting on the reader, or of a task done.
+ final ValueChanged<String> onOpenConversation;
final DateTime Function() now;
@override
State<SuperTabActivityView> createState() => _SuperTabActivityViewState();
}
-/// One row of the merged list: a tag, or a reply or reaction.
-typedef _Entry = ({
- DateTime at,
- SuperTabMention? mention,
- SuperTabActivityItem? item,
-});
-
class _SuperTabActivityViewState extends State<SuperTabActivityView> {
final _marking = <String>{};
+ final _answering = <String>{};
late SuperTabActivity _activity = widget.activity;
@override
@@ -74,279 +72,129 @@ class _SuperTabActivityViewState extends State<SuperTabActivityView> {
if (mounted) setState(() => _marking.remove(mention.id));
}
- List<_Entry> _entries() {
- final a = _activity;
- final filter = a.filter;
- final mentions =
- filter == SuperTabActivityFilter.all ||
- filter == SuperTabActivityFilter.mentions;
- final epoch = DateTime.fromMillisecondsSinceEpoch(0);
- return [
- if (mentions)
- for (final m in [...a.mentions.waiting, ...a.mentions.earlier])
- (at: m.createdAt ?? epoch, mention: m, item: null),
- for (final i in a.items)
- if (a.shows(i)) (at: i.createdAt ?? epoch, mention: null, item: i),
- ]..sort((x, y) => y.at.compareTo(x.at));
- }
-
- Widget _filters() {
- Widget tab(SuperTabActivityFilter value, String label) {
- final selected = _activity.filter == value;
- return Padding(
- padding: const EdgeInsets.only(right: grid.AppDesktop.menuInset),
- child: Material(
- color: selected ? grid.AppSurface.selectedFill : Colors.transparent,
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- clipBehavior: Clip.antiAlias,
- child: InkWell(
- key: ValueKey('super-activity-filter-${value.name}'),
- onTap: () => _activity.setFilter(value),
- hoverColor: grid.AppSurface.hoverFill,
- child: Semantics(
- selected: selected,
- button: true,
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.controlGap,
- vertical: grid.AppDesktop.menuInset,
- ),
- child: Text(
- label,
- style: DesktopChrome.control(
- medium: selected,
- color: selected ? null : DesktopChrome.muted,
- ),
- ),
- ),
- ),
- ),
- ),
- );
+ /// Today's clock time, else how long ago: a row's one word of when.
+ String _when(DateTime at) {
+ final now = widget.now(), local = at.toLocal();
+ if (local.year == now.year &&
+ local.month == now.month &&
+ local.day == now.day) {
+ String two(int n) => n.toString().padLeft(2, '0');
+ return '${two(local.hour)}:${two(local.minute)}';
}
-
- return Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.groupGap,
- 0,
- ),
- child: Wrap(
- children: [
- tab(SuperTabActivityFilter.all, 'All'),
- tab(SuperTabActivityFilter.decisions, 'Decisions'),
- tab(SuperTabActivityFilter.mentions, 'Mentions'),
- tab(SuperTabActivityFilter.replies, 'Replies'),
- tab(SuperTabActivityFilter.reactions, 'Reactions'),
- ],
- ),
- );
+ return superTabAgoShort(now.difference(local));
}
- Widget _empty(String text) => Padding(
+ /// Starts where a row's mark does: the row's own two insets.
+ Widget _heading(String title) => Padding(
padding: const EdgeInsets.fromLTRB(
+ grid.AppDesktop.controlGap + grid.AppDesktop.groupGap,
grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
+ grid.AppDesktop.menuInset,
),
- child: Text(text, style: DesktopChrome.metadata()),
+ child: SuperTabSectionHeading(title, startInset: 0, endInset: 0),
);
- Widget _face({String? personId, String? agentId, required String name}) {
- final snapshot = _activity.controller.snapshot;
- final person = personId == null
- ? null
- : snapshot?.people.where((p) => p.id == personId).firstOrNull;
- if (person != null) return SuperTabAvatar.person(person, size: 24);
- final agent = agentId == null ? null : snapshot?.agent(agentId);
- if (agent != null) {
- return SuperTabAvatar.agent(agent, name: name, size: 24);
- }
- return const SizedBox(width: 24);
- }
-
- Widget _row({
- required Key key,
- required Widget face,
- required String title,
- required String place,
- required String text,
- required DateTime? at,
- required bool unread,
- required VoidCallback onTap,
- Widget? trailing,
- }) => Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.controlGap,
- vertical: grid.AppDesktop.listRowGap,
- ),
- child: Material(
- color: Colors.transparent,
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- clipBehavior: Clip.antiAlias,
- child: InkWell(
- key: key,
- onTap: onTap,
- hoverColor: grid.AppSurface.hoverFill,
- focusColor: grid.AppSurface.hoverFill,
- child: Semantics(
- label: unread ? 'Unread' : null,
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.controlGap,
- ),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.only(
- right: grid.AppDesktop.controlGap,
- top: grid.AppDesktop.listRowGap,
- ),
- child: face,
- ),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Flexible(
- child: Text(
- title,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style:
- DesktopChrome.control(
- color: unread ? null : DesktopChrome.muted,
- ).copyWith(
- fontWeight: unread
- ? grid.AppFont.semibold
- : null,
- ),
- ),
- ),
- if (at != null) ...[
- const SizedBox(width: 8),
- Text(
- superTabAgo(widget.now().difference(at)),
- style: DesktopChrome.metadata(),
- ),
- ],
- ],
- ),
- Text(
- place,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata(),
- ),
- const SizedBox(height: 2),
- Text(
- text,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.control(
- color: unread ? null : DesktopChrome.muted,
- ),
- ),
- ],
- ),
- ),
- ?trailing,
- ],
- ),
- ),
- ),
- ),
+ Widget _empty(String text) => Padding(
+ padding: const EdgeInsets.fromLTRB(
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.controlGap,
),
+ child: Text(text, style: DesktopChrome.metadata()),
);
- Widget _mentionRow(SuperTabMention mention) {
- final c = _activity.controller;
- final hidden = c.snapshot?.conversation(mention.conversationId);
- // An old Chat with PM an older server still sends opens the project's
- // chat, and is named so; every other place by its title.
- final place = hidden == null || !c.hiddenByBuddies(hidden)
- ? mention.conversationTitle
- : '#${c.snapshot?.projects.where((p) => p.id == mention.projectId).firstOrNull?.name ?? mention.projectName}';
- final person = c.snapshot?.people
- .where((p) => p.id == mention.leadId)
- .firstOrNull;
- final author = person?.username ?? mention.leadName;
- final waiting = mention.resolvedBy == null;
- return _row(
- key: ValueKey('super-mention-${mention.id}'),
- face: _face(
- personId: mention.leadId,
- agentId: mention.leadId,
- name: mention.leadName,
- ),
- title: '$author tagged you',
- place: '${mention.projectName} · $place',
- text: mention.text,
- at: mention.createdAt,
- unread: _activity.mentionUnread(mention),
- onTap: () => widget.onOpenMention(mention),
- trailing: waiting
- ? Padding(
- padding: const EdgeInsets.only(left: grid.AppDesktop.controlGap),
- child: TextButton(
- onPressed: _marking.contains(mention.id)
- ? null
- : () => unawaited(_done(mention)),
- child: const Text('Mark done'),
- ),
+ Widget _need(SuperTabNeed need) {
+ final decision = need.decision;
+ final mention = need.mention;
+ final open = decision != null && _answering.contains(decision.id);
+ final row = _Row(
+ key: ValueKey('super-activity-row-${need.id}'),
+ mark: switch (need.kind) {
+ SuperTabNeedKind.mention => '@',
+ _ => '◐',
+ },
+ title: need.title,
+ unread: true,
+ trailing: switch (need.kind) {
+ SuperTabNeedKind.decision => 'Answer',
+ SuperTabNeedKind.agent => 'Open',
+ SuperTabNeedKind.mention => need.at == null ? '' : _when(need.at!),
+ },
+ hoverAction: mention != null && mention.resolvedBy == null
+ ? (
+ label: 'Mark done',
+ busy: _marking.contains(mention.id),
+ run: () => unawaited(_done(mention)),
)
: null,
+ onTap: () {
+ if (decision != null) {
+ setState(() {
+ if (!_answering.remove(decision.id)) _answering.add(decision.id);
+ });
+ } else if (mention != null) {
+ widget.onOpenMention(mention);
+ } else {
+ widget.onOpenConversation(need.conversationId);
+ }
+ },
+ );
+ if (!open) return row;
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ row,
+ SuperTabDecisionCard(
+ decisions: _activity.decisions,
+ decision: decision,
+ ),
+ ],
);
}
- Widget _itemRow(SuperTabActivityItem item) {
- final name = item.actorName;
- final glyph = SuperTabReactionEmoji.of(item.emoji)?.glyph ?? '';
- return _row(
- key: ValueKey('super-activity-${item.id}'),
- face: _face(
- personId: item.byAgent ? null : item.actorId,
- agentId: item.byAgent ? item.actorId : null,
- name: name,
+ Widget _thread(SuperTabFollowedThread thread) {
+ final text = thread.rootText.replaceAll(RegExp(r'\s+'), ' ').trim();
+ return _Row(
+ key: ValueKey('super-activity-row-thread:${thread.key}'),
+ mark: '↳',
+ title: text.isEmpty ? 'Thread' : text,
+ unread: true,
+ trailing: '${_activity.attention.newCount(thread)} new',
+ hoverAction: (
+ label: 'Unfollow',
+ busy: _activity.attention.following.contains(thread.key),
+ run: () => unawaited(_activity.attention.setFollow(thread, false)),
),
- title: item.kind == SuperTabActivityKind.reply
- ? '$name replied to your message'
- : '$name reacted $glyph to your message',
- place: '${item.projectName} · ${item.conversationTitle}',
- text: item.text,
- at: item.createdAt,
- unread: _activity.isUnread(item),
- onTap: () => widget.onOpenMessage(item.conversationId, item.messageId),
+ onTap: () => widget.onOpenThread(thread.conversationId, thread.rootId),
);
}
+ Widget _finished(SuperTabConversation group) => _Row(
+ key: ValueKey('super-activity-row-done:${group.id}'),
+ mark: '✓',
+ title: group.title,
+ unread: false,
+ trailing: _when(group.shippedAt!),
+ onTap: () => widget.onOpenConversation(group.id),
+ );
+
@override
Widget build(BuildContext context) => ListenableBuilder(
- listenable: _activity,
+ // The threads are read only while this view shows them.
+ listenable: Listenable.merge([_activity, _activity.attention]),
builder: (context, _) {
grid.AppTheme.watch(context);
final a = _activity;
- final filter = a.filter;
- final decisions =
- filter == SuperTabActivityFilter.all ||
- filter == SuperTabActivityFilter.decisions;
- final entries = filter == SuperTabActivityFilter.decisions
- ? const <_Entry>[]
- : _entries();
- final error = a.error ?? a.mentions.error;
+ final needs = a.needsYou;
+ final replies = a.newReplies;
+ final done = a.doneToday;
+ final error = a.mentions.error ?? a.decisions.error ?? a.attention.error;
return LaidOutListView(
key: const ValueKey('super-activity-list'),
padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
children: [
- _filters(),
if (error != null)
Padding(
padding: const EdgeInsets.fromLTRB(
@@ -360,48 +208,121 @@ class _SuperTabActivityViewState extends State<SuperTabActivityView> {
Expanded(child: Text(error, style: DesktopChrome.control())),
TextButton(
onPressed: () {
- unawaited(a.load());
unawaited(a.mentions.load());
+ unawaited(a.decisions.load());
+ unawaited(a.attention.load());
},
child: const Text('Retry'),
),
],
),
),
- if (decisions) SuperTabDecisionList(decisions: a.decisions),
- if (filter != SuperTabActivityFilter.decisions) ...[
- if (filter == SuperTabActivityFilter.all)
- const Padding(
- padding: EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.menuInset,
- ),
- child: SuperTabSectionHeading('Activity', endInset: 0),
- ),
- if (entries.isEmpty)
- _empty(switch (filter) {
- SuperTabActivityFilter.mentions => 'Nobody tagged you yet.',
- SuperTabActivityFilter.replies =>
- a.supported
- ? 'No replies to your messages yet.'
- : 'Update the server to see replies here.',
- SuperTabActivityFilter.reactions =>
- a.supported
- ? 'No reactions to your messages yet.'
- : 'Update the server to see reactions here.',
- _ => 'Nothing yet.',
- }),
- for (final e in entries)
- if (e.mention case final mention?)
- _mentionRow(mention)
- else
- _itemRow(e.item!),
- if (a.more) _empty('Older activity is not shown.'),
+ if (needs.isEmpty && replies.isEmpty && done.isEmpty)
+ _empty("You're all caught up."),
+ if (needs.isNotEmpty) ...[
+ _heading('Needs you'),
+ for (final need in needs) _need(need),
+ ],
+ if (replies.isNotEmpty) ...[
+ _heading('New replies'),
+ for (final thread in replies) _thread(thread),
+ ],
+ if (done.isNotEmpty) ...[
+ _heading('Done today'),
+ for (final group in done) _finished(group),
],
],
);
},
);
}
+
+/// One line: a mark, the name, and one word or time at the end. Bold when it
+/// is new; a hover action (Mark done) takes the place of the time.
+class _Row extends StatefulWidget {
+ const _Row({
+ super.key,
+ this.mark,
+ required this.title,
+ required this.unread,
+ required this.trailing,
+ required this.onTap,
+ this.hoverAction,
+ });
+ final String? mark;
+ final String title;
+ final bool unread;
+ final String trailing;
+ final VoidCallback onTap;
+ final ({String label, bool busy, VoidCallback run})? hoverAction;
+
+ @override
+ State<_Row> createState() => _RowState();
+}
+
+class _RowState extends State<_Row> {
+ bool _hovered = false;
+
+ @override
+ Widget build(BuildContext context) {
+ final action = widget.hoverAction;
+ final bold = widget.unread;
+ final style = DesktopChrome.control(
+ color: bold ? null : DesktopChrome.muted,
+ ).copyWith(fontWeight: bold ? grid.AppFont.semibold : null);
+ return Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.controlGap,
+ vertical: grid.AppDesktop.listRowGap,
+ ),
+ child: MouseRegion(
+ onEnter: (_) => setState(() => _hovered = true),
+ onExit: (_) => setState(() => _hovered = false),
+ child: Material(
+ color: Colors.transparent,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ onTap: widget.onTap,
+ hoverColor: grid.AppSurface.hoverFill,
+ focusColor: grid.AppSurface.hoverFill,
+ child: Semantics(
+ label: bold ? 'New' : null,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.groupGap,
+ vertical: grid.AppDesktop.controlGap,
+ ),
+ child: Row(
+ children: [
+ // Every row has the slot, so every title starts in one column.
+ SizedBox(
+ width: 20,
+ child: Text(widget.mark ?? '', style: style),
+ ),
+ Expanded(
+ child: Text(
+ widget.title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ ),
+ ),
+ const SizedBox(width: grid.AppDesktop.groupGap),
+ if (action != null && _hovered)
+ GestureDetector(
+ onTap: action.busy ? null : action.run,
+ child: Text(action.label, style: style),
+ )
+ else
+ Text(widget.trailing, style: DesktopChrome.metadata()),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/attention.dart b/desktop/lib/super_tabs/attention.dart
index 229ae1fd1..b1a2a9ff2 100644
--- a/desktop/lib/super_tabs/attention.dart
+++ b/desktop/lib/super_tabs/attention.dart
@@ -1,7 +1,5 @@
import 'dart:async';
-import 'dart:math';
-import 'package:clock/clock.dart';
import 'package:flutter/foundation.dart';
import 'controller.dart';
@@ -50,33 +48,11 @@ class SuperTabFollowedThread {
/// What needs the reader in one Swarm, the way Slack shows it: which
/// conversations hold a tag of them (the red number), and which threads they
-/// follow have replies they have not read (the Threads row and view). Tags and
+/// follow have replies they have not read (Activity's New replies). Tags and
/// decisions come from [SuperTabMentions] and [SuperTabDecisions]; threads
/// from the server's followed-threads read, read again when the Swarm moves,
-/// at most every [quietGap] (every [openGap] while the Threads view is open).
+/// at most every [quietGap] (every [openGap] while Activity is open).
/// One per controller.
-/// One of the reader's replies on a Threads card ([SuperTabAttention.ownReplies]).
-class SuperTabOwnReply {
- const SuperTabOwnReply(this.text, this.at, {this.outgoing});
- final String text;
-
- /// What its row says: a reply of files alone has no text of its own.
- String get shownText => text.isEmpty ? 'Files' : text;
-
- /// When it was seen on its way this visit; null for one that failed earlier.
- final DateTime? at;
-
- /// Where it stands while the transcript does not hold it; null once it does.
- final SuperTabOutgoing? outgoing;
-
- /// On its way, nothing back from the server yet.
- bool get sending => outgoing?.state == SuperTabOutgoingState.sending;
-
- /// The server took it.
- bool get sent =>
- outgoing == null || outgoing!.state == SuperTabOutgoingState.confirmed;
-}
-
class SuperTabAttention extends ChangeNotifier {
SuperTabAttention._(this.controller, {DateTime Function()? now})
: mentions = SuperTabMentions.of(controller),
@@ -124,26 +100,11 @@ class SuperTabAttention extends ChangeNotifier {
/// The server stopped short of everything (its bounds).
bool more = false;
- /// Threads shown as new in this visit of the Threads view: they stay new
+ /// Threads shown as new in this visit of Activity: they stay new
/// until the view is left, though opening them marked them read.
final Set<String> _newThisVisit = {};
bool _open = false;
- /// New replies under each unread thread's root, read when the view showed
- /// it; by [SuperTabFollowedThread.key].
- final Map<String, List<SuperTabMessage>> newReplies = {};
- final Set<String> _readingReplies = {};
-
- /// The replies seen on their way from this view this visit, by thread and
- /// then by receipt: what [ownReplies] still shows, as sent, once the
- /// transcript holds them and they leave [SuperTabController.outgoing].
- final Map<String, Map<String, ({String text, DateTime at})>> _ownThisVisit =
- {};
-
- /// Threads whose replies failed to read this visit: not asked again until
- /// the next one, so a failing read is not repeated on every redraw.
- final Set<String> _repliesFailed = {};
-
/// Threads whose Follow is being sent.
final Set<String> following = {};
@@ -196,13 +157,13 @@ class SuperTabAttention extends ChangeNotifier {
/// A tag from a server that does not say where it is: it counts until
/// answered, past any read mark.
- static const _unknown = 1 << 52;
+ static const _unknown = 9007199254740991;
- /// The Threads row's number: tags of the reader inside threads they have
+ /// The number of tags of the reader inside threads they have
/// not read past, in chats this Swarm still lists for them. A muted chat's
/// threads never count, as its main stream does not ([mentionsIn]).
///
- /// Only threads the Threads view lists count ([unread] and [read]): the
+ /// Only threads Activity lists count ([unread] and [read]): the
/// number promises something to open there. A tag in a thread the server
/// left out (older than its bounds, unfollowed, a root the reader cannot
/// read) stays in Activity, and counts nothing here. None until the list
@@ -274,9 +235,6 @@ class SuperTabAttention extends ChangeNotifier {
_trailing = null;
_newThisVisit.clear();
_counts.clear();
- newReplies.clear();
- _ownThisVisit.clear();
- _repliesFailed.clear();
if (!_disposed) notifyListeners();
}
@@ -287,17 +245,12 @@ class SuperTabAttention extends ChangeNotifier {
more = false;
_newThisVisit.clear();
_counts.clear();
- newReplies.clear();
- _ownThisVisit.clear();
- _readingReplies.clear();
- _repliesFailed.clear();
_trailing?.cancel();
_trailing = null;
}
void _changed() {
if (_disposed) return;
- if (_open) _noteOwnReplies();
if (controller.accessRevoked) {
if (loaded || unread.isNotEmpty || read.isNotEmpty) {
_clear();
@@ -332,7 +285,7 @@ class SuperTabAttention extends ChangeNotifier {
if (_lastRead case final last?) last.add(_open ? openGap : quietGap),
].fold<DateTime?>(null, (a, b) => a == null || b.isAfter(a) ? b : a);
if (until != null && now.isBefore(until)) {
- // Only while something shows it (the sidebar, the Threads view).
+ // Only while something shows it (the sidebar, Activity).
if (!hasListeners) return;
_trailing ??= Timer(until.difference(now), () {
_trailing = null;
@@ -425,126 +378,6 @@ class SuperTabAttention extends ChangeNotifier {
}
}
- /// Reads the replies of [thread] the reader has not read, to show under its
- /// root, then marks the thread read: opening the view reads what it shows.
- Future<void> showReplies(SuperTabFollowedThread thread) async {
- if (_disposed ||
- controller.accessRevoked ||
- newReplies.containsKey(thread.key) ||
- _repliesFailed.contains(thread.key) ||
- !_readingReplies.add(thread.key)) {
- return;
- }
- final epoch = controller.visibilityEpoch;
- final seen = controller.threadReadMark(thread.rootId);
- try {
- final answer = await controller.request(
- 'GET',
- '$_path/conversations/${Uri.encodeComponent(thread.conversationId)}'
- '/messages?thread=${Uri.encodeQueryComponent(thread.rootId)}',
- );
- if (_disposed ||
- controller.accessRevoked ||
- controller.visibilityEpoch != epoch ||
- !_readingReplies.contains(thread.key)) {
- return;
- }
- final replies = [
- for (final row in answer['messages'] as List? ?? const [])
- if (SuperTabMessage.fromJson(superTabMap(row)) case final m
- when m.conversationId == thread.conversationId &&
- m.thread == thread.rootId &&
- m.threadReply &&
- m.sequence > seen)
- m,
- ]..sort(superTabMessageOrder);
- newReplies[thread.key] = replies.length > 5
- ? replies.sublist(replies.length - 5)
- : replies;
- final through = max(
- thread.lastReplySequence,
- replies.lastOrNull?.sequence ?? 0,
- );
- controller.markThreadRead(thread.conversationId, thread.rootId, through);
- notifyListeners();
- } catch (_) {
- // The thread stays unread and its root shows; the next visit tries again.
- _repliesFailed.add(thread.key);
- } finally {
- _readingReplies.remove(thread.key);
- }
- }
-
- /// Whether [message] is a reply to [thread].
- static bool _repliesTo(
- SuperTabOutgoing message,
- SuperTabFollowedThread thread,
- ) => message.replyTo == thread.rootId || message.thread == thread.rootId;
-
- /// Whether [message] failed: refused, or sent with no answer. Never called
- /// sent; a Retry brings it back on its way.
- static bool _failed(SuperTabOutgoing message) =>
- message.state == SuperTabOutgoingState.refused ||
- message.state == SuperTabOutgoingState.unconfirmed;
-
- /// Notes the replies on their way from each thread listed, on every change
- /// of the controller and not only when a frame draws: a send can go from on
- /// its way to read back between two frames.
- void _noteOwnReplies() {
- final threads = [...unread, ...read];
- for (final conversationId in {for (final t in threads) t.conversationId}) {
- final rows = controller.outgoing(conversationId);
- if (rows.isEmpty) continue;
- for (final thread in threads) {
- if (thread.conversationId != conversationId) continue;
- for (final message in rows) {
- final operationId = message.operationId;
- if (operationId == null || !_repliesTo(message, thread)) continue;
- final kept = _ownThisVisit[thread.key] ??= {};
- if (_failed(message)) {
- kept.remove(operationId);
- } else if (message.state == SuperTabOutgoingState.sending) {
- // First seen on its way only: a sent reply stays in that list
- // until its chat's transcript loads, and one from an earlier visit
- // must not come back as new (review of #2555).
- kept.putIfAbsent(
- operationId,
- () => (text: message.text, at: clock.now()),
- );
- }
- }
- }
- }
- }
-
- /// The reader's own replies to [thread] that its card shows beside
- /// [newReplies], oldest first: on their way, failed, or sent during this
- /// visit (Scholes, 2026-11-02: a reply showed only after an agent answered,
- /// so it looked unsent). One [newReplies] already holds is not shown twice.
- List<SuperTabOwnReply> ownReplies(SuperTabFollowedThread thread) {
- final rows = [
- for (final message in controller.outgoing(thread.conversationId))
- if (_repliesTo(message, thread)) message,
- ];
- final live = {for (final m in rows) ?m.operationId: m};
- final read = {for (final m in newReplies[thread.key] ?? const []) m.id};
- return [
- for (final MapEntry(key: operationId, :value)
- in (_ownThisVisit[thread.key] ?? const {}).entries)
- if (!read.contains(
- superTabMessageId(
- tabId: controller.tabId,
- accountId: controller.accountId,
- operationId: operationId,
- ),
- ))
- SuperTabOwnReply(value.text, value.at, outgoing: live[operationId]),
- for (final message in rows)
- if (_failed(message))
- SuperTabOwnReply(message.text, null, outgoing: message),
- ];
- }
-
/// Follows (true) or unfollows (false) [thread] on every device of the
/// reader; false when the server did not keep it.
Future<bool> setFollow(SuperTabFollowedThread thread, bool follow) async {
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index dd68630dd..9a64ad192 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -2941,6 +2941,21 @@ class SuperTabController extends ChangeNotifier {
bool isOwn(SuperTabMessage m) =>
!m.fromAgent && !m.fromTerminal && m.authorId == accountId;
+ /// Whether what [id]'s main stream gained since sequence [after] is all the reader's own, sent from
+ /// any device. Unsure is no: a message that can't be read is told about, never lost.
+ Future<bool> onlyOwnSince(String id, int after) async {
+ try {
+ final answer = await request('GET', '${_messagesPath(id)}?after=$after');
+ if (answer['next'] != null) return false;
+ final main = (answer['messages'] as List)
+ .map((row) => SuperTabMessage.fromJson(superTabMap(row)))
+ .where((message) => message.inMainStream);
+ return main.isNotEmpty && main.every(isOwn);
+ } catch (_) {
+ return false;
+ }
+ }
+
/// Whether the messages held of [group] run from its read mark (or its
/// first message) to its newest, update requests included.
bool _heldSinceRead(SuperTabConversation group) {
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index 8dcc05dfb..55559d87b 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -340,6 +340,12 @@ class SuperTabConversation {
task = row['task'] is Map
? SuperTabTask.fromJson(superTabMap(row['task']))
: null,
+ requesterId = row['requesterId'] as String?,
+ shippedAt = row['shippedAt'] is num
+ ? DateTime.fromMillisecondsSinceEpoch(
+ (row['shippedAt'] as num).toInt(),
+ )
+ : null,
lastMessageSequence = (row['lastMessageSequence'] as num?)?.toInt() ?? 0,
lastMainSequence = (row['lastMainSequence'] as num?)?.toInt(),
assignment = row['assignment'] == null
@@ -415,6 +421,14 @@ class SuperTabConversation {
/// leaves it. Null from a backend before threads, or before this
/// conversation's first message since.
final int? lastMainSequence;
+
+ /// The person who asked for this task; null on a conversation that is no
+ /// task, and from a server that does not say.
+ final String? requesterId;
+
+ /// When it shipped (its first Done); null until it has, and from a server
+ /// that does not say.
+ final DateTime? shippedAt;
final Map<String, dynamic>? assignment;
/// Whether its task waits on purpose or is stuck, as the server last found
diff --git a/desktop/lib/super_tabs/notifications.dart b/desktop/lib/super_tabs/notifications.dart
index 984558d7b..fb1f88550 100644
--- a/desktop/lib/super_tabs/notifications.dart
+++ b/desktop/lib/super_tabs/notifications.dart
@@ -76,8 +76,8 @@ void Function(String tabId, SuperTabMention mention)? superTabMentionNotice(
);
/// What tells the person about a new message in a chat they set to All new
-/// messages: the operating system, on Desktop only, as tags are. The chat's
-/// newest message is not read for it; the notice names the chat.
+/// messages: the operating system, on Desktop only, as tags are. The notice
+/// names the chat, not its newest message.
void Function(String tabId, SuperTabConversation group, int sequence)?
superTabChatNotice(SystemNotifications system, {bool web = kIsWeb}) => web
? null
diff --git a/desktop/lib/super_tabs/threads_view.dart b/desktop/lib/super_tabs/threads_view.dart
deleted file mode 100644
index ec834ac98..000000000
--- a/desktop/lib/super_tabs/threads_view.dart
+++ /dev/null
@@ -1,755 +0,0 @@
-import 'dart:async';
-
-import 'package:flutter/material.dart';
-
-import '../shared/theme/app_theme.dart' as grid;
-import '../widgets/desktop_chrome.dart';
-import 'attention.dart';
-import 'composer_newline.dart' show kComposerMaxLength;
-import 'composer_tags.dart';
-import '../shared/theme/app_icons.dart';
-import 'controller.dart';
-import 'identity.dart';
-import 'message_more_menu.dart';
-import 'message_receipt.dart';
-import 'machine_status.dart' show superTabAgo;
-import 'model.dart';
-import 'reply_box.dart';
-import 'section_heading.dart';
-import 'workgroup_name.dart';
-import '../widgets/laid_out_list.dart';
-
-/// How many threads with new replies read their replies when the view opens;
-/// the rest show their root and count until opened.
-const kThreadsShowingReplies = 10;
-
-/// Slack's Threads view: every thread the reader follows (started, replied
-/// in, tagged in, or followed by hand), those with new replies first and in
-/// bold with the new replies under the root and a reply box, the rest after.
-/// Showing a thread's new replies marks it read, on every device; it stays
-/// new until the view is left.
-class SuperTabThreadsView extends StatefulWidget {
- const SuperTabThreadsView({
- super.key,
- required this.attention,
- required this.onOpen,
- this.now = DateTime.now,
- this.machineName,
- });
-
- final SuperTabAttention attention;
-
- /// Names an agent's machine in the @ list, as the thread pane does.
- final String Function(String machineId)? machineName;
-
- /// Opens [rootId]'s thread in its chat [conversationId].
- final void Function(String conversationId, String rootId) onOpen;
- final DateTime Function() now;
-
- @override
- State<SuperTabThreadsView> createState() => _SuperTabThreadsViewState();
-}
-
-class _SuperTabThreadsViewState extends State<SuperTabThreadsView> {
- late SuperTabAttention _attention;
-
- @override
- void initState() {
- super.initState();
- _attention = widget.attention..opened();
- }
-
- @override
- void didUpdateWidget(SuperTabThreadsView old) {
- super.didUpdateWidget(old);
- if (old.attention != widget.attention) {
- old.attention.closed();
- _attention = widget.attention..opened();
- }
- }
-
- @override
- void dispose() {
- _attention.closed();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) => ListenableBuilder(
- listenable: _attention,
- builder: (context, _) {
- grid.AppTheme.watch(context);
- final a = _attention;
- final shown = a.shown;
- final fresh = shown.where(a.isNew).toList();
- final rest = shown.where((t) => !a.isNew(t)).toList();
- // Opening reads what it shows: the first threads with new replies.
- WidgetsBinding.instance.addPostFrameCallback((_) {
- if (!mounted) return;
- for (final thread in fresh.take(kThreadsShowingReplies)) {
- unawaited(a.showReplies(thread));
- }
- });
- return LaidOutListView(
- key: const ValueKey('super-threads-view'),
- padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
- children: [
- if (a.error case final error?)
- Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.groupGap,
- 0,
- ),
- child: Row(
- children: [
- Expanded(child: Text(error, style: DesktopChrome.control())),
- TextButton(
- onPressed: () => unawaited(a.load()),
- child: const Text('Retry'),
- ),
- ],
- ),
- ),
- if (!a.loaded && a.error == null)
- Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- ),
- child: Text('Loading threads…', style: DesktopChrome.metadata()),
- )
- else if (a.loaded && shown.isEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- ),
- child: Text(
- 'No threads yet. Threads you start, reply in or are '
- 'tagged in show here.',
- style: DesktopChrome.metadata(),
- ),
- ),
- if (fresh.isNotEmpty) ...[
- const Padding(
- padding: EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- ),
- child: SuperTabSectionHeading('New replies', endInset: 0),
- ),
- for (final thread in fresh)
- _ThreadCard(
- key: ValueKey('super-thread-${thread.key}'),
- attention: a,
- thread: thread,
- onOpen: widget.onOpen,
- now: widget.now,
- machineName: widget.machineName,
- ),
- ],
- if (rest.isNotEmpty) ...[
- const Padding(
- padding: EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- ),
- child: SuperTabSectionHeading('Earlier', endInset: 0),
- ),
- for (final thread in rest)
- _ThreadCard(
- key: ValueKey('super-thread-${thread.key}'),
- attention: a,
- thread: thread,
- onOpen: widget.onOpen,
- now: widget.now,
- machineName: widget.machineName,
- ),
- ],
- if (a.more)
- Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- ),
- child: Text(
- 'Older threads are not listed.',
- style: DesktopChrome.metadata(),
- ),
- ),
- ],
- );
- },
- );
-}
-
-/// One followed thread in the list: where it is, its root, its new replies
-/// and a reply box while it is new, else its reply count. Follow or Unfollow
-/// waits behind a quiet ⋯ that shows on hover or focus, as in Slack.
-class _ThreadCard extends StatefulWidget {
- const _ThreadCard({
- super.key,
- required this.attention,
- required this.thread,
- required this.onOpen,
- required this.now,
- this.machineName,
- });
-
- final SuperTabAttention attention;
- final SuperTabFollowedThread thread;
- final String Function(String machineId)? machineName;
- final void Function(String conversationId, String rootId) onOpen;
- final DateTime Function() now;
-
- @override
- State<_ThreadCard> createState() => _ThreadCardState();
-}
-
-class _ThreadCardState extends State<_ThreadCard> {
- /// An avatar, and the column the text beside it starts at.
- static const _face = SuperTabAvatar.rowSize;
- static const _indent = _face + grid.AppDesktop.controlGap;
-
- late final _text = TextEditingController(
- text: _c.threadDraft(widget.thread.rootId),
- );
- final _focus = FocusNode(debugLabel: 'Threads reply');
- bool _hovered = false, _focused = false;
-
- // `@` in the reply box, as in the thread pane's (composer_tags.dart): the
- // choice selected, and the text before the caret where it was dismissed.
- final _tagIndex = ValueNotifier(0);
- final _tagDismissed = ValueNotifier<String?>(null);
- final _tagRows = List.generate(superTabCompletionLimit, (_) => GlobalKey());
- late final _tagBackspace = SuperTabTagBackspace(
- () => _c.threadMentions(_thread.conversationId, _thread.rootId).values,
- );
-
- SuperTabController get _c => widget.attention.controller;
- SuperTabFollowedThread get _thread => widget.thread;
- SuperTabSnapshot? get _snapshot => _c.snapshot;
-
- @override
- void dispose() {
- _text.dispose();
- _focus.dispose();
- _tagIndex.dispose();
- _tagDismissed.dispose();
- super.dispose();
- }
-
- /// The `@` tag typed at the caret.
- ({int start, int end, String query})? get _tagAt => superTabTagAtCaret(
- _text.value,
- dismissed: _tagDismissed.value,
- tags: _c.threadMentions(_thread.conversationId, _thread.rootId).values,
- );
-
- /// Who `@` offers in this reply: whom the thread's own chat offers.
- List<SuperTabComposerChoice> get _tagChoices {
- final group = _snapshot?.conversation(_thread.conversationId);
- if (!_writable || group == null) return const [];
- final at = _tagAt;
- if (at == null) return const [];
- return superTabTagChoices(
- _c,
- group,
- at.query,
- machineName: widget.machineName ?? (_) => '',
- choose: _chooseTag,
- );
- }
-
- void _chooseTag(String id, String name) {
- final at = _tagAt;
- if (at == null) return;
- final token = '@$name';
- final value = superTabInsertTag(_text.value, at, token);
- _c.setThreadDraft(
- _thread.rootId,
- value.text,
- conversationId: _thread.conversationId,
- );
- _c.threadMention(id, token, to: _target);
- _text.value = value;
- _tagIndex.value = 0;
- _focus.requestFocus();
- setState(() {});
- }
-
- void _moveTag(int index) {
- _tagIndex.value = index;
- WidgetsBinding.instance.addPostFrameCallback((_) {
- final row = _tagRows[index].currentContext;
- if (mounted && row != null) Scrollable.ensureVisible(row, alignment: .5);
- });
- }
-
- /// Where the thread is, named as the sidebar names it.
- String _place() {
- final snapshot = _snapshot;
- final group = snapshot?.conversation(_thread.conversationId);
- if (snapshot == null || group == null) return '';
- final project = snapshot.projectFor(group.id);
- if (snapshot.isProjectLead(group.id)) return '# ${project?.name ?? ''}';
- if (group.isBuddyChat) return 'Buddy · ${project?.name ?? ''}';
- final name = SuperTabWorkgroupName.plain(group);
- return project == null ? name : '# ${project.name} · $name';
- }
-
- /// An author as the chat names them now.
- String _name(Map<String, dynamic> author) {
- final id = author['id'] as String? ?? '';
- final recorded =
- author['displayName'] as String? ?? author['name'] as String? ?? '';
- if (author['kind'] == 'agent') {
- return _snapshot?.agentName(id, fallback: recorded) ?? recorded;
- }
- return _snapshot?.people.where((p) => p.id == id).firstOrNull?.username ??
- superTabPersonName(recorded);
- }
-
- Widget? _avatar(Map<String, dynamic> author) {
- final id = author['id'] as String? ?? '';
- if (author['kind'] == 'agent') {
- return switch (_snapshot?.agent(id)) {
- final agent? => SuperTabAvatar.agent(
- agent,
- name: _name(author),
- size: _face,
- engineBadge: false,
- ),
- null => null,
- };
- }
- return switch (_snapshot?.people.where((p) => p.id == id).firstOrNull) {
- final person? => SuperTabAvatar.person(person, size: _face),
- null => null,
- };
- }
-
- Widget _message(
- Map<String, dynamic> author,
- String text, {
- DateTime? at,
- required bool strong,
- int lines = 3,
- }) => Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SizedBox(width: _face, height: _face, child: _avatar(author)),
- const SizedBox(width: grid.AppDesktop.controlGap),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Flexible(
- child: Text(
- _name(author),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.control(medium: true).copyWith(
- fontWeight: strong ? grid.AppFont.semibold : null,
- ),
- ),
- ),
- if (at != null) ...[
- const SizedBox(width: grid.AppDesktop.controlGap),
- Text(
- superTabAgo(widget.now().difference(at)),
- style: DesktopChrome.metadata(),
- ),
- ],
- ],
- ),
- Text(
- text,
- maxLines: lines,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.control(
- color: strong ? null : DesktopChrome.muted,
- ),
- ),
- ],
- ),
- ),
- ],
- );
-
- /// The thread's root, for a reply sent from here.
- ({String conversationId, String root}) get _target =>
- (conversationId: _thread.conversationId, root: _thread.rootId);
-
- bool get _writable =>
- _c.canWrite &&
- _snapshot?.conversation(_thread.conversationId)?.archived == false &&
- !_c.isEarlierBuddyChat(_snapshot?.conversation(_thread.conversationId)) &&
- !_c.hasPendingAction;
-
- bool get _busy => _c.uploading || _c.saving;
-
- void _edited(String text) {
- _c.setThreadDraft(
- _thread.rootId,
- text,
- conversationId: _thread.conversationId,
- );
- _tagIndex.value = 0;
- _tagDismissed.value = null;
- setState(() {});
- }
-
- Future<void> _send() async {
- final files = _c.threadAttachments(_thread.conversationId, _thread.rootId);
- if (!_writable || _busy || (_text.text.trim().isEmpty && files.isEmpty)) {
- return;
- }
- final root = _thread.rootId;
- _c.setThreadDraft(root, _text.text, conversationId: _thread.conversationId);
- await _c.sendThreadReply(
- to: _target,
- onSending: () {
- if (mounted && _c.threadDraft(root).isEmpty) _text.clear();
- },
- );
- if (mounted) setState(() {});
- }
-
- /// What the box says, unless a failed reply above it already says the same.
- String? _boxError() {
- final error = _c.threadComposerError(
- _thread.conversationId,
- _thread.rootId,
- );
- return widget.attention
- .ownReplies(_thread)
- .any((reply) => reply.outgoing?.error == error)
- ? null
- : error;
- }
-
- /// The reader's own reply: as sent, or the thread pane's Sending… and Not
- /// sent with Retry and Delete. A failed one keeps its text here.
- Widget _ownReply(SuperTabOwnReply reply) {
- final outgoing = reply.outgoing;
- return Padding(
- padding: const EdgeInsets.only(
- left: _indent,
- top: grid.AppDesktop.controlGap,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _message(
- {'kind': 'person', 'id': _c.accountId},
- reply.shownText,
- at: reply.at,
- strong: !reply.sending,
- // A failed one whole: this row is all that is left of its text.
- lines: reply.sent || reply.sending ? 4 : kComposerMaxLength,
- ),
- Padding(
- padding: const EdgeInsets.only(left: _indent),
- child: reply.sent || outgoing == null
- ? Semantics(
- liveRegion: true,
- child: Text('Sent', style: DesktopChrome.metadata()),
- )
- : SuperTabOutgoingReceipt(
- inline: true,
- message: outgoing,
- // A refused reply goes again only when nothing else is on
- // its way.
- onRetry:
- _c.saving ||
- (outgoing.state == SuperTabOutgoingState.refused &&
- _c.hasPendingAction)
- ? null
- : () => unawaited(_c.retryOutgoing(outgoing)),
- onDelete: () => _c.discardOutgoing(outgoing),
- ),
- ),
- ],
- ),
- );
- }
-
- Future<void> _follow(bool follow) async {
- final kept = await widget.attention.setFollow(_thread, follow);
- if (!mounted || kept) return;
- ScaffoldMessenger.maybeOf(context)?.showSnackBar(
- SnackBar(
- content: Text(
- follow ? 'Could not follow this thread.' : 'Could not unfollow.',
- ),
- ),
- );
- }
-
- @override
- Widget build(BuildContext context) {
- grid.AppTheme.watch(context);
- final a = widget.attention;
- final fresh = a.isNew(_thread);
- final replies = a.newReplies[_thread.key];
- final count = a.newCount(_thread);
- final followed = _thread.follow != false;
- final group = _snapshot?.conversation(_thread.conversationId);
- // An older Buddy chat is kept to read: nothing here offers a reply.
- final canReply =
- fresh &&
- _c.canWrite &&
- group?.archived == false &&
- !_c.isEarlierBuddyChat(group);
- // A Buddy chat's thread may need a new session (its last one ended),
- // which only the thread pane offers: a box here would be refused.
- final buddyThread = group?.isBuddyChat == true;
- final showMore = _hovered || _focused;
- return Focus(
- canRequestFocus: false,
- skipTraversal: true,
- onFocusChange: (focused) => setState(() => _focused = focused),
- child: MouseRegion(
- onEnter: (_) => setState(() => _hovered = true),
- onExit: (_) => setState(() => _hovered = false),
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.controlGap,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Expanded(
- child: Text(
- _place(),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata(),
- ),
- ),
- // Quiet until the card is pointed at or focused: the
- // replies are what the eye is for (Lead's review, 10-31).
- if (a.followSupported)
- Opacity(
- opacity: showMore ? 1 : 0,
- child: KeyedSubtree(
- key: ValueKey('super-thread-more-${_thread.key}'),
- child: SuperTabMessageMoreMenu(
- actions: [
- followed
- ? (
- label: 'Unfollow thread',
- icon: AppIcons.eyeOff,
- onPressed: () => unawaited(_follow(false)),
- )
- : (
- label: 'Follow thread',
- icon: AppIcons.bell,
- onPressed: () => unawaited(_follow(true)),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- InkWell(
- key: ValueKey('super-thread-open-${_thread.key}'),
- onTap: () =>
- widget.onOpen(_thread.conversationId, _thread.rootId),
- hoverColor: grid.AppSurface.hoverFill,
- focusColor: grid.AppSurface.hoverFill,
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- vertical: grid.AppDesktop.listRowGap,
- ),
- child: _message(
- _thread.rootAuthor,
- _thread.rootText,
- at: DateTime.tryParse(
- _thread.root['createdAt'] as String? ?? '',
- ),
- strong: fresh,
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(left: _indent),
- child: fresh
- ? Text(
- count == 1 ? '1 new reply' : '$count new replies',
- style: DesktopChrome.metadata(
- color: DesktopChrome.accent,
- ).copyWith(fontWeight: grid.AppFont.semibold),
- )
- : Text(
- [
- if (_thread.replies case final n?)
- n == 1 ? '1 reply' : '$n replies',
- if (_thread.lastReplyAt case final at?)
- 'last ${superTabAgo(widget.now().difference(at))}',
- ].join(' · '),
- style: DesktopChrome.metadata(),
- ),
- ),
- if (fresh && replies != null)
- for (final reply in replies)
- Padding(
- padding: const EdgeInsets.only(
- left: _indent,
- top: grid.AppDesktop.controlGap,
- ),
- child: _message(
- reply.author,
- reply.text,
- at: reply.createdAt,
- strong: true,
- lines: 4,
- ),
- ),
- // Its own listener: a send moves on with no change to the list.
- ListenableBuilder(
- listenable: _c,
- builder: (context, _) {
- // Sent ones only while the card is new; one on its way or
- // failed always.
- final own = [
- for (final reply in a.ownReplies(_thread))
- if (fresh || !reply.sent) reply,
- ];
- return own.isEmpty
- ? const SizedBox.shrink()
- : Column(
- key: ValueKey(
- 'super-thread-own-reply-${_thread.key}',
- ),
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [for (final r in own) _ownReply(r)],
- );
- },
- ),
- if (canReply && buddyThread)
- Padding(
- padding: const EdgeInsets.only(
- left: _indent,
- top: grid.AppDesktop.controlGap,
- ),
- child: TextButton(
- key: ValueKey('super-thread-open-reply-${_thread.key}'),
- onPressed: () =>
- widget.onOpen(_thread.conversationId, _thread.rootId),
- child: const Text('Open thread to reply'),
- ),
- ),
- if (canReply && !buddyThread)
- Padding(
- padding: const EdgeInsets.only(
- left: _indent,
- top: grid.AppDesktop.controlGap,
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- // The @ list above the box, as in the thread pane.
- ListenableBuilder(
- listenable: Listenable.merge([
- _text,
- _tagIndex,
- _tagDismissed,
- ]),
- builder: (context, _) {
- final choices = _tagChoices;
- if (choices.isEmpty) return const SizedBox.shrink();
- return Padding(
- padding: const EdgeInsets.only(
- bottom: grid.AppDesktop.controlGap,
- ),
- child: SuperTabCompletionList(
- listKey: ValueKey(
- 'super-thread-completions-${_thread.key}',
- ),
- choices: choices,
- index: _tagIndex.value,
- rowKeys: _tagRows,
- ),
- );
- },
- ),
- ListenableBuilder(
- listenable: _c,
- builder: (context, _) => SuperTabReplyBox(
- controller: _c,
- text: _text,
- focus: _focus,
- files: _c.threadAttachments(
- _thread.conversationId,
- _thread.rootId,
- ),
- enabled: _c.canWrite,
- writable: _writable,
- busy: _busy,
- error: _boxError(),
- onEdited: _edited,
- onSend: () => unawaited(_send()),
- surfaceKey: ValueKey(
- 'super-thread-reply-surface-${_thread.key}',
- ),
- fieldKey: ValueKey(
- 'super-thread-reply-${_thread.key}',
- ),
- sendKey: ValueKey('super-thread-send-${_thread.key}'),
- // `@`: the open list takes its keys first.
- onKey: (event) {
- final composing = _text.value.composing;
- return _focus.hasFocus &&
- !(composing.isValid &&
- !composing.isCollapsed)
- ? superTabCompletionKey(
- event,
- choices: () => _tagChoices,
- index: _tagIndex.value,
- move: _moveTag,
- dismiss: () => _tagDismissed.value = _text
- .text
- .substring(
- 0,
- _text.selection.baseOffset,
- ),
- )
- : null;
- },
- inputFormatters: [_tagBackspace],
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index e0c731558..dab6e81c1 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -57,7 +57,6 @@ import 'decisions_view.dart';
import 'route_row.dart';
import 'terminal_row.dart';
import 'thread_panel.dart';
-import 'threads_view.dart';
import 'work_details.dart';
import 'project_sidebar.dart';
import 'buddy_sessions.dart';
@@ -154,8 +153,6 @@ class _SuperTabViewState extends State<SuperTabView>
bool _showNotifications = false;
- /// The Threads view holds the main pane (threads_view.dart).
- bool _showThreads = false;
// The message a tag opened, scrolled to once it is laid out.
String? _target;
// The conversation a link or tag opened at its own message this visit: its
@@ -473,8 +470,7 @@ class _SuperTabViewState extends State<SuperTabView>
_devicesVisible ||
_terminalsVisible ||
_showPullRequests ||
- _showNotifications ||
- _showThreads) {
+ _showNotifications) {
return false;
}
final lifecycle = WidgetsBinding.instance.lifecycleState;
@@ -702,7 +698,7 @@ class _SuperTabViewState extends State<SuperTabView>
if (group == null || !c.unreadShown(group)) continue;
widget.onCloseTerminal?.call();
setState(() {
- _showNotifications = _showThreads = false;
+ _showNotifications = false;
_showPullRequests = false;
});
unawaited(c.select(group.id));
@@ -1595,16 +1591,6 @@ class _SuperTabViewState extends State<SuperTabView>
notificationsSelected: _notificationsVisible,
attention: SuperTabAttention.of(c),
activity: SuperTabActivity.of(c),
- threadsSelected: _threadsVisible,
- onThreads: () {
- _closeSidebar();
- setState(() {
- _showThreads = true;
- _showNotifications = false;
- _showPullRequests = false;
- });
- widget.onCloseTerminal?.call();
- },
// Activity on every platform (Lead, 10-31): the Mac's menu bar and Dock
// still say what waits, and the sidebar lists it as Slack does.
onNotifications: _openActivity,
@@ -1612,7 +1598,7 @@ class _SuperTabViewState extends State<SuperTabView>
_closeSidebar();
setState(() {
_showPullRequests = false;
- _showNotifications = _showThreads = false;
+ _showNotifications = false;
});
(widget.onChooseAgentTerminal ?? widget.onOpenTerminal)(agent);
},
@@ -1620,12 +1606,12 @@ class _SuperTabViewState extends State<SuperTabView>
? null
: () {
_closeSidebar();
- setState(() => _showNotifications = _showThreads = false);
+ setState(() => _showNotifications = false);
widget.app!.openDevices();
},
needsHuman: (group) => _needsHuman(group).length,
onSelect: (id) {
- setState(() => _showNotifications = _showThreads = false);
+ setState(() => _showNotifications = false);
c.select(id);
_closeSidebar();
},
@@ -1638,7 +1624,7 @@ class _SuperTabViewState extends State<SuperTabView>
/// ([SuperTabController.buddyChatOpener]).
Future<bool> _openBuddyChat(String projectId) {
setState(() {
- _showNotifications = _showThreads = false;
+ _showNotifications = false;
_showPullRequests = false;
});
widget.onCloseTerminal?.call();
@@ -1655,7 +1641,6 @@ class _SuperTabViewState extends State<SuperTabView>
widget.onCloseTerminal?.call();
setState(() {
_showNotifications = true;
- _showThreads = false;
_showPullRequests = false;
});
if (request.kind != 'mention') return;
@@ -1665,21 +1650,14 @@ class _SuperTabViewState extends State<SuperTabView>
if (mention != null) unawaited(_openMention(mention));
}
- /// Shows Activity in the main pane, as its sidebar row does; with [filter],
- /// on that list. [from] is the controller the
- /// asking widget was built for: a press arriving once the view has moved to
- /// another Swarm opens nothing.
- void _openActivity({
- SuperTabActivityFilter? filter,
- SuperTabController? from,
- }) {
+ /// Shows Activity in the main pane, as its sidebar row does. [from] is the
+ /// controller the asking widget was built for: a press arriving once the
+ /// view has moved to another Swarm opens nothing.
+ void _openActivity({SuperTabController? from}) {
if (!mounted || (from != null && from != c)) return;
- // Its row asks for no list: All, whichever one was showing.
- SuperTabActivity.of(c).setFilter(filter ?? SuperTabActivityFilter.all);
_closeSidebar();
setState(() {
_showNotifications = true;
- _showThreads = false;
_showPullRequests = false;
});
widget.onCloseTerminal?.call();
@@ -1688,28 +1666,28 @@ class _SuperTabViewState extends State<SuperTabView>
bool get _notificationsVisible =>
_showNotifications && !_devicesVisible && !c.accessRevoked;
- /// Notifications or Threads holds the main pane, with no chat header.
- bool get _listViewHoldsThePane => _notificationsVisible || _threadsVisible;
+ /// Activity holds the main pane, with no chat header.
+ bool get _listViewHoldsThePane => _notificationsVisible;
- bool get _threadsVisible =>
- _showThreads &&
- !_showNotifications &&
- !_devicesVisible &&
- !c.accessRevoked;
-
- /// Opens [root]'s thread in its chat from the Threads view.
+ /// Opens [root]'s thread in its chat from Activity's New replies.
void _openThreadFromList(String conversationId, String root) {
+ if (_openConversation(conversationId)) c.openThread(root);
+ }
+
+ /// Opens chat [conversationId] from a row of Activity; false when it is
+ /// gone or the reader's access is.
+ bool _openConversation(String conversationId) {
if (c.accessRevoked || c.snapshot?.conversation(conversationId) == null) {
- return;
+ return false;
}
widget.onCloseTerminal?.call();
_closeSidebar();
setState(() {
- _showThreads = _showNotifications = false;
+ _showNotifications = false;
_showPullRequests = false;
});
c.select(conversationId);
- c.openThread(root);
+ return true;
}
/// [messageId] of [id], read from the pages held, then what arrived after
@@ -1783,7 +1761,7 @@ class _SuperTabViewState extends State<SuperTabView>
}
final shownBy = _rowShowing(id, messageId) ?? messageId;
setState(() {
- _showNotifications = _showThreads = false;
+ _showNotifications = false;
_showPullRequests = false;
_back = null;
_target = shownBy;
@@ -2211,8 +2189,6 @@ class _SuperTabViewState extends State<SuperTabView>
? 'Your devices'
: _notificationsVisible
? 'Activity'
- : _threadsVisible
- ? 'Threads'
: group == null
? c.snapshot?.projects.isEmpty == true
? c.snapshot!.name
@@ -2232,8 +2208,7 @@ class _SuperTabViewState extends State<SuperTabView>
if (group != null &&
c.snapshot!.isProjectLead(group.id) &&
!_devicesVisible &&
- !_notificationsVisible &&
- !_threadsVisible) {
+ !_notificationsVisible) {
return _projectMenu(group, name, style);
}
return Text(
@@ -4346,8 +4321,6 @@ class _SuperTabViewState extends State<SuperTabView>
? 1
: _notificationsVisible
? 3
- : _threadsVisible
- ? 4
: c.snapshot?.projects.isEmpty == true
? 0
: _terminalsVisible
@@ -4370,15 +4343,8 @@ class _SuperTabViewState extends State<SuperTabView>
activity: SuperTabActivity.of(c),
onOpenMention: (mention) =>
unawaited(_openMention(mention)),
- onOpenMessage: (id, messageId) =>
- unawaited(_openMessage(id, messageId)),
- )
- : const SizedBox.shrink(),
- _threadsVisible
- ? SuperTabThreadsView(
- attention: SuperTabAttention.of(c),
- onOpen: _openThreadFromList,
- machineName: widget.machineName,
+ onOpenThread: _openThreadFromList,
+ onOpenConversation: _openConversation,
)
: const SizedBox.shrink(),
],
diff --git a/desktop/test/super_tab_activity_lists_test.dart b/desktop/test/super_tab_activity_lists_test.dart
new file mode 100644
index 000000000..535f0fedc
--- /dev/null
+++ b/desktop/test/super_tab_activity_lists_test.dart
@@ -0,0 +1,445 @@
+import 'package:clock/clock.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/super_tabs/activity.dart';
+
+import 'support/super_tab_fixture.dart';
+
+/// One project, "web-project", whose chat is `lead`; `offline` is a workgroup
+/// of it that Kestrel works in.
+ConversationServer swarm() {
+ final server = ConversationServer()..threads = true;
+ server.state['projects'] = [projectFixture('lead', 'web-project', 'lead')];
+ server.state['agents'] = [
+ {
+ 'id': 'kestrel',
+ 'projectId': 'lead',
+ 'name': 'Builder',
+ 'displayName': 'Kestrel',
+ 'machineId': 'host',
+ 'harnessId': 'session',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ final offline = _group(server, 'offline');
+ offline
+ ..['projectId'] = 'lead'
+ ..['title'] = 'Windows credential fix'
+ ..['agentIds'] = ['kestrel'];
+ return server;
+}
+
+Map<String, dynamic> _group(ConversationServer server, String id) =>
+ (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == id);
+
+/// The task in `offline` waiting on its requester, the default reader.
+void wait(ConversationServer server, {String requester = 'owner'}) {
+ _group(server, 'offline')['requesterId'] = requester;
+ _group(server, 'offline')['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'needs_human',
+ };
+}
+
+/// The task in `offline` finished at [at], local time.
+void finish(ConversationServer server, DateTime at, {String? title}) {
+ _group(server, 'offline')
+ ..['title'] = title ?? 'Windows credential fix'
+ ..['assignment'] = {'id': 'a1', 'agentId': 'kestrel', 'status': 'done'}
+ ..['shippedAt'] = at.millisecondsSinceEpoch;
+}
+
+Map<String, dynamic> unreadThread(String root, {String text = 'Root text'}) => {
+ 'conversationId': 'offline',
+ 'rootId': root,
+ 'root': {
+ 'id': root,
+ 'sequence': 1,
+ 'author': {'kind': 'agent', 'id': 'lead-agent', 'name': 'Lead'},
+ 'text': text,
+ 'createdAt': '2026-10-31T01:00:00Z',
+ 'attachments': 0,
+ },
+ 'lastReplyAt': '2026-10-31T02:00:00Z',
+ 'lastReplySequence': 2,
+ 'lastReplier': {'kind': 'agent', 'id': 'lead-agent', 'name': 'Lead'},
+ 'unreadReplies': 3,
+ 'follow': null,
+};
+
+Future<SuperTabActivity> load(
+ ConversationServer server, {
+ String account = 'owner',
+}) async {
+ final c = server.controller(account: account);
+ addTearDown(() async {
+ await c.flush();
+ c.dispose();
+ });
+ await c.refresh();
+ final activity = SuperTabActivity.of(c);
+ await activity.mentions.load();
+ await activity.decisions.load();
+ await activity.attention.load();
+ return activity;
+}
+
+final _evening = DateTime(2026, 11, 2, 20, 30);
+
+void main() {
+ group('Needs you', () {
+ test('lists the decisions asked of the reader, the agents waiting on them '
+ 'and their tags, in that order, and counts each', () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Ship it?']);
+ wait(server);
+ server.tag('message-1');
+ final activity = await load(server);
+ expect(
+ [for (final n in activity.needsYou) n.kind],
+ [
+ SuperTabNeedKind.decision,
+ SuperTabNeedKind.agent,
+ SuperTabNeedKind.mention,
+ ],
+ );
+ expect(
+ [for (final n in activity.needsYou) n.title],
+ [
+ 'Ship it?',
+ 'Kestrel is waiting on you',
+ 'Wren mentioned you in # web-project',
+ ],
+ );
+ expect(activity.count, 3);
+ });
+
+ test(
+ 'an agent whose question is already a decision is listed once',
+ () async {
+ final server = swarm();
+ server.ask(['Ship it?'], conversationId: 'offline');
+ wait(server);
+ final activity = await load(server);
+ expect(
+ [for (final n in activity.needsYou) n.kind],
+ [SuperTabNeedKind.decision],
+ );
+ },
+ );
+
+ test(
+ 'a task asked of someone else, or not waiting, is not listed',
+ () async {
+ final server = swarm();
+ _group(server, 'offline')['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'needs_human',
+ 'askedOf': 'someone-else',
+ };
+ final asked = await load(server);
+ expect(asked.needsYou, isEmpty);
+ _group(server, 'offline')['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'working',
+ };
+ final working = await load(server);
+ expect(working.needsYou, isEmpty);
+ },
+ );
+ });
+
+ group('what is for this reader', () {
+ ConversationServer twoPeople() {
+ final server = swarm()..followedThreads = null;
+ (server.state['people'] as List).add({
+ 'id': 'peer',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ return server;
+ }
+
+ test('a task waiting on nobody named is for its requester alone', () async {
+ final server = twoPeople();
+ wait(server, requester: 'peer');
+ final other = await load(server);
+ expect(other.needsYou, isEmpty);
+ expect(other.count, 0);
+ expect(other.unread, isFalse);
+ final requester = await load(server, account: 'peer');
+ expect(
+ [for (final n in requester.needsYou) n.kind],
+ [SuperTabNeedKind.agent],
+ );
+ expect(requester.count, 1);
+ });
+
+ test('a task asked of one person is for that person alone', () async {
+ final server = twoPeople();
+ wait(server, requester: 'owner');
+ _group(server, 'offline')['assignment']['askedOf'] = 'peer';
+ expect((await load(server)).count, 0);
+ expect((await load(server, account: 'peer')).count, 1);
+ });
+
+ test(
+ 'a tag in a thread the reader does not follow is still Needs you',
+ () async {
+ final server = swarm();
+ server.tag('message-2', threadId: 'message-1', messageSequence: 2);
+ server.followedThreads = {'unread': [], 'read': [], 'more': false};
+ final activity = await load(server);
+ expect(
+ [for (final n in activity.needsYou) n.kind],
+ [SuperTabNeedKind.mention],
+ );
+ expect(activity.count, 1);
+ expect(activity.newReplies, isEmpty);
+ },
+ );
+ });
+
+ group('the number', () {
+ test('counts only Needs you: new replies, done work and replies to the '
+ 'reader add nothing', () async {
+ final server = swarm();
+ server.tag('message-1');
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1')],
+ 'read': [],
+ 'more': false,
+ };
+ finish(server, DateTime(2026, 11, 2, 8));
+ server.state['activityDigest'] = 'd1';
+ server.activity = {
+ 'items': [
+ {
+ 'id': 'r1',
+ 'kind': 'reply',
+ 'conversationId': 'lead',
+ 'conversationTitle': 'Lead',
+ 'projectName': 'web-project',
+ 'messageId': 'm-r1',
+ 'messageSequence': 4,
+ 'threadId': 'root',
+ 'actor': {'kind': 'person', 'id': 'peer', 'name': 'peer'},
+ 'emoji': null,
+ 'text': 'Reply',
+ 'createdAt': '2026-10-31T03:00:00.000Z',
+ 'read': false,
+ },
+ ],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_evening), () async {
+ final activity = await load(server);
+ expect(activity.count, 1);
+ expect(activity.newReplies, hasLength(1));
+ expect(activity.doneToday, hasLength(1));
+ });
+ });
+
+ test('is bold for new replies alone, and not for done work', () async {
+ final server = swarm();
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1')],
+ 'read': [],
+ 'more': false,
+ };
+ final replies = await load(server);
+ expect(replies.count, 0);
+ expect(replies.unread, isTrue);
+
+ final done = swarm()..followedThreads = null;
+ finish(done, DateTime(2026, 11, 2, 8));
+ await withClock(Clock.fixed(_evening), () async {
+ final activity = await load(done);
+ expect(activity.unread, isFalse);
+ });
+ });
+ });
+
+ group('the number clears by reading (Dee: every number)', () {
+ Future<void> reload(
+ SuperTabActivity activity,
+ ConversationServer server,
+ ) async {
+ server.revision++;
+ await activity.controller.refresh();
+ await activity.mentions.load();
+ await activity.decisions.load();
+ }
+
+ test(
+ 'a tag counts until its chat is read past it, then it leaves Needs you',
+ () async {
+ final server = swarm()..followedThreads = null;
+ server.tag('message-1', messageSequence: 5);
+ server.state['readMarks'] = {
+ 'owner': {'lead': 4},
+ };
+ final activity = await load(server);
+ expect(activity.count, 1);
+ expect(
+ [for (final n in activity.needsYou) n.kind],
+ [SuperTabNeedKind.mention],
+ );
+ server.state['readMarks'] = {
+ 'owner': {'lead': 5},
+ };
+ await reload(activity, server);
+ expect(activity.count, 0);
+ expect(activity.needsYou, isEmpty);
+ },
+ );
+
+ test('a decision counts until it is answered', () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Ship it?']);
+ final activity = await load(server);
+ expect(activity.count, 1);
+ server.answerDecision('decision-1', 0);
+ server.state['decisionsWaiting'] = 0;
+ await reload(activity, server);
+ expect(activity.count, 0);
+ expect(activity.needsYou, isEmpty);
+ });
+
+ test('an agent waiting counts until it is answered', () async {
+ final server = swarm()..followedThreads = null;
+ wait(server);
+ final activity = await load(server);
+ expect(activity.count, 1);
+ _group(server, 'offline')['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'working',
+ };
+ await reload(activity, server);
+ expect(activity.count, 0);
+ expect(activity.needsYou, isEmpty);
+ });
+
+ test(
+ 'a tag in a thread-only reply is a new reply, not Needs you',
+ () async {
+ final server = swarm();
+ server.tag(
+ 'message-2',
+ conversationId: 'offline',
+ threadId: 'message-1',
+ messageSequence: 2,
+ );
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1')],
+ 'read': [],
+ 'more': false,
+ };
+ final activity = await load(server);
+ expect(activity.needsYou, isEmpty);
+ expect(activity.count, 0);
+ expect(activity.newReplies.map((t) => t.rootId), ['message-1']);
+ },
+ );
+ });
+
+ group('New replies', () {
+ test(
+ 'are the followed threads with replies the reader has not read',
+ () async {
+ final server = swarm();
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1', text: 'Fix the credential')],
+ 'read': [],
+ 'more': false,
+ };
+ final activity = await load(server);
+ expect(
+ [for (final t in activity.newReplies) (t.rootText, t.unreadReplies)],
+ [('Fix the credential', 3)],
+ );
+ },
+ );
+ });
+
+ group('Done today', () {
+ test(
+ 'lists what shipped today, newest first, not yesterday, not a step',
+ () async {
+ final server = swarm()..followedThreads = null;
+ finish(server, DateTime(2026, 11, 2, 8, 8));
+ (server.state['conversations'] as List).addAll(<Map<String, dynamic>>[
+ {
+ ...conversationFixture('later', 'Commits read Harness'),
+ 'projectId': 'lead',
+ 'assignment': {'id': 'a2', 'agentId': 'kestrel', 'status': 'done'},
+ 'shippedAt': DateTime(2026, 11, 2, 8, 28).millisecondsSinceEpoch,
+ },
+ {
+ ...conversationFixture('yesterday', 'Shipped yesterday'),
+ 'projectId': 'lead',
+ 'assignment': {'id': 'a3', 'agentId': 'kestrel', 'status': 'done'},
+ 'shippedAt': DateTime(2026, 11, 1, 23, 50).millisecondsSinceEpoch,
+ },
+ {
+ ...conversationFixture('review', 'Review: Windows credential fix'),
+ 'projectId': 'lead',
+ 'reviewOf': 'offline',
+ 'assignment': {'id': 'a4', 'agentId': 'kestrel', 'status': 'done'},
+ 'shippedAt': DateTime(2026, 11, 2, 9).millisecondsSinceEpoch,
+ },
+ ]);
+ await withClock(Clock.fixed(_evening), () async {
+ final activity = await load(server);
+ expect(
+ [for (final g in activity.doneToday) g.title],
+ ['Commits read Harness', 'Windows credential fix'],
+ );
+ });
+ },
+ );
+
+ test(
+ 'is empty from a server that does not say when work shipped',
+ () async {
+ final server = swarm()..followedThreads = null;
+ _group(server, 'offline')['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'done',
+ };
+ await withClock(Clock.fixed(_evening), () async {
+ expect((await load(server)).doneToday, isEmpty);
+ });
+ },
+ );
+ });
+
+ group('leaving', () {
+ test(
+ 'marks nothing read: the visit showed no reply or reaction row',
+ () async {
+ final server = swarm();
+ server.state['activityDigest'] = 'd1';
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1')],
+ 'read': [],
+ 'more': false,
+ };
+ final activity = await load(server);
+ activity.opened();
+ await pumpEventQueue();
+ activity.closed();
+ await pumpEventQueue();
+ expect(server.activityReadPosts, isEmpty);
+ expect(server.activityReads, isEmpty);
+ },
+ );
+ });
+}
diff --git a/desktop/test/super_tab_activity_test.dart b/desktop/test/super_tab_activity_test.dart
index 216f2d805..42c5589b6 100644
--- a/desktop/test/super_tab_activity_test.dart
+++ b/desktop/test/super_tab_activity_test.dart
@@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/super_tabs/activity.dart';
-import 'package:harness/super_tabs/activity_view.dart';
import 'package:harness/super_tabs/attention.dart';
import 'package:harness/super_tabs/buddy_rows.dart';
import 'package:harness/super_tabs/controller.dart';
@@ -17,46 +16,10 @@ import 'package:harness/super_tabs/workgroup_name.dart';
import 'package:harness/widgets/desktop_chrome.dart';
import 'super_tab_attention_test.dart'
- show
- close,
- conversation,
- fromLead,
- inRow,
- openHere,
- projectServer,
- rowText,
- unreadThread;
+ show close, fromLead, inRow, openHere, projectServer, unreadThread;
import 'support/buddy_fixture.dart';
import 'support/super_tab_fixture.dart';
-Map<String, dynamic> reply(
- String id, {
- String conversationId = 'lead',
- bool read = false,
- String createdAt = '2026-10-31T03:00:00.000Z',
-}) => {
- 'id': id,
- 'kind': 'reply',
- 'conversationId': conversationId,
- 'conversationTitle': 'Chat $conversationId',
- 'projectName': 'web-project',
- 'messageId': 'm-$id',
- 'messageSequence': 4,
- 'threadId': 'root',
- 'actor': {'kind': 'person', 'id': 'peer', 'name': 'peer'},
- 'emoji': null,
- 'text': 'Reply $id',
- 'createdAt': createdAt,
- 'read': read,
-};
-
-Map<String, dynamic> reaction(String id, {bool read = false}) => {
- ...reply(id, read: read),
- 'kind': 'reaction',
- 'emoji': 'check',
- 'text': 'My message',
-};
-
Future<SuperTabController> open(ConversationServer server) async {
final c = server.controller();
addTearDown(() async {
@@ -398,160 +361,6 @@ void main() {
});
});
- group('Activity: replies and reactions to the reader', () {
- test('reads when its digest moves, not again for the same digest, and '
- 'keeps only chats this Swarm lists', () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {
- 'items': [reply('r1'), reply('r2', conversationId: 'other-swarm-chat')],
- 'more': false,
- };
- final c = await open(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- expect(server.activityReads, hasLength(1));
- expect(activity.items.map((i) => i.id), ['r1']);
- expect(activity.count, 1);
- await c.refresh();
- await settle();
- expect(server.activityReads, hasLength(1));
- server.state['activityDigest'] = 'd2';
- server.revision++;
- await c.refresh();
- await settle();
- expect(server.activityReads, hasLength(2));
- });
-
- test('a server before Activity (404) asks once; tags and decisions still '
- 'count', () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.state['mentionsWaiting'] = 2;
- server.activity = null;
- final c = await open(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- expect(activity.supported, isFalse);
- expect(activity.count, 2);
- server.state['activityDigest'] = 'd2';
- server.revision++;
- await c.refresh();
- await settle();
- expect(server.activityReads, hasLength(1));
- });
-
- test(
- 'a failed first read says so, and a later digest recovers it',
- () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activityStatus = 503;
- server.activity = {
- 'items': [reply('r1')],
- 'more': false,
- };
- final c = await open(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- expect(activity.error, isNotNull);
- expect(activity.items, isEmpty);
- server.activityStatus = 0;
- // The next change of the Swarm reads it again, though its digest
- // did not move.
- fromLead(server, 'Something else changed');
- await c.refresh();
- await settle();
- expect(activity.error, isNull);
- expect(activity.items.map((i) => i.id), ['r1']);
- },
- );
-
- test(
- 'access lost: rows go at once and an answer on its way is dropped',
- () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {
- 'items': [reply('r1')],
- 'more': false,
- };
- final c = await open(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- expect(activity.items, hasLength(1));
- server.holdActivity = Completer();
- unawaited(activity.load());
- await pumpEventQueue();
- c.revokeAccess('Removed from this Swarm.');
- expect(activity.items, isEmpty);
- expect(activity.count, 0);
- server.holdActivity!.complete();
- await settle();
- expect(activity.items, isEmpty);
- },
- );
-
- test(
- 'a read that answers after the Swarm\'s audience moved is dropped',
- () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {
- 'items': [reply('r1')],
- 'more': false,
- };
- final c = await open(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- server.holdActivity = Completer();
- unawaited(activity.load());
- await pumpEventQueue();
- server.parts.epoch++;
- server.revision++;
- server.activity = {'items': <dynamic>[], 'more': false};
- await c.refresh();
- // Every state shown from here: the old answer must never show.
- final shown = <List<String>>[];
- activity.addListener(
- () => shown.add([for (final i in activity.items) i.id]),
- );
- server.holdActivity!.complete();
- await settle();
- expect(activity.items, isEmpty);
- expect(shown.where((ids) => ids.contains('r1')), isEmpty);
- },
- );
-
- test(
- 'leaving the view marks what it showed read, bold until then',
- () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {
- 'items': [reply('r1'), reaction('x1', read: true)],
- 'more': false,
- };
- final c = await open(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- activity.opened();
- await settle();
- final r1 = activity.items.firstWhere((i) => i.id == 'r1');
- expect(activity.isUnread(r1), isTrue);
- expect(activity.unread, isTrue);
- activity.closed();
- await settle();
- expect(
- server.activityReadPosts.single['through'],
- '2026-10-31T03:00:00.000Z',
- );
- expect(activity.items.every((i) => i.read), isTrue);
- expect(activity.count, 0);
- },
- );
- });
-
group('All new messages tells the system about each new message', () {
test('only for a chat set to all, not on the first look, not the open '
'chat', () async {
@@ -561,13 +370,16 @@ void main() {
SuperTabChatNotices.of(c).onMessage = (g, s) => told.add((g.id, s));
fromLead(server, 'Before', conversationId: 'offline');
await c.refresh();
+ await settle();
expect(told, isEmpty);
await c.setNotify('offline', SuperTabNotify.all);
fromLead(server, 'After', conversationId: 'offline');
await c.refresh();
+ await settle();
expect(told.map((t) => t.$1), ['offline']);
fromLead(server, 'In the project chat');
await c.refresh();
+ await settle();
expect(told.map((t) => t.$1), ['offline']);
});
@@ -588,6 +400,7 @@ void main() {
c.away = true;
fromLead(server, 'While on another Swarm');
await c.refresh();
+ await settle();
expect(told, hasLength(1));
});
@@ -600,6 +413,111 @@ void main() {
binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
fromLead(server, 'While in another app');
await c.refresh();
+ await settle();
+ expect(told, hasLength(1));
+ });
+
+ // Task #2224: what a person sent from their phone, the web or another Mac tells them nothing.
+ Future<(SuperTabController, ConversationServer, List<int>)>
+ chatSetToAll() async {
+ final server = projectServer();
+ final c = await open(server);
+ final told = <int>[];
+ SuperTabChatNotices.of(c).onMessage = (_, s) => told.add(s);
+ await c.setNotify('offline', SuperTabNotify.all);
+ return (c, server, told);
+ }
+
+ test('their own message from another device tells them nothing', () async {
+ final (c, server, told) = await chatSetToAll();
+ server.append('From my phone', conversationId: 'offline');
+ await c.refresh();
+ await settle();
+ expect(told, isEmpty);
+ });
+
+ test(
+ 'a message whose author can\'t be read is told about, never lost',
+ () async {
+ final server = projectServer();
+ final c = SuperTabController(
+ tabId: 'tab',
+ accountId: 'owner',
+ save: server.save,
+ request: (method, path, {body}) async {
+ if (path.contains('offline/messages?after=')) {
+ throw StateError('Offline');
+ }
+ return server.request(method, path, body: body);
+ },
+ );
+ addTearDown(c.dispose);
+ await c.refresh();
+ final told = <int>[];
+ SuperTabChatNotices.of(c).onMessage = (_, s) => told.add(s);
+ await c.setNotify('offline', SuperTabNotify.all);
+ fromLead(server, 'From the Lead', conversationId: 'offline');
+ await c.refresh();
+ await settle();
+ expect(told, hasLength(1));
+ },
+ );
+
+ // Review of #2646: a chat's top is its main stream, and agents answer in threads.
+ test(
+ 'a teammate\'s thread reply before their own message tells nothing',
+ () async {
+ final (c, server, told) = await chatSetToAll();
+ fromLead(server, 'In a thread', conversationId: 'offline');
+ server.messages.last['thread'] = 'a-root';
+ server.append('From my phone', conversationId: 'offline');
+ await c.refresh();
+ await settle();
+ expect(told, isEmpty);
+ },
+ );
+
+ test('a page with more behind it is unsure, so it tells', () async {
+ final server = projectServer();
+ final c = SuperTabController(
+ tabId: 'tab',
+ accountId: 'owner',
+ save: server.save,
+ request: (method, path, {body}) async {
+ final answer = await server.request(method, path, body: body);
+ return path.contains('offline/messages?after=')
+ ? {
+ ...answer,
+ 'next': {'sequence': 1, 'id': 'more'},
+ }
+ : answer;
+ },
+ );
+ addTearDown(c.dispose);
+ await c.refresh();
+ final told = <int>[];
+ SuperTabChatNotices.of(c).onMessage = (_, s) => told.add(s);
+ await c.setNotify('offline', SuperTabNotify.all);
+ server.append('From my phone', conversationId: 'offline');
+ await c.refresh();
+ await settle();
+ expect(told, hasLength(1));
+ });
+
+ test('a teammate\'s message still does', () async {
+ final (c, server, told) = await chatSetToAll();
+ fromLead(server, 'From the Lead', conversationId: 'offline');
+ await c.refresh();
+ await settle();
+ expect(told, hasLength(1));
+ });
+
+ test('a teammate\'s message among their own still does', () async {
+ final (c, server, told) = await chatSetToAll();
+ fromLead(server, 'From the Lead', conversationId: 'offline');
+ server.append('From my phone', conversationId: 'offline');
+ await c.refresh();
+ await settle();
expect(told, hasLength(1));
});
@@ -680,245 +598,6 @@ void main() {
});
});
- group('Activity view', () {
- testWidgets('lists tags, replies and reactions newest first, filters one '
- 'kind, and opens a row at its message', (tester) async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {
- 'items': [
- reply('r1', createdAt: '2026-10-31T05:00:00.000Z'),
- reaction('x1', read: true),
- ],
- 'more': false,
- };
- final c = await openHere(server);
- final activity = SuperTabActivity.of(c);
- await tester.runAsync(settle);
- final opened = <(String, String)>[];
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabActivityView(
- activity: activity,
- onOpenMention: (_) {},
- onOpenMessage: (id, m) => opened.add((id, m)),
- now: () => DateTime.utc(2026, 10, 31, 6),
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- expect(find.text('peer replied to your message'), findsOneWidget);
- expect(find.text('peer reacted ✅ to your message'), findsOneWidget);
- await tester.tap(
- find.byKey(const ValueKey('super-activity-filter-reactions')),
- );
- await tester.pumpAndSettle();
- expect(find.text('peer replied to your message'), findsNothing);
- await tester.tap(
- find.byKey(const ValueKey('super-activity-filter-replies')),
- );
- await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-activity-r1')));
- expect(opened, [('lead', 'm-r1')]);
- await close(tester, c);
- expect(server.activityReadPosts, isNotEmpty);
- });
- });
-
- group('leaving Activity marks read only what the visit showed (Diego)', () {
- Future<void> visit(
- WidgetTester tester,
- SuperTabActivity activity, {
- List<SuperTabActivityFilter> filters = const [],
- Future<void> Function()? during,
- }) async {
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabActivityView(
- activity: activity,
- onOpenMention: (_) {},
- onOpenMessage: (_, _) {},
- now: () => DateTime.utc(2026, 10, 31, 6),
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- for (final filter in filters) {
- await tester.tap(
- find.byKey(ValueKey('super-activity-filter-${filter.name}')),
- );
- await tester.pumpAndSettle();
- }
- await during?.call();
- await tester.pumpWidget(const SizedBox());
- await tester.runAsync(settle);
- }
-
- Future<(ConversationServer, SuperTabController, SuperTabActivity)> unread(
- WidgetTester tester,
- List<Map<String, dynamic>> items,
- ) async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {'items': items, 'more': false};
- final c = await openHere(server);
- final activity = SuperTabActivity.of(c);
- await tester.runAsync(settle);
- return (server, c, activity);
- }
-
- Map<String, dynamic> at(Map<String, dynamic> item, String time) => {
- ...item,
- 'createdAt': '2026-10-31T$time:00.000Z',
- };
-
- testWidgets('a Decisions-only visit leaves replies unread', (tester) async {
- final (server, c, activity) = await unread(tester, [reply('r1')]);
- final count = activity.count;
- await visit(
- tester,
- activity,
- filters: [SuperTabActivityFilter.decisions],
- );
- expect(server.activityReadPosts, isEmpty);
- expect(activity.items.single.read, isFalse);
- expect(activity.count, count);
- await close(tester, c);
- });
-
- testWidgets('a Mentions-only visit leaves reactions unread', (
- tester,
- ) async {
- final (server, c, activity) = await unread(tester, [reaction('x1')]);
- await visit(tester, activity, filters: [SuperTabActivityFilter.mentions]);
- expect(server.activityReadPosts, isEmpty);
- expect(activity.items.single.read, isFalse);
- await close(tester, c);
- });
-
- testWidgets('a visit on All marks both kinds through the newest', (
- tester,
- ) async {
- final (server, c, activity) = await unread(tester, [
- at(reply('r1'), '05:00'),
- at(reaction('x1'), '04:00'),
- ]);
- await visit(tester, activity);
- expect(server.activityReadPosts, hasLength(1));
- expect(
- server.activityReadPosts.single['through'],
- '2026-10-31T05:00:00.000Z',
- );
- expect(activity.items.every((i) => i.read), isTrue);
- await close(tester, c);
- });
-
- testWidgets(
- 'only the list showing when it is left counts: Replies, then Reactions',
- (tester) async {
- final (server, c, activity) = await unread(tester, [
- at(reaction('x1'), '05:00'),
- at(reply('r1'), '06:00'),
- ]);
- await visit(
- tester,
- activity,
- filters: [
- SuperTabActivityFilter.replies,
- SuperTabActivityFilter.reactions,
- ],
- );
- expect(
- server.activityReadPosts.single['through'],
- '2026-10-31T05:00:00.000Z',
- );
- expect(
- {for (final i in activity.items) i.id: i.read},
- {'x1': true, 'r1': false},
- );
- await close(tester, c);
- },
- );
-
- testWidgets(
- 'a Replies visit stops before an unread reaction it did not show: '
- 'the mark is by time',
- (tester) async {
- final (server, c, activity) = await unread(tester, [
- at(reply('new'), '06:00'),
- at(reaction('x1'), '05:00'),
- at(reply('old'), '04:00'),
- ]);
- activity.setFilter(SuperTabActivityFilter.replies);
- await visit(tester, activity);
- expect(
- server.activityReadPosts.single['through'],
- '2026-10-31T04:00:00.000Z',
- );
- final read = {for (final i in activity.items) i.id: i.read};
- expect(read, {'new': false, 'x1': false, 'old': true});
- await close(tester, c);
- },
- );
-
- testWidgets(
- 'an unread reaction at the same moment as a shown reply stops it too',
- (tester) async {
- final (server, c, activity) = await unread(tester, [
- at(reply('r1'), '05:00'),
- at(reaction('x1'), '05:00'),
- ]);
- activity.setFilter(SuperTabActivityFilter.replies);
- await visit(tester, activity);
- expect(server.activityReadPosts, isEmpty);
- await close(tester, c);
- },
- );
-
- testWidgets(
- 'a row that arrives while Replies shows is listed, and is read on leaving',
- (tester) async {
- final (server, c, activity) = await unread(tester, [
- at(reply('r1'), '05:00'),
- ]);
- await visit(
- tester,
- activity,
- filters: [SuperTabActivityFilter.replies],
- during: () async {
- server.activity = {
- 'items': [at(reply('r2'), '06:00'), at(reply('r1'), '05:00')],
- 'more': false,
- };
- await tester.runAsync(() => activity.load());
- },
- );
- expect(
- server.activityReadPosts.single['through'],
- '2026-10-31T06:00:00.000Z',
- );
- await close(tester, c);
- },
- );
-
- testWidgets(
- 'leaving puts the filter back on All; a filter asked for still opens on it',
- (tester) async {
- final (_, c, activity) = await unread(tester, [reply('r1')]);
- activity.setFilter(SuperTabActivityFilter.decisions);
- await visit(tester, activity);
- expect(activity.filter, SuperTabActivityFilter.all);
- await close(tester, c);
- },
- );
- });
-
group('the one # buddy row (#2447) follows the same rules', () {
Future<SuperTabController> show(
WidgetTester tester,
diff --git a/desktop/test/super_tab_activity_view_test.dart b/desktop/test/super_tab_activity_view_test.dart
new file mode 100644
index 000000000..2052c2d9a
--- /dev/null
+++ b/desktop/test/super_tab_activity_view_test.dart
@@ -0,0 +1,309 @@
+import 'package:clock/clock.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/super_tabs/activity.dart';
+import 'package:harness/super_tabs/activity_view.dart';
+
+import 'super_tab_activity_lists_test.dart'
+ show finish, load, swarm, unreadThread;
+import 'support/super_tab_fixture.dart';
+
+final _now = DateTime(2026, 11, 2, 20, 30);
+
+Future<SuperTabActivity> loaded(
+ WidgetTester tester,
+ ConversationServer server,
+) async => (await tester.runAsync(() => load(server)))!;
+
+class _Opened {
+ final mentions = <String>[];
+ final threads = <(String, String)>[];
+ final conversations = <String>[];
+}
+
+Future<_Opened> show(
+ WidgetTester tester,
+ SuperTabActivity activity, {
+ double width = 900,
+ Brightness brightness = Brightness.dark,
+}) async {
+ await tester.binding.setSurfaceSize(Size(width, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final opened = _Opened();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: brightness),
+ home: Scaffold(
+ body: SuperTabActivityView(
+ activity: activity,
+ onOpenMention: (m) => opened.mentions.add(m.id),
+ onOpenThread: (conversation, root) =>
+ opened.threads.add((conversation, root)),
+ onOpenConversation: opened.conversations.add,
+ now: () => _now,
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return opened;
+}
+
+/// Everything the Activity screen draws: a decision, an agent waiting, a tag,
+/// a thread with new replies and two tasks done today.
+ConversationServer full() {
+ final server = swarm();
+ server.ask(['W1 ships alone or waits?']);
+ server.state['agents'] = [
+ ...(server.state['agents'] as List),
+ {
+ 'id': 'nico',
+ 'projectId': 'lead',
+ 'name': 'Builder',
+ 'displayName': 'Nico',
+ 'machineId': 'host',
+ 'harnessId': 'nico',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ (server.state['conversations'] as List).add(<String, dynamic>{
+ ...conversationFixture('waiting', 'Mac fix'),
+ 'projectId': 'lead',
+ 'agentIds': ['nico'],
+ 'assignment': {'id': 'a9', 'agentId': 'nico', 'status': 'needs_human'},
+ });
+ server.tag('message-1', createdAt: '2026-11-02T13:09:00Z');
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1', text: 'Windows credential fix')],
+ 'read': [],
+ 'more': false,
+ };
+ finish(
+ server,
+ DateTime(2026, 11, 2, 8, 8),
+ title: 'Closed agents leave the list',
+ );
+ return server;
+}
+
+void main() {
+ testWidgets('has the three sections in order, and no filter', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await loaded(tester, full());
+ await show(tester, activity);
+ double top(String text) => tester.getTopLeft(find.text(text)).dy;
+ expect(top('Needs you'), lessThan(top('New replies')));
+ expect(top('New replies'), lessThan(top('Done today')));
+ for (final filter in [
+ 'All',
+ 'Decisions',
+ 'Mentions',
+ 'Replies',
+ 'Reactions',
+ ]) {
+ expect(find.text(filter), findsNothing, reason: filter);
+ }
+ expect(find.text("You're all caught up."), findsNothing);
+ });
+ });
+
+ testWidgets('draws each row as one line with its word or time', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await loaded(tester, full());
+ await show(tester, activity);
+ expect(find.text('W1 ships alone or waits?'), findsOneWidget);
+ expect(find.text('Answer'), findsOneWidget);
+ expect(find.text('Nico is waiting on you'), findsOneWidget);
+ expect(find.text('Open'), findsOneWidget);
+ expect(find.text('Wren mentioned you in # web-project'), findsOneWidget);
+ expect(find.text('Windows credential fix'), findsOneWidget);
+ expect(find.text('3 new'), findsOneWidget);
+ expect(find.text('Closed agents leave the list'), findsOneWidget);
+ expect(find.text('08:08'), findsOneWidget);
+ });
+ });
+
+ for (final width in [900.0, 360.0]) {
+ testWidgets('every row stays one line at $width px with long names', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = full();
+ final long = 'A very long name that cannot fit on one line ' * 4;
+ server.ask([long]);
+ (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == 'offline')['title'] =
+ long;
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1', text: long)],
+ 'read': [],
+ 'more': false,
+ };
+ final activity = await loaded(tester, server);
+ await show(tester, activity, width: width);
+ final rows = find.byWidgetPredicate(
+ (w) =>
+ w.key is ValueKey<String> &&
+ (w.key! as ValueKey<String>).value.startsWith(
+ 'super-activity-row-',
+ ),
+ );
+ expect(rows, findsNWidgets(6));
+ final heights = {
+ for (final row in rows.evaluate())
+ tester.getSize(find.byWidget(row.widget)).height,
+ };
+ expect(
+ heights,
+ hasLength(1),
+ reason: 'all rows are one height: $heights',
+ );
+ expect(heights.single, lessThan(48));
+ expect(tester.takeException(), isNull);
+ });
+ });
+ }
+
+ testWidgets(
+ 'a decision row opens its card to answer, a second tap folds it',
+ (tester) async {
+ final activity = await loaded(tester, full());
+ await show(tester, activity);
+ expect(find.text('Behind a flag'), findsNothing);
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-decision:decision-1')),
+ );
+ await tester.pumpAndSettle();
+ expect(find.textContaining('Behind a flag'), findsOneWidget);
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-decision:decision-1')),
+ );
+ await tester.pumpAndSettle();
+ expect(find.textContaining('Behind a flag'), findsNothing);
+ },
+ );
+
+ testWidgets('every title starts in one column, and a heading starts where '
+ 'its rows do', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await loaded(tester, full());
+ await show(tester, activity);
+ double left(Finder f) => tester.getTopLeft(f).dx;
+ final titles = {
+ left(find.text('W1 ships alone or waits?')),
+ left(find.text('Nico is waiting on you')),
+ left(find.text('Wren mentioned you in # web-project')),
+ left(find.text('Windows credential fix')),
+ left(find.text('Closed agents leave the list')),
+ };
+ expect(titles, hasLength(1), reason: 'title columns: $titles');
+ // The mark column starts where the headings do.
+ final marks = {
+ left(find.text('◐').first),
+ left(find.text('@')),
+ left(find.text('↳')),
+ left(find.text('✓').first),
+ };
+ expect(marks, hasLength(1), reason: 'mark columns: $marks');
+ for (final heading in ['Needs you', 'New replies', 'Done today']) {
+ expect(left(find.text(heading)), marks.single, reason: heading);
+ }
+ });
+ });
+
+ testWidgets('a New replies row offers Unfollow on hover, nothing at rest', (
+ tester,
+ ) async {
+ final server = full();
+ final activity = await loaded(tester, server);
+ await show(tester, activity);
+ final row = find.byKey(
+ const ValueKey('super-activity-row-thread:offline/message-1'),
+ );
+ expect(find.text('Unfollow'), findsNothing);
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ addTearDown(mouse.removePointer);
+ await mouse.moveTo(tester.getCenter(row));
+ await tester.pumpAndSettle();
+ expect(find.text('Unfollow'), findsOneWidget);
+ await tester.runAsync(() async {
+ await tester.tap(find.text('Unfollow'));
+ await Future<void>.delayed(const Duration(milliseconds: 50));
+ });
+ await tester.pumpAndSettle();
+ expect(server.followPosts.single['follow'], false);
+ expect(server.followPosts.single['root'], 'message-1');
+ });
+
+ testWidgets('a row opens where it is: agent, tag, thread and done task', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await loaded(tester, full());
+ final opened = await show(tester, activity);
+ await tester.tap(find.text('Nico is waiting on you'));
+ await tester.tap(find.text('Wren mentioned you in # web-project'));
+ await tester.tap(find.text('Windows credential fix'));
+ await tester.tap(find.text('Closed agents leave the list'));
+ expect(opened.conversations, ['waiting', 'offline']);
+ expect(opened.mentions, hasLength(1));
+ expect(opened.threads, [('offline', 'message-1')]);
+ });
+ });
+
+ testWidgets('a tag read past leaves the list, one not read is bold', (
+ tester,
+ ) async {
+ final server = swarm()..followedThreads = null;
+ server.tag('message-1', messageSequence: 1);
+ server.tag('message-2', messageSequence: 9);
+ server.state['readMarks'] = {
+ 'owner': {'lead': 4},
+ };
+ final activity = await loaded(tester, server);
+ await show(tester, activity);
+ final unread = find.byKey(
+ const ValueKey('super-activity-row-mention:mention-2'),
+ );
+ expect(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ findsNothing,
+ );
+ expect(unread, findsOneWidget);
+ final title = find.descendant(
+ of: unread,
+ matching: find.textContaining('mentioned you'),
+ );
+ expect(tester.widget<Text>(title).style?.fontWeight, FontWeight.w600);
+ });
+
+ for (final brightness in Brightness.values) {
+ testWidgets(
+ 'says you are all caught up when nothing is new ($brightness)',
+ (tester) async {
+ final server = swarm()..followedThreads = null;
+ final activity = await loaded(tester, server);
+ await show(tester, activity, brightness: brightness);
+ expect(find.text("You're all caught up."), findsOneWidget);
+ for (final heading in ['Needs you', 'New replies', 'Done today']) {
+ expect(find.text(heading), findsNothing, reason: heading);
+ }
+ },
+ );
+ }
+
+ testWidgets('leaving the view marks nothing read', (tester) async {
+ final server = full();
+ final activity = await loaded(tester, server);
+ await show(tester, activity);
+ await tester.pumpWidget(const SizedBox());
+ await tester.pump();
+ expect(server.activityReadPosts, isEmpty);
+ });
+}
diff --git a/desktop/test/super_tab_attention_test.dart b/desktop/test/super_tab_attention_test.dart
index 2f17c26f8..3861662b9 100644
--- a/desktop/test/super_tab_attention_test.dart
+++ b/desktop/test/super_tab_attention_test.dart
@@ -12,7 +12,6 @@ import 'package:harness/super_tabs/buddy_rows.dart';
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/model.dart';
import 'package:harness/super_tabs/project_sidebar.dart';
-import 'package:harness/super_tabs/threads_view.dart';
import 'package:harness/widgets/desktop_chrome.dart';
import 'support/super_tab_fixture.dart';
@@ -342,6 +341,27 @@ void main() {
});
});
+ test('Unfollow is kept on the server and the list read again', () async {
+ final server = projectServer();
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [readThread('message-9', 7)],
+ 'more': false,
+ };
+ final c = await open(server);
+ final attention = SuperTabAttention.of(c);
+ await attention.load();
+ final reads = server.threadListReads.length;
+ expect(await attention.setFollow(attention.read.single, false), isTrue);
+ await pumpEventQueue();
+ expect(server.followPosts.single, {
+ 'conversationId': 'lead',
+ 'root': 'message-9',
+ 'follow': false,
+ });
+ expect(server.threadListReads.length, greaterThan(reads));
+ });
+
group('read rows are muted, unread rows full strength and bold', () {
for (final brightness in Brightness.values) {
testWidgets('in $brightness', (tester) async {
@@ -745,95 +765,6 @@ void main() {
});
group('the Threads list', () {
- test('lists threads with new replies first, then the rest; showing one '
- 'reads its new replies and marks it read on every device', () async {
- final server = projectServer();
- fromLead(server, 'Root');
- fromLead(server, 'Old reply');
- server.messages.last['thread'] = 'message-1';
- fromLead(server, 'New reply');
- server.messages.last['thread'] = 'message-1';
- server.followedThreads = {
- 'unread': [unreadThread('message-1', 3)],
- 'read': [readThread('message-9', 7, follow: true)],
- 'more': false,
- };
- conversation(server, 'lead')['lastMainSequence'] = 1;
- server.markThreadReadElsewhere('lead', 'message-1', 2);
- final c = await open(server);
- final attention = SuperTabAttention.of(c)..opened();
- await attention.load();
- expect(attention.shown.map((t) => t.rootId), ['message-1', 'message-9']);
- expect(attention.isNew(attention.shown.first), isTrue);
- expect(attention.isNew(attention.shown.last), isFalse);
- await attention.showReplies(attention.shown.first);
- expect(attention.newReplies['lead/message-1']!.map((m) => m.text), [
- 'New reply',
- ]);
- expect(server.threadMarkPosts.last, {
- 'conversationId': 'lead',
- 'root': 'message-1',
- 'sequence': 3,
- });
- // Read now, it stays new until the view is left.
- server.followedThreads = {
- 'unread': [],
- 'read': [readThread('message-1', 3), readThread('message-9', 7)],
- 'more': false,
- };
- await attention.load();
- expect(attention.isNew(attention.shown.first), isTrue);
- attention.closed();
- expect(attention.shown.every((t) => !attention.isNew(t)), isTrue);
- });
-
- test('Unfollow is kept on the server and the list read again', () async {
- final server = projectServer();
- server.followedThreads = {
- 'unread': [],
- 'read': [readThread('message-9', 7)],
- 'more': false,
- };
- final c = await open(server);
- final attention = SuperTabAttention.of(c);
- await attention.load();
- final reads = server.threadListReads.length;
- expect(await attention.setFollow(attention.read.single, false), isTrue);
- await pumpEventQueue();
- expect(server.followPosts.single, {
- 'conversationId': 'lead',
- 'root': 'message-9',
- 'follow': false,
- });
- expect(server.threadListReads.length, greaterThan(reads));
- });
-
- test('a server before followed threads lists the inbox\'s unread ones '
- 'and offers no Follow', () async {
- final server = projectServer()
- ..inbox = {
- 'threads': [unreadThread('message-1', 3)],
- 'latest': [],
- 'more': false,
- };
- final c = await open(server);
- final attention = SuperTabAttention.of(c);
- await attention.load();
- expect(attention.unread.single.rootId, 'message-1');
- expect(attention.followSupported, isFalse);
- expect(
- await attention.setFollow(attention.unread.single, false),
- isFalse,
- );
- expect(server.followPosts, isEmpty);
- // It does not ask the missing route again.
- await attention.load();
- expect(
- server.threadListReads.where((p) => p.endsWith('/threads')),
- hasLength(1),
- );
- });
-
test('a thread in a chat the reader no longer has is not listed', () async {
final server = projectServer();
server.followedThreads = {
@@ -1004,340 +935,6 @@ void main() {
});
});
- // Scholes, 2026-11-02: a reply sent from a card did not show until an agent
- // answered, so it looked unsent.
- group('a reply sent from the Threads view', () {
- const field = ValueKey('super-thread-reply-lead/message-1');
- const send = ValueKey('super-thread-send-lead/message-1');
- const own = ValueKey('super-thread-own-reply-lead/message-1');
-
- Future<(ConversationServer, SuperTabController, SuperTabAttention)> shown(
- WidgetTester tester,
- ) async {
- final server = projectServer();
- fromLead(server, 'Root');
- fromLead(server, 'Fresh reply');
- server.messages.last['thread'] = 'message-1';
- conversation(server, 'lead')['lastMainSequence'] = 1;
- server.followedThreads = {
- 'unread': [unreadThread('message-1', 2, text: 'Root')],
- 'read': const [],
- 'more': false,
- };
- final c = await openHere(server);
- final attention = SuperTabAttention.of(c);
- await attention.load();
- await tester.binding.setSurfaceSize(const Size(700, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabThreadsView(attention: attention, onOpen: (_, _) {}),
- ),
- ),
- );
- await tester.pumpAndSettle();
- return (server, c, attention);
- }
-
- Finder inOwn(Finder what) =>
- find.descendant(of: find.byKey(own), matching: what);
-
- testWidgets('shows at once as sending, then sent, and stays', (
- tester,
- ) async {
- final (server, c, attention) = await shown(tester);
- final hold = server.holdCommands = Completer<void>();
- await tester.enterText(find.byKey(field), 'On it');
- await tester.pump();
- await tester.tap(find.byKey(send));
- await tester.pump();
- await tester.pump();
- // Before any answer, and before the server has answered at all.
- expect(inOwn(find.text('On it')), findsOneWidget);
- expect(inOwn(find.text('Sending…')), findsOneWidget);
- expect(inOwn(find.text('Sent')), findsNothing);
- expect(tester.widget<TextField>(find.byKey(field)).controller!.text, '');
- hold.complete();
- server.holdCommands = null;
- await tester.pumpAndSettle();
- expect(inOwn(find.text('On it')), findsOneWidget);
- expect(inOwn(find.text('Sent')), findsOneWidget);
- expect(inOwn(find.text('Sending…')), findsNothing);
- // An agent answers, and the transcript holds the reply: it stays, once.
- await c.loadMessages('lead');
- fromLead(server, 'Answer');
- server.messages.last['thread'] = 'message-1';
- await c.refresh();
- await attention.load();
- await tester.pumpAndSettle();
- expect(find.text('On it'), findsOneWidget);
- expect(inOwn(find.text('Sent')), findsOneWidget);
- await close(tester, c);
- });
-
- testWidgets('failed: its text stays, with Retry, and Retry sends it', (
- tester,
- ) async {
- final (server, c, _) = await shown(tester);
- server.refuse = {'code': 'SWARM_BUSY', 'message': 'Busy, try again.'};
- await tester.enterText(find.byKey(field), 'On it');
- await tester.pump();
- await tester.tap(find.byKey(send));
- await tester.pumpAndSettle();
- expect(inOwn(find.text('On it')), findsOneWidget);
- expect(inOwn(find.text('Not sent')), findsOneWidget);
- expect(inOwn(find.text('Sent')), findsNothing);
- // Why it failed is said once, on the reply, not again in the box.
- expect(find.text('Busy, try again.'), findsOneWidget);
- server.refuse = null;
- final posts = server.posts.length;
- await tester.tap(inOwn(find.text('Retry')));
- await tester.pumpAndSettle();
- expect(server.posts.length, posts + 1);
- expect((server.posts.last['command'] as Map)['text'], 'On it');
- expect(inOwn(find.text('Sent')), findsOneWidget);
- expect(inOwn(find.text('Not sent')), findsNothing);
- await close(tester, c);
- });
-
- testWidgets('failed: Delete takes it away, and it is never called sent', (
- tester,
- ) async {
- final (server, c, _) = await shown(tester);
- server.refuse = {'code': 'SWARM_BUSY', 'message': 'Busy, try again.'};
- await tester.enterText(find.byKey(field), 'On it');
- await tester.pump();
- await tester.tap(find.byKey(send));
- await tester.pumpAndSettle();
- await tester.tap(inOwn(find.text('Delete')));
- await tester.pumpAndSettle();
- expect(find.text('On it'), findsNothing);
- expect(find.text('Sent'), findsNothing);
- await close(tester, c);
- });
-
- // Review of #2555: a sent reply stays in the controller's list until its
- // chat's transcript loads, and must not come back as new on a later visit.
- testWidgets('a reply from an earlier visit does not come back as new', (
- tester,
- ) async {
- // A chat that is not open: its transcript never loads here.
- final server = projectServer();
- fromLead(server, 'Root', conversationId: 'offline');
- fromLead(server, 'Fresh reply', conversationId: 'offline');
- server.messages.last['thread'] = 'message-1';
- conversation(server, 'offline')['lastMainSequence'] = 1;
- Map<String, dynamic> listed(int lastReply) => {
- 'unread': [
- unreadThread(
- 'message-1',
- lastReply,
- conversationId: 'offline',
- text: 'Root',
- ),
- ],
- 'read': const [],
- 'more': false,
- };
- server.followedThreads = listed(2);
- final c = await openHere(server);
- final attention = SuperTabAttention.of(c);
- await attention.load();
- await tester.binding.setSurfaceSize(const Size(700, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabThreadsView(attention: attention, onOpen: (_, _) {}),
- ),
- ),
- );
- await tester.pumpAndSettle();
- const reply = ValueKey('super-thread-reply-offline/message-1');
- const ownHere = ValueKey('super-thread-own-reply-offline/message-1');
- await tester.enterText(find.byKey(reply), 'On it');
- await tester.pump();
- await tester.tap(
- find.byKey(const ValueKey('super-thread-send-offline/message-1')),
- );
- await tester.pumpAndSettle();
- expect(find.byKey(ownHere), findsOneWidget);
- // Still in the list: this chat's transcript has not loaded.
- expect(c.outgoing('offline').where((m) => m.text == 'On it'), isNotEmpty);
- attention.closed();
- server.followedThreads = listed(9);
- attention.opened();
- await attention.load();
- await tester.pumpAndSettle();
- expect(attention.isNew(attention.shown.single), isTrue);
- expect(find.byKey(ownHere), findsNothing);
- await close(tester, c);
- });
-
- test('a reply with only files says so', () {
- expect(const SuperTabOwnReply('', null).shownText, 'Files');
- expect(const SuperTabOwnReply('On it', null).shownText, 'On it');
- });
-
- testWidgets('failed: its whole text shows, not cut short', (tester) async {
- final (server, c, _) = await shown(tester);
- server.refuse = {'code': 'SWARM_BUSY', 'message': 'Busy, try again.'};
- final long = List.generate(9, (i) => 'line $i').join('\n');
- await tester.enterText(find.byKey(field), long);
- await tester.pump();
- await tester.tap(find.byKey(send));
- await tester.pumpAndSettle();
- final row = tester.renderObject<RenderParagraph>(inOwn(find.text(long)));
- expect(row.didExceedMaxLines, isFalse);
- await close(tester, c);
- });
-
- testWidgets('a reply the card already read back is not shown twice', (
- tester,
- ) async {
- final (server, c, attention) = await shown(tester);
- await tester.enterText(find.byKey(field), 'On it');
- await tester.pump();
- await tester.tap(find.byKey(send));
- await tester.pumpAndSettle();
- final thread = attention.shown.single;
- final operationId = server.posts.last['operationId'] as String;
- final id = superTabMessageId(
- tabId: c.tabId,
- accountId: c.accountId,
- operationId: operationId,
- );
- attention.newReplies[thread.key] = [
- ...attention.newReplies[thread.key]!,
- SuperTabMessage.fromJson({
- 'id': id,
- 'conversationId': 'lead',
- 'sequence': 90,
- 'author': {'kind': 'person', 'id': c.accountId, 'name': 'Me'},
- 'text': 'On it',
- 'thread': 'message-1',
- 'replyTo': 'message-1',
- 'createdAt': '2026-11-02T00:00:00Z',
- }),
- ];
- await attention.load();
- await tester.pumpAndSettle();
- expect(find.text('On it'), findsOneWidget);
- expect(find.byKey(own), findsNothing);
- await close(tester, c);
- });
- });
-
- testWidgets('the Threads view shows new replies under their root with a '
- 'reply box, the rest after, and Unfollow', (tester) async {
- final server = projectServer();
- fromLead(server, 'Root');
- fromLead(server, 'Fresh reply');
- server.messages.last['thread'] = 'message-1';
- conversation(server, 'lead')['lastMainSequence'] = 1;
- server.followedThreads = {
- 'unread': [unreadThread('message-1', 2, text: 'Root')],
- 'read': [readThread('message-7', 5, text: 'Settled question')],
- 'more': false,
- };
- final c = await openHere(server);
- final attention = SuperTabAttention.of(c);
- await attention.load();
- String? opened;
- await tester.binding.setSurfaceSize(const Size(700, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabThreadsView(
- attention: attention,
- onOpen: (id, root) => opened = '$id/$root',
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- expect(find.text('New replies'), findsOneWidget);
- expect(find.text('Earlier'), findsOneWidget);
- expect(
- tester.getTopLeft(find.text('Root')).dy,
- lessThan(tester.getTopLeft(find.text('Settled question')).dy),
- );
- expect(find.text('Fresh reply'), findsOneWidget);
- expect(find.text('1 new reply'), findsOneWidget);
- expect(
- find.byKey(const ValueKey('super-thread-reply-lead/message-1')),
- findsOneWidget,
- );
- expect(
- find.byKey(const ValueKey('super-thread-reply-lead/message-7')),
- findsNothing,
- );
- expect(server.threadMarkPosts.last['root'], 'message-1');
- await tester.tap(find.text('Root'));
- expect(opened, 'lead/message-1');
- // The reply box is the thread pane's own: attach and the arrow send.
- final box = find.byKey(
- const ValueKey('super-thread-reply-surface-lead/message-1'),
- );
- expect(
- find.descendant(of: box, matching: find.byTooltip('Send reply')),
- findsOneWidget,
- );
- expect(find.text('Send'), findsNothing);
- await tester.enterText(
- find.byKey(const ValueKey('super-thread-reply-lead/message-1')),
- 'On it',
- );
- await tester.pump();
- await tester.tap(
- find.byKey(const ValueKey('super-thread-send-lead/message-1')),
- );
- await tester.pumpAndSettle();
- final sent = server.posts.last['command'] as Map;
- expect(sent['type'], 'message.send');
- expect(sent['conversationId'], 'lead');
- expect(sent['replyTo'], 'message-1');
- expect(sent['text'], 'On it');
- Opacity more(String key) => tester.widget<Opacity>(
- find
- .ancestor(
- of: find.byKey(ValueKey('super-thread-more-$key')),
- matching: find.byType(Opacity),
- )
- .first,
- );
- // Unfollow is quiet: its ⋯ shows only while the card is pointed at, or
- // focused (the reply box focused shows its card's).
- expect(more('lead/message-1').opacity, 1);
- FocusManager.instance.primaryFocus?.unfocus();
- await tester.pumpAndSettle();
- expect(find.text('Unfollow'), findsNothing);
- expect(more('lead/message-7').opacity, 0);
- final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
- addTearDown(mouse.removePointer);
- await mouse.addPointer(location: Offset.zero);
- await mouse.moveTo(tester.getCenter(find.text('Settled question')));
- await tester.pumpAndSettle();
- expect(more('lead/message-7').opacity, 1);
- expect(more('lead/message-1').opacity, 0);
- await tester.tap(
- find.descendant(
- of: find.byKey(const ValueKey('super-thread-more-lead/message-7')),
- matching: find.byTooltip('More'),
- ),
- );
- await tester.pumpAndSettle();
- await tester.tap(find.text('Unfollow thread'));
- await tester.pumpAndSettle();
- expect(server.followPosts.single['follow'], isFalse);
- await close(tester, c);
- });
-
testWidgets('a read workgroup with a tag of the reader is never behind '
'"… N more"', (tester) async {
final server = projectServer();
@@ -1371,56 +968,6 @@ void main() {
await close(tester, c);
});
- testWidgets('a thread in the reader\'s Buddy chat offers Open thread to '
- 'reply, not a box its ended session would refuse', (tester) async {
- final server = projectServer();
- (server.state['conversations'] as List).add({
- ...conversationFixture('buddy-owner-lead', "owner's Buddy"),
- 'kind': 'buddy',
- 'projectId': 'lead',
- 'buddyOwnerId': 'owner',
- });
- server.followedThreads = {
- 'unread': [
- unreadThread(
- 'message-1',
- 2,
- conversationId: 'buddy-owner-lead',
- text: 'Plan the week',
- ),
- ],
- 'read': [],
- 'more': false,
- };
- final c = await openHere(server);
- final attention = SuperTabAttention.of(c);
- await attention.load();
- String? opened;
- await tester.binding.setSurfaceSize(const Size(700, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabThreadsView(
- attention: attention,
- onOpen: (id, root) => opened = '$id/$root',
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- expect(
- find.byKey(
- const ValueKey('super-thread-reply-buddy-owner-lead/message-1'),
- ),
- findsNothing,
- );
- await tester.tap(find.text('Open thread to reply'));
- expect(opened, 'buddy-owner-lead/message-1');
- await close(tester, c);
- });
-
group('tags from the Threads view (merge check of 67c32a3)', () {
/// Kestrel is an agent of "offline", not of "lead"; "offline" has a
/// thread at message-1 with a new reply.
@@ -1468,69 +1015,5 @@ void main() {
expect(sent['replyTo'], 'message-1');
expect(sent['recipientIds'], ['kestrel']);
});
-
- testWidgets('the Threads view\'s box offers @ as the thread pane does: '
- 'whom the thread\'s chat offers, Backspace takes a tag whole, and the '
- 'reply carries it', (tester) async {
- final server = tagged();
- final c = await openHere(server);
- c.select('lead');
- final attention = SuperTabAttention.of(c);
- await attention.load();
- await tester.binding.setSurfaceSize(const Size(700, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabThreadsView(
- attention: attention,
- onOpen: (_, _) {},
- machineName: (_) => 'Studio',
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- final field = find.byKey(
- const ValueKey('super-thread-reply-offline/message-1'),
- );
- final picker = find.byKey(
- const ValueKey('super-thread-completions-offline/message-1'),
- );
- await tester.tap(field);
- await tester.enterText(field, '@Kes');
- await tester.pumpAndSettle();
- expect(picker, findsOneWidget);
- expect(
- find.descendant(of: picker, matching: find.textContaining('Kestrel')),
- findsWidgets,
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- expect(picker, findsNothing);
- expect(tester.widget<TextField>(field).controller!.text, '@Kestrel ');
- expect(c.threadMentions('offline', 'message-1'), {'kestrel': '@Kestrel'});
- // Backspace into the tag takes it whole.
- await tester.sendKeyEvent(LogicalKeyboardKey.backspace);
- await tester.sendKeyEvent(LogicalKeyboardKey.backspace);
- await tester.pumpAndSettle();
- expect(tester.widget<TextField>(field).controller!.text, '');
- // Picked again and sent: the reply carries the tag.
- await tester.enterText(field, '@Kes');
- await tester.pumpAndSettle();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- await tester.enterText(field, '@Kestrel please look');
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-thread-send-offline/message-1')),
- );
- await tester.pumpAndSettle();
- final sent = server.posts.last['command'] as Map;
- expect(sent['conversationId'], 'offline');
- expect(sent['recipientIds'], ['kestrel']);
- await close(tester, c);
- });
});
}
diff --git a/desktop/test/super_tab_attention_wave2_test.dart b/desktop/test/super_tab_attention_wave2_test.dart
index 1cfc16ea2..e03a80382 100644
--- a/desktop/test/super_tab_attention_wave2_test.dart
+++ b/desktop/test/super_tab_attention_wave2_test.dart
@@ -5,7 +5,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:flutter/services.dart';
-import 'package:harness/super_tabs/activity.dart';
import 'package:harness/super_tabs/attention.dart';
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/model.dart';
@@ -207,7 +206,6 @@ Future<(SuperTabController, GlobalKey)> _show(
await attention.mentions.load();
await attention.decisions.load();
await attention.load();
- await SuperTabActivity.of(c).load();
await c.select(selected);
if (!c.expandedProjects.contains('lead')) c.toggleProject('lead');
final picture = GlobalKey();
diff --git a/desktop/test/super_tab_backend_transport_test.dart b/desktop/test/super_tab_backend_transport_test.dart
index 8095d935f..a90b62933 100644
--- a/desktop/test/super_tab_backend_transport_test.dart
+++ b/desktop/test/super_tab_backend_transport_test.dart
@@ -11,14 +11,12 @@ import 'package:harness/api/access_token_source.dart';
import 'package:harness/api/api_client.dart';
import 'package:harness/auth/auth_session.dart';
import 'package:harness/core/config.dart';
-import 'package:harness/super_tabs/activity.dart';
import 'package:harness/super_tabs/attention.dart';
import 'package:harness/super_tabs/backend_transport.dart';
import 'package:harness/super_tabs/client.dart';
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/model.dart';
-import 'super_tab_activity_test.dart' show reply;
import 'super_tab_attention_test.dart' show projectServer, unreadThread;
import 'support/super_tab_fixture.dart';
import 'swarm_state_test.dart' show MemoryStore;
@@ -541,8 +539,6 @@ void main() {
expect(
paths,
containsAll([
- '/api/super-tabs/1/activity',
- '/api/super-tabs/1/activity/read',
'/api/super-tabs/1/threads',
'/api/super-tabs/1/inbox',
'/api/super-tabs/1/conversations/1/threads/1/follow',
@@ -611,121 +607,6 @@ void main() {
}
group('on the web, through the backend', () {
- test('Activity lists replies to the reader, and leaving it marks them '
- 'read on the backend', () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {
- 'items': [reply('r1')],
- 'more': false,
- };
- final c = await webSwarm(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- expect(activity.error, isNull);
- expect(activity.supported, isTrue);
- expect(activity.items.map((i) => i.id), ['r1']);
- activity.opened();
- await settle();
- activity.closed();
- await settle();
- expect(server.activityReadPosts, hasLength(1));
- expect(
- sent(),
- containsAll([
- 'GET /api/super-tabs/tab/activity',
- 'POST /api/super-tabs/tab/activity/read',
- ]),
- );
- });
-
- test(
- 'Activity that failed its first read recovers on the next change',
- () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activityStatus = 503;
- server.activity = {
- 'items': [reply('r1')],
- 'more': false,
- };
- final c = await webSwarm(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- expect(activity.error, isNotNull);
- expect(activity.items, isEmpty);
- server.activityStatus = 0;
- server.append('Something else changed');
- await c.refresh();
- await settle();
- expect(activity.error, isNull);
- expect(activity.items.map((i) => i.id), ['r1']);
- },
- );
-
- test('Activity drops its rows when access goes, and an answer on its way '
- 'shows nothing', () async {
- final server = projectServer();
- server.state['activityDigest'] = 'd1';
- server.activity = {
- 'items': [reply('r1')],
- 'more': false,
- };
- final c = await webSwarm(server);
- final activity = SuperTabActivity.of(c);
- await settle();
- expect(activity.items, hasLength(1));
- server.holdActivity = Completer();
- unawaited(activity.load());
- await settle();
- c.revokeAccess('Removed from this Swarm.');
- expect(activity.items, isEmpty);
- server.holdActivity!.complete();
- await settle();
- expect(activity.items, isEmpty);
- expect(activity.count, 0);
- });
-
- test(
- 'Threads lists followed threads, and Follow is kept on the backend',
- () async {
- final server = projectServer();
- server.followedThreads = {
- 'unread': [
- unreadThread('message-1', 2),
- // A chat this reader does not have: never shown on its word.
- unreadThread('message-9', 3, conversationId: 'elsewhere'),
- ],
- 'read': [],
- 'more': false,
- };
- final c = await webSwarm(server);
- final attention = SuperTabAttention.of(c);
- await attention.load();
- expect(attention.error, isNull);
- expect(attention.followSupported, isTrue);
- expect(attention.unread.map((t) => t.rootId), ['message-1']);
- expect(sent(), contains('GET /api/super-tabs/tab/threads'));
- expect(sent(), isNot(contains('GET /api/super-tabs/tab/inbox')));
- expect(
- await attention.setFollow(attention.unread.single, false),
- isTrue,
- );
- expect(server.followPosts, [
- {'conversationId': 'lead', 'root': 'message-1', 'follow': false},
- ]);
- // Access gone: no Follow is sent at all. (A kept Follow reads the
- // list again first.)
- await settle();
- final thread = attention.unread.single;
- backend.requests.clear();
- c.revokeAccess('Removed from this Swarm.');
- expect(await attention.setFollow(thread, true), isFalse);
- await settle();
- expect(backend.requests, isEmpty);
- },
- );
-
test(
'Threads on a backend before followed threads reads its inbox',
() async {
diff --git a/desktop/test/super_tab_buddies_test.dart b/desktop/test/super_tab_buddies_test.dart
index 0d1f241ad..44b6cf11f 100644
--- a/desktop/test/super_tab_buddies_test.dart
+++ b/desktop/test/super_tab_buddies_test.dart
@@ -10,7 +10,6 @@ import 'package:harness/widgets/harness_activity_mark.dart';
import 'package:harness/super_tabs/buddies.dart' show kBuddyEngineRefusals;
import 'package:harness/super_tabs/buddy_machines.dart' show kBuddyNoMachine;
import 'package:harness/super_tabs/controller.dart';
-import 'package:harness/super_tabs/decisions_view.dart';
import 'package:harness/super_tabs/view.dart';
import 'support/buddy_fixture.dart';
@@ -1490,7 +1489,7 @@ void main() {
});
testWidgets(
- 'Notifications keep Decisions, for anyone with or without a Buddy',
+ 'Activity keeps Needs you, for anyone with or without a Buddy',
(tester) async {
final server = buddySwarm();
server.ask(['Ship it?']);
@@ -1498,13 +1497,7 @@ void main() {
await tester.tap(find.byKey(const ValueKey('super-activity')));
await tester.pumpAndSettle();
- expect(
- find.descendant(
- of: find.byType(SuperTabDecisionList),
- matching: find.text('Decisions'),
- ),
- findsOneWidget,
- );
+ expect(find.text('Needs you'), findsOneWidget);
expect(find.text('Ship it?'), findsOneWidget);
await close(tester, c);
},
@@ -1532,7 +1525,7 @@ void main() {
expect(find.textContaining('Chat with PM'), findsNothing);
await tester.tap(
- find.byKey(const ValueKey('super-mention-mention-1')),
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
);
await tester.pumpAndSettle();
diff --git a/desktop/test/super_tab_chat_test.dart b/desktop/test/super_tab_chat_test.dart
index 508f1f931..0b56daf6d 100644
--- a/desktop/test/super_tab_chat_test.dart
+++ b/desktop/test/super_tab_chat_test.dart
@@ -161,16 +161,27 @@ void main() {
addTearDown(c.dispose);
await c.refresh();
final told = <int>[];
+ void fromTeammate(String text) {
+ server.append(text);
+ server.messages.last['author'] = {
+ 'kind': 'agent',
+ 'id': 'lead-agent',
+ 'name': 'Lead',
+ };
+ }
+
SuperTabChatNotices.of(c).onMessage = (_, s) => told.add(s);
await c.setNotify(c.selectedId, SuperTabNotify.all);
await showReadView(tester, c);
- server.append('While reading it');
+ fromTeammate('While reading it');
await tester.runAsync(c.refresh);
+ await tester.runAsync(pumpEventQueue);
await tester.pump();
expect(told, isEmpty);
await showReadView(tester, c, terminals: true);
- server.append('Behind the terminals');
+ fromTeammate('Behind the terminals');
await tester.runAsync(c.refresh);
+ await tester.runAsync(pumpEventQueue);
await tester.pump();
expect(told, hasLength(1));
await closeReadView(tester, c);
diff --git a/desktop/test/super_tab_decisions_test.dart b/desktop/test/super_tab_decisions_test.dart
index a07621291..0f1f9dfd0 100644
--- a/desktop/test/super_tab_decisions_test.dart
+++ b/desktop/test/super_tab_decisions_test.dart
@@ -7,7 +7,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/super_tabs/controller.dart';
-import 'package:harness/super_tabs/decisions_view.dart';
import 'package:harness/super_tabs/decisions.dart';
import 'package:harness/super_tabs/model.dart';
import 'package:harness/super_tabs/view.dart';
@@ -231,7 +230,7 @@ void main() {
group('the Decisions list', () {
testWidgets(
- 'lists one batch per ask, marks the recommendation, and answers with one tap',
+ 'lists each question as one row, opens its card with the recommendation, and answers with one tap',
(tester) async {
final server = swarm()..ask(['Ship how?', 'Name it?']);
await showView(tester, server);
@@ -241,19 +240,16 @@ void main() {
);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- expect(
- find.descendant(
- of: find.byType(SuperTabDecisionList),
- matching: find.text('Decisions'),
- ),
- findsOneWidget,
- );
- expect(
- find.text('Wren asked 2 questions · web-project · Lead'),
- findsOneWidget,
+ expect(find.text('Needs you'), findsOneWidget);
+ expect(find.text('Answer'), findsNWidgets(2));
+ expect(find.text('Behind a flag · Recommended'), findsNothing);
+
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-decision:decision-2')),
);
- expect(find.text('Behind a flag · Recommended'), findsNWidgets(2));
- expect(find.text('Unblocks: The release'), findsNWidgets(2));
+ await tester.pumpAndSettle();
+ expect(find.text('Behind a flag · Recommended'), findsOneWidget);
+ expect(find.text('Unblocks: The release'), findsOneWidget);
await tester.tap(option('decision-2', 1));
await tester.pumpAndSettle();
@@ -263,9 +259,14 @@ void main() {
'decisionId': 'decision-2',
'choice': 1,
});
- expect(find.text('You chose: To everyone'), findsOneWidget);
+ // Answered, it leaves Needs you and the number.
+ expect(
+ find.byKey(const ValueKey('super-activity-row-decision:decision-2')),
+ findsNothing,
+ );
+ expect(find.text('Ship how?'), findsOneWidget);
expect(
- find.text('Wren asked 1 question · web-project · Lead'),
+ find.descendant(of: notificationsEntry(), matching: find.text('1')),
findsOneWidget,
);
},
@@ -314,7 +315,7 @@ void main() {
await showView(tester, swarm());
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- expect(find.text('No decisions waiting for you.'), findsOneWidget);
+ expect(find.text("You're all caught up."), findsOneWidget);
});
});
@@ -338,16 +339,6 @@ void main() {
find.descendant(of: panel, matching: find.text('Elsewhere?')),
findsNothing,
);
- // The list names where each was asked: the project chat, for both.
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- expect(
- find.text('Wren asked 1 question · web-project · Lead'),
- findsNWidgets(2),
- );
- await tester.tap(find.byKey(const ValueKey('super-buddy-lead')));
- await tester.pumpAndSettle();
-
await tester.tap(option('decision-1', 0));
await tester.pumpAndSettle();
expect(panel, findsNothing);
@@ -400,14 +391,6 @@ void main() {
'delegate': true,
});
expect(inPanel('Ship how?'), findsNothing);
- // The answered list says the Product Manager decided, never that the reader chose.
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- expect(
- find.text('Product Manager decided: Behind a flag'),
- findsOneWidget,
- );
- expect(find.text('You chose: Behind a flag'), findsNothing);
},
);
@@ -428,9 +411,11 @@ void main() {
);
await tester.tap(letPmDecide('decision-1'));
await tester.pumpAndSettle();
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- expect(find.text('Coordinator decided: Behind a flag'), findsOneWidget);
+ expect(server.posts.last['command'], {
+ 'type': 'decision.answer',
+ 'decisionId': 'decision-1',
+ 'delegate': true,
+ });
expect(find.textContaining('PM decide'), findsNothing);
});
@@ -628,6 +613,10 @@ void main() {
await showView(tester, server);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-decision:decision-1')),
+ );
+ await tester.pumpAndSettle();
server.refuse = {'code': 'DECISION_ANSWERED', 'message': 'Answered.'};
await tester.tap(option('decision-1', 1));
diff --git a/desktop/test/super_tab_mentions_test.dart b/desktop/test/super_tab_mentions_test.dart
index 56c050f7a..3adcc75a0 100644
--- a/desktop/test/super_tab_mentions_test.dart
+++ b/desktop/test/super_tab_mentions_test.dart
@@ -4,6 +4,7 @@ import 'dart:io';
import 'dart:math' as math;
import 'dart:ui' as ui;
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
@@ -575,7 +576,7 @@ void main() {
});
group('notifications view', () {
- testWidgets('the entry counts what waits and lists Waiting and Earlier', (
+ testWidgets('the entry counts what waits; the view lists only that', (
tester,
) async {
final server = ConversationServer()
@@ -594,106 +595,45 @@ void main() {
);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- final waiting = find.byKey(const ValueKey('super-mention-mention-2'));
- final earlier = find.byKey(const ValueKey('super-mention-mention-1'));
- // Activity is one list, newest first (Slack); the waiting tag is newer.
- expect(
- tester.getTopLeft(waiting).dy,
- lessThan(tester.getTopLeft(earlier).dy),
+ final waiting = find.byKey(
+ const ValueKey('super-activity-row-mention:mention-2'),
);
- for (final text in [
- 'web-project · Lead',
- 'Wren tagged you',
- 'Ship it?',
- '3 min ago',
- ]) {
- expect(
- find.descendant(of: waiting, matching: find.text(text)),
- findsOneWidget,
- reason: text,
- );
- }
+ expect(waiting, findsOneWidget);
expect(
- find.descendant(of: earlier, matching: find.text('1 h ago')),
+ find.descendant(
+ of: waiting,
+ matching: find.text('Wren mentioned you in # web-project'),
+ ),
findsOneWidget,
);
- });
-
- testWidgets('a tag shows the Lead’s avatar beside its name', (
- tester,
- ) async {
- final server = ConversationServer()
- ..append('Ship it?')
- ..tag('message-1', text: 'Ship it?', leadId: 'lead-agent');
- server.state['agents'] = [
- {
- 'id': 'lead-agent',
- 'name': 'Lead',
- 'displayName': 'Wren',
- 'machineId': 'm',
- 'harnessId': 'h',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'claude'},
- 'avatar': {'kind': 'preset', 'key': 'owl'},
- },
- ];
- await showView(tester, server);
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- final row = find.byKey(const ValueKey('super-mention-mention-1'));
expect(
- find.descendant(of: row, matching: find.text('🦉')),
- findsOneWidget,
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ findsNothing,
);
});
- testWidgets('a person’s tag shows their avatar and username', (
- tester,
- ) async {
+ testWidgets('Mark done, offered where the time is on hover, clears the tag '
+ 'and the count', (tester) async {
final server = ConversationServer()
..append('Ship it?')
- ..tag('message-1', text: 'Ship it?', leadId: 'dee');
- server.mentions.last['leadName'] = 'dee';
- server.state['people'] = [
- {'id': 'owner', 'email': '[email protected]', 'role': 'owner'},
- {
- 'id': 'dee',
- 'email': '[email protected]',
- 'role': 'collaborator',
- 'username': 'deedee',
- 'avatar': {'kind': 'preset', 'key': 'fox'},
- },
- ];
+ ..tag('message-1', text: 'Ship it?', createdAt: minutesAgo(3));
await showView(tester, server);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- final row = find.byKey(const ValueKey('super-mention-mention-1'));
- expect(
- find.descendant(of: row, matching: find.text('🦊')),
- findsOneWidget,
- );
- // The name they go by now, though they were tagged under another.
- expect(
- find.descendant(of: row, matching: find.text('deedee tagged you')),
- findsOneWidget,
+ expect(find.text('Mark done'), findsNothing);
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ addTearDown(mouse.removePointer);
+ await mouse.moveTo(
+ tester.getCenter(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ ),
);
- });
-
- testWidgets('mark done moves the tag to Earlier and clears the count', (
- tester,
- ) async {
- final server = ConversationServer()
- ..append('Ship it?')
- ..tag('message-1', text: 'Ship it?', createdAt: minutesAgo(3));
- await showView(tester, server);
- await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
await tester.tap(find.text('Mark done'));
await tester.pumpAndSettle();
- expect(find.text('Mark done'), findsNothing);
expect(
- find.byKey(const ValueKey('super-mention-mention-1')),
- findsOneWidget,
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ findsNothing,
);
expect(
find.descendant(of: notificationsEntry(), matching: find.text('1')),
@@ -720,7 +660,9 @@ void main() {
expect(c.snapshot?.conversation('group'), isNull);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(c.selectedId, 'group');
expect(find.text('Builder could not start.'), findsWidgets);
@@ -737,7 +679,9 @@ void main() {
final c = await showView(tester, server);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(find.text('Message unavailable'), findsOneWidget);
expect(c.selectedId, isNot('private-chat'));
@@ -759,7 +703,9 @@ void main() {
final c = await showView(tester, server);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(
find.text('This message is too far back to open.'),
@@ -790,7 +736,9 @@ void main() {
server.tag('message-150', conversationId: 'group', text: 'Note 150');
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(
find.text('This message is no longer in the conversation.'),
@@ -824,7 +772,9 @@ void main() {
server.tag('message-120', conversationId: 'group', text: 'Note 120');
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(
find.text('This message is no longer in the conversation.'),
@@ -859,7 +809,9 @@ void main() {
server.tag('message-650', conversationId: 'group', text: 'Note 650');
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(
find.text('This message is no longer in the conversation.'),
@@ -901,7 +853,9 @@ void main() {
// A background poll is reading the rows held when the tag opens.
final held = server.holdReads = Completer<void>();
final poll = c.loadMessages('group');
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pump();
server.holdReads = null;
held.complete();
@@ -940,7 +894,9 @@ void main() {
final c = await showView(tester, server);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(c.selectedId, 'group');
expect(find.text('Replying to owner'), findsOneWidget);
@@ -1409,7 +1365,9 @@ void main() {
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
await shot(tester, 'notifications');
- await tester.tap(find.byKey(const ValueKey('super-mention-mention-1')));
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ );
await tester.pumpAndSettle();
expect(find.text('Replying to Wren'), findsOneWidget);
await shot(tester, 'opened-at-message');
diff --git a/desktop/test/super_tab_one_buddy_test.dart b/desktop/test/super_tab_one_buddy_test.dart
index 4bbefe0c0..7bd5c7a98 100644
--- a/desktop/test/super_tab_one_buddy_test.dart
+++ b/desktop/test/super_tab_one_buddy_test.dart
@@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
-import 'package:harness/super_tabs/attention.dart';
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/section_heading.dart';
-import 'package:harness/super_tabs/threads_view.dart';
import 'package:harness/super_tabs/view.dart';
import 'support/buddy_fixture.dart';
@@ -423,78 +421,4 @@ void main() {
},
);
});
-
- testWidgets('the Threads list offers no reply in an earlier Buddy chat, '
- 'and still offers one in # buddy (merge with #2434)', (tester) async {
- final server = oneBuddySwarm()..threads = true;
- giveSwarmBuddy(server);
- giveBuddy(server, id: 'old', name: 'Wren');
- Map<String, dynamic> thread(String chat) {
- server.append('Root in $chat', conversationId: chat);
- final root = server.messages.last['id'] as String;
- server.append('New reply in $chat', conversationId: chat);
- server.messages.last['thread'] = root;
- return {
- 'conversationId': chat,
- 'rootId': root,
- 'root': {
- 'id': root,
- 'sequence': 1,
- 'author': {'kind': 'agent', 'id': 'wren', 'name': 'Wren'},
- 'text': 'Root in $chat',
- 'createdAt': '2026-10-31T01:00:00Z',
- 'attachments': 0,
- },
- 'lastReplyAt': '2026-10-31T02:00:00Z',
- 'lastReplySequence': 2,
- 'lastReplier': {'kind': 'agent', 'id': 'wren', 'name': 'Wren'},
- 'unreadReplies': 1,
- 'follow': null,
- };
- }
-
- final earlier = thread('buddy-peer-lead');
- final current = thread('swarm-buddy-peer');
- server.followedThreads = {
- 'unread': [earlier, current],
- 'read': [],
- 'more': false,
- };
- final c = server.controller(account: 'peer');
- await c.refresh();
- final attention = SuperTabAttention.of(c);
- await attention.load();
- expect(attention.shown, hasLength(2));
- await tester.binding.setSurfaceSize(const Size(700, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabThreadsView(attention: attention, onOpen: (_, _) {}),
- ),
- ),
- );
- await tester.pumpAndSettle();
- expect(find.text('Root in buddy-peer-lead'), findsOneWidget);
- expect(
- find.byKey(
- ValueKey(
- 'super-thread-open-reply-buddy-peer-lead/${earlier['rootId']}',
- ),
- ),
- findsNothing,
- );
- expect(
- find.byKey(
- ValueKey(
- 'super-thread-open-reply-swarm-buddy-peer/${current['rootId']}',
- ),
- ),
- findsOneWidget,
- );
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
- });
}
diff --git a/desktop/test/super_tab_project_status_test.dart b/desktop/test/super_tab_project_status_test.dart
index 23dd32ab7..f995762a4 100644
--- a/desktop/test/super_tab_project_status_test.dart
+++ b/desktop/test/super_tab_project_status_test.dart
@@ -8,7 +8,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/super_tabs/controller.dart';
-import 'package:harness/super_tabs/decisions_view.dart';
import 'package:harness/super_tabs/model.dart';
import 'package:harness/super_tabs/project_status.dart';
import 'package:harness/super_tabs/view.dart';
diff --git a/desktop/test/super_tab_sidebar_cleanup_test.dart b/desktop/test/super_tab_sidebar_cleanup_test.dart
index 9677678f3..4fac88954 100644
--- a/desktop/test/super_tab_sidebar_cleanup_test.dart
+++ b/desktop/test/super_tab_sidebar_cleanup_test.dart
@@ -78,18 +78,18 @@ Future<void> closeSwarm(WidgetTester tester, SuperTabController c) async {
}
void main() {
- // Slack's Activity takes Notifications' place on every platform, above
- // Threads (Lead, 10-31): on a Mac too, beside the menu bar and the Dock.
+ // Slack's Activity takes Notifications' place on every platform (Lead,
+ // 10-31), and takes in Threads (Quiet Swarm): on a Mac too, beside the menu
+ // bar and the Dock.
for (final platform in [TargetPlatform.macOS, TargetPlatform.linux]) {
testWidgets('the top reads New project, Your devices, Your models, '
- 'Activity with its count, Threads', (tester) async {
+ 'Activity with its count', (tester) async {
final c = await showSwarm(tester);
expect(topRows(tester), [
'New project',
'Your devices',
'Your models',
'Activity3',
- 'Threads',
]);
expect(find.text('Notifications'), findsNothing);
expect(tester.takeException(), isNull);
diff --git a/desktop/tool/super_tab_mobile_fixture.dart b/desktop/tool/super_tab_mobile_fixture.dart
index 16b5c4cd0..9280056b5 100644
--- a/desktop/tool/super_tab_mobile_fixture.dart
+++ b/desktop/tool/super_tab_mobile_fixture.dart
@@ -1,7 +1,7 @@
/// No-login review fixture for the Super Tab on mobile web.
///
/// Build for web with `--dart-define=HARNESS_TEST=true` and open with a
-/// `?scenario=rich|empty|one|viewer|offline` and optional `?group=<id>` and
+/// `?scenario=rich|empty|one|viewer|offline|activity|caught-up` and optional `?group=<id>` and
/// `?theme=dark` (Graphite; light Paper is the default) queries.
/// This is a review-only target: it renders the real [SuperTabView] against an
/// in-memory fake backend and never touches a real account or production data.
@@ -32,7 +32,21 @@ Future<void> main() async {
: HarnessPalette.paper;
grid.AppTheme.palette.value = palette;
grid.AppTheme.brightness.value = palette.brightness;
- final server = _seed(scenario);
+ final server = _seed(
+ scenario == 'activity'
+ ? 'rich'
+ : scenario == 'caught-up'
+ ? 'one'
+ : scenario,
+ );
+ if (scenario == 'activity') _activity(server);
+ if (scenario == 'caught-up') {
+ server.followedThreads = {
+ 'unread': <dynamic>[],
+ 'read': <dynamic>[],
+ 'more': false,
+ };
+ }
final controller = server.controller(
account: scenario == 'viewer' ? 'viewer' : 'owner',
);
@@ -76,8 +90,6 @@ class _FixtureState extends State<_Fixture> {
// a phone below the web's compact width, as the workspace does.
Widget build(BuildContext context) => WorkspaceChromeScope(
chrome: WorkspaceChrome(
- leadingWidth: (_) => 0,
- leading: (_, _) => const SizedBox.shrink(),
compactBelow: kWebCompactBelow,
superTabRecovers: true,
),
@@ -98,6 +110,85 @@ class _FixtureState extends State<_Fixture> {
final _now = DateTime.now();
+/// Made-up news for the Activity screens: a decision, a tag, two threads
+/// with new replies, and two tasks that shipped today (Quiet Swarm, screen 6).
+void _activity(ConversationServer server) {
+ final projects = (server.state['projects'] as List)
+ .cast<Map<String, dynamic>>();
+ projects.first['name'] = 'openharness';
+ server.ask(
+ ['W1 ships alone or waits?'],
+ conversationId: 'lead',
+ projectId: 'project-harness',
+ );
+ server.mentions.add({
+ 'id': 'mention-1',
+ 'projectId': 'project-harness',
+ 'projectName': 'openharness',
+ 'conversationId': 'lead',
+ 'conversationTitle': 'Lead',
+ 'messageId': 'tag-1',
+ 'leadId': 'collab',
+ 'leadName': 'River',
+ 'text': 'Three fixes are on main.',
+ 'createdAt': _now
+ .subtract(const Duration(minutes: 20))
+ .toUtc()
+ .toIso8601String(),
+ 'resolvedAt': null,
+ 'resolvedBy': null,
+ });
+ server.state['mentionsWaiting'] = 1;
+ Map<String, dynamic> thread(String root, String text, int unread) => {
+ 'conversationId': 'wg-working',
+ 'rootId': root,
+ 'root': {
+ 'id': root,
+ 'sequence': 1,
+ 'author': {'kind': 'person', 'id': 'collab', 'name': 'diego'},
+ 'text': text,
+ 'createdAt': _now
+ .subtract(const Duration(hours: 5))
+ .toUtc()
+ .toIso8601String(),
+ 'attachments': 0,
+ },
+ 'lastReplyAt': _now
+ .subtract(const Duration(minutes: 30))
+ .toUtc()
+ .toIso8601String(),
+ 'lastReplySequence': 9,
+ 'lastReplier': {'kind': 'agent', 'id': 'builder', 'name': 'Lark'},
+ 'unreadReplies': unread,
+ 'follow': null,
+ };
+ server.followedThreads = {
+ 'unread': [
+ thread('root-1', 'Windows credential fix', 3),
+ thread('root-2', 'Prod DB profile', 1),
+ ],
+ 'read': <dynamic>[],
+ 'more': false,
+ };
+ final conversations = (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>();
+ final done = conversations.firstWhere((g) => g['id'] == 'wg-done');
+ done
+ ..['title'] = 'Closed agents leave the list'
+ ..['shippedAt'] = _now
+ .subtract(const Duration(hours: 2))
+ .millisecondsSinceEpoch;
+ conversations.add({
+ ...done,
+ 'id': 'wg-done-2',
+ 'number': 7,
+ 'title': 'Commits read Harness by Autonomous',
+ 'shippedAt': _now
+ .subtract(const Duration(minutes: 40))
+ .millisecondsSinceEpoch,
+ });
+}
+
ConversationServer _seed(String scenario) {
final server = ConversationServer();
if (scenario == 'offline') {
@@ -111,19 +202,21 @@ ConversationServer _seed(String scenario) {
? _projects()
: _projects().take(1).toList();
final conversations = _conversations(scenario);
- server.state..clear()..addAll({
- 'version': 1,
- 'id': 'tab',
- 'name': _name(scenario),
- 'ownerId': 'owner',
- 'paused': false,
- 'people': _people(),
- 'agents': _agents(),
- 'machines': _machines(),
- 'invitations': scenario == 'rich' ? _invitations() : <Object>[],
- 'conversations': conversations,
- 'projects': projects,
- });
+ server.state
+ ..clear()
+ ..addAll({
+ 'version': 1,
+ 'id': 'tab',
+ 'name': _name(scenario),
+ 'ownerId': 'owner',
+ 'paused': false,
+ 'people': _people(),
+ 'agents': _agents(),
+ 'machines': _machines(),
+ 'invitations': scenario == 'rich' ? _invitations() : <Object>[],
+ 'conversations': conversations,
+ 'projects': projects,
+ });
server.revision = 200;
server.messages.addAll(_messages(scenario));
return server;
@@ -163,7 +256,8 @@ List<Map<String, dynamic>> _projects() => [
},
{
'id': 'project-platform',
- 'name': 'A Very Long Mobile Application Project Title That Runs Past Any Row',
+ 'name':
+ 'A Very Long Mobile Application Project Title That Runs Past Any Row',
'ownerId': 'collab',
'leadConversationId': 'lead-platform',
'visibility': 'private',
@@ -187,13 +281,67 @@ List<Map<String, dynamic>> _projects() => [
];
List<Map<String, dynamic>> _agents() => [
- _agent('lead-agent', 'lead', 'Lead agent', 'Lead', 'm1', 'h-lead', 'owner', 'claude'),
- _agent('builder', 'project-harness', 'Builder', 'Lark', 'm1', 'h-builder', 'owner', 'claude'),
- _agent('designer', 'project-harness', 'Designer', 'Juno', 'm2', 'h-design', 'owner', 'codex'),
- _agent('qa', 'project-platform', 'QA', 'Pixel', 'm2', 'h-qa', 'collab', 'codex'),
- _agent('idle-lead', 'project-harness', 'Lead agent', 'Lead', 'm4', 'h-idle', 'owner', 'claude'),
+ _agent(
+ 'lead-agent',
+ 'lead',
+ 'Lead agent',
+ 'Lead',
+ 'm1',
+ 'h-lead',
+ 'owner',
+ 'claude',
+ ),
+ _agent(
+ 'builder',
+ 'project-harness',
+ 'Builder',
+ 'Lark',
+ 'm1',
+ 'h-builder',
+ 'owner',
+ 'claude',
+ ),
+ _agent(
+ 'designer',
+ 'project-harness',
+ 'Designer',
+ 'Juno',
+ 'm2',
+ 'h-design',
+ 'owner',
+ 'codex',
+ ),
+ _agent(
+ 'qa',
+ 'project-platform',
+ 'QA',
+ 'Pixel',
+ 'm2',
+ 'h-qa',
+ 'collab',
+ 'codex',
+ ),
+ _agent(
+ 'idle-lead',
+ 'project-harness',
+ 'Lead agent',
+ 'Lead',
+ 'm4',
+ 'h-idle',
+ 'owner',
+ 'claude',
+ ),
for (var i = 1; i <= 6; i++)
- _agent('swarm-$i', 'project-harness', 'Worker $i', 'Bot $i', 'm3', 'h-swarm-$i', 'owner', 'claude'),
+ _agent(
+ 'swarm-$i',
+ 'project-harness',
+ 'Worker $i',
+ 'Bot $i',
+ 'm3',
+ 'h-swarm-$i',
+ 'owner',
+ 'claude',
+ ),
];
Map<String, dynamic> _agent(
@@ -221,12 +369,29 @@ Map<String, dynamic> _agent(
};
List<Map<String, dynamic>> _machines() {
- final live = _now.millisecondsSinceEpoch - const Duration(seconds: 40).inMilliseconds;
- final offline = _now.millisecondsSinceEpoch - const Duration(days: 2).inMilliseconds;
- final many = _now.millisecondsSinceEpoch - const Duration(minutes: 1).inMilliseconds;
+ final live =
+ _now.millisecondsSinceEpoch - const Duration(seconds: 40).inMilliseconds;
+ final offline =
+ _now.millisecondsSinceEpoch - const Duration(days: 2).inMilliseconds;
+ final many =
+ _now.millisecondsSinceEpoch - const Duration(minutes: 1).inMilliseconds;
return [
- _machine('m1', 'MacBook Pro (Local)', 'owner', ['claude', 'codex'], live, false),
- _machine('m2', "Diego's Mac", 'collab', ['claude', 'codex'], offline, false),
+ _machine(
+ 'm1',
+ 'MacBook Pro (Local)',
+ 'owner',
+ ['claude', 'codex'],
+ live,
+ false,
+ ),
+ _machine(
+ 'm2',
+ "Diego's Mac",
+ 'collab',
+ ['claude', 'codex'],
+ offline,
+ false,
+ ),
_machine('m3', 'Build Farm', 'owner', ['claude', 'codex'], many, true),
];
}
@@ -275,40 +440,150 @@ List<Map<String, dynamic>> _conversations(String scenario) {
brief: 'Phase 1 mobile-web redesign of the Super Tab. Audit the current phone experience and propose a mobile-first flow before any production change.',
checks: _checks(),
),
- _conversation('lead-platform', 'project-platform', 0, 'Lead', 'qa', ['qa'],
- brief: 'Mobile platform hardening.'),
- _conversation('lead-on-hold', 'project-empty', 0, 'Lead', null, [],
- brief: 'Paused until the release settles.'),
- _conversation('wg-working', 'project-harness', 1, 'Layout audit', 'builder', ['builder'],
- brief: 'Reproduce the mobile layout in a disposable fixture.',
- task: _task('Capture every Super Tab state on a phone.', 'Add a fixture and screenshots.', 'No production UI change.', ['desktop/tool']),
- assignment: _assignment('attempt-a', 'builder', 'working', 'Fixture built; capturing widths.'),
- checks: _checks()),
- _conversation('wg-needs-human', 'project-harness', 2, 'Owner decision', 'designer', ['designer'],
- brief: 'Pick a mobile navigation pattern before the mockup.',
- task: _task('Choose the bottom-sheet pattern.', 'Present two options.', 'Keep 44px targets.', ['web']),
- assignment: _assignment('attempt-b', 'designer', 'needs_human', 'Need a decision on the bottom sheet.'),
- checks: _checks()),
- _conversation('wg-blocked', 'project-harness', 3, 'Flutter web render', 'builder', ['builder'],
- brief: 'CanvasKit text measurement differs at 320px.',
- task: _task('Investigate CanvasKit text overflow.', 'Reproduce on 320px.', 'No production change.', ['desktop/lib/super_tabs']),
- assignment: _assignment('attempt-c', 'builder', 'blocked', 'Cannot reproduce outside a real device.'),
- checks: _checks()),
- _conversation('wg-review', 'project-harness', 4, 'Composer patch', 'builder', ['builder'],
- brief: 'A width fix for the composer.',
- task: _task('Review the composer width fix.', 'Send a small patch.', 'Do not regress desktop.', ['desktop/lib/super_tabs/view.dart']),
- assignment: _assignment('attempt-d', 'builder', 'review', 'Patch open for review.'),
- checks: _checks()),
- _conversation('wg-done', 'project-harness', 5, 'Accessibility pass', 'designer', ['designer'],
- brief: 'Touch targets on a phone.',
- task: _task('Audit touch targets.', 'List and fix below 44px.', 'Web only.', ['web']),
- assignment: _assignment('attempt-e', 'designer', 'done', 'All targets at or above 44px.'),
- checks: _checks()),
- _conversation('wg-stopped', 'project-harness', 6, 'Hold notice copy', 'builder', ['builder'],
- brief: 'Waiting-message wording.',
- task: _task('Tune the waiting message.', 'Shorten two lines.', 'Keep the reason.', ['backend']),
- assignment: _assignment('attempt-f', 'builder', 'stopped', 'Out of scope for this phase.'),
- checks: _checks()),
+ _conversation('lead-platform', 'project-platform', 0, 'Lead', 'qa', [
+ 'qa',
+ ], brief: 'Mobile platform hardening.'),
+ _conversation(
+ 'lead-on-hold',
+ 'project-empty',
+ 0,
+ 'Lead',
+ null,
+ [],
+ brief: 'Paused until the release settles.',
+ ),
+ _conversation(
+ 'wg-working',
+ 'project-harness',
+ 1,
+ 'Layout audit',
+ 'builder',
+ ['builder'],
+ brief: 'Reproduce the mobile layout in a disposable fixture.',
+ task: _task(
+ 'Capture every Super Tab state on a phone.',
+ 'Add a fixture and screenshots.',
+ 'No production UI change.',
+ ['desktop/tool'],
+ ),
+ assignment: _assignment(
+ 'attempt-a',
+ 'builder',
+ 'working',
+ 'Fixture built; capturing widths.',
+ ),
+ checks: _checks(),
+ ),
+ _conversation(
+ 'wg-needs-human',
+ 'project-harness',
+ 2,
+ 'Owner decision',
+ 'designer',
+ ['designer'],
+ brief: 'Pick a mobile navigation pattern before the mockup.',
+ task: _task(
+ 'Choose the bottom-sheet pattern.',
+ 'Present two options.',
+ 'Keep 44px targets.',
+ ['web'],
+ ),
+ assignment: _assignment(
+ 'attempt-b',
+ 'designer',
+ 'needs_human',
+ 'Need a decision on the bottom sheet.',
+ ),
+ checks: _checks(),
+ ),
+ _conversation(
+ 'wg-blocked',
+ 'project-harness',
+ 3,
+ 'Flutter web render',
+ 'builder',
+ ['builder'],
+ brief: 'CanvasKit text measurement differs at 320px.',
+ task: _task(
+ 'Investigate CanvasKit text overflow.',
+ 'Reproduce on 320px.',
+ 'No production change.',
+ ['desktop/lib/super_tabs'],
+ ),
+ assignment: _assignment(
+ 'attempt-c',
+ 'builder',
+ 'blocked',
+ 'Cannot reproduce outside a real device.',
+ ),
+ checks: _checks(),
+ ),
+ _conversation(
+ 'wg-review',
+ 'project-harness',
+ 4,
+ 'Composer patch',
+ 'builder',
+ ['builder'],
+ brief: 'A width fix for the composer.',
+ task: _task(
+ 'Review the composer width fix.',
+ 'Send a small patch.',
+ 'Do not regress desktop.',
+ ['desktop/lib/super_tabs/view.dart'],
+ ),
+ assignment: _assignment(
+ 'attempt-d',
+ 'builder',
+ 'review',
+ 'Patch open for review.',
+ ),
+ checks: _checks(),
+ ),
+ _conversation(
+ 'wg-done',
+ 'project-harness',
+ 5,
+ 'Accessibility pass',
+ 'designer',
+ ['designer'],
+ brief: 'Touch targets on a phone.',
+ task: _task(
+ 'Audit touch targets.',
+ 'List and fix below 44px.',
+ 'Web only.',
+ ['web'],
+ ),
+ assignment: _assignment(
+ 'attempt-e',
+ 'designer',
+ 'done',
+ 'All targets at or above 44px.',
+ ),
+ checks: _checks(),
+ ),
+ _conversation(
+ 'wg-stopped',
+ 'project-harness',
+ 6,
+ 'Hold notice copy',
+ 'builder',
+ ['builder'],
+ brief: 'Waiting-message wording.',
+ task: _task(
+ 'Tune the waiting message.',
+ 'Shorten two lines.',
+ 'Keep the reason.',
+ ['backend'],
+ ),
+ assignment: _assignment(
+ 'attempt-f',
+ 'builder',
+ 'stopped',
+ 'Out of scope for this phase.',
+ ),
+ checks: _checks(),
+ ),
];
if (scenario == 'empty') return <Map<String, dynamic>>[];
if (scenario == 'one') return [all.first];
@@ -341,23 +616,54 @@ Map<String, dynamic> _conversation(
'lastMessageSequence': 100,
};
-Map<String, dynamic> _task(String goal, String changes, String constraints, List<String> owns) =>
- {'goal': goal, 'changes': changes, 'constraints': constraints, 'owns': owns};
+Map<String, dynamic> _task(
+ String goal,
+ String changes,
+ String constraints,
+ List<String> owns,
+) => {
+ 'goal': goal,
+ 'changes': changes,
+ 'constraints': constraints,
+ 'owns': owns,
+};
-Map<String, dynamic> _assignment(String id, String agentId, String status, String result) =>
- {
- 'id': id,
- 'agentId': agentId,
- 'status': status,
- 'result': result,
- 'configuration': {'engine': 'codex'},
- 'execution': {'machineId': 'm1', 'harnessId': 'h-builder'},
- };
+Map<String, dynamic> _assignment(
+ String id,
+ String agentId,
+ String status,
+ String result,
+) => {
+ 'id': id,
+ 'agentId': agentId,
+ 'status': status,
+ 'result': result,
+ 'configuration': {'engine': 'codex'},
+ 'execution': {'machineId': 'm1', 'harnessId': 'h-builder'},
+};
List<Map<String, dynamic>> _checks() => [
- {'id': 'check-1', 'description': 'Fixture covers every listed case.', 'independent': false, 'evidence': 'Screenshots at 320/375/390/1440px.', 'passedBy': 'owner'},
- {'id': 'check-2', 'description': 'Every problem has a severity and a why.', 'independent': true, 'evidence': null, 'passedBy': null},
- {'id': 'check-3', 'description': 'Mockup keeps 44px touch targets.', 'independent': false, 'evidence': 'Height audit in the review page.', 'passedBy': 'designer'},
+ {
+ 'id': 'check-1',
+ 'description': 'Fixture covers every listed case.',
+ 'independent': false,
+ 'evidence': 'Screenshots at 320/375/390/1440px.',
+ 'passedBy': 'owner',
+ },
+ {
+ 'id': 'check-2',
+ 'description': 'Every problem has a severity and a why.',
+ 'independent': true,
+ 'evidence': null,
+ 'passedBy': null,
+ },
+ {
+ 'id': 'check-3',
+ 'description': 'Mockup keeps 44px touch targets.',
+ 'independent': false,
+ 'evidence': 'Height audit in the review page.',
+ 'passedBy': 'designer',
+ },
];
List<String> _groupIds(String scenario) {
@@ -377,11 +683,15 @@ List<Map<String, dynamic>> _messages(String scenario) {
if (scenario == 'empty') return <Map<String, dynamic>>[];
final lead = <Map<String, dynamic>>[];
var seq = 1;
- void add(String conversationId, Map<String, dynamic> author, String text,
- {Map<String, dynamic>? source,
- List<Map<String, dynamic>> attachments = const [],
- List<Map<String, dynamic>> deliveries = const [],
- String? replyTo}) {
+ void add(
+ String conversationId,
+ Map<String, dynamic> author,
+ String text, {
+ Map<String, dynamic>? source,
+ List<Map<String, dynamic>> attachments = const [],
+ List<Map<String, dynamic>> deliveries = const [],
+ String? replyTo,
+ }) {
lead.add({
'id': '$conversationId-$seq',
'conversationId': conversationId,
@@ -408,61 +718,126 @@ List<Map<String, dynamic>> _messages(String scenario) {
'name': 'Builder',
'displayName': 'Lark',
};
- const owner = {'kind': 'person', 'id': 'owner', 'name': '[email protected]'};
+ const owner = {
+ 'kind': 'person',
+ 'id': 'owner',
+ 'name': '[email protected]',
+ };
- add('lead', leadAgent,
- '**Phase 1 plan**\n\nHere is the mobile-web breakdown:\n\n- Build a no-login fixture from fake data\n- Capture every screen at **320 / 375 / 390 / 1440 px**\n- List concrete phone problems with a severity\n- Propose a mobile-first flow\n\n| Width | Target |\n| --- | --- |\n| Phone | 44px tap targets |\n| Desktop | unchanged |\n\nOpen https://github.com/autonomous-ai/harness/pull/1543');
- add('lead', builder,
- '```dart\nfinal width = MediaQuery.sizeOf(context).width;\nfinal narrow = width < 720;\nreturn narrow ? const PhoneLayout() : const DesktopLayout();\n```');
- add('lead', builder, 'Here is the fixture screenshot at 375px.',
- attachments: [
- {'id': 'att-img', 'name': 'fixture-375.png', 'mime': 'image/png', 'size': 64000, 'url': 'https://cdn.harness.local/fixture-375.png'},
- ]);
- add('lead', builder, 'And the release notes.',
- attachments: [
- {'id': 'att-pdf', 'name': 'mobile-audit.pdf', 'mime': 'application/pdf', 'size': 218000, 'url': 'https://cdn.harness.local/mobile-audit.pdf'},
- ]);
+ add(
+ 'lead',
+ leadAgent,
+ '**Phase 1 plan**\n\nHere is the mobile-web breakdown:\n\n- Build a no-login fixture from fake data\n- Capture every screen at **320 / 375 / 390 / 1440 px**\n- List concrete phone problems with a severity\n- Propose a mobile-first flow\n\n| Width | Target |\n| --- | --- |\n| Phone | 44px tap targets |\n| Desktop | unchanged |\n\nOpen https://github.com/autonomous-ai/harness/pull/1543',
+ );
+ add(
+ 'lead',
+ builder,
+ '```dart\nfinal width = MediaQuery.sizeOf(context).width;\nfinal narrow = width < 720;\nreturn narrow ? const PhoneLayout() : const DesktopLayout();\n```',
+ );
+ add(
+ 'lead',
+ builder,
+ 'Here is the fixture screenshot at 375px.',
+ attachments: [
+ {
+ 'id': 'att-img',
+ 'name': 'fixture-375.png',
+ 'mime': 'image/png',
+ 'size': 64000,
+ 'url': 'https://cdn.harness.local/fixture-375.png',
+ },
+ ],
+ );
+ add(
+ 'lead',
+ builder,
+ 'And the release notes.',
+ attachments: [
+ {
+ 'id': 'att-pdf',
+ 'name': 'mobile-audit.pdf',
+ 'mime': 'application/pdf',
+ 'size': 218000,
+ 'url': 'https://cdn.harness.local/mobile-audit.pdf',
+ },
+ ],
+ );
add('lead', owner, 'Thanks, starting the 320px pass now.', replyTo: 'lead-1');
- add('lead', leadAgent,
- 'Routed to Builder · Codex gpt-5 high · MacBook Pro (Local) — only candidate · "Full fake Super Tab data"',
- source: {
- 'kind': 'route',
- 'decisionId': 'decision-1',
- 'via': 'only',
- 'why': 'Flutter fixture with full fake data',
- 'pick': {'id': 'builder', 'title': 'Builder · Codex gpt-5 high · MacBook Pro (Local)'},
- 'alternatives': <Object>[],
- });
- // The newest own message carries a held delivery so the hold notice renders.
- add('lead', owner, 'Can you run the 320px pass now?', deliveries: [
- {
- 'id': 'delivery-1',
- 'agentId': 'idle-lead',
- 'status': 'queued',
- 'holdReason': 'team_waiting_idle',
- 'holdSince': _now.subtract(const Duration(seconds: 35)).toIso8601String(),
+ add(
+ 'lead',
+ leadAgent,
+ 'Routed to Builder · Codex gpt-5 high · MacBook Pro (Local) — only candidate · "Full fake Super Tab data"',
+ source: {
+ 'kind': 'route',
+ 'decisionId': 'decision-1',
+ 'via': 'only',
+ 'why': 'Flutter fixture with full fake data',
+ 'pick': {
+ 'id': 'builder',
+ 'title': 'Builder · Codex gpt-5 high · MacBook Pro (Local)',
+ },
+ 'alternatives': <Object>[],
},
- ]);
+ );
+ // The newest own message carries a held delivery so the hold notice renders.
+ add(
+ 'lead',
+ owner,
+ 'Can you run the 320px pass now?',
+ deliveries: [
+ {
+ 'id': 'delivery-1',
+ 'agentId': 'idle-lead',
+ 'status': 'queued',
+ 'holdReason': 'team_waiting_idle',
+ 'holdSince': _now
+ .subtract(const Duration(seconds: 35))
+ .toIso8601String(),
+ },
+ ],
+ );
if (scenario == 'one') return lead;
- add('wg-working', builder,
- 'Working through the fixture. All four widths render from one dataset.\n\nhttps://github.com/autonomous-ai/harness/pull/1543');
- add('wg-needs-human', builder,
- 'Routed to Designer · Claude sonnet xhigh · Diego\'s Mac — only available candidate\n\nNeed a decision.',
- source: {
- 'kind': 'route',
- 'decisionId': 'decision-2',
- 'via': 'only',
- 'why': 'Bottom sheet pattern choice',
- 'pick': {'id': 'designer', 'title': 'Designer · Claude sonnet xhigh · Diego\'s Mac'},
- 'alternatives': <Object>[],
- });
- add('wg-blocked', builder, 'Blocked: cannot reproduce the overflow outside a real device.');
- add('wg-blocked', owner, 'I tried resending the patch.', deliveries: [
- {'id': 'delivery-fail', 'agentId': 'builder', 'status': 'uncertain'},
- ]);
- add('wg-review', builder, 'Reviewing the composer width patch.\n\nhttps://github.com/autonomous-ai/harness/pull/1543');
+ add(
+ 'wg-working',
+ builder,
+ 'Working through the fixture. All four widths render from one dataset.\n\nhttps://github.com/autonomous-ai/harness/pull/1543',
+ );
+ add(
+ 'wg-needs-human',
+ builder,
+ 'Routed to Designer · Claude sonnet xhigh · Diego\'s Mac — only available candidate\n\nNeed a decision.',
+ source: {
+ 'kind': 'route',
+ 'decisionId': 'decision-2',
+ 'via': 'only',
+ 'why': 'Bottom sheet pattern choice',
+ 'pick': {
+ 'id': 'designer',
+ 'title': 'Designer · Claude sonnet xhigh · Diego\'s Mac',
+ },
+ 'alternatives': <Object>[],
+ },
+ );
+ add(
+ 'wg-blocked',
+ builder,
+ 'Blocked: cannot reproduce the overflow outside a real device.',
+ );
+ add(
+ 'wg-blocked',
+ owner,
+ 'I tried resending the patch.',
+ deliveries: [
+ {'id': 'delivery-fail', 'agentId': 'builder', 'status': 'uncertain'},
+ ],
+ );
+ add(
+ 'wg-review',
+ builder,
+ 'Reviewing the composer width patch.\n\nhttps://github.com/autonomous-ai/harness/pull/1543',
+ );
add('wg-done', builder, 'Done. All targets measured at 44px.');
add('wg-stopped', builder, 'Stopped: out of scope for this phase.');
return lead;
diff --git a/docs/plans/2026-11-02-quiet-swarm-activity-plan.md b/docs/plans/2026-11-02-quiet-swarm-activity-plan.md
new file mode 100644
index 000000000..0d413bc0d
--- /dev/null
+++ b/docs/plans/2026-11-02-quiet-swarm-activity-plan.md
@@ -0,0 +1,101 @@
+# Quiet Swarm 4/6: Activity takes in Threads Implementation Plan
+
+> **For agentic workers:** Work this plan task by task, test first: each failing test is committed before its code (project instructions, Engineer). The header names this way of working, not subagent-driven-development, and there is no execution handoff.
+
+**Goal:** Activity becomes the one place for everything new for the reader: Needs you, New replies, Done today, one line per row, a number that counts only Needs you; the Threads row and view go.
+
+**Architecture:** `SuperTabActivity` (activity.dart) stops being a feed of replies and reactions and becomes three derived lists over data Desktop already holds: open decisions, agents waiting and unanswered tags (Needs you); the followed threads with unread replies, taken from `SuperTabAttention` (New replies); and tasks shipped today (Done today). `SuperTabActivityView` draws them as one-line rows; the Threads view (threads_view.dart) and the parts of attention.dart only it used are deleted. Done today needs the time a task shipped, which the server keeps in the group's ledger and does not send, so the conversation read adds `shippedAt`.
+
+**Tech Stack:** Flutter/Dart (desktop/), TypeScript (backend/src/superTabs/read/views.ts, one field).
+
+**Spec:** docs/plans/2026-11-02-quiet-swarm-design.md (rules "Activity is the one place…", screens 6 and 11b; "What moves where": Activity with 36, and the Threads view).
+
+## Global Constraints
+
+- "Activity is the one place for everything new for you: Needs you, New replies (the old Threads view), Done today. No filter pills; every row one line."
+- "Activity's number counts only what needs you."
+- "Something new makes a row bold, with no dot."
+- "More words: no. Headings, names and one status word; reasons go in tooltips." No new colors, icons or controls outside desktop/design/desktop-design-system.md.
+- Keep #2618's rule: leaving Activity marks read only what the visit showed.
+- No on/off switch: it ships on. Swarm code stays out of cli/src/core. Tests use a memory store and a fake sign-in.
+- Screen 6 rows: `◐ <question> Answer`, `◐ <agent> is waiting on you Open`, `@ <author> mentioned you in # <project> <time>`, `<thread> N new`, `✓ <task> <time>`. Screen 11b: "You're all caught up."
+
+## Review Focus
+
+- The Activity number must not count New replies, Done today or reactions; it must clear as the reader answers.
+- A thread that is read while the view is open stays bold until the view is left (no row vanishing under the pointer).
+- Leaving Activity must send no read mark for rows it did not show (reactions, other threads, older pages).
+- A very long question, thread or task name stays on one line (ellipsis); the time never wraps.
+- Work finished yesterday, a private task and a task with no ship time never appear in Done today.
+- An older server that does not send `shippedAt`: Done today is empty, the rest works.
+
+---
+
+### Task 1: Done today needs the time a task shipped
+
+**Files:**
+- Modify: `backend/src/superTabs/read/views.ts:64` (send `shippedAt` from the ledger)
+- Modify: `desktop/lib/super_tabs/model.dart` (`SuperTabConversation.shippedAt`)
+- Test: `backend/src/superTabs/read/views.test.ts` (or the nearest existing view test), `desktop/test/super_tab_activity_test.dart`
+
+**Interfaces:**
+- Produces: conversation row `shippedAt: number | undefined` (ms since epoch; `ledger.shipPostedAt ?? ledger.shippedAt`); Dart `DateTime? SuperTabConversation.shippedAt`.
+
+- [ ] **Step 1: Failing test** — a group whose ledger has `shipPostedAt` reads back `shippedAt`; one with only `shippedAt` reads that; one with neither has no key; a private group's row is unchanged for readers outside its audience.
+- [ ] **Step 2: Run it** — `cd backend && npx vitest run src/superTabs/read` fails.
+- [ ] **Step 3: Implement** in `views.ts` next to the ledger strip; parse `shippedAt` in `SuperTabConversation.fromJson` (num → `DateTime`, absent → null).
+- [ ] **Step 4: Run** the backend tests and the Super Tab integration suite, then the Dart model test.
+- [ ] **Step 5: Commit.**
+
+### Task 2: Activity is three lists and a count
+
+**Files:**
+- Modify: `desktop/lib/super_tabs/activity.dart` (drop the replies/reactions feed, filter and its read mark; add the lists)
+- Test: `desktop/test/super_tab_activity_test.dart` (rewritten), `desktop/test/super_tab_backend_transport_test.dart` (feed cases removed)
+
+**Interfaces:**
+- Produces:
+ - `List<SuperTabNeed> SuperTabActivity.needsYou` — decisions asked of the reader (`SuperTabNeedKind.decision`), agents waiting on them (`agent`: a task whose status waits on a person and is not already an open decision), tags waiting on them (`mention`); newest first.
+ - `List<SuperTabFollowedThread> SuperTabActivity.newReplies` — `SuperTabAttention.unread` plus threads read during this visit.
+ - `List<SuperTabConversation> SuperTabActivity.doneToday` — tasks (no steps, no Buddy chats) whose `shippedAt` is today in the reader's time zone, newest first.
+ - `int count` = `needsYou.length`; `bool unread` = `needsYou.isNotEmpty || newReplies.isNotEmpty`.
+ - `opened()` / `closed()` keep their names; `closed()` sends no read request.
+
+- [ ] **Step 1: Failing tests** (names are the assertions): `count counts only Needs you` (a reply, a reaction, a done task add nothing); `Needs you lists a decision, a waiting agent and a tag, newest first, a decision's agent once`; `New replies lists the followed threads with unread replies`; `Done today lists what shipped today, not yesterday, not a step, not a private task of someone else's`; `unread is bold for new replies alone`; `leaving sends no read request`.
+- [ ] **Step 2: Run** `flutter test test/super_tab_activity_test.dart` — fails (no `needsYou`).
+- [ ] **Step 3: Implement** the lists as getters over `decisions.open`, the snapshot's waiting tasks, `mentions.waiting`, `SuperTabAttention.of(controller)` and `doneToday`; delete `items`, `filter`, `_markShownRead`, the `/activity` reads and their digest handling.
+- [ ] **Step 4: Run** the file, `flutter analyze`.
+- [ ] **Step 5: Commit.**
+
+### Task 3: The Activity view
+
+**Files:**
+- Modify: `desktop/lib/super_tabs/activity_view.dart`
+- Test: `desktop/test/super_tab_activity_view_test.dart` (new), `desktop/test/super_tab_activity_shots_test.dart` (pictures of screens 6 and 11b)
+
+**Interfaces:**
+- Consumes: Task 2's lists.
+- Produces: `SuperTabActivityView({activity, onOpenMention, onOpenThread(conversationId, rootId), onOpenConversation(conversationId), now})`.
+
+- [ ] **Step 1: Failing widget tests**: three headings in order and no filter pills; every row is one line at 480 px wide and with long names (no wrap, ellipsis); a decision row says `Answer` and opens its card inline; an agent row says `Open`; a tag row shows `<author> mentioned you in # <project>` and its time; a thread row shows `N new`; a done row shows `✓` and the time; rows with something new are bold, others not; empty is `You're all caught up.` with no headings; a thread read during the visit stays bold until the view is left.
+- [ ] **Step 2: Run** — fails.
+- [ ] **Step 3: Implement** with the existing `DesktopChrome`/`grid` tokens: one `_row` of a single `Row` (leading mark, `Expanded` ellipsised title, trailing word or time); section headings via `SuperTabSectionHeading`; decision rows expand `SuperTabDecisionCard`.
+- [ ] **Step 4: Run** the new tests and the pictures (`ACTIVITY_SHOTS=<dir>`).
+- [ ] **Step 5: Commit.**
+
+### Task 4: The Threads row and view go
+
+**Files:**
+- Delete: `desktop/lib/super_tabs/threads_view.dart`, and the tests that only drew it (`super_tab_threads_test.dart`, `super_tab_threads_shots_test.dart`)
+- Modify: `desktop/lib/super_tabs/view.dart` (no `_showThreads`, no `SuperTabThreadsView`, Activity gets `onOpenThread`/`onOpenConversation`, the catch-up card's counts open Activity), `desktop/lib/super_tabs/project_sidebar.dart` (no Threads row or its params), `desktop/lib/super_tabs/attention.dart` (drop what only the Threads view used: own replies, new-reply reads, Follow toggles), their tests
+- Test: `desktop/test/super_tab_attention_test.dart`, `super_tab_catch_up_test.dart`, `super_tab_one_buddy_test.dart`
+
+- [ ] **Step 1: Failing tests**: the sidebar has an Activity row and no Threads row; the red number on a project row still counts tags in its chat (unchanged); the catch-up card's decision and tag counts open Activity; a thread row opens that thread in its chat.
+- [ ] **Step 2: Run** — fails.
+- [ ] **Step 3: Implement** the deletions and wiring; keep `mentionsIn`, `threadMentions` and the unread-thread read that the sidebar and Activity use.
+- [ ] **Step 4: Run** every test file that mentions Activity, attention, threads or the sidebar, and `flutter analyze`.
+- [ ] **Step 5: Commit.**
+
+### Task 5: Pictures and the PR
+
+- [ ] Screens 6 and 11b from a browser build on made-up data in the PR; red/green and the suites in PR comments; rebase on main.
diff --git a/docs/plans/2026-11-02-quiet-swarm-activity-shots/11b-caught-up-dark.png b/docs/plans/2026-11-02-quiet-swarm-activity-shots/11b-caught-up-dark.png
new file mode 100644
index 000000000..a47bcbd2b
Binary files /dev/null and b/docs/plans/2026-11-02-quiet-swarm-activity-shots/11b-caught-up-dark.png differ
diff --git a/docs/plans/2026-11-02-quiet-swarm-activity-shots/11b-caught-up-light.png b/docs/plans/2026-11-02-quiet-swarm-activity-shots/11b-caught-up-light.png
new file mode 100644
index 000000000..a9c6749cd
Binary files /dev/null and b/docs/plans/2026-11-02-quiet-swarm-activity-shots/11b-caught-up-light.png differ
diff --git a/docs/plans/2026-11-02-quiet-swarm-activity-shots/6-activity-dark.png b/docs/plans/2026-11-02-quiet-swarm-activity-shots/6-activity-dark.png
new file mode 100644
index 000000000..d58a23aaa
Binary files /dev/null and b/docs/plans/2026-11-02-quiet-swarm-activity-shots/6-activity-dark.png differ
diff --git a/docs/plans/2026-11-02-quiet-swarm-activity-shots/6-activity-light.png b/docs/plans/2026-11-02-quiet-swarm-activity-shots/6-activity-light.png
new file mode 100644
index 000000000..65594f8bb
Binary files /dev/null and b/docs/plans/2026-11-02-quiet-swarm-activity-shots/6-activity-light.png differ
diff --git a/docs/plans/2026-11-02-quiet-swarm-task-line-plan.md b/docs/plans/2026-11-02-quiet-swarm-task-line-plan.md
new file mode 100644
index 000000000..3e3252ccb
--- /dev/null
+++ b/docs/plans/2026-11-02-quiet-swarm-task-line-plan.md
@@ -0,0 +1,153 @@
+# Quiet Swarm 2/6: one server message per task — Implementation Plan
+
+> Worked by the project instructions' Engineer role (revision 26): this plan's tasks are implemented in order, test first,
+> by the Engineer that wrote it; the Review step on the pull request is the one independent review.
+
+**Goal:** For each task that has an Engineer, the server posts one message in its project chat and edits it in place as
+the task moves (planned, working, waiting on a person, in review, shipped); it replaces the Shipped line.
+
+**Architecture:** A pure function (`taskLine.ts`) runs after every command: it compares each work group's drawn line
+(state, person asked, title, Engineer) with the one it last drew (`cards.line`) and either posts the line's first message
+in the project chat or edits that message. Edits are a new `CommandEffects.edits` list the store writes as row updates;
+the project chat's `reactionSeq` moves with each edit, so every reader already polling for reaction changes (Desktop,
+phone, older releases) reads the page again and sees the new words. A private conversation is chat only (it never holds
+work), so a private task is a task of a private project: its line is posted in that project's own chat, which only the
+project's readers read; a group with an audience never gets a line.
+
+**Tech Stack:** TypeScript, Prisma on MongoDB, vitest (unit), MongoMemoryReplSet (integration).
+
+**Spec:** [2026-11-02-quiet-swarm-design.md](2026-11-02-quiet-swarm-design.md) (Screens 1, 2, 3; "Calls made by the PM",
+first bullet). Task #2191's brief.
+
+## Global Constraints
+
+- The PR body starts with: Requested by [email protected] through Harness.
+- Swarm code stays out of cli/src/core. No on/off switch: it ships on.
+- Stay inside backend/src/superTabs, its tests and the wire format; Desktop and phone draw it (parts 3/6 and the phone pass).
+- Fewer words: the line's text is the task's name and one status word.
+- Full backend Super Tab integration suite (`npm run test:super-tabs` in backend) passes before Ready.
+
+## Wire format (agreed with part 3/6)
+
+A project-chat message, `source`:
+
+```
+{ kind: 'task-line', taskId: string, number?: number, title: string,
+ state: 'planned' | 'working' | 'waiting' | 'review' | 'ready' | 'shipped' | 'done' | 'stopped',
+ answerFor?: string, // the asked person's id, only while waiting
+ builderId: string, // the task's Engineer (its assignment's agent)
+ requesterId?: string } // who asked for it, when recorded
+```
+
+- `text` is `<title> · <word>` (`planned`, `working`, `waiting on <username>`, `in review`, `shipped`, `stopped`), so an
+ older client reads a current line. New clients draw from `source` and open `taskId` on the right.
+- The message keeps its id through every edit; its author is the project's coordinator (else whoever caused the post).
+- No recipients and no deliveries: it wakes nobody.
+- `stopped` (cancelled, or stopped and not shipped) is the one state the design does not draw; part 3/6 shows it with
+ the same one-word style.
+
+## State rules
+
+| Group now | `state` |
+| --- | --- |
+| assigned, its agent has sent no status on this line yet | `planned` |
+| working, blocked, reconciling, lost | `working` |
+| needs_human | `waiting` (`answerFor` = `assignment.askedOf` when set) |
+| review | `review` |
+| a merge recorded (`ledger.mergedAt`, by `conversation.merged`), no active work | `shipped` |
+| done with a linked pull request, no merge recorded yet | `ready` |
+| done with no pull request (a review task) | `done` |
+| cancelled / stopped, never merged | `stopped` |
+
+PM's calls on the review of #2633: shipped only once a merge is recorded, never on Done alone; the requester's Buddy
+hears it then, once. An edit only when the line's words change is accepted as the rate limit.
+
+A line exists only for a top-level work group of a project (not a step or `reviewOf` group, not the project chat, not a
+Buddy chat, not Leads) and is first posted on a command that changes its assignment. Older tasks get theirs at their next
+change; finished tasks never get one.
+
+## Design
+
+- growth: one message per task, deleted with its project chat; `cards.line` is a few fields per group.
+- concurrency: the line is written in the command's transaction; posting or editing writes the project chat's group part,
+ as the Shipped line did, so it locks at the group part like every chat post.
+- read cost: no new read. Edits move `reactionSeq`; readers read only the page they show, as for a reaction.
+- scale: at 10x tasks, edits stay one row update per state change (at most about six per task). First warning:
+ page re-reads per poll (messageReadStats) on project chats.
+- rate: an edit is written only when the line's words change (state, person asked, title, Engineer), never for a repeated
+ status or a progress note, so a task's line is edited at most once per state change and never by a plain message.
+- compatibility: older clients read `text` and refresh on `reactionSeq`; an unknown kind reads as people's.
+- migration + rollback: none stored ahead; open tasks get a line on their next change. Rolling back leaves lines as plain
+ messages and the Shipped line returns.
+- audience: the line is a row of its task's project chat, so the server's project read check decides who reads it; a
+ private project's line is read only by that project's readers, and a private conversation (chat only) gets none.
+- identity: authored by the project's coordinator agent, never a machine owner's login.
+- failure: the post and edit are in the command's transaction; a failed write fails the command and retries.
+- platforms: backend only; Desktop and phone draw `source`.
+
+## Review Focus
+
+1. A private project's task line must never show to a Swarm member outside that project, on any read: pinned by the
+ integration test reading every project chat page the outsider can read.
+2. A status repeated (working → working with a new note) must not edit or bump anything.
+3. A reassigned task (lost, then a new Engineer) keeps its one line, never a second.
+4. A step (review or test) of a task gets no line, and its statuses do not change its task's line.
+5. A task renamed or answered changes the line's words; the person asked shows only while waiting.
+
+---
+
+### Task 1: The drawn line and its sync (pure)
+
+**Files:**
+- Create: `backend/src/superTabs/taskLine.ts`
+- Modify: `backend/src/superTabs/cards.ts` (`GroupCards.line`), `backend/src/superTabs/model.ts` (`CommandEffects.edits`,
+ `NOTICE_READERS['task-line']`), `backend/src/superTabs/commands.ts` (`applyCommand` runs `syncTaskLines` on every
+ return; the Shipped line is no longer written), `backend/src/superTabs/buddyNews.ts` (`shippedNotice`: the requester's
+ Buddy still hears that their work shipped, as the Shipped line told it)
+- Test: `backend/src/superTabs/taskLine.test.ts`
+
+**Interfaces:**
+- Produces:
+ - `TASK_LINE_KIND = 'task-line'`
+ - `type TaskLineState = 'planned' | 'working' | 'waiting' | 'review' | 'shipped' | 'stopped'`
+ - `interface TaskLine { messageId: string; state: TaskLineState; title: string; builderId: string; answerFor?: string; reported?: string }` (stored at `group.cards.line`; `reported`: the assignment whose agent has sent a status)
+ - `interface MessageEdit { id: string; conversationId: string; text: string; source: Record<string, unknown> }`
+ - `CommandEffects.edits?: MessageEdit[]`
+ - `syncTaskLines(before: SuperTabState, effects: CommandEffects, reported: string | undefined, sender: Author | undefined, operationId: string): void`
+ (`reported`: the group whose agent sent a `work.status` in this command)
+
+- [ ] **Step 1: Write the failing tests** (`taskLine.test.ts`, through `applyCommand` on the commands.test fixtures)
+ - `posts one line in the project chat when a task is assigned`: kind `task-line`, `state: 'planned'`, `taskId`, text `<title> · planned`, no recipients.
+ - `edits the same line through working, waiting, review and shipped`: `effects.edits` names the first message's id each time; `answerFor` is the asked person while waiting and absent after; the project chat's `reactionSeq` moves by one per edit.
+ - `writes no Shipped line for a task with a line`.
+ - `does not edit for a repeated status or a plain message`.
+ - `gives a step no line and leaves its task's line alone`.
+ - `keeps one line through a lost task reassigned`.
+ - `follows a rename of the task`.
+ - `posts a private project's task line in that project's own chat`.
+ - `posts nothing for a task that existed before lines until it changes`.
+- [ ] **Step 2: Run** `cd backend && npx vitest run src/superTabs/taskLine.test.ts` — Expected: FAIL (module missing).
+- [ ] **Step 3: Commit the failing tests.**
+- [ ] **Step 4: Implement** `taskLine.ts`, wire it into `applyCommand` (rename the body `applyCommandOnce`), add
+ `edits` in `model.ts`, drop `shipNotice` and send `shippedNotice` instead.
+- [ ] **Step 5: Run** the unit file plus `src/superTabs/commands.test.ts src/superTabs/ship.test.ts src/superTabs/notices.test.ts` — Expected: PASS.
+- [ ] **Step 6: Commit.**
+
+### Task 2: The store writes edits
+
+**Files:**
+- Modify: `backend/src/superTabs/store.ts` (write `effects.edits` after `writeMessages`), `backend/vitest.super-tabs.config.ts`
+- Test: `backend/integration/superTabTaskLines.test.ts`
+
+**Interfaces:**
+- Consumes: `CommandEffects.edits` (Task 1).
+
+- [ ] **Step 1: Write the failing integration tests** (MongoMemoryReplSet, as superTabWorkflow.test.ts)
+ - `one message per task with an Engineer, edited through each state`: the project chat's page holds one `task-line` row for the task whose `source.state`/`text` read planned → working → waiting (with `answerFor`) → review → shipped, and the page's `reactionSeq` moved.
+ - `none for steps`: a review step assigned and done adds no row.
+ - `a private task's line only to its audience`: a member of the private project reads it on that project's chat page; a Swarm member outside it reads no `task-line` row on any chat page they can read and is refused the private chat.
+- [ ] **Step 2: Run** `cd backend && npx vitest run --config vitest.super-tabs.config.ts integration/superTabTaskLines.test.ts` — Expected: FAIL.
+- [ ] **Step 3: Commit the failing tests.**
+- [ ] **Step 4: Implement** the edit write (`updateMany` by tab, conversation and id).
+- [ ] **Step 5: Run** the new file, then the full `npm run test:super-tabs` and `npx tsc --noEmit` — Expected: PASS.
+- [ ] **Step 6: Commit and push; post red/green evidence on the PR.**