Skip to content
Open
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
2 changes: 2 additions & 0 deletions apps/mobile/src/features/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export function HomeScreen(props: HomeScreenProps) {
settledShelfExpanded,
snoozedShelfExpanded,
workingShelfEnabled,
inboxOldestFirst,
workingShelfExpanded,
toggleSettledShelf,
toggleSnoozedShelf,
Expand Down Expand Up @@ -478,6 +479,7 @@ export function HomeScreen(props: HomeScreenProps) {
pendingOrder,
shelfPreferencesLoaded,
workingShelfEnabled,
inboxOldestFirst,
workingShelfExpanded,
snoozedShelfExpanded,
settledShelfExpanded,
Expand Down
16 changes: 13 additions & 3 deletions apps/mobile/src/features/settings/ThreadSettingsSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<View className="gap-3">
Expand All @@ -199,11 +201,19 @@ export function WorkingSectionSettings() {
value={workingShelfEnabled}
onValueChange={(value) => savePreferences({ workingShelfEnabled: value })}
/>
{workingShelfEnabled ? (
<SettingsSwitchRow
icon="arrow.up.circle"
label="Oldest first"
subtitle="The thread that has waited longest stays at the top."
value={inboxOldestFirst}
onValueChange={(value) => savePreferences({ inboxOldestFirst: value })}
/>
) : null}
</SettingsSection>
<Text className="px-2 text-sm text-foreground-muted">
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.
</Text>
</View>
);
Expand Down
14 changes: 11 additions & 3 deletions apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
settledShelfExpanded,
snoozedShelfExpanded,
workingShelfEnabled,
inboxOldestFirst,
workingShelfExpanded,
toggleSettledShelf,
toggleSnoozedShelf,
Expand Down Expand Up @@ -281,6 +282,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
pendingOrder,
shelfPreferencesLoaded,
workingShelfEnabled,
inboxOldestFirst,
workingShelfExpanded,
snoozedShelfExpanded,
settledShelfExpanded,
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/features/threads/threadListV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -46,6 +47,7 @@ export function useThreadListV2ShelfPreferences() {
settledShelfExpanded,
snoozedShelfExpanded,
workingShelfEnabled,
inboxOldestFirst,
workingShelfExpanded,
toggleSettledShelf,
toggleSnoozedShelf,
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/src/features/threads/useThreadListV2.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/src/features/threads/useThreadListV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -178,6 +180,7 @@ export function useThreadListV2(input: {
input.settledLimit,
layoutTime,
workingShelfEnabled,
input.inboxOldestFirst,
input.workingShelfExpanded,
inbox.returnedAt,
inbox.isWorking,
Expand Down
5 changes: 5 additions & 0 deletions apps/mobile/src/persistence/mobile-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -394,6 +396,7 @@ function resolveDraggedOrders(input: {
? sortInboxThreadsByReturn(
[...others(activeThreads), applySidebarThreadDrop(thread, "active", drag.occurredAt)],
inboxReturns.returnedAt,
input.inboxOldestFirst,
).map(threadShellKey)
: undefined,
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -482,6 +486,7 @@ function useSidebarThreads(input: {
optimisticDrop,
workingShelfEnabled,
sortActiveBySend: folderGroups !== null,
inboxOldestFirst,
clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`,
});

Expand Down Expand Up @@ -562,6 +567,7 @@ function useSidebarThreads(input: {
...partition,
threads,
workingShelfEnabled,
inboxOldestFirst,
searchableThreads: [
...pinnedThreads,
...activeThreads,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1288,6 +1294,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve

const {
workingShelfEnabled,
inboxOldestFirst,
pinnedThreads,
draggableThreadKeys,
activeReorderableThreadKeys,
Expand Down Expand Up @@ -2009,6 +2016,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
settledThreads,
activeThreads,
workingShelfEnabled,
inboxOldestFirst,
});
const sidebarSortingStrategy = createSidebarSortingStrategy({
items: sidebarListItems,
Expand Down
36 changes: 35 additions & 1 deletion apps/web/src/components/settings/SettingsPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
: []),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -884,7 +888,7 @@ export function GeneralSettingsPanel() {
/>
<SettingsRow
{...searchableSetting("working-shelf")}
description="Fold working and monitoring threads into a Working section. They return to the top of the inbox when they need you. The boring sidebar in Labs has no Working section."
description="Fold working and monitoring threads into a Working section. They return to the inbox when they need you. The boring sidebar in Labs has no Working section."
resetAction={
settings.sidebarWorkingShelfEnabled !==
DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled ? (
Expand All @@ -908,6 +912,36 @@ export function GeneralSettingsPanel() {
/>
}
/>
{settings.sidebarWorkingShelfEnabled &&
!settings.boringSidebarEnabled &&
!settings.legacySidebarEnabled ? (
<SettingsRow
title={searchableSetting("inbox-oldest-first").title}
description="The thread that has waited longest stays at the top of the inbox. Threads that come back later join at the bottom."
resetAction={
settings.sidebarInboxOldestFirst !==
DEFAULT_UNIFIED_SETTINGS.sidebarInboxOldestFirst ? (
<SettingResetButton
label="oldest first"
onClick={() =>
updateSettings({
sidebarInboxOldestFirst: DEFAULT_UNIFIED_SETTINGS.sidebarInboxOldestFirst,
})
}
/>
) : null
}
control={
<Switch
checked={settings.sidebarInboxOldestFirst}
onCheckedChange={(checked) =>
updateSettings({ sidebarInboxOldestFirst: Boolean(checked) })
}
aria-label="Oldest first"
/>
}
/>
) : null}
</SettingsSection>

<SettingsSection id="confirmations" title="Confirmations">
Expand Down
7 changes: 7 additions & 0 deletions apps/web/src/components/settings/settingsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
8 changes: 6 additions & 2 deletions docs/user/thread-sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/client-runtime/src/state/threadInbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/client-runtime/src/state/threadInbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type InboxThreadInput = Pick<
export function sortInboxThreadsByReturn<T extends InboxThreadInput>(
threads: readonly T[],
observedReturnAt?: (thread: T) => number | undefined,
oldestFirst = false,
): T[] {
const timestamps = new Map(
threads.map((thread) => [
Expand All @@ -51,7 +52,8 @@ export function sortInboxThreadsByReturn<T extends InboxThreadInput>(
),
]),
);
return sortNewestFirst(threads, timestamps);
const newestFirst = sortNewestFirst(threads, timestamps);
return oldestFirst ? newestFirst.reverse() : newestFirst;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

type WorkingSortInput = Pick<
Expand Down
Loading
Loading