From 36f86ddefdd706707dd1660eca9421609095165e Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:34:09 +0000 Subject: [PATCH 1/2] fix(web): threads waiting on their own agents list under Working, even when pinned A pinned thread waiting on its own background task or child agent stayed in Pinned at the top of the list among finished threads, reading "Waiting", instead of moving to Working. The partition sent every pinned thread to Pinned before asking whether it was working. A working pinned thread now lists under Working and returns to Pinned when it finishes; it gets the same exit grace as any other Working thread. Done, snoozed and settled threads keep their groups. A thread waiting on a person (a pending approval or question) reads "Needs you" instead of "Approval" or "Input". Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/Sidebar.logic.test.ts | 24 +++++++++++++++++++ apps/web/src/components/Sidebar.logic.ts | 12 ++++++++++ apps/web/src/components/Sidebar.tsx | 18 +++++++++----- .../components/sidebar/SidebarThreadRow.tsx | 4 ++-- .../src/state/threadInbox.test.ts | 10 ++++++++ .../client-runtime/src/state/threadInbox.ts | 3 ++- 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index 2fa0d608b1f1..68a195716a02 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -15,6 +15,8 @@ import { pinOrderKeyBetween, resolveSidebarSweepKeys, resolveSidebarRowStatus, + resolveSidebarShelf, + resolveSidebarThreadSection, resolveSidebarThreadStatus, resolveThreadStatusPill, resolveWindowTitleThreadStatus, @@ -1047,6 +1049,28 @@ describe("Working shelf (beta)", () => { ).toBe(false); }); + it("lists a pinned thread that waits on its own agents under Working until it finishes", () => { + // A pinned parent waiting on a delegated child reads Waiting; it belongs in Working. + const shelf = (thread: typeof waiting | typeof idle, placement: { pinned?: boolean } = {}) => + resolveSidebarShelf( + resolveSidebarThreadSection({ + snoozed: false, + settled: false, + pinned: placement.pinned ?? false, + }), + isSidebarThreadWorking(thread), + ); + expect(shelf(waiting, { pinned: true })).toBe("working"); + expect(shelf(waiting)).toBe("working"); + expect(shelf(idle, { pinned: true })).toBe("pinned"); + expect(shelf(idle)).toBe("active"); + // Settled and snoozed threads stay in their own groups even while working. + expect(resolveSidebarShelf("settled", true)).toBe("settled"); + expect(resolveSidebarShelf("snoozed", true)).toBe("snoozed"); + // A thread waiting on a person is not Working, pinned or not. + expect(shelf({ ...waiting, hasPendingApprovals: true }, { pinned: true })).toBe("pinned"); + }); + it("keeps a ready plan in the inbox while background work runs", () => { expect( isSidebarThreadWorking({ diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index 3d0288f1bbf6..577035f47800 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -210,6 +210,18 @@ export function resolveSidebarThreadSection(input: { return "active"; } +/** + * The shelf a thread lists in while the Working shelf is on. Work the thread waits on, such as + * its own background task or child agent, keeps it Working even when pinned; it returns to + * Pinned when it finishes. Snoozed and settled threads stay put. + */ +export function resolveSidebarShelf( + section: SidebarSection, + working: boolean, +): SidebarSection | "working" { + return working && (section === "active" || section === "pinned") ? "working" : section; +} + const SIDEBAR_MARKER_PREFIX = "sidebar-marker-"; export type SidebarListMarker = diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index ab7a874106bc..e62fabe4b203 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -203,6 +203,7 @@ import { resolveSidebarSweepKeys, resolveSidebarDropTarget, resolveSidebarDropVerb, + resolveSidebarShelf, resolveSidebarThreadSection, resolveSidebarReorderableThreadKeys, searchSidebarThreads, @@ -673,18 +674,23 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { : { ...projected, snoozedAt: thread.snoozedAt, snoozedUntil: thread.snoozedUntil }, ); } else { - const section = resolveSidebarThreadSection({ - snoozed: configLoaded && effectiveSnoozed(thread, { now: preciseNow }), - settled: configLoaded && thread.settledOverride === "settled", - pinned: thread.pinnedAt != null, - }); + const section = resolveSidebarShelf( + resolveSidebarThreadSection({ + snoozed: configLoaded && effectiveSnoozed(thread, { now: preciseNow }), + settled: configLoaded && thread.settledOverride === "settled", + pinned: thread.pinnedAt != null, + }), + workingShelfEnabled && inboxObservation.isWorking(thread), + ); (section === "snoozed" ? snoozed : section === "settled" ? settled : section === "pinned" ? pinned - : inbox(thread) + : section === "working" + ? working + : active ).push(thread); } } diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index 12f79eb6a843..d9e17f4df974 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -800,13 +800,13 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP } : status === "approval" ? { - label: "Approval", + label: "Needs you", icon: "approval" as const, className: "text-warning-foreground", } : status === "input" ? { - label: "Input", + label: "Needs you", icon: "input" as const, className: "text-indigo-600 dark:text-indigo-300", } diff --git a/packages/client-runtime/src/state/threadInbox.test.ts b/packages/client-runtime/src/state/threadInbox.test.ts index 4e4a39d2c8a2..6511ab5784f6 100644 --- a/packages/client-runtime/src/state/threadInbox.test.ts +++ b/packages/client-runtime/src/state/threadInbox.test.ts @@ -79,6 +79,16 @@ describe("createInboxReturnTracker", () => { unsubscribe(); }); + it("gives a pinned thread the same grace, so it doesn't flicker out of Working", () => { + const tracker = createInboxReturnTracker(); + const pinned = { pinnedAt: "2026-06-01T00:00:01Z" }; + tracker.observe([{ ...thread("a", true), ...pinned }]); + tracker.observe([{ ...thread("a", false), ...pinned }]); + expect(tracker.isWorking(thread("a", false))).toBe(true); + vi.advanceTimersByTime(2_000); + expect(tracker.isWorking(thread("a", false))).toBe(false); + }); + it("moves a thread whose run ended long ago at once, as after a reconnect", () => { const tracker = createInboxReturnTracker(); const finished = { diff --git a/packages/client-runtime/src/state/threadInbox.ts b/packages/client-runtime/src/state/threadInbox.ts index ac820acc9d1e..718d13c443bb 100644 --- a/packages/client-runtime/src/state/threadInbox.ts +++ b/packages/client-runtime/src/state/threadInbox.ts @@ -234,10 +234,11 @@ export function createInboxReturnTracker() { thread.runtime?.lastError != null || thread.latestRun?.status === "failed"; const moved = previous !== undefined && previous.placement !== placement; + // Pinned threads list in Working too, so they get the same grace; pinning one mid-grace + // still ends it, since that changes its placement. const excluded = thread.archivedAt != null || thread.deletedAt != null || - thread.pinnedAt != null || thread.settledOverride === "settled" || effectiveSnoozed(thread, { now: observedAt }); // Only shelf placement is held: execution state and attention requests stay authoritative. From d1b01cc33e17f91d16e2d822a89cdfc1ac33ef13 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:54:44 +0000 Subject: [PATCH 2/2] fix(mobile): threads waiting on their own agents list under Working, even when pinned Mobile had the same order as web: every pinned thread went to Pinned before the Working check, so a pinned parent waiting on its child sat in the top list. A working thread now lists under Working pinned or not, and a thread waiting on a person reads "Needs you", matching the web sidebar. Co-Authored-By: Claude Opus 5.5 --- .../features/threads/thread-list-v2-items.tsx | 4 +-- .../src/features/threads/threadListV2.test.ts | 28 ++++++++++++------- .../src/features/threads/threadListV2.ts | 5 ++-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx index d304bc87ed45..14acc06c0108 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -103,13 +103,13 @@ interface StatusLabel { } const STATUS_LABEL_BY_STATUS: Partial> = { approval: { - label: "Approval", + label: "Needs you", icon: "exclamationmark.shield", className: "text-warning-foreground", iconTintClassName: "accent-warning-foreground", }, input: { - label: "Input", + label: "Needs you", icon: "questionmark.bubble", className: "text-adaptive-indigo-600-300", iconTintClassName: "accent-adaptive-indigo-600-300", diff --git a/apps/mobile/src/features/threads/threadListV2.test.ts b/apps/mobile/src/features/threads/threadListV2.test.ts index 16ef19a32993..a930516c0745 100644 --- a/apps/mobile/src/features/threads/threadListV2.test.ts +++ b/apps/mobile/src/features/threads/threadListV2.test.ts @@ -1742,16 +1742,24 @@ describe("Working section beta", () => { const ids = (layout: ReturnType) => layout.items.map((item) => item.thread.id); - it("folds unpinned working threads into a collapsed shelf", () => { + it("folds working threads, pinned ones too, into a collapsed shelf", () => { const layout = build(); - expect(ids(layout)).toEqual([ - "pinned-working", - "finished-late", - "asks-approval", - "finished-early", - ]); - expect(layout.workingCount).toBe(1); - expect(layout.workingShelfHeaderIndex).toBe(4); + expect(ids(layout)).toEqual(["finished-late", "asks-approval", "finished-early"]); + expect(layout.workingCount).toBe(2); + expect(layout.workingShelfHeaderIndex).toBe(3); + // A pinned thread waiting on its own child agent is Working, not in the top list. + const waitingOnChild = makeThread({ + id: ThreadId.make("pinned-waiting"), + title: "pinned-waiting", + pinnedAt: "2026-06-01T00:00:00.000Z", + runtime: { ...running, status: "idle" }, + pendingBackgroundTasks: [{ taskId: "child", kind: "subagent" }], + }); + expect(ids(build({ threads: [waitingOnChild] }))).toEqual([]); + expect(build({ threads: [waitingOnChild] }).workingCount).toBe(1); + expect( + ids(build({ threads: [{ ...waitingOnChild, runtime: null, pendingBackgroundTasks: [] }] })), + ).toEqual(["pinned-waiting"]); const off = build({ workingShelfEnabled: false }); expect(ids(off)).toContain("working"); @@ -1791,7 +1799,7 @@ describe("Working section beta", () => { inboxReturnAt: (thread) => thread.id === "finished-early" ? Date.parse("2026-06-01T04:00:00.000Z") : undefined, }); - expect(ids(layout).slice(1)).toEqual(["finished-early", "finished-late", "asks-approval"]); + expect(ids(layout)).toEqual(["finished-early", "finished-late", "asks-approval"]); }); it("places the shelf after queued tasks and before snoozed and settled threads", () => { diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.ts index 5aad60e7b1f0..de66a869c517 100644 --- a/apps/mobile/src/features/threads/threadListV2.ts +++ b/apps/mobile/src/features/threads/threadListV2.ts @@ -795,10 +795,11 @@ export function buildThreadListV2Items(input: { queuedThreadKeys?.has(`${thread.environmentId}:${thread.id}`) === true; if (supportsSettlement && thread.settledOverride === "settled" && !hasQueuedMessages) { settled.push(thread); - } else if (thread.pinnedAt != null) { - pinned.push(thread); } else if (workingShelfEnabled && (input.isWorking ?? isThreadWorking)(thread)) { + // Pinned or not: a thread working or waiting on its own agents returns to Pinned when done. working.push(thread); + } else if (thread.pinnedAt != null) { + pinned.push(thread); } else { active.push(thread); }