diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index 7463e325f734c..f4b1d5a542a90 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -435,6 +435,7 @@ export function HomeScreen(props: HomeScreenProps) {
settledShelfExpanded,
snoozedShelfExpanded,
workingShelfEnabled,
+ inboxOldestFirst,
workingShelfExpanded,
toggleSettledShelf,
toggleSnoozedShelf,
@@ -478,6 +479,7 @@ export function HomeScreen(props: HomeScreenProps) {
pendingOrder,
shelfPreferencesLoaded,
workingShelfEnabled,
+ inboxOldestFirst,
workingShelfExpanded,
snoozedShelfExpanded,
settledShelfExpanded,
diff --git a/apps/mobile/src/features/settings/ThreadSettingsSections.tsx b/apps/mobile/src/features/settings/ThreadSettingsSections.tsx
index df463bd1f664c..efbd07896be8a 100644
--- a/apps/mobile/src/features/settings/ThreadSettingsSections.tsx
+++ b/apps/mobile/src/features/settings/ThreadSettingsSections.tsx
@@ -189,6 +189,8 @@ export function WorkingSectionSettings() {
const preferences = useAtomValue(mobilePreferencesAtom);
const workingShelfEnabled =
AsyncResult.isSuccess(preferences) && preferences.value.workingShelfEnabled !== false;
+ const inboxOldestFirst =
+ AsyncResult.isSuccess(preferences) && preferences.value.inboxOldestFirst === true;
return (
@@ -199,11 +201,19 @@ export function WorkingSectionSettings() {
value={workingShelfEnabled}
onValueChange={(value) => savePreferences({ workingShelfEnabled: value })}
/>
+ {workingShelfEnabled ? (
+ savePreferences({ inboxOldestFirst: value })}
+ />
+ ) : null}
- Fold working and monitoring threads into a Working section. They return to the top of the
- list when they need you. While this is on, active threads are ordered by time and cannot be
- moved.
+ Fold working and monitoring threads into a Working section. They return to the list when
+ they need you. While this is on, active threads are ordered by time and cannot be moved.
);
diff --git a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
index 839506c84bc19..e738e1065d565 100644
--- a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
@@ -176,7 +176,7 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
const pendingOrder = useAtomValue(pendingThreadOrderAtom);
const dropBusy = useAtomValue(threadDropBusyAtom);
const { moveThread } = useThreadListActions();
- const { workingShelfEnabled } = useThreadListV2ShelfPreferences();
+ const { workingShelfEnabled, inboxOldestFirst } = useThreadListV2ShelfPreferences();
const now = useThreadListNow(threads);
const [expanded, setExpanded] = useState({ snoozed: false, settled: false });
const [settledVisibleCount, setSettledVisibleCount] = useState(
@@ -206,12 +206,20 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
return {
pinned,
active: workingShelfEnabled
- ? sortInboxThreadsByReturn(active, threadListInboxReturns.returnedAt)
+ ? sortInboxThreadsByReturn(active, threadListInboxReturns.returnedAt, inboxOldestFirst)
: active,
snoozed: parked.filter((thread) => effectiveSnoozed(thread, { now })),
settled: sortSettledThreads(parked.filter((thread) => !effectiveSnoozed(thread, { now }))),
};
- }, [threads, configs, now, queuedThreadKeys, pendingOrder, workingShelfEnabled]);
+ }, [
+ threads,
+ configs,
+ now,
+ queuedThreadKeys,
+ pendingOrder,
+ workingShelfEnabled,
+ inboxOldestFirst,
+ ]);
const listedSettled = sections.settled.filter(olderSettledShelf.isListed);
useOlderSettledShelfGrowth(olderSettledShelf, listedSettled);
const visibleSettled = listedSettled.slice(0, settledVisibleCount);
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index dce389c836669..2e4b653e978ca 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -238,6 +238,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
settledShelfExpanded,
snoozedShelfExpanded,
workingShelfEnabled,
+ inboxOldestFirst,
workingShelfExpanded,
toggleSettledShelf,
toggleSnoozedShelf,
@@ -281,6 +282,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
pendingOrder,
shelfPreferencesLoaded,
workingShelfEnabled,
+ inboxOldestFirst,
workingShelfExpanded,
snoozedShelfExpanded,
settledShelfExpanded,
diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.ts
index 1b79c9a15d6f0..d7f85ddb1a054 100644
--- a/apps/mobile/src/features/threads/threadListV2.ts
+++ b/apps/mobile/src/features/threads/threadListV2.ts
@@ -663,6 +663,7 @@ export function buildThreadListV2Items(input: {
readonly settledLimit?: number;
readonly now: string;
readonly workingShelfEnabled?: boolean;
+ readonly inboxOldestFirst?: boolean;
readonly workingShelfExpanded?: boolean;
readonly isWorking?: (thread: EnvironmentThreadShell) => boolean;
readonly inboxReturnAt?: (thread: EnvironmentThreadShell) => number | undefined;
@@ -799,7 +800,7 @@ export function buildThreadListV2Items(input: {
}
const orderedActive = workingShelfEnabled
- ? sortInboxThreadsByReturn(active, input.inboxReturnAt)
+ ? sortInboxThreadsByReturn(active, input.inboxReturnAt, input.inboxOldestFirst)
: applyPendingThreadOrder(sortThreadsForListV2(active), "active", pending);
const orderedWorking = sortWorkingThreadsBySend(working);
const orderedSnoozed = [...snoozed].sort(
diff --git a/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts b/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts
index 4348908e5371b..7f15a6c13b740 100644
--- a/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts
+++ b/apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts
@@ -12,6 +12,7 @@ export function useThreadListV2ShelfPreferences() {
const settledShelfExpanded =
loaded && preferencesResult.value.threadListSettledShelfExpanded === true;
const workingShelfEnabled = loaded && preferencesResult.value.workingShelfEnabled !== false;
+ const inboxOldestFirst = loaded && preferencesResult.value.inboxOldestFirst === true;
const workingShelfExpanded =
loaded && preferencesResult.value.threadListWorkingShelfExpanded === true;
@@ -46,6 +47,7 @@ export function useThreadListV2ShelfPreferences() {
settledShelfExpanded,
snoozedShelfExpanded,
workingShelfEnabled,
+ inboxOldestFirst,
workingShelfExpanded,
toggleSettledShelf,
toggleSnoozedShelf,
diff --git a/apps/mobile/src/features/threads/useThreadListV2.test.tsx b/apps/mobile/src/features/threads/useThreadListV2.test.tsx
index 7eac8955efa14..bbe76e62e73f4 100644
--- a/apps/mobile/src/features/threads/useThreadListV2.test.tsx
+++ b/apps/mobile/src/features/threads/useThreadListV2.test.tsx
@@ -56,6 +56,7 @@ it("reuses a large thread list across tab renders and updates when its inputs ch
pendingOrder: null,
shelfPreferencesLoaded: true,
workingShelfEnabled: true,
+ inboxOldestFirst: false,
workingShelfExpanded: false,
snoozedShelfExpanded: false,
settledShelfExpanded: true,
diff --git a/apps/mobile/src/features/threads/useThreadListV2.ts b/apps/mobile/src/features/threads/useThreadListV2.ts
index fcf1048d2b6af..3f4fb4d50487b 100644
--- a/apps/mobile/src/features/threads/useThreadListV2.ts
+++ b/apps/mobile/src/features/threads/useThreadListV2.ts
@@ -61,6 +61,7 @@ export function useThreadListV2(input: {
readonly pendingOrder: LayoutInput["pendingOrder"];
readonly shelfPreferencesLoaded: boolean;
readonly workingShelfEnabled: boolean;
+ readonly inboxOldestFirst: boolean;
readonly workingShelfExpanded: boolean;
readonly snoozedShelfExpanded: boolean;
readonly settledShelfExpanded: boolean;
@@ -146,6 +147,7 @@ export function useThreadListV2(input: {
settledLimit: input.settledLimit,
now: layoutTime,
workingShelfEnabled,
+ inboxOldestFirst: input.inboxOldestFirst,
workingShelfExpanded: input.workingShelfExpanded,
inboxReturnAt: inbox.returnedAt,
isWorking: inbox.isWorking,
@@ -178,6 +180,7 @@ export function useThreadListV2(input: {
input.settledLimit,
layoutTime,
workingShelfEnabled,
+ input.inboxOldestFirst,
input.workingShelfExpanded,
inbox.returnedAt,
inbox.isWorking,
diff --git a/apps/mobile/src/persistence/mobile-preferences.ts b/apps/mobile/src/persistence/mobile-preferences.ts
index 436f3b172cdae..c53e732bc7256 100644
--- a/apps/mobile/src/persistence/mobile-preferences.ts
+++ b/apps/mobile/src/persistence/mobile-preferences.ts
@@ -119,6 +119,7 @@ export interface Preferences {
readonly planModeEnabled?: boolean;
readonly toolCallVisibility?: ToolCallVisibility;
readonly workingShelfEnabled?: boolean;
+ readonly inboxOldestFirst?: boolean;
readonly useLastProjectForNewThreads?: boolean;
readonly lastThreadProject?: typeof ThreadProject.Type;
readonly modelFavorites?: ReadonlyArray<{
@@ -204,6 +205,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
planModeEnabled?: boolean;
toolCallVisibility?: ToolCallVisibility;
workingShelfEnabled?: boolean;
+ inboxOldestFirst?: boolean;
useLastProjectForNewThreads?: boolean;
lastThreadProject?: typeof ThreadProject.Type;
modelFavorites?: Preferences["modelFavorites"];
@@ -335,6 +337,9 @@ function sanitizePreferences(parsed: Preferences): Preferences {
if (typeof parsed.workingShelfEnabled === "boolean") {
preferences.workingShelfEnabled = parsed.workingShelfEnabled;
}
+ if (typeof parsed.inboxOldestFirst === "boolean") {
+ preferences.inboxOldestFirst = parsed.inboxOldestFirst;
+ }
if (typeof parsed.useLastProjectForNewThreads === "boolean") {
preferences.useLastProjectForNewThreads = parsed.useLastProjectForNewThreads;
}
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 1ed3065a92c0d..8c5deb467007f 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -353,6 +353,7 @@ interface SidebarThreadPartitionInput {
readonly workingShelfEnabled: boolean;
/** Boring mode: folders list active threads by the user's latest message. */
readonly sortActiveBySend: boolean;
+ readonly inboxOldestFirst: boolean;
// Snooze wakes, the queued-turn grace and the Working shelf's exit grace depend
// on the clock, so the minute tick, the precise snooze-wake tick and the inbox
// tracker's expiry version are inputs: a new key repartitions.
@@ -379,6 +380,7 @@ function resolveDraggedOrders(input: {
readonly settledThreads: readonly EnvironmentThreadShell[];
readonly activeThreads: readonly EnvironmentThreadShell[];
readonly workingShelfEnabled: boolean;
+ readonly inboxOldestFirst: boolean;
}): typeof NO_DRAGGED_ORDERS {
const { drag, threadByKey, settledThreads, activeThreads, workingShelfEnabled } = input;
const thread = threadByKey.get(drag.activeKey);
@@ -394,6 +396,7 @@ function resolveDraggedOrders(input: {
? sortInboxThreadsByReturn(
[...others(activeThreads), applySidebarThreadDrop(thread, "active", drag.occurredAt)],
inboxReturns.returnedAt,
+ input.inboxOldestFirst,
).map(threadShellKey)
: undefined,
};
@@ -438,6 +441,7 @@ function useSidebarThreads(input: {
// Folders already separate the work, so boring mode has no Working shelf.
const workingShelfEnabled =
useClientSettings((s) => s.sidebarWorkingShelfEnabled) && folderGroups === null;
+ const inboxOldestFirst = useClientSettings((s) => s.sidebarInboxOldestFirst);
const inboxReturnsVersion = useSyncExternalStore(
inboxReturns.subscribe,
inboxReturns.getSnapshot,
@@ -482,6 +486,7 @@ function useSidebarThreads(input: {
optimisticDrop,
workingShelfEnabled,
sortActiveBySend: folderGroups !== null,
+ inboxOldestFirst,
clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`,
});
@@ -562,6 +567,7 @@ function useSidebarThreads(input: {
...partition,
threads,
workingShelfEnabled,
+ inboxOldestFirst,
searchableThreads: [
...pinnedThreads,
...activeThreads,
@@ -677,7 +683,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
const sortedActive = sortActiveBySend
? sortWorkingThreadsBySend(active)
: workingShelfEnabled
- ? sortInboxThreadsByReturn(active, inboxObservation.returnedAt)
+ ? sortInboxThreadsByReturn(active, inboxObservation.returnedAt, input.inboxOldestFirst)
: sortThreadsForSidebar(active);
return {
pinnedThreads:
@@ -1288,6 +1294,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
const {
workingShelfEnabled,
+ inboxOldestFirst,
pinnedThreads,
draggableThreadKeys,
activeReorderableThreadKeys,
@@ -2009,6 +2016,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
settledThreads,
activeThreads,
workingShelfEnabled,
+ inboxOldestFirst,
});
const sidebarSortingStrategy = createSidebarSortingStrategy({
items: sidebarListItems,
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index d408d6c8d5d94..1e0224831e140 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -483,6 +483,9 @@ export function useSettingsRestore(onRestored?: () => void) {
...(settings.sidebarWorkingShelfEnabled !== DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled
? ["Working section"]
: []),
+ ...(settings.sidebarInboxOldestFirst !== DEFAULT_UNIFIED_SETTINGS.sidebarInboxOldestFirst
+ ? ["Oldest first"]
+ : []),
...(settings.sidebarAutoSettleAfterDays !== DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays
? ["Auto-settle inactive threads"]
: []),
@@ -652,6 +655,7 @@ export function useSettingsRestore(onRestored?: () => void) {
sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode,
sidebarProjectSortOrder: DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder,
sidebarWorkingShelfEnabled: DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled,
+ sidebarInboxOldestFirst: DEFAULT_UNIFIED_SETTINGS.sidebarInboxOldestFirst,
sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays,
sidebarAutoSettleKeepPullRequests: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests,
sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge,
@@ -884,7 +888,7 @@ export function GeneralSettingsPanel() {
/>
}
/>
+ {settings.sidebarWorkingShelfEnabled &&
+ !settings.boringSidebarEnabled &&
+ !settings.legacySidebarEnabled ? (
+
+ updateSettings({
+ sidebarInboxOldestFirst: DEFAULT_UNIFIED_SETTINGS.sidebarInboxOldestFirst,
+ })
+ }
+ />
+ ) : null
+ }
+ control={
+
+ updateSettings({ sidebarInboxOldestFirst: Boolean(checked) })
+ }
+ aria-label="Oldest first"
+ />
+ }
+ />
+ ) : null}
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index 4c890c05aa4e9..ba342712703bb 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -456,6 +456,13 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/general",
searchTerms: ["hide fold running monitoring threads inbox sidebar shelf"],
},
+ {
+ id: "inbox-oldest-first",
+ title: "Oldest first",
+ to: "/settings/general",
+ targetId: "working-shelf",
+ searchTerms: ["sort order reverse queue inbox threads sidebar newest"],
+ },
{
id: "boring-sidebar",
title: "Boring sidebar (group by project)",
diff --git a/docs/user/thread-sidebar.md b/docs/user/thread-sidebar.md
index 25095b70f1c3d..23577d53146ce 100644
--- a/docs/user/thread-sidebar.md
+++ b/docs/user/thread-sidebar.md
@@ -137,8 +137,8 @@ Threads that are working or waiting on work they will resume from move into a co
**Working** section below the active list.
That includes subagents, watched pull requests, and background commands or monitors the agent
says it is waiting on. A dev server or other process an agent leaves running does not keep a thread
-there. A thread returns to the top of the active list when it finishes, fails, or needs an approval or
-answer. The Working section lists the thread you last sent work to first. Pinned threads stay in
+there. A thread returns to the top of the active list, or the bottom with Oldest first, when it
+finishes, fails, or needs an approval or answer. The Working section lists the thread you last sent work to first. Pinned threads stay in
the pinned section.
This is on by default. Turn it off with **Settings → General → Working section** on web and desktop,
@@ -148,6 +148,10 @@ choice.
While this is on, the active list is ordered by when each thread last came back to you, so you
cannot drag or move threads within it. Your saved order returns when you turn it off.
+To work through the active list as a queue, turn on **Settings → General → Oldest first**. The
+thread that has waited longest stays at the top, and threads that come back later join at the
+bottom. Each device keeps its own choice.
+
### Group threads by project (beta)
Turn on **Settings → Labs → Boring sidebar (group by project)** on web and desktop to put active
diff --git a/packages/client-runtime/src/state/threadInbox.test.ts b/packages/client-runtime/src/state/threadInbox.test.ts
index 35c7fa8355e39..4a7fc707c3e31 100644
--- a/packages/client-runtime/src/state/threadInbox.test.ts
+++ b/packages/client-runtime/src/state/threadInbox.test.ts
@@ -198,6 +198,9 @@ describe("createInboxReturnTracker", () => {
"b",
"a",
]);
+ expect(
+ sortInboxThreadsByReturn([b, a], tracker.returnedAt, true).map((entry) => entry.id),
+ ).toEqual(["a", "b"]);
});
it("cancels pending timers for removed threads and disabled shelves", () => {
diff --git a/packages/client-runtime/src/state/threadInbox.ts b/packages/client-runtime/src/state/threadInbox.ts
index 2669416db42fe..249a6f26b9c3f 100644
--- a/packages/client-runtime/src/state/threadInbox.ts
+++ b/packages/client-runtime/src/state/threadInbox.ts
@@ -38,6 +38,7 @@ type InboxThreadInput = Pick<
export function sortInboxThreadsByReturn(
threads: readonly T[],
observedReturnAt?: (thread: T) => number | undefined,
+ oldestFirst = false,
): T[] {
const timestamps = new Map(
threads.map((thread) => [
@@ -51,7 +52,8 @@ export function sortInboxThreadsByReturn(
),
]),
);
- return sortNewestFirst(threads, timestamps);
+ const newestFirst = sortNewestFirst(threads, timestamps);
+ return oldestFirst ? newestFirst.reverse() : newestFirst;
}
type WorkingSortInput = Pick<
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 8a4b25589121c..796a60d6915f1 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -516,6 +516,7 @@ export const ClientSettingsSchema = Schema.Struct({
// the boring sidebar; the boring sidebar toggle clears it.
legacySidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
sidebarWorkingShelfEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
+ sidebarInboxOldestFirst: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE)),
),
@@ -1888,6 +1889,7 @@ export const ClientSettingsPatch = Schema.Struct({
threadDetailsItems: Schema.optionalKey(Schema.Record(Schema.String, Schema.Boolean)),
legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
sidebarWorkingShelfEnabled: Schema.optionalKey(Schema.Boolean),
+ sidebarInboxOldestFirst: Schema.optionalKey(Schema.Boolean),
sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
sidebarProjectGroupingOverrides: Schema.optionalKey(
Schema.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode),