Skip to content

Commit 36fdf12

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 36fdf12

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ export class WorkspaceService extends EventEmitter {
210210
this.emit("activity", { workspaceId, activity: snapshot });
211211
}
212212

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

0 commit comments

Comments
 (0)