Skip to content

Commit 770a297

Browse files
committed
🤖 fix: bump parent recency on subagent report
When a subagent calls agent_report, we append the report message to the parent history and emit chat events. Also bump the parent workspace recency (using the same message timestamp) so sidebar ordering reflects background task completions. Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with `mux` • Model: `openai:gpt-5.2` • Thinking: `xhigh`_ Change-Id: I605ccc04ef857ee2fadf0daa44a11090738c087c
1 parent ce51e26 commit 770a297

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/node/services/taskService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,12 @@ export class TaskService {
427427
? `### Subagent report (${preset.agentType})\n\n`
428428
: "### Subagent report\n\n";
429429

430+
const messageTimestamp = Date.now();
430431
const reportMessage = createMuxMessage(
431432
this.config.generateStableId(),
432433
"assistant",
433-
`${reportHeader}${report.reportMarkdown}`
434+
`${reportHeader}${report.reportMarkdown}`,
435+
{ timestamp: messageTimestamp }
434436
);
435437

436438
const appendResult = await this.historyService.appendToHistory(
@@ -448,6 +450,7 @@ export class TaskService {
448450
...reportMessage,
449451
type: "message",
450452
} satisfies WorkspaceChatMessage);
453+
await this.workspaceService.bumpRecencyTimestamp(parentWorkspaceId, messageTimestamp);
451454
}
452455

453456
// Mark reported after best-effort delivery to the parent.

src/node/services/workspaceService.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ export class WorkspaceService extends EventEmitter {
210210
this.emit("activity", { workspaceId, activity: snapshot });
211211
}
212212

213+
214+
/**
215+
* Bump recency/activity for a workspace.
216+
*
217+
* Useful when the backend appends messages outside of the normal send/stream lifecycle
218+
* (e.g. subagent reports written into a parent workspace).
219+
*/
220+
public async bumpRecencyTimestamp(workspaceId: string, timestamp?: number): Promise<void> {
221+
assert(typeof workspaceId === "string", "workspaceId must be a string");
222+
const trimmed = workspaceId.trim();
223+
assert(trimmed.length > 0, "workspaceId must not be empty");
224+
225+
await this.updateRecencyTimestamp(trimmed, timestamp);
226+
}
213227
private async updateRecencyTimestamp(workspaceId: string, timestamp?: number): Promise<void> {
214228
try {
215229
const snapshot = await this.extensionMetadata.updateRecency(

0 commit comments

Comments
 (0)