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.

fix: distinguish personal approvals from Buddy proposals in Tasks (#3454)

harness-for-autonomous[bot]aef31e41e8fb
diff --git a/backend/integration/superTabProposalCards.test.ts b/backend/integration/superTabProposalCards.test.ts
index cbc24252f..332b139a3 100644
--- a/backend/integration/superTabProposalCards.test.ts
+++ b/backend/integration/superTabProposalCards.test.ts
@@ -58,7 +58,7 @@ describe('durable proposal cards', () => {
expect((await f.card(id)).taskApproval).toMatchObject({ personId: peer.sub, state: 'proposal' })
f.clock.now += 100
const changed = await read.changes(peer, f.tab, initial.cursor)
- expect(changed).toMatchObject({ reload: false, personalTasks: { reset: false, upserts: [{ id, status: 'proposal' }] } })
+ expect(changed).toMatchObject({ reload: false, personalTasks: { reset: false, upserts: [{ id, status: 'proposal', canApprove: true }] } })
const decision = { type: 'task.reject', conversationId: id, reason: 'Do later' }, operationId = randomUUID()
await expect(f.execute(decision, owner, f.pm, operationId)).rejects.toThrow()
await f.execute(decision, peer, undefined, operationId)
@@ -66,7 +66,7 @@ describe('durable proposal cards', () => {
await expect(f.execute(decision, owner, undefined, operationId)).rejects.toThrow()
f.clock.now = Date.now() + 60_000 // Existing cursors intentionally overlap writes by thirty seconds.
const latest = await read.firstLoad(peer, f.tab)
- expect(latest.personalTasks!.upserts).toContainEqual(expect.objectContaining({ id, status: 'rejected', reason: 'Do later' }))
+ expect(latest.personalTasks!.upserts).toContainEqual(expect.objectContaining({ id, status: 'rejected', reason: 'Do later', canApprove: false }))
f.clock.now += 100
expect(await read.changes(peer, f.tab, latest.cursor)).toMatchObject({ personalTasks: { upserts: [], removed: [] } })
const actorRead = await read.firstLoad(owner, f.tab, f.pm)
diff --git a/backend/src/superTabs/read/personalTasks.test.ts b/backend/src/superTabs/read/personalTasks.test.ts
index 1f55c046a..edc66de30 100644
--- a/backend/src/superTabs/read/personalTasks.test.ts
+++ b/backend/src/superTabs/read/personalTasks.test.ts
@@ -21,6 +21,31 @@ function scene() {
}
describe('personal Tasks summaries', () => {
+ it.each([
+ [undefined, false, false],
+ [undefined, true, false],
+ ['proposal', false, true],
+ ['proposal', true, true],
+ ['approved', false, false],
+ ['rejected', false, false],
+ ] as const)('exposes approval capability for decision %s with Buddy proposal %s as %s', (decision, proposal, canApprove) => {
+ const s = scene(), row = s.stored.groups.find(g => g.key === s.f.web)!, data = row.data!
+ data.assignment = null
+ if (decision) data.taskApproval = { ...data.taskApproval!, state: decision }
+ else delete data.taskApproval
+ if (proposal) data.proposal = { version: 1, text: 'Keep drafts', goal: 'Drafts', why: 'Loss', doneWhen: 'Returns', evidence: ['Repro'], priority: 'P2',
+ createdAt: NOW, questions: [], senders: [{ personId: peer.userId, generation: s.f.state.people.find(p => p.id === peer.userId)!.generation }] }
+ for (const reset of [true, false])
+ expect(personalTasksFor([row], s.view(), peer, reset)!.upserts).toEqual([expect.objectContaining({ id: row.key, canApprove })])
+ })
+ it.each(['foreign', 'stale'])('never exposes an actionable pending approval for a %s membership', kind => {
+ const s = scene(), row = s.stored.groups.find(g => g.key === s.f.web)!, data = row.data!
+ data.assignment = null
+ data.taskApproval = { ...data.taskApproval!, state: 'proposal',
+ ...kind === 'foreign' ? { personId: owner.userId } : { generation: 'previous-membership' } }
+ expect(personalTasksFor([row], s.view(), peer, true)!.upserts).toEqual([])
+ expect(personalTasksFor([row], s.view(), peer, false)).toMatchObject({ upserts: [], removed: [row.key] })
+ })
it('includes only my visible requested tasks and proposals, with project, assigned identity and execution status', () => {
const s = scene(), feed = personalTasksFor(s.stored.groups, s.view(), peer, true)!
expect(feed).toMatchObject({ approvalMode: 'review', reset: true, removed: [] })
diff --git a/backend/src/superTabs/read/personalTasks.ts b/backend/src/superTabs/read/personalTasks.ts
index f187ddfe2..ac46d1a7f 100644
--- a/backend/src/superTabs/read/personalTasks.ts
+++ b/backend/src/superTabs/read/personalTasks.ts
@@ -15,6 +15,7 @@ export interface PersonalTask {
agent: { id: string; name: string; avatar?: AgentView['avatar'] } | null
status: import('../model.js').WorkStatus | 'proposal' | 'rejected'
suggested: boolean
+ canApprove: boolean
reason?: string
}
export interface PersonalTasks {
@@ -51,7 +52,7 @@ export function personalTasksFor(changed: readonly Part[], view: ReaderView, act
const status = approval?.state === 'proposal' || approval?.state === 'rejected' ? approval.state
: group.assignment?.status ?? (group.proposal && !['accept', 'reshape'].includes(group.proposal.decision?.kind ?? '') ? 'proposal' : 'planned')
out.upserts.push({ id: group.id, version: part.version, at: part.changedAt, projectId: project.id, projectName: project.name,
- title: group.title, status, suggested: !group.assignment && !!approval?.suggestedAgentId,
+ title: group.title, status, suggested: !group.assignment && !!approval?.suggestedAgentId, canApprove: approval?.state === 'proposal',
agent: worker ? { id: worker.id, name: worker.displayName ?? worker.name, ...worker.avatar ? { avatar: worker.avatar } : {} } : null,
...approval?.reason ? { reason: approval.reason } : {} })
}
diff --git a/docs/plans/2026-11-07-tasks-can-approve-plan.md b/docs/plans/2026-11-07-tasks-can-approve-plan.md
new file mode 100644
index 000000000..e675c38ba
--- /dev/null
+++ b/docs/plans/2026-11-07-tasks-can-approve-plan.md
@@ -0,0 +1,41 @@
+# Tasks approval capability implementation plan
+
+> Implement natively, task by task, with failing tests committed before code and one independent review.
+
+**Goal:** Let Desktop distinguish a pending personal approval from an ordinary Buddy proposal.
+
+**Architecture:** Add a computed `canApprove` boolean to existing personal Tasks summaries after their existing audience and membership filters. No command or authorization policy changes.
+
+**Tech Stack:** TypeScript, existing parts projection, Vitest.
+
+**Spec:** `docs/specs/2026-11-07-swarm-v3.md`; Layoutfix's contract finding in task #4138.
+
+## Global Constraints
+
+- Backend only; no credentials, production operations, database query, or stored field.
+- Missing capability means false on clients; old clients ignore the additive field.
+- Run affected checks locally and full backend/integration in PR CI.
+
+## Review Focus
+
+- Plain Buddy proposal and pending approval share status but must differ in capability.
+- Approved and rejected decisions must not remain actionable.
+- Foreign or stale memberships must not receive an actionable row.
+- Initial and change projections use the same capability rule.
+- Missing capability on older servers must not enable controls.
+
+## Design
+
+The boolean is computed from the already-loaded taskApproval after the existing identity/read filters. It adds no retained state, query, timer, collection, index, migration or concurrency scope. Existing cursors and visibility resets carry it. Growth is one boolean per existing row; rollback removes the field and clients default false. The server's decision commands remain authoritative. All backend platforms use the same projection; no process or window changes.
+
+### Task 1: expose the capability
+
+**Files:** `backend/src/superTabs/read/personalTasks.ts`, its test, and the shared v3 spec.
+
+**Interfaces:** `PersonalTask.canApprove: boolean`; true exactly for this membership's pending taskApproval. All other emitted rows carry false.
+
+- [ ] Add table cases for pending/approved/rejected/no approval with and without a Buddy proposal; assert both initial and delta reads. Assert stale/foreign pending membership produces no row.
+- [ ] Run the affected test and commit the expected failures before code.
+- [ ] Add the boolean to the existing projection and document false fallback.
+- [ ] Run affected read/approval tests, typecheck and diff check; record red/green and payload/timing evidence.
+- [ ] Push, request independent review, and hold for current-head ci/required before completion.
diff --git a/docs/specs/2026-11-07-swarm-v3.md b/docs/specs/2026-11-07-swarm-v3.md
index dd727df50..ac04ea0a9 100644
--- a/docs/specs/2026-11-07-swarm-v3.md
+++ b/docs/specs/2026-11-07-swarm-v3.md
@@ -32,6 +32,7 @@ Use existing authenticated command transport and first-load/change transport; no
- Apply Review to new PM tasks for that requester and to their Buddy proposal cards. Keep the exact-consent Buddy checks and legacy proposal delivery. Represent legacy Buddy proposals on a durable card too, and link them when the PM creates the resulting task, so the feed has one continuing entry rather than duplicate work.
- Changing an unassigned task’s requester to a person in Review stages that person’s approval, including a task originally opened with no requester. Refuse that attribution after assignment. Keeping the same requester does not retroactively gate existing work.
- Add optional `personalTasks` to `/parts` and `/changes`, for person readers only. It uses that response's existing cursor and visibility epoch, including its 30-second safety overlap; merge duplicate versions idempotently. Shape: `{ approvalMode, reset, upserts, removed }`. `reset` is true on first load; apply removals and upserts on changes. Each row has `id`, `version`, `at` (epoch ms), `projectId`, `projectName`, `title`, `agent` (null or id/name/avatar), `status`, `suggested`, and optional `reason`. Order newest first by `at`, then id. Overlay agent/project roster changes using their existing part updates; do not request the feed on a timer.
+- Each row also carries `canApprove`, true only for a pending personal approval owned by the reading membership. A plain undecided Buddy proposal still has `status: proposal` but `canApprove: false`: open its conversation instead of showing personal decision controls. Missing `canApprove` on an older server means false. Decision commands continue to enforce authority themselves.
- The feed contains readable, active tasks requested by the person and their proposals; no chats or review steps. Archived, deleted, merged or dormant records leave the active feed through removals. Existing project history reads retain old work. First load uses the existing active snapshot; changes summarize only changed task parts, never all task history.
## Design (docs/feature-design-rules.md)