Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/mobile/src/features/threads/thread-list-v2-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ interface StatusLabel {
}
const STATUS_LABEL_BY_STATUS: Partial<Record<ThreadListV2Status, StatusLabel>> = {
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",
Expand Down
28 changes: 18 additions & 10 deletions apps/mobile/src/features/threads/threadListV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1742,16 +1742,24 @@ describe("Working section beta", () => {
const ids = (layout: ReturnType<typeof buildThreadListV2Items>) =>
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");
Expand Down Expand Up @@ -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", () => {
Expand Down
5 changes: 3 additions & 2 deletions apps/mobile/src/features/threads/threadListV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
24 changes: 24 additions & 0 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
pinOrderKeyBetween,
resolveSidebarSweepKeys,
resolveSidebarRowStatus,
resolveSidebarShelf,
resolveSidebarThreadSection,
resolveSidebarThreadStatus,
resolveThreadStatusPill,
resolveWindowTitleThreadStatus,
Expand Down Expand Up @@ -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({
Expand Down
12 changes: 12 additions & 0 deletions apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
18 changes: 12 additions & 6 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ import {
resolveSidebarSweepKeys,
resolveSidebarDropTarget,
resolveSidebarDropVerb,
resolveSidebarShelf,
resolveSidebarThreadSection,
resolveSidebarReorderableThreadKeys,
searchSidebarThreads,
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/sidebar/SidebarThreadRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
10 changes: 10 additions & 0 deletions packages/client-runtime/src/state/threadInbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion packages/client-runtime/src/state/threadInbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading