@devries-cameron20 / t3code-1 / commits / b4ae3c8f9c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(muse): list background children under their turn item's native id (#23856)

Koushik_xd committed Nov 1, 2026 at 07:59 UTC b4ae3c8f9cc1d742f1f744d7b0fbfb7c1d2efcf3
2 files changed +65 -5
packages/provider-muse/src/server/adapter.test.ts
+53
@@ -1739,6 +1739,59 @@ describe("MuseAdapterV2", () => {
1739 }).pipe(Effect.scoped, Effect.provide(testLayer)),
1740 );
1741
1742 + it.effect("lists a running subagent under its turn item's native id as Muse reveals it", () =>
1743 + Effect.gen(function* () {
1744 + const fake = yield* makeFakeMuse();
1745 + const harness = yield* makeHarness(fake);
1746 + const { nativeId } = yield* startConversation(harness, fake);
1747 + const revisions = [
1748 + { revision: 1, status: "inProgress" },
1749 + { revision: 2, status: "inProgress", subagentId: "" },
1750 + { revision: 3, status: "inProgress", subagentId: "subagent-1" },
1751 + {
1752 + revision: 4,
1753 + status: "inProgress",
1754 + subagentId: "subagent-1",
1755 + childSessionId: "child-session-1",
1756 + },
1757 + {
1758 + revision: 5,
1759 + status: "completed",
1760 + subagentId: "subagent-1",
1761 + childSessionId: "child-session-1",
1762 + },
1763 + ];
1764 + const listed: Array<{ nativeId: string | null | undefined; roster: Array<string> }> = [];
1765 + for (const fields of revisions) {
1766 + yield* fake.emit(fields.revision === 1 ? "item/started" : "item/updated", {
1767 + turnId: nativeId,
1768 + item: { itemId: "sub-1", kind: "subagent", turnId: nativeId, ...fields },
1769 + });
1770 + const item = yield* harness.takeEvent(
1771 + "turn_item.updated",
1772 + (event) => event.turnItem.type === "subagent",
1773 + );
1774 + const roster = harness.allEvents.findLast(
1775 + (event) => event.type === "provider_thread.updated",
1776 + );
1777 + listed.push({
1778 + nativeId: item.turnItem.nativeItemRef?.nativeId,
1779 + roster:
1780 + roster?.type === "provider_thread.updated"
1781 + ? (roster.providerThread.pendingBackgroundTasks ?? []).map((task) => task.taskId)
1782 + : [],
1783 + });
1784 + }
1785 + assert.deepStrictEqual(listed, [
1786 + { nativeId: "sub-1", roster: ["sub-1"] },
1787 + { nativeId: "sub-1", roster: ["sub-1"] },
1788 + { nativeId: "subagent-1", roster: ["subagent-1"] },
1789 + { nativeId: "child-session-1", roster: ["child-session-1"] },
1790 + { nativeId: "child-session-1", roster: [] },
1791 + ]);
1792 + }).pipe(Effect.scoped, Effect.provide(testLayer)),
1793 + );
1794 +
1795 it.effect("keeps a workflow child's first label after later revisions drop it", () =>
1796 Effect.gen(function* () {
1797 const fake = yield* makeFakeMuse();
packages/provider-muse/src/server/adapter.ts
+12 -5
@@ -248,6 +248,9 @@ const nativeRef = (nativeId: string) => ({
248 nativeId,
249 strength: "strong" as const,
250 });
251 +/** The roster lists a child under its turn item's native id, so readers can pair the two. */
252 +const backgroundTaskId = (item: MuseItem) =>
253 + item.kind === "subagent" ? item.childSessionId || item.subagentId || item.itemId : item.itemId;
254 const recordSchema = Schema.Record(Schema.String, Schema.Unknown);
255 const INFORMATIONAL_NOTIFICATIONS = new Set([
256 "session/contextUsage",
@@ -597,9 +600,7 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
600 item.result?.summary ??
601 (status === "failed" ? item.failureReason : undefined);
602 const result = resultText ?? null;
600 - const nativeTaskRef = item.childSessionId
601 - ? nativeRef(item.childSessionId)
602 - : nativeRef(item.subagentId ?? item.itemId);
603 + const nativeTaskRef = nativeRef(backgroundTaskId(item));
604 const subagent: OrchestrationV2Subagent = {
605 id: base.nodeId,
606 threadId: base.threadId,
@@ -677,7 +678,7 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
678 const description = item?.objective ?? item?.entryId ?? item?.fallbackText;
679 return [
680 {
680 - taskId: itemId,
681 + taskId: item ? backgroundTaskId(item) : itemId,
682 kind:
683 item?.kind === "subagent" ? ("subagent" as const) : ("background_task" as const),
684 ...(description ? { description } : {}),
@@ -716,7 +717,13 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
717 ? "cancelled"
718 : "failed",
719 });
719 - if (wasRunning !== observedChildren.has(item.itemId)) yield* syncBackground();
720 + const running = observedChildren.has(item.itemId);
721 + // Muse reveals a subagent's ids over several revisions, so a running child is
722 + // relisted whenever the id its turn item carries moves.
723 + const listed = thread?.pendingBackgroundTasks?.some(
724 + (task) => task.taskId === backgroundTaskId(item),
725 + );
726 + if (wasRunning !== running || (running && !listed)) yield* syncBackground();
727 }
728 const streaming = status === "running";
729 const base = {