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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(super-tabs): work opened from a Buddy's proposal is requested by the proposal's person (#2411)
0xken15c141ea3f4779
diff --git a/backend/integration/superTabBuddies.test.ts b/backend/integration/superTabBuddies.test.tsindex 2c2f50d85..1507d8383 100644--- a/backend/integration/superTabBuddies.test.ts+++ b/backend/integration/superTabBuddies.test.ts@@ -729,6 +729,22 @@ describe('a Buddy hears how its person\'s requests go, unasked (Diego, 10-29)',expect((await f.store.messages(peer, f.tab, group, {}, agentId)).messages.map(m => m.id)).toContain(notice.id)})+ it('is told of work the PM opens from its proposal without naming anyone: the proposal\'s person is its requester (groups #294, #327)', async () => {+ const { f, agentId, proposal, heard } = await proposed()+ const created = await f.execute({ type: 'conversation.create', projectId: 'lead', title: 'Offline sync', brief: 'Desktop keeps edits offline.',+ checks: [{ description: 'Edits survive a restart', independent: false }], proposalMessageId: proposal }, owner, f.lead)+ const group = String(created.result.conversationId)+ expect(created.result.requesterUnknown).toBeUndefined()+ const stored = (await f.store.read(owner, f.tab)).state.conversations.find(c => c.id === group)!+ expect(stored.requesterId).toBe(peer.sub)+ const builder = String((await f.execute({ type: 'agent.add', conversationId: group, machineId: 'owner-mac', harnessId: randomUUID(), name: 'Builder',+ configuration: config, lead: false })).result.agentId)+ await f.execute({ type: 'work.assign', conversationId: group, agentId: builder })+ const notice = await db.superTabMessage.findFirstOrThrow({ where: { tabId: f.tab, conversationId: group, recipientIds: { has: agentId } } })+ expect(notice.text).toMatch(/^News for your owner: #\d+ "Offline sync", which they requested, is assigned and working\.$/)+ expect(await heard()).toEqual([notice.id])+ })+it('stops hearing once its person stops reading the project: nothing new is sent, and what waits is refused at pickup', async () => {const { f, agentId, proposal, pm, heard } = await proposed()const answer = String((await pm('Taking it.', { replyTo: proposal })).result.messageId)diff --git a/backend/src/superTabs/buddyNews.test.ts b/backend/src/superTabs/buddyNews.test.tsindex b0e7add9d..59a47ee23 100644--- a/backend/src/superTabs/buddyNews.test.ts+++ b/backend/src/superTabs/buddyNews.test.ts@@ -4,6 +4,8 @@ import { createSuperTab, forRecipients, type Actor, type Conversation, type Messimport { buddyChatId } from './buddies.js'import { assignedNotice, buddiesTold } from './buddyNews.js'import { SHIP_KIND } from './ship.js'+import { leaderboard } from './leaderboard/stats.js'+import { weekStart } from './leaderboard/week.js'const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }const peer: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'peer', email: '[email protected]' }@@ -154,3 +156,68 @@ describe('the assignment notice a Buddy gets for work its person requested', ()expect(notices(requested({ requesterId: 'owner' }).assign())).toEqual([])})})++describe('work the PM opens from a Buddy\'s proposal without naming anyone (groups #294 and #327, 10-30)', () => {+ /** peer's Buddy proposes; the PM opens a group from it, the store loading the proposal row by its id. */+ function opened(extra: Record<string, unknown> = {}) {+ const f = setup(), sent = f.propose()+ const created = f.run({ type: 'conversation.create', projectId: f.app.projectId, title: 'Offline edits', brief: 'Save edits offline.',+ checks: [{ description: 'Tests pass', independent: false }], proposalMessageId: sent.id, ...extra } as Command, agentActor(f.pm),+ { proposal: { id: sent.id, conversationId: sent.conversationId, author: sent.author, source: sent.source ?? null } })+ const group = created.result.conversationId as string+ return { f, group, created, find: () => f.state.conversations.find(c => c.id === group)! }+ }++ it('is requested by the person the proposal was sent for, who gets the assignment news, the ship news and the Shipped points', () => {+ const { f, group, created, find } = opened()+ expect(find().requesterId).toBe('peer')+ expect(created.result.requesterUnknown).toBeUndefined()+ const worker = f.add(group, 'worker')+ expect(f.run({ type: 'work.assign', conversationId: group, agentId: worker }).messages.filter(m => m.recipients.includes('buddy')))+ .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')+ 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 } })+ })++ it('keeps the requester the PM names, even someone else', () => {+ const { find } = opened({ requesterId: 'owner' })+ expect(find().requesterId).toBe('owner')+ })++ it('names nobody, and says so, when the proposal\'s person left the Swarm or no longer reads the project; the group still opens', () => {+ for (const lose of [(f: ReturnType<typeof setup>) => { f.state.people = f.state.people.filter(p => p.id !== 'peer') },+ (f: ReturnType<typeof setup>) => { f.state.projects!.find(p => p.id === f.app.projectId)!.visibility = 'private' }]) {+ const f = setup(), sent = f.propose()+ lose(f)+ const created = f.run({ type: 'conversation.create', projectId: f.app.projectId, title: 'Offline edits', brief: 'Save edits offline.',+ checks: [{ description: 'Tests pass', independent: false }], proposalMessageId: sent.id } as Command, agentActor(f.pm),+ { proposal: { id: sent.id, conversationId: sent.conversationId, author: sent.author, source: sent.source ?? null } })+ const group = f.state.conversations.find(c => c.id === created.result.conversationId)!+ expect(group.requesterId).toBeUndefined()+ expect(group.ledger?.proposal).toEqual({ buddyId: 'buddy', messageId: sent.id })+ expect(created.result).toMatchObject({ requesterUnknown: true, warnings: [expect.stringContaining('Name the person who asked')] })+ }+ })++ it('credits nobody from a proposal posted in another project\'s chat, a private chat or by anyone but a Buddy: refused alike, nothing opened', () => {+ const f = setup(), sent = f.propose()+ const web = f.run({ type: 'project.create', name: 'Web', visibility: 'public', brief: '' }).result as { projectId: string; conversationId: string }+ const before = f.state.conversations.length+ const wrongs = [{ ...sent, conversationId: web.conversationId }, { ...sent, conversationId: f.chat },+ { ...sent, author: { kind: 'person' as const, id: 'peer', name: 'peer', membershipGeneration: 'first' } },+ { ...sent, author: { ...sent.author, id: f.pm } }, { ...sent, source: { kind: 'route', personId: 'peer' } }]+ for (const wrong of wrongs) {+ expect(() => f.run({ type: 'conversation.create', projectId: f.app.projectId, title: 'Offline', brief: 'Save.',+ checks: [{ description: 'Done', independent: false }], proposalMessageId: wrong.id } as Command, agentActor(f.pm),+ { proposal: { id: wrong.id, conversationId: wrong.conversationId, author: wrong.author, source: wrong.source ?? null } }), JSON.stringify(wrong))+ .toThrow('Name a Buddy\'s proposal posted in this project\'s chat, or leave the proposal out.')+ }+ expect(f.state.conversations.length).toBe(before)+ })+})diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex f3c8d366b..00bc12960 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -554,15 +554,25 @@ function requester(state: SuperTabState, project: SwarmProject, personId: string}/** The Buddy whose proposal a new group comes from: the message must be a Buddy's proposal posted in the project's chat. Its* row is the Swarm's own (buddy.propose), so a Buddy removed since still earns for it. */-function proposalOf(state: SuperTabState, project: SwarmProject, proposal: CommandContext['proposal']): { buddyId: string; messageId: string } {+function proposalOf(state: SuperTabState, project: SwarmProject, proposal: CommandContext['proposal']): { buddyId: string; messageId: string; personId?: string } {const author = proposal?.authorconst buddy = author?.kind === 'agent' ? state.agents.find(a => a.id === author.id) : undefinedif (!proposal || proposal.conversationId !== project.leadConversationId || proposal.source?.kind !== 'buddy-proposal'|| author?.kind !== 'agent' || (buddy && !isBuddy(buddy))) {fail('PROPOSAL_UNKNOWN', 'Name a Buddy\'s proposal posted in this project\'s chat, or leave the proposal out.', 400)}- return { buddyId: author.id, messageId: proposal.id }+ // The person it was sent for, as buddy.propose recorded them: the Swarm writes this source, never a sender.+ const personId = typeof proposal.source.personId === 'string' ? proposal.source.personId : undefined+ return { buddyId: author.id, messageId: proposal.id, ...personId ? { personId } : {} }}+/** The person a proposal was sent for, while they are still in the Swarm and read [project]; otherwise nobody, so a person+ * who left or lost the project is never credited and opening the group still works (the PM is told to name someone). */+function proposalRequester(state: SuperTabState, project: SwarmProject, personId: string | undefined): string | undefined {+ const member = personId ? state.people.find(p => p.id === personId) : undefined+ return member && canReadProject(state, { kind: 'person', userId: member.id, email: member.email }, project) ? member.id : undefined+}+/** What an agent opening a group for nobody is told, so the person who asked still gets the credit (groups #294, #327). */+export const REQUESTER_UNKNOWN = 'Name the person who asked: conversation.requester with their personId for this group, or requesterId when you open a group.'function open(state: SuperTabState, conversationId: string) {const group = conversation(state, conversationId)@@ -1463,7 +1473,10 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma}// A review by hand of a task wanting two reviews reviews its current hand-over, as one the Swarm opens does.const reviewStamp = command.reviewOf ? reviewStampOf(conversation(state, command.reviewOf)) : undefined- const requesterId = command.requesterId ? requester(state, project, command.requesterId) : actor.kind === 'person' ? actor.userId : undefined+ // Who asked: the person named, else the one a Buddy's proposal was sent for, else a person opening it themselves.+ const proposal = command.proposalMessageId ? proposalOf(state, project, context.proposal) : undefined+ const requesterId = command.requesterId ? requester(state, project, command.requesterId)+ : proposalRequester(state, project, proposal?.personId) ?? (actor.kind === 'person' ? actor.userId : undefined)const number = nextConversationNumber(state)state.groupCounter = numberstate.conversations.push({ id: operationId, ...(state.projects ? { projectId: project.id } : {}),@@ -1473,9 +1486,14 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commachecks: command.checks.map((c, i) => ({ ...c, id: stableId(operationId, String(i)), evidence: null, passedBy: null })),})recordAsked(state.conversations.at(-1)!, requesterId, context.now)- if (command.proposalMessageId) recordProposal(state.conversations.at(-1)!, proposalOf(state, project, context.proposal))+ if (proposal) recordProposal(state.conversations.at(-1)!, { buddyId: proposal.buddyId, messageId: proposal.messageId })result.conversationId = operationIdresult.number = number+ // A build group an agent opens for nobody credits nobody when it ships: say so, as the PM can still name them.+ if (actor.kind === 'agent' && !requesterId && !command.reviewOf) {+ result.requesterUnknown = true+ result.warnings = [REQUESTER_UNKNOWN]+ }if (brief) {message(operationId, brief, [], null, SYSTEM_ROW)bindTaskCard(state.conversations.at(-1)!, effects.messages.at(-1)!)diff --git a/backend/src/superTabs/leaderboard/record.test.ts b/backend/src/superTabs/leaderboard/record.test.tsindex 6a7602477..07acd97b0 100644--- a/backend/src/superTabs/leaderboard/record.test.ts+++ b/backend/src/superTabs/leaderboard/record.test.ts@@ -75,6 +75,20 @@ describe('who asked for a group', () => {expect(f.group(id).ledger).toEqual({ askedAt: 1_000 })})+ it('tells a Lead that opens a build group for nobody to name who asked; never for a named requester, a person or a review', () => {+ const f = fixture(), lead = f.add('lead', 'lead', true)+ f.invitePeer()+ const open = (actor: Actor, extra: Record<string, unknown> = {}) =>+ f.run(commandSchema.parse({ type: 'conversation.create', title: 'Offline editing', brief: 'Save edits.', checks, ...extra }), actor).result+ const unnamed = open(f.asAgent(lead))+ expect(unnamed).toMatchObject({ requesterUnknown: true, warnings: [expect.stringContaining('Name the person who asked')] })+ for (const result of [open(f.asAgent(lead), { requesterId: 'peer' }), open(owner),+ open(f.asAgent(lead), { reviewOf: unnamed.conversationId as string, title: 'Review: Offline editing' })]) {+ expect(result.requesterUnknown).toBeUndefined()+ expect(result.warnings).toBeUndefined()+ }+ })+it('refuses a requester who is not a member of the Swarm', () => {const f = fixture(), lead = f.add('lead', 'lead', true)expect(() => f.create(f.asAgent(lead), { requesterId: 'stranger' })).toThrow('no longer have access')@@ -1050,6 +1064,19 @@ describe('a group opened from a Buddy\'s proposal (Lead, 2026-10-29: the Buddy eexpect(f.group(id).ledger).toEqual({ askedAt: 5_000, proposal: { buddyId: buddy, messageId: 'm-proposal' } })})+ it('is requested by the person the proposal was sent for when a Lead names nobody, and by the one it names otherwise', () => {+ const f = fixture(), lead = f.asAgent(f.add('lead', 'lead', true))+ f.invitePeer()+ const { proposal } = proposed(f)+ const fromLead = (extra: Record<string, unknown> = {}) => f.run(commandSchema.parse({ type: 'conversation.create', title: 'Dark mode', brief: 'Add it.',+ checks, proposalMessageId: 'm-proposal', ...extra }), lead, { proposal }).result.conversationId as string+ expect(f.group(fromLead()).requesterId).toBe('owner')+ expect(f.group(fromLead({ requesterId: 'peer' })).requesterId).toBe('peer')+ // A person opening it from someone else's proposal opens it for that someone.+ const forPeer = { ...proposal, source: { ...proposal.source, personId: 'peer' } }+ expect(f.group(createFrom(f, forPeer)).requesterId).toBe('peer')+ })+it('refuses a link to a message that is not a Buddy\'s proposal in this project\'s chat', () => {const f = fixture()const { proposal } = proposed(f)