Skip to content

Commit e0262e6

Browse files
authored
feat(ui): add people session sorting (#121470)
* feat(ui): add people session sorting Offer People sorting in the Control UI session sidebar when the Gateway reports multiple session-sharing identities. * fix(ui): restore sidebar translation dependency * fix(ui): preserve session sort ordering contracts
1 parent a7d61fc commit e0262e6

9 files changed

Lines changed: 250 additions & 53 deletions

‎docs/web/control-ui.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ and [Linux](/platforms/linux) desktop apps, the
230230

231231
## Sidebar navigation
232232

233-
The sidebar organizes everything around the agent. The identity row at the top is the active agent; below it, the **Pages** section starts with **Home** — the agent's rolling main session, badged with its unread or running state — followed by the pinned destinations (**Automations** and **Plugins** by default). The customize control on the Pages header opens a menu with every other destination, including **Usage** and plugin-provided tabs, plus **Edit pinned items**; right-clicking the navigation area opens the pin editor directly. The session list below splits into zones: **Threads** for the agent's chat sessions (the main session stays behind Home; sessions it spawned appear here as top-level threads, and named threads show without a type prefix), **Groups** for group and room conversations, and **Coding** for sessions bound to a managed worktree or exec node (rows show a `repo ⎇ branch` line plus the node host), ACP-backed harness sessions, and the Codex/Claude CLI catalogs. Coding starts collapsed on first run and remembers your choice; its collapsed header keeps the true count and shows a running indicator while contained sessions work. Custom groups (the session `category`) and **Pinned** rows sit above Threads, and assigning a session to a custom group always wins over the automatic zone classification. The Threads header holds the sort control (Created or Last updated, Group by, and a persisted **Status** filter for Active, Archived, or All) and the **+** that opens the New session page. Archived rows stay inline, dimmed with an archive glyph; they do not contribute unread or attention state and stay outside lineage promotion. Opening a session moves the selection highlight without reordering rows. Parent sessions with recent child runs show a disclosure and child count; expand it to inspect nested child sessions, live or terminal status, and runtime without leaving the sidebar. Selecting a child opens its chat and automatically reveals its ancestor path. Child rows stay outside root grouping, pinning, dragging, multi-select, and pagination; collapsed zones do not consume the visible page budget. Sessions with new activity since they were last read show an unread dot, and opening one marks it read. An agent can also publish a short expiring status line and optionally request attention with a curated amber icon; that declaration clears when you open the session, send the next message, clear it explicitly, or its TTL expires. Cloud-worker lifecycle states use a globe badge; local and reclaimed sessions omit a placement badge because local execution is the default. Each root session row has a context menu (kebab button or right-click) with Pin/Unpin, Mark as unread/read, Rename, Fork, Move to group (including New group and Remove from group), Archive or Unarchive, and Delete; touch layouts keep the direct pin and menu controls visible. Cmd/Ctrl-click toggles root rows into a multi-select and Shift-click extends it across the visible order; opening the menu on a selected row then offers batch actions (Mark N as unread/read, Move N to group, Archive N, Delete N) that apply to every selected session, with a single confirmation for batch delete. Drag a root session onto **Pinned** to pin it, or onto a custom group to move it. Custom group headers can be collapsed, expanded, or dragged to reorder them; group names and their order live in the gateway (`sessions.groups.*`), so they follow you across browsers, while collapsed state stays in the browser profile. Group headers also have a menu (kebab button or right-click) with Rename group, New group, and Delete group; renaming or deleting a group updates every member session server-side, including archived ones, and deleting a group keeps its sessions and moves them back to Threads.
233+
The sidebar organizes everything around the agent. The identity row at the top is the active agent; below it, the **Pages** section starts with **Home** — the agent's rolling main session, badged with its unread or running state — followed by the pinned destinations (**Automations** and **Plugins** by default). The customize control on the Pages header opens a menu with every other destination, including **Usage** and plugin-provided tabs, plus **Edit pinned items**; right-clicking the navigation area opens the pin editor directly. The session list below splits into zones: **Threads** for the agent's chat sessions (the main session stays behind Home; sessions it spawned appear here as top-level threads, and named threads show without a type prefix), **Groups** for group and room conversations, and **Coding** for sessions bound to a managed worktree or exec node (rows show a `repo ⎇ branch` line plus the node host), ACP-backed harness sessions, and the Codex/Claude CLI catalogs. Coding starts collapsed on first run and remembers your choice; its collapsed header keeps the true count and shows a running indicator while contained sessions work. Custom groups (the session `category`) and **Pinned** rows sit above Threads, and assigning a session to a custom group always wins over the automatic zone classification. The Threads header holds the sort control (Created, Last updated, or People when the Gateway reports multiple server identities), Group by, a persisted **Status** filter for Active, Archived, or All, and the **+** that opens the New session page. People orders creator groups by name and keeps Created order within each group. Archived rows stay inline, dimmed with an archive glyph; they do not contribute unread or attention state and stay outside lineage promotion. Opening a session moves the selection highlight without reordering rows. Parent sessions with recent child runs show a disclosure and child count; expand it to inspect nested child sessions, live or terminal status, and runtime without leaving the sidebar. Selecting a child opens its chat and automatically reveals its ancestor path. Child rows stay outside root grouping, pinning, dragging, multi-select, and pagination; collapsed zones do not consume the visible page budget. Sessions with new activity since they were last read show an unread dot, and opening one marks it read. An agent can also publish a short expiring status line and optionally request attention with a curated amber icon; that declaration clears when you open the session, send the next message, clear it explicitly, or its TTL expires. Cloud-worker lifecycle states use a globe badge; local and reclaimed sessions omit a placement badge because local execution is the default. Each root session row has a context menu (kebab button or right-click) with Pin/Unpin, Mark as unread/read, Rename, Fork, Move to group (including New group and Remove from group), Archive or Unarchive, and Delete; touch layouts keep the direct pin and menu controls visible. Cmd/Ctrl-click toggles root rows into a multi-select and Shift-click extends it across the visible order; opening the menu on a selected row then offers batch actions (Mark N as unread/read, Move N to group, Archive N, Delete N) that apply to every selected session, with a single confirmation for batch delete. Drag a root session onto **Pinned** to pin it, or onto a custom group to move it. Custom group headers can be collapsed, expanded, or dragged to reorder them; group names and their order live in the gateway (`sessions.groups.*`), so they follow you across browsers, while collapsed state stays in the browser profile. Group headers also have a menu (kebab button or right-click) with Rename group, New group, and Delete group; renaming or deleting a group updates every member session server-side, including archived ones, and deleting a group keeps its sessions and moves them back to Threads.
234234

235235
## New session page
236236

‎ui/src/components/app-sidebar-session-menu-renderers.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export function renderSidebarSessionSortMenu(params: {
229229
trigger: HTMLElement | null;
230230
grouping: SidebarSessionsGrouping;
231231
sortMode: SidebarSessionSortMode;
232+
peopleSortAvailable: boolean;
232233
statusFilter: SidebarSessionStatusFilter;
233234
showCron: boolean;
234235
creators: readonly SessionCreatorOption[];
@@ -291,7 +292,9 @@ export function renderSidebarSessionSortMenu(params: {
291292
)}
292293
<div class="session-menu__separator" role="separator"></div>
293294
<div class="sidebar-session-sort-menu__title">${t("chat.sidebar.sortBy")}</div>
294-
${SIDEBAR_SESSION_SORT_OPTIONS.map((option) =>
295+
${SIDEBAR_SESSION_SORT_OPTIONS.filter(
296+
(option) => option.mode !== "people" || params.peopleSortAvailable,
297+
).map((option) =>
295298
renderSidebarMenuRadioItem({
296299
value: `sort:${option.mode}`,
297300
checked: params.sortMode === option.mode,

‎ui/src/components/app-sidebar-session-navigation-logic.ts‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SIDEBAR_NAV_ROUTES } from "../app-navigation.ts";
33
import type { NavigationRouteId } from "../app-navigation.ts";
44
import type { RouteId } from "../app-route-paths.ts";
55
import type { ApplicationContext } from "../app/context.ts";
6+
import { t } from "../i18n/index.ts";
67
import {
78
resolveChannelSessionInfo,
89
resolveSessionDisplayName,
@@ -41,6 +42,7 @@ import {
4142
SIDEBAR_SESSION_NO_ATTENTION,
4243
SIDEBAR_SESSION_PAGE_SIZE,
4344
type SidebarRecentSession,
45+
type SidebarSessionSortMode,
4446
type SidebarSessionStatusFilter,
4547
} from "./app-sidebar-session-types.ts";
4648
import type { SidebarWorkboardBoard } from "./app-sidebar-workboard.ts";
@@ -53,6 +55,39 @@ import {
5355

5456
type SessionRow = SessionsListResult["sessions"][number];
5557

58+
export function compareSidebarSessionRowsByMode(input: {
59+
a: SessionRow;
60+
b: SessionRow;
61+
sortMode: SidebarSessionSortMode;
62+
creators: SessionsListResult["creators"];
63+
createdOrder: ReadonlyMap<string, number>;
64+
}): number {
65+
const { a, b } = input;
66+
if (input.sortMode !== "people") {
67+
return input.sortMode === "updated"
68+
? compareSessionRowsByUpdatedAt(a, b)
69+
: (input.createdOrder.get(a.key) ?? Number.MAX_SAFE_INTEGER) -
70+
(input.createdOrder.get(b.key) ?? Number.MAX_SAFE_INTEGER);
71+
}
72+
const creators = input.creators ?? [];
73+
const idA = a.createdActor?.id?.trim() ?? "";
74+
const idB = b.createdActor?.id?.trim() ?? "";
75+
if (idA !== idB) {
76+
const creatorA = creators.find((candidate) => candidate.id === idA);
77+
const creatorB = creators.find((candidate) => candidate.id === idB);
78+
const labelA = creatorA?.label?.trim() || a.createdActor?.label?.trim() || idA;
79+
const labelB = creatorB?.label?.trim() || b.createdActor?.label?.trim() || idB;
80+
const byCreator = labelA.localeCompare(labelB) || idA.localeCompare(idB);
81+
if (byCreator !== 0) {
82+
return byCreator;
83+
}
84+
}
85+
const byCreated =
86+
(input.createdOrder.get(a.key) ?? Number.MAX_SAFE_INTEGER) -
87+
(input.createdOrder.get(b.key) ?? Number.MAX_SAFE_INTEGER);
88+
return byCreated || a.key.localeCompare(b.key);
89+
}
90+
5691
function isSidebarDraftOwnedBySelf(
5792
row: Pick<SessionRow, "createdActor" | "sharingRole" | "visibility">,
5893
selfUserId: string | undefined,
@@ -350,6 +385,37 @@ export function latestVisibleAgentSessionRow(input: {
350385
return visible.toSorted(compareSessionRowsByUpdatedAt)[0] ?? null;
351386
}
352387

388+
export function resolveSidebarAgentResumeKey(
389+
latest: SessionRow | null,
390+
agentId: string,
391+
mainKey: string,
392+
): string {
393+
return latest?.key ?? buildAgentMainSessionKey({ agentId, mainKey });
394+
}
395+
396+
export function resolveSidebarAgentChipSubtitle(latest: SessionRow | null): string {
397+
if (latest?.hasActiveRun) {
398+
return t("agentChip.working");
399+
}
400+
return latest ? resolveSessionDisplayName(latest.key, latest) : t("agentChip.ready");
401+
}
402+
403+
export function collectKnownSidebarSessionCatalogIds(input: {
404+
loadedCatalogIds: readonly string[];
405+
hasLoaded: boolean;
406+
sectionOrder: readonly string[];
407+
}): string[] {
408+
if (input.hasLoaded) {
409+
return [...input.loadedCatalogIds];
410+
}
411+
// Until the first authoritative list completes, progressive rows are only
412+
// a partial view. Preserve stored slots so an unrelated drag cannot erase them.
413+
const storedCatalogIds = input.sectionOrder.flatMap((sectionId) =>
414+
sectionId.startsWith("catalog:") ? [sectionId.slice("catalog:".length)] : [],
415+
);
416+
return [...new Set([...input.loadedCatalogIds, ...storedCatalogIds])];
417+
}
418+
353419
export function resolveSidebarMainSessionKey(input: {
354420
agentId: string;
355421
agentsList: ApplicationContext<RouteId>["agents"]["state"]["agentsList"] | undefined;

‎ui/src/components/app-sidebar-session-navigation.ts‎

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ import { isSessionRouteId } from "../app-route-paths.ts";
66
import { t } from "../i18n/index.ts";
77
import { listSelectableAgents } from "../lib/agents/display.ts";
88
import { shouldHandleNavigationClick } from "../lib/navigation-click.ts";
9-
import { isCronSessionKey, resolveSessionDisplayName } from "../lib/session-display.ts";
9+
import { isCronSessionKey } from "../lib/session-display.ts";
1010
import type { SidebarSessionsGrouping } from "../lib/sessions/grouping.ts";
11-
import {
12-
compareSessionRowsByUpdatedAt,
13-
filterVisibleSessionRows,
14-
sessionMatchesArchivedFilter,
15-
} from "../lib/sessions/index.ts";
11+
import { filterVisibleSessionRows, sessionMatchesArchivedFilter } from "../lib/sessions/index.ts";
1612
import {
1713
composerDraftSearch,
1814
resolveSessionPreferredFace,
1915
sessionNavigationTarget,
2016
} from "../lib/sessions/route-navigation.ts";
2117
import {
2218
areUiSessionKeysEquivalent,
23-
buildAgentMainSessionKey,
2419
normalizeAgentId,
2520
parseAgentSessionKey,
2621
resolveUiConfiguredMainKey,
@@ -34,13 +29,17 @@ import {
3429
applySidebarSessionCreatorFilter,
3530
buildReconciledSidebarZone,
3631
buildSidebarSessionNavigationState,
32+
compareSidebarSessionRowsByMode,
33+
collectKnownSidebarSessionCatalogIds,
3734
collectKnownSidebarSessionGroups,
3835
extendSidebarSessionSelection,
3936
findSidebarMainSessionRow,
4037
findProjectedSidebarSession,
4138
latestVisibleAgentSessionRow,
4239
partitionSidebarVisibleSections,
4340
promoteSidebarSessionCreatedOrder,
41+
resolveSidebarAgentChipSubtitle,
42+
resolveSidebarAgentResumeKey,
4443
resolveSidebarMainSessionKey,
4544
toggleSidebarSessionSelection,
4645
type SidebarSessionNavigationState,
@@ -77,15 +76,35 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
7776
protected readonly compareSidebarSessionRows = (
7877
a: SessionsListResult["sessions"][number],
7978
b: SessionsListResult["sessions"][number],
80-
) => {
81-
if (this.sessionSortMode === "updated") {
82-
return compareSessionRowsByUpdatedAt(a, b);
83-
}
84-
return (
85-
(this.sessionData.sessionCreatedOrder.get(a.key) ?? Number.MAX_SAFE_INTEGER) -
86-
(this.sessionData.sessionCreatedOrder.get(b.key) ?? Number.MAX_SAFE_INTEGER)
87-
);
88-
};
79+
) =>
80+
compareSidebarSessionRowsByMode({
81+
a,
82+
b,
83+
sortMode: this.effectiveSessionSortMode(),
84+
creators: this.sessionData.sessionsResult?.creators,
85+
createdOrder: this.sessionData.sessionCreatedOrder,
86+
});
87+
88+
private sessionPeopleSortCapability(): boolean | undefined {
89+
return this.context?.gateway.snapshot.hello?.policy?.hasMultipleSessionSharingIdentities;
90+
}
91+
92+
sessionPeopleSortAvailable(): boolean {
93+
return this.sessionPeopleSortCapability() === true;
94+
}
95+
96+
effectiveSessionSortMode(): SidebarSessionSortMode {
97+
// A reconnect can temporarily hide the capability. Render Created without
98+
// discarding People until an authoritative single-identity hello arrives.
99+
return this.sessionSortMode === "people" && !this.sessionPeopleSortAvailable()
100+
? "created"
101+
: this.sessionSortMode;
102+
}
103+
104+
setSessionSortMode(mode: SidebarSessionSortMode) {
105+
this.sessionSortMode =
106+
mode === "people" && this.sessionPeopleSortCapability() === false ? "created" : mode;
107+
}
89108

90109
@state() sessionCreatorFilterId: string | null = null;
91110

@@ -165,6 +184,9 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
165184
super.updated(changedProperties);
166185
const selectedId = this.sessionCreatorFilterId;
167186
const creators = this.sessionData.sessionsResult?.creators;
187+
if (this.sessionSortMode === "people" && this.sessionPeopleSortCapability() === false) {
188+
this.setSessionSortMode("created");
189+
}
168190
if (
169191
selectedId &&
170192
creators &&
@@ -494,14 +516,11 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
494516
}
495517

496518
private agentResumeKey(agentId: string): string {
497-
const latest = this.latestAgentSessionRow(agentId);
498-
if (latest) {
499-
return latest.key;
500-
}
501-
return buildAgentMainSessionKey({
519+
return resolveSidebarAgentResumeKey(
520+
this.latestAgentSessionRow(agentId),
502521
agentId,
503-
mainKey: this.sessionMainKey(),
504-
});
522+
this.sessionMainKey(),
523+
);
505524
}
506525

507526
protected sessionMainKey(): string {
@@ -521,14 +540,7 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
521540
}
522541

523542
agentChipSubtitle(agentId: string): string {
524-
const latest = this.latestAgentSessionRow(agentId);
525-
if (latest?.hasActiveRun) {
526-
return t("agentChip.working");
527-
}
528-
if (latest) {
529-
return resolveSessionDisplayName(latest.key, latest);
530-
}
531-
return t("agentChip.ready");
543+
return resolveSidebarAgentChipSubtitle(this.latestAgentSessionRow(agentId));
532544
}
533545

534546
switchChipAgent(agentId: string) {
@@ -565,21 +577,14 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
565577
);
566578
}
567579

568-
knownSectionOrder(): string[] {
569-
return [...(this.context?.sessions.state.sectionOrder ?? [])];
570-
}
580+
readonly knownSectionOrder = () => [...(this.context?.sessions.state.sectionOrder ?? [])];
571581

572582
knownSessionCatalogIds(): string[] {
573-
const loadedCatalogIds = this.sessionData.sessionCatalogs.map((catalog) => catalog.id);
574-
if (this.sessionData.sessionCatalogRefreshStatus.hasLoaded) {
575-
return loadedCatalogIds;
576-
}
577-
// Until the first authoritative list completes, progressive rows are only
578-
// a partial view. Preserve stored slots so an unrelated drag cannot erase them.
579-
const storedCatalogIds = this.knownSectionOrder().flatMap((sectionId) =>
580-
sectionId.startsWith("catalog:") ? [sectionId.slice("catalog:".length)] : [],
581-
);
582-
return [...new Set([...loadedCatalogIds, ...storedCatalogIds])];
583+
return collectKnownSidebarSessionCatalogIds({
584+
loadedCatalogIds: this.sessionData.sessionCatalogs.map((catalog) => catalog.id),
585+
hasLoaded: this.sessionData.sessionCatalogRefreshStatus.hasLoaded,
586+
sectionOrder: this.knownSectionOrder(),
587+
});
583588
}
584589

585590
findSidebarSessionByKey(sessionKey: string): SidebarRecentSession | undefined {

‎ui/src/components/app-sidebar-session-types.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export type SidebarSessionGroupMenuState = {
146146
y: number;
147147
};
148148

149-
export type SidebarSessionSortMode = "created" | "updated";
149+
export type SidebarSessionSortMode = "created" | "updated" | "people";
150150
export type SidebarSessionStatusFilter = "active" | "archived" | "all";
151151
export type SidebarSessionsScrollState = "none" | "top" | "middle" | "bottom";
152152

@@ -331,9 +331,10 @@ export function setStoredSessionCatalogHidden(catalogId: string, hidden: boolean
331331
export const SIDEBAR_SESSION_SORT_OPTIONS = [
332332
{ mode: "created", labelKey: "chat.sidebar.sortCreated" },
333333
{ mode: "updated", labelKey: "chat.sidebar.sortUpdated" },
334+
{ mode: "people", labelKey: "sessionsView.people" },
334335
] as const satisfies ReadonlyArray<{
335336
mode: SidebarSessionSortMode;
336-
labelKey: "chat.sidebar.sortCreated" | "chat.sidebar.sortUpdated";
337+
labelKey: "chat.sidebar.sortCreated" | "chat.sidebar.sortUpdated" | "sessionsView.people";
337338
}>;
338339

339340
export const SIDEBAR_SESSION_STATUS_OPTIONS = [

‎ui/src/components/sidebar-menus-controller.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export interface SidebarMenusControllerHost
104104
setCatalogProjectGrouping(grouping: CatalogProjectGrouping): void;
105105
hideSessionCatalog(catalogId: string): void;
106106
sessionSortMode: SidebarSessionSortMode;
107+
effectiveSessionSortMode(): SidebarSessionSortMode;
108+
sessionPeopleSortAvailable(): boolean;
109+
setSessionSortMode(mode: SidebarSessionSortMode): void;
107110
readonly terminalAvailable: boolean;
108111
readonly themeMode: ThemeMode;
109112
readonly workboardBoards: readonly SidebarWorkboardBoard[];

0 commit comments

Comments
 (0)