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-06 j1010: #3264 #3259 (#3270)

0xken15c6012a547257
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index 26f02a710..1df7ed85e 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -14,7 +14,7 @@ import { agentWrittenNameOf, setName, shownNameOf } from './personNames.js'
import { z } from 'zod'
import { tokensByModelSchema } from './costs/tokens.js'
import {
- activeWork, occupiesAgent, actorKey, agent, appendPullRequestUrls, author, projectPullRequestUrl, conversation, crossProjectActive, fail, isLeads, person, stableId, numberConversations, nextConversationNumber, renderWorkTask,
+ activeWork, occupiesAgent, actorKey, agent, appendPullRequestUrls, author, projectPullRequestUrl, pullRequestLinks, conversation, crossProjectActive, fail, isLeads, person, stableId, numberConversations, nextConversationNumber, renderWorkTask,
finishWorker, seenMachineIds, SuperTabError, swarmGridName, visibleState, AGENT_ONLY, STATUS_LABELS, forRecipients,
type Actor, type AgentConfiguration, type AgentStart, type AgentStartRequest, type BuddySessionEntry, type WorkTask, type Agent, type Author, type Check, type CommandEffects, type Conversation, type SuperTabState,
} from './model.js'
@@ -919,6 +919,14 @@ 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. */
+/** Whether [assignment]'s builder can no longer close it: its attempt already ended (stopped or lost), or its agent is gone
+ * from the Swarm or stopping (task #3510). */
+function builderGone(state: SuperTabState, assignment: NonNullable<Conversation['assignment']>): boolean {
+ if (['stopped', 'lost'].includes(assignment.status)) return true
+ const builder = state.agents.find(a => a.id === assignment.agentId)
+ return !builder || builder.workDecision === 'stop'
+}
+
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
@@ -2685,6 +2693,25 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,
else bindPullRequestCards(group, posted, repositoryUrl)
}
recordCardMerged(group, pullRequestUrl, mergedAt)
+ // A merged task whose builder is gone closes itself with the merge as its result (task #3510): a released builder can
+ // no longer set its own Done, and the task would stay in review for good. A live builder still closes its own task, and
+ // a step never closes here, nor its parent through it. Only the task's own pull request closes it: one its builder named in
+ // its result (the Ready line) or a check's evidence names, which a merge record never writes. A merge of an unrelated one
+ // recorded here, even twice, only links it (Aster, review of #3259).
+ const assignment = group.assignment
+ const ownPullRequest = assignment && [assignment.result, ...group.checks.map(check => check.evidence)]
+ .some(text => !!text && pullRequestLinks(text, repositoryUrl).includes(pullRequestUrl))
+ if (ownPullRequest && !isStep(group) && assignment && !['done', 'cancelled'].includes(assignment.status) && builderGone(state, assignment)) {
+ const previous = assignment.status
+ assignment.status = 'done'
+ assignment.result = `Merged ${pullRequestUrl}. Its builder is no longer running, so the recorded merge closes the task.`
+ delete assignment.hold
+ delete assignment.askedOf
+ recordStatus(group, assignment, previous, context.now, operationId)
+ effects.closedAssignment = { assignmentId: assignment.id, outcome: 'done' }
+ message(group.id, `Done\n\n${assignment.result}`, [], null, { ...SYSTEM_ROW, status: 'done' }, undefined, undefined, undefined,
+ stableId(operationId, 'merged-done'))
+ }
break
}
case 'conversation.archive': {
diff --git a/backend/src/superTabs/mergedCloses.test.ts b/backend/src/superTabs/mergedCloses.test.ts
new file mode 100644
index 000000000..6423b31a4
--- /dev/null
+++ b/backend/src/superTabs/mergedCloses.test.ts
@@ -0,0 +1,109 @@
+// Task #3510 (anh Dee's Swarm redesign): a recorded merge closes a task whose builder is gone, so a released builder no longer
+// leaves its merged task in review for good; a live builder still closes its own task.
+import { describe, expect, it } from 'vitest'
+import { appendPullRequestUrls } from './model.js'
+import { stepsFixture } from './steps.test-support.js'
+
+const PR = 'https://github.com/acme/app/pull/7'
+
+function mergedFixture() {
+ const f = stepsFixture()
+ const assignment = f.group(f.task).assignment!.id
+ f.run({ type: 'work.status', conversationId: f.task, assignmentId: assignment, status: 'review', result: `Ready for review: ${PR} at abc1234` }, f.as(f.dev))
+ // As the store does after each command: the Ready line's link is the task's linked pull request.
+ appendPullRequestUrls(f.group(f.task), [PR])
+ const merge = (conversationId = f.task) => f.run({ type: 'conversation.merged', conversationId, pullRequestUrl: PR }, f.as(f.lead))
+ /** The builder released and its session gone, as a host's confirmed stop leaves it. */
+ const removeBuilder = () => { f.state.agents.splice(f.state.agents.findIndex(a => a.id === f.dev), 1) }
+ return Object.assign(f, { assignment, merge, removeBuilder })
+}
+
+describe('a recorded merge closes a task whose builder is gone (#3510)', () => {
+ it('closes the task of a released builder with the merge as its result', () => {
+ const f = mergedFixture()
+ f.removeBuilder()
+ const effects = f.merge()
+ expect(f.group(f.task).assignment).toMatchObject({ id: f.assignment, status: 'done' })
+ expect(f.group(f.task).assignment!.result).toContain(PR)
+ expect(f.group(f.task).ledger?.shippedAt).toBe(f.now)
+ // The store closes the attempt as a builder's own done does.
+ expect(effects.closedAssignment).toEqual({ assignmentId: f.assignment, outcome: 'done' })
+ expect(effects.messages.some(m => m.conversationId === f.task && m.text.startsWith('Done'))).toBe(true)
+ })
+
+ it('closes it while the released builder is still stopping', () => {
+ const f = mergedFixture()
+ // A stop on its way (an idle stop, or a release after its work closed), before its host confirms it.
+ f.state.agents.find(a => a.id === f.dev)!.workDecision = 'stop'
+ f.merge()
+ expect(f.group(f.task).assignment).toMatchObject({ status: 'done' })
+ })
+
+ it('closes a task whose attempt already ended without finishing', () => {
+ const f = mergedFixture()
+ f.group(f.task).assignment!.status = 'lost'
+ f.merge()
+ expect(f.group(f.task).assignment).toMatchObject({ status: 'done' })
+ })
+
+ // Aster's review of #3259: a merge of a pull request the task never linked closes nothing.
+ it('leaves the task in review when the merged pull request was never linked to it', () => {
+ const f = mergedFixture()
+ expect(f.group(f.task).pullRequestUrls).toContain(PR)
+ f.removeBuilder()
+ const effects = f.run({ type: 'conversation.merged', conversationId: f.task, pullRequestUrl: 'https://github.com/acme/app/pull/99' }, f.as(f.lead))
+ expect(f.group(f.task).assignment).toMatchObject({ id: f.assignment, status: 'review' })
+ expect(effects.closedAssignment).toBeUndefined()
+ })
+
+ // Aster's re-check of #3259: the first record of an unrelated pull request links it to the task, so a second record (a
+ // retry, a backfill) must still close nothing. Ownership is what the task said itself, which a merge record never writes.
+ it('leaves the task in review when an unrelated pull request\'s merge is recorded twice', () => {
+ const f = mergedFixture()
+ f.removeBuilder()
+ const other = { type: 'conversation.merged' as const, conversationId: f.task, pullRequestUrl: 'https://github.com/acme/app/pull/99' }
+ f.run(other, f.as(f.lead))
+ appendPullRequestUrls(f.group(f.task), ['https://github.com/acme/app/pull/99'])
+ const effects = f.run(other, f.as(f.lead))
+ expect(f.group(f.task).assignment).toMatchObject({ id: f.assignment, status: 'review' })
+ expect(effects.closedAssignment).toBeUndefined()
+ })
+
+ it('closes on a pull request a check\'s evidence names, as the task\'s own', () => {
+ const f = mergedFixture()
+ const own = 'https://github.com/acme/app/pull/12'
+ f.group(f.task).checks[0]!.evidence = `Passed on ${own} at abc1234`
+ f.removeBuilder()
+ f.run({ type: 'conversation.merged', conversationId: f.task, pullRequestUrl: own }, f.as(f.lead))
+ expect(f.group(f.task).assignment).toMatchObject({ status: 'done' })
+ })
+
+ it('leaves a live builder\'s task for the builder to close', () => {
+ const f = mergedFixture()
+ const effects = f.merge()
+ expect(f.group(f.task).assignment).toMatchObject({ id: f.assignment, status: 'review' })
+ expect(effects.closedAssignment).toBeUndefined()
+ })
+
+ it('never closes the parent task, or a step, when a merge is recorded on a step', () => {
+ const f = mergedFixture()
+ const review = f.step('Review')
+ const reviewer = f.add('reviewer', review)
+ f.run({ type: 'work.assign', conversationId: review, agentId: reviewer }, f.as(f.dev))
+ f.removeBuilder()
+ f.state.agents.splice(f.state.agents.findIndex(a => a.id === reviewer), 1)
+ const effects = f.merge(review)
+ expect(f.group(f.task).assignment).toMatchObject({ status: 'review' })
+ expect(f.group(review).assignment).toMatchObject({ status: 'working' })
+ expect(effects.closedAssignment).toBeUndefined()
+ })
+
+ it('leaves a finished or cancelled task as it is', () => {
+ const f = mergedFixture()
+ f.run({ type: 'work.status', conversationId: f.task, assignmentId: f.assignment, status: 'done', result: `Merged ${PR}` }, f.as(f.dev))
+ f.removeBuilder()
+ const effects = f.merge()
+ expect(f.group(f.task).assignment).toMatchObject({ status: 'done', result: `Merged ${PR}` })
+ expect(effects.closedAssignment).toBeUndefined()
+ })
+})
diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.ts
index 8f6f99924..c69d15f92 100644
--- a/backend/src/superTabs/model.ts
+++ b/backend/src/superTabs/model.ts
@@ -825,6 +825,9 @@ export interface CommandEffects {
/** Deliveries of messages already stored: a Buddy thread session's first messages, sent while it started (buddySessions.ts). */
/** `lead`: a project's Lead hearing its person's messages sent while the chat had none (leadStart.ts leadArrived). */
lateDeliveries?: Array<{ messageId: string; conversationId: string; agentId: string; author: { kind: 'person'; id: string; generation: string }; lead?: true }>
+ /** An attempt the command closed for its gone builder (commands.ts conversation.merged, task #3510): the store closes its
+ * attempt row as a builder's own done does. */
+ closedAssignment?: { assignmentId: string; outcome: 'done' }
/** A project's new instructions revision, written outside the tab state by the store (instructions.ts). */
instructions?: import('./instructions.js').InstructionsWrite
/** A project's new rules revision, written outside the tab state by the store (policyStore.ts). */
diff --git a/backend/src/superTabs/parts/light.test.ts b/backend/src/superTabs/parts/light.test.ts
index 50c6c1e73..72a732b1b 100644
--- a/backend/src/superTabs/parts/light.test.ts
+++ b/backend/src/superTabs/parts/light.test.ts
@@ -1,3 +1,4 @@
+import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
import { activeWork, type Actor, type Assignment, type Conversation, type WorkStatus } from '../model.js'
import { canReadGroup } from '../projects.js'
@@ -7,16 +8,77 @@ import { FINISHED, GROUP_FIELDS } from './light.js'
/** Every field a conversation and its assignment can carry: adding one to model.ts fails this file's typecheck until it is
* here, and the test below until light.ts either projects it or names it as unread by reads (review of #1745). */
const assignment: Required<Assignment> = {
- id: 'w', agentId: 'a', status: 'working', configuration: { engine: 'codex', model: null, effort: null, contextWindow: null, engineVersion: null },
- execution: { machineId: 'm', harnessId: 'h', machineOwnerId: 'o' }, result: null, recordingProgress: { at: 1, revision: 1 }, leaseUntil: 1, progressAt: 1, nudgedAt: 1, askedOf: 'p', hold: { kind: 'requester' }, reviewFoundAt: 1, changesRequestedAt: 1, toldEngineerAt: 1,
- reopened: { at: 1, why: 'r' }, handoffs: 1, verdicts: [{ by: 'agent:r', passed: true, handoff: 1, review: 'g' }], lost: { reason: 'r', at: 1 },
+ agentId: 'a',
+ askedOf: 'p',
+ changesRequestedAt: 1,
+ configuration: { engine: 'codex', model: null, effort: null, contextWindow: null, engineVersion: null },
+ execution: { machineId: 'm', harnessId: 'h', machineOwnerId: 'o' },
+ handoffs: 1,
+ hold: { kind: 'requester' },
+ id: 'w',
+ leaseUntil: 1,
+ lost: { reason: 'r', at: 1 },
+ nudgedAt: 1,
+ progressAt: 1,
+ recordingProgress: { at: 1, revision: 1 },
+ reopened: { at: 1, why: 'r' },
+ result: null,
+ reviewFoundAt: 1,
+ status: 'working',
+ toldEngineerAt: 1,
+ verdicts: [{ by: 'agent:r', passed: true, handoff: 1, review: 'g' }],
}
const conversation: Required<Conversation> = {
- id: 'g', kind: 'leads', projectId: 'p', number: 1, title: 't', leadId: null, agentIds: [], archived: false, brief: '',
- task: { goal: '', changes: '', constraints: '', owns: [] }, reviewOf: 'r', teamWritten: true, teamWrittenBy: { kind: 'assigned' }, step: 'Review', reviewStamp: { assignmentId: 'w', handoff: 1 }, checks: [], assignment, lastMessageSequence: 0, lastMainSequence: 0, lastPersonSequence: 0, heardAt: 0, pullRequestUrls: [], pullRequestEvents: {}, cards: {},
- messageSeq: 0, reportSeq: 0, dormant: false, lastActivityAt: '', audience: { people: [] }, lostAttempt: { id: 'w', agentId: 'a' }, reactionSeq: 0,
- requesterId: 'p', ledger: {}, released: { at: 1, tags: [] }, proposals: [], buddyName: 'Sparky', buddySessions: [], buddyDownTold: true, liveness: { state: 'quiet', why: 'silent', since: 1 }, leadAction: { kind: 'post', at: 1 },
- stepUp: { attempt: 2, floor: 2, reason: 'r', at: 1, carry: '' }, queueRank: 1.5, notBefore: '2026-12-04', hold: { kind: 'requester' }, priority: 'P0', lane: 'Desktop', handOutLane: 'Desktop', pin: { agentId: 'a', why: 'ci', at: 1 }, owed: [], pulse: {} as never,
+ agentIds: [],
+ archived: false,
+ assignment,
+ audience: { people: [] },
+ brief: '',
+ buddyDownTold: true,
+ buddyName: 'Sparky',
+ buddySessions: [],
+ cards: {},
+ checks: [],
+ dormant: false,
+ handOutLane: 'Desktop',
+ heardAt: 0,
+ hold: { kind: 'requester' },
+ id: 'g',
+ kind: 'leads',
+ lane: 'Desktop',
+ lastActivityAt: '',
+ lastMainSequence: 0,
+ lastMessageSequence: 0,
+ lastPersonSequence: 0,
+ leadAction: { kind: 'post', at: 1 },
+ leadId: null,
+ ledger: {},
+ liveness: { state: 'quiet', why: 'silent', since: 1 },
+ lostAttempt: { id: 'w', agentId: 'a' },
+ messageSeq: 0,
+ notBefore: '2026-12-04',
+ number: 1,
+ owed: [],
+ pin: { agentId: 'a', why: 'ci', at: 1 },
+ priority: 'P0',
+ projectId: 'p',
+ proposals: [],
+ pullRequestEvents: {},
+ pullRequestUrls: [],
+ pulse: {} as never,
+ queueRank: 1.5,
+ reactionSeq: 0,
+ released: { at: 1, tags: [] },
+ reportSeq: 0,
+ requesterId: 'p',
+ reviewOf: 'r',
+ reviewStamp: { assignmentId: 'w', handoff: 1 },
+ step: 'Review',
+ stepUp: { attempt: 2, floor: 2, reason: 'r', at: 1, carry: '' },
+ task: { goal: '', changes: '', constraints: '', owns: [] },
+ teamWritten: true,
+ teamWrittenBy: { kind: 'assigned' },
+ title: 't',
}
describe('the light conversation projection (parts/light.ts)', () => {
@@ -65,3 +127,52 @@ describe('the light conversation projection (parts/light.ts)', () => {
expect(reads).toContain(false)
})
})
+
+/** The lines of [text] from the line that starts with [open] to the next one that starts with [close], both left out. */
+function block(text: string, open: string, close: string): string[] {
+ const lines = text.split('\n'), from = lines.findIndex(line => line.startsWith(open))
+ expect(from, open).toBeGreaterThanOrEqual(0)
+ const to = lines.findIndex((line, i) => i > from && line.startsWith(close))
+ return lines.slice(from + 1, to)
+}
+/** How many entries [line] holds at its top level: commas outside brackets, braces, parentheses and quotes, a trailing one aside. */
+function entriesOn(line: string): number {
+ let depth = 0, quote: string | null = null, commas = 0
+ const body = line.trim().replace(/,$/, '')
+ for (let i = 0; i < body.length; i++) {
+ const c = body[i]!
+ if (quote) { if (c === '\\') i++; else if (c === quote) quote = null; continue }
+ if (c === "'" || c === '"' || c === '`') quote = c
+ else if ('[{('.includes(c)) depth++
+ else if (']})'.includes(c)) depth--
+ else if (c === ',' && depth === 0) commas++
+ }
+ return commas + 1
+}
+const sorted = (names: string[]) => [...names].sort((a, b) => a < b ? -1 : a > b ? 1 : 0)
+
+// Task #3519: on 11-05 nearly every merge batch left the next pull requests conflicting here, as each feature appended its field
+// to the same one-line lists. One entry per line in a fixed order lets git merge two additions cleanly.
+describe('the field lists stay one entry per line, in order', () => {
+ it('lists each of GROUP_FIELDS\' fields on its own line, sorted', () => {
+ const lines = block(readFileSync(new URL('./light.ts', import.meta.url), 'utf8'), 'export const GROUP_FIELDS = {', '} as const')
+ for (const list of Object.keys(GROUP_FIELDS) as Array<keyof typeof GROUP_FIELDS>) {
+ const entries = block(lines.join('\n'), ` ${list}: [`, ' ],')
+ expect(entries.every(line => /^ {4}'[^']+',$/.test(line)), `${list}: one quoted field a line`).toBe(true)
+ const names = entries.map(line => line.trim().slice(1, -2))
+ expect(names, list).toEqual(sorted(names))
+ expect(names, list).toEqual([...GROUP_FIELDS[list]])
+ }
+ })
+
+ it('writes the test\'s every-field fixtures one field a line, sorted', () => {
+ const text = readFileSync(new URL('./light.test.ts', import.meta.url), 'utf8')
+ for (const open of ['const assignment: Required<Assignment> = {', 'const conversation: Required<Conversation> = {']) {
+ const lines = block(text, open, '}')
+ // A field written `key: value,`, or in shorthand, `key,`.
+ expect(lines.filter(line => !/^ {2}[A-Za-z]+(: |,$)/.test(line) || entriesOn(line) !== 1), open).toEqual([])
+ const keys = lines.map(line => line.trim().split(/[:,]/)[0]!)
+ expect(keys, open).toEqual(sorted(keys))
+ }
+ })
+})
diff --git a/backend/src/superTabs/parts/light.ts b/backend/src/superTabs/parts/light.ts
index 1dce3b748..f0e0bf939 100644
--- a/backend/src/superTabs/parts/light.ts
+++ b/backend/src/superTabs/parts/light.ts
@@ -22,15 +22,84 @@ const running = { $and: [{ $ne: [{ $type: '$data.assignment.status' }, 'missing'
* usage limit is still that one before its host resumes it (read/hostRows.ts), and whether it is a step, whose Ready is no hand-over
* (model.ts handed: a handed task's Engineer reads as free). `whenRunning`: what other projects' work and host rows read of
* running work. `unread`: what visibility checks, derived values and host rows never read. light.test.ts fails when
- * model.ts gains a field this does not place.
+ * model.ts gains a field this does not place. One field a line, in sorted order (light.test.ts keeps it so), so that two pull
+ * requests adding fields merge without a conflict (task #3519).
*/
export const GROUP_FIELDS = {
- always: ['id', 'kind', 'projectId', 'leadId', 'agentIds', 'archived', 'audience', 'dormant', 'assignment.id', 'assignment.agentId', 'assignment.status',
- 'assignment.lost', 'reviewOf', 'pulse'],
- whenRunning: ['title', 'task.owns', 'assignment.execution', 'assignment.result'],
- unread: ['number', 'brief', 'teamWritten', 'teamWrittenBy', 'step', 'reviewStamp', 'checks', 'lastMessageSequence', 'lastMainSequence', 'lastPersonSequence', 'heardAt', 'pullRequestUrls', 'pullRequestEvents', 'cards', 'messageSeq', 'reportSeq', 'lastActivityAt', 'lostAttempt', 'requesterId', 'ledger', 'reactionSeq', 'proposals', 'buddyName', 'buddySessions', 'buddyDownTold', 'liveness', 'leadAction', 'stepUp', 'queueRank', 'notBefore', 'hold', 'priority', 'released', 'owed', 'lane', 'handOutLane', 'pin',
- 'assignment.configuration', 'assignment.recordingProgress', 'assignment.leaseUntil', 'assignment.progressAt', 'assignment.nudgedAt', 'assignment.askedOf', 'assignment.hold', 'assignment.reviewFoundAt', 'assignment.changesRequestedAt', 'assignment.toldEngineerAt',
- 'assignment.reopened', 'assignment.handoffs', 'assignment.verdicts'],
+ always: [
+ 'agentIds',
+ 'archived',
+ 'assignment.agentId',
+ 'assignment.id',
+ 'assignment.lost',
+ 'assignment.status',
+ 'audience',
+ 'dormant',
+ 'id',
+ 'kind',
+ 'leadId',
+ 'projectId',
+ 'pulse',
+ 'reviewOf',
+ ],
+ whenRunning: [
+ 'assignment.execution',
+ 'assignment.result',
+ 'task.owns',
+ 'title',
+ ],
+ unread: [
+ 'assignment.askedOf',
+ 'assignment.changesRequestedAt',
+ 'assignment.configuration',
+ 'assignment.handoffs',
+ 'assignment.hold',
+ 'assignment.leaseUntil',
+ 'assignment.nudgedAt',
+ 'assignment.progressAt',
+ 'assignment.recordingProgress',
+ 'assignment.reopened',
+ 'assignment.reviewFoundAt',
+ 'assignment.toldEngineerAt',
+ 'assignment.verdicts',
+ 'brief',
+ 'buddyDownTold',
+ 'buddyName',
+ 'buddySessions',
+ 'cards',
+ 'checks',
+ 'handOutLane',
+ 'heardAt',
+ 'hold',
+ 'lane',
+ 'lastActivityAt',
+ 'lastMainSequence',
+ 'lastMessageSequence',
+ 'lastPersonSequence',
+ 'leadAction',
+ 'ledger',
+ 'liveness',
+ 'lostAttempt',
+ 'messageSeq',
+ 'notBefore',
+ 'number',
+ 'owed',
+ 'pin',
+ 'priority',
+ 'proposals',
+ 'pullRequestEvents',
+ 'pullRequestUrls',
+ 'queueRank',
+ 'reactionSeq',
+ 'released',
+ 'reportSeq',
+ 'requesterId',
+ 'reviewStamp',
+ 'step',
+ 'stepUp',
+ 'teamWritten',
+ 'teamWrittenBy',
+ ],
} as const
const LIGHT_GROUP = {
_id: 0, key: 1, version: 1, changedAt: 1, ordinal: 1, dormant: 1,
diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.ts
index b4bfdac6d..303dece4d 100644
--- a/backend/src/superTabs/store.ts
+++ b/backend/src/superTabs/store.ts
@@ -2161,6 +2161,7 @@ export class SuperTabStore {
if (command.type === 'work.status' && (command.status === 'done' || command.status === 'stopped')) {
await closeAssignment(tx, tabId, command.assignmentId, command.status, context.now)
}
+ if (effects.closedAssignment) await closeAssignment(tx, tabId, effects.closedAssignment.assignmentId, effects.closedAssignment.outcome, context.now)
await recordEvidence(tx, tabId, original, effects.state, context.now)
const threads = await this.writeMessages(tx, tabId, effects.state, effects.messages, sequences)
if (effects.lateDeliveries?.length) await this.writeLateDeliveries(tx, tabId, effects.state, effects.lateDeliveries)