Skip to content

Commit 3ea90bd

Browse files
authored
feat(ui): add Person grouping mode for sessions sidebar and sessions page (#127346)
* feat(ui): add Person grouping mode for sessions sidebar and sessions page Sessions can now be grouped by their durable owner identity: the sidebar Group-by menu gains a capability-gated Person mode (self first, humans by label, agent identities after; ownerless rows keep their smart zones), and the sessions page gains the matching person mode. Person section headers render the owner avatar and profile label; the mock dev server now advertises the multi-identity policy and carries explicit row owners the way the gateway projects createdActor fallbacks. * feat(ui): gate sessions-page Person grouping on the identity capability Mirrors the sidebar: the Person option hides without hasMultipleSessionSharingIdentities and a stored Person preference renders as None until the capability returns.
1 parent 7909ea6 commit 3ea90bd

14 files changed

Lines changed: 360 additions & 52 deletions

‎scripts/control-ui-mock-dev.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const MOCK_ACTOR_MIRA: SessionActorFixture = {
6565
id: "profile-mira",
6666
label: "Mira",
6767
};
68-
// These actors are also the effective owners because the mock rows are unassigned.
68+
// Rows carry explicit owners the way the gateway projects createdActor fallbacks.
6969
const MOCK_SESSION_OWNERS: readonly SessionActorFixture[] = [MOCK_ACTOR_PETER, MOCK_ACTOR_MIRA];
7070

7171
const SESSION_PAGE_SIZE = 50;
@@ -1531,6 +1531,7 @@ async function createChatPickerScenario(
15311531
sessionRow(NARRATION_DEMO_SESSION_KEY, "Sidebar narration demo", baseTime - 15_000, {
15321532
createdActor: MOCK_ACTOR_MIRA,
15331533
hasActiveRun: true,
1534+
owner: { actor: MOCK_ACTOR_MIRA },
15341535
startedAt: baseTime - 45_000,
15351536
status: "running",
15361537
}),
@@ -1544,17 +1545,20 @@ async function createChatPickerScenario(
15441545
category: "Research",
15451546
createdActor: MOCK_ACTOR_MIRA,
15461547
execCwd: "/Users/peter/Projects/clawdbot",
1548+
owner: { actor: MOCK_ACTOR_MIRA },
15471549
}),
15481550
sessionRow("agent:main:model-budget", "Model budget review", baseTime - 80_000, {
15491551
category: "Research",
15501552
execCwd: "/Users/peter/Projects/openclaw",
1553+
owner: { actor: { type: "human", id: "presence-riley", label: "Riley" } },
15511554
status: "failed",
15521555
lastRunError: "Model out of credits: openai/gpt-5.6",
15531556
}),
15541557
sessionRow("agent:main:work-openclaw", "OpenClaw work checkout", baseTime - 85_000, {
15551558
createdActor: MOCK_ACTOR_PETER,
15561559
execCwd: "/Users/peter/Work/openclaw",
15571560
lastReadAt: baseTime - 120_000,
1561+
owner: { actor: MOCK_ACTOR_PETER },
15581562
observerDigest: {
15591563
headline: "Done: fixed the flaky retry-window test",
15601564
health: "done",
@@ -1787,6 +1791,9 @@ async function createChatPickerScenario(
17871791
// Terminal has a second gate beyond the advertised method (see
17881792
// ui/src/lib/terminal-availability.ts).
17891793
terminalEnabled: true,
1794+
// The mock rows span several owners; advertise the multi-identity policy
1795+
// so people-aware UI (People sort, Person grouping) is exercisable here.
1796+
hasMultipleSessionSharingIdentities: true,
17901797
historyMessages,
17911798
// Lights up the footer facepile and who's-online roster; the email-only
17921799
// entry keeps the roster's no-display-name row exercised.

‎ui/src/components/app-sidebar-session-list-render.ts‎

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,28 @@ function renderSessionSection(params: {
5959
const { host, section } = params;
6060
const totalRowCount = section.totalRowCount;
6161
const group = section.category;
62+
const personOwner = section.personOwner;
6263
// Pinned rows render in the nav zone; renderHeader records whether this list
6364
// section owns collapse UI or sits directly below the global toolbar.
6465
const collapsed = section.renderHeader && host.collapsedSessionSections.has(section.id);
65-
const label = section.groups
66-
? t("chat.sidebar.groups")
67-
: section.work
68-
? t("chat.sidebar.coding")
69-
: group
70-
? group
71-
: t("chat.sidebar.otherSessions");
72-
const zone = section.groups ? "groups" : section.work ? "coding" : group ? "category" : "threads";
66+
const label = personOwner
67+
? personOwner.label || personOwner.id
68+
: section.groups
69+
? t("chat.sidebar.groups")
70+
: section.work
71+
? t("chat.sidebar.coding")
72+
: group
73+
? group
74+
: t("chat.sidebar.otherSessions");
75+
const zone = personOwner
76+
? "person"
77+
: section.groups
78+
? "groups"
79+
: section.work
80+
? "coding"
81+
: group
82+
? "category"
83+
: "threads";
7384
// Collapsed Coding still signals live runs so background work stays visible.
7485
const collapsedRunningDot =
7586
collapsed &&
@@ -83,6 +94,7 @@ function renderSessionSection(params: {
8394
method: "sessions.groups.put",
8495
requiredScope: "operator.write",
8596
});
97+
const sectionDropEnabled = groupWriteAccess.allowed && !personOwner;
8698
const sectionClass = [
8799
"sidebar-recent-sessions__group",
88100
`sidebar-recent-sessions__group--zone-${zone}`,
@@ -103,19 +115,21 @@ function renderSessionSection(params: {
103115
<div
104116
class=${sectionClass}
105117
data-session-section=${section.id}
106-
@dragover=${groupWriteAccess.allowed
118+
data-zone=${zone}
119+
@dragover=${sectionDropEnabled
107120
? (event: DragEvent) => host.sectionDragOver(event, section.id, group)
108121
: nothing}
109-
@dragleave=${groupWriteAccess.allowed
122+
@dragleave=${sectionDropEnabled
110123
? (event: DragEvent) => host.sectionDragLeave(event, section.id, group)
111124
: nothing}
112-
@drop=${groupWriteAccess.allowed
125+
@drop=${sectionDropEnabled
113126
? (event: DragEvent) => host.sectionDrop(event, section.id, group)
114127
: nothing}
115128
>
116129
${section.renderHeader
117130
? renderSidebarSessionSectionHeader({
118131
sectionId: section.id,
132+
draggable: !personOwner,
119133
disabledReason: groupWriteAccess.allowed ? undefined : groupWriteAccess.reason,
120134
onStartDrag: (sectionId) => host.startSidebarSectionDrag(sectionId),
121135
onFinishDrag: () => host.finishSidebarSectionDrag(),
@@ -138,6 +152,19 @@ function renderSessionSection(params: {
138152
>${collapsed ? icons.chevronRight : icons.chevronDown}</span
139153
>
140154
</span>
155+
${personOwner
156+
? html`<openclaw-viewer-avatar
157+
.user=${{
158+
id: personOwner.id,
159+
name: personOwner.label,
160+
avatarUrl: personOwner.avatarUrl,
161+
watchedSessions: [],
162+
}}
163+
.markAsViewer=${false}
164+
variant="session"
165+
aria-hidden="true"
166+
></openclaw-viewer-avatar>`
167+
: nothing}
141168
<span class="sidebar-recent-sessions__label-text">${label}</span>
142169
${collapsed && totalRowCount > 0
143170
? html`<span class="sidebar-session-group-count">${totalRowCount}</span>`

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ export function renderSidebarSessionSortMenu(params: {
294294
}
295295
const groupingOptions = [
296296
{ grouping: "category", label: t("sessionsView.groupByCategory") },
297+
{ grouping: "person", label: t("sessionsView.groupByPerson") },
297298
{ grouping: "none", label: t("sessionsView.groupByNone") },
298299
] as const satisfies ReadonlyArray<{ grouping: SidebarSessionsGrouping; label: string }>;
299300
return keyed(
@@ -336,13 +337,15 @@ export function renderSidebarSessionSortMenu(params: {
336337
>
337338
${renderSidebarMenuTrigger(position, t("chat.sidebar.sortSessions"))}
338339
<div class="sidebar-session-sort-menu__title">${t("sessionsView.groupBy")}</div>
339-
${groupingOptions.map((option) =>
340-
renderSidebarMenuRadioItem({
341-
value: `grouping:${option.grouping}`,
342-
checked: params.grouping === option.grouping,
343-
label: option.label,
344-
}),
345-
)}
340+
${groupingOptions
341+
.filter((option) => option.grouping !== "person" || params.peopleSortAvailable)
342+
.map((option) =>
343+
renderSidebarMenuRadioItem({
344+
value: `grouping:${option.grouping}`,
345+
checked: params.grouping === option.grouping,
346+
label: option.label,
347+
}),
348+
)}
346349
<div class="session-menu__separator" role="separator"></div>
347350
<div class="sidebar-session-sort-menu__title">${t("chat.sidebar.sortBy")}</div>
348351
${SIDEBAR_SESSION_SORT_OPTIONS.filter(

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,16 @@ export function partitionSidebarVisibleSections(input: {
308308
rows: SidebarRecentSession[];
309309
grouping: SidebarSessionsGrouping;
310310
knownGroups: string[] | undefined;
311+
selfOwnerId?: string | null;
311312
catalogIds?: readonly string[];
312313
sectionOrder?: readonly string[];
313314
collapsedSections: ReadonlySet<string>;
314315
hideEmptyOwnerFilteredGroup: (category: string | undefined, rowCount: number) => boolean;
315316
visibleSessionLimits: ReadonlyMap<string, number>;
316317
}): SidebarVisibleSections {
317-
const sections = groupSidebarSessionRows(input.rows, {
318-
grouping: input.grouping,
319-
knownGroups: input.knownGroups,
320-
sectionOrder: input.sectionOrder,
321-
catalogIds: input.catalogIds,
322-
}).filter(
318+
const { grouping, knownGroups, selfOwnerId, sectionOrder, catalogIds } = input;
319+
const sectionOptions = { grouping, knownGroups, selfOwnerId, sectionOrder, catalogIds };
320+
const sections = groupSidebarSessionRows(input.rows, sectionOptions).filter(
323321
(section) =>
324322
section.id !== "pinned" &&
325323
!input.hideEmptyOwnerFilteredGroup(section.category, section.rows.length),

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
120120
return resolveSidebarSessionSortMode(this.sessionSortMode, this.sessionPeopleSortAvailable());
121121
}
122122

123+
effectiveSessionsGrouping(): SidebarSessionsGrouping {
124+
// Reconnects temporarily hide the capability; retain the stored Person
125+
// preference so it returns when the authoritative identity policy does.
126+
const grouping = this.sessionsGrouping;
127+
return grouping === "person" && !this.sessionPeopleSortAvailable() ? "category" : grouping;
128+
}
129+
123130
setSessionSortMode(mode: SidebarSessionSortMode) {
124131
this.sessionSortMode = storeSidebarSessionSortMode(mode, this.sessionPeopleSortCapability());
125132
}
@@ -331,10 +338,12 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
331338

332339
/** Collapsed zones keep full rows for true header counts and status dots. */
333340
protected zonedVisibleSections(rows: SidebarRecentSession[]): SidebarVisibleSections {
341+
const grouping = this.effectiveSessionsGrouping();
334342
return partitionSidebarVisibleSections({
335343
rows,
336-
grouping: this.sessionsGrouping,
337-
knownGroups: this.sessionsGrouping === "category" ? this.knownSessionGroups() : [],
344+
grouping,
345+
knownGroups: grouping === "category" ? this.knownSessionGroups() : [],
346+
selfOwnerId: this.context?.gateway.snapshot.selfUser?.id ?? null,
338347
// Normalize gateway order without dropping catalog-lagging categories.
339348
sectionOrder: this.knownSectionOrder(),
340349
catalogIds:
@@ -381,13 +390,10 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
381390
const rows = this.selectedAgentSessionRows(navigationState);
382391
const { visibleRows } = this.zonedVisibleSections(rows);
383392
const pinnedByKey = new Map(rows.filter((row) => row.pinned).map((row) => [row.key, row]));
384-
const pinnedRows = this.reconciledSidebarZone().entries.flatMap((entry) =>
385-
entry.type === "session"
386-
? pinnedByKey.get(entry.key)
387-
? [pinnedByKey.get(entry.key)!]
388-
: []
389-
: [],
390-
);
393+
const pinnedRows = this.reconciledSidebarZone().entries.flatMap((entry) => {
394+
const row = entry.type === "session" ? pinnedByKey.get(entry.key) : undefined;
395+
return row ? [row] : [];
396+
});
391397
return [...pinnedRows, ...visibleRows];
392398
}
393399

@@ -486,9 +492,7 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
486492

487493
expandedAgentId(): string {
488494
const selected = normalizeOptionalString(this.context?.agentSelection.state.selectedId);
489-
return selected
490-
? normalizeAgentId(selected)
491-
: normalizeAgentId(this.getSessionNavigationState().selectedAgentId);
495+
return normalizeAgentId(selected || this.getSessionNavigationState().selectedAgentId);
492496
}
493497

494498
activeChipAgent() {
@@ -509,11 +513,8 @@ export class AppSidebarSessionNavigationElement extends AppSidebarBase {
509513
}
510514

511515
private agentResumeKey(agentId: string): string {
512-
return resolveSidebarAgentResumeKey(
513-
this.latestAgentSessionRow(agentId),
514-
agentId,
515-
this.sessionMainKey(),
516-
);
516+
const latest = this.latestAgentSessionRow(agentId);
517+
return resolveSidebarAgentResumeKey(latest, agentId, this.sessionMainKey());
517518
}
518519

519520
/** Offline routes to Settings instead of a dead chat load. */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
sessionPullRequestsForGateway,
1818
} from "../lib/session-pull-requests.ts";
1919
import type { CatalogProjectGrouping } from "../lib/sessions/catalog-project-grouping.ts";
20+
import type { SidebarSessionsGrouping } from "../lib/sessions/grouping.ts";
2021
import { sessionNavigationTarget } from "../lib/sessions/route-navigation.ts";
2122
import { parseAgentSessionKey } from "../lib/sessions/session-key.ts";
2223
import { SidebarCatalogMenuController } from "./app-sidebar-catalog-menu.ts";
@@ -117,6 +118,7 @@ interface SidebarMenusControllerHost
117118
hideSessionCatalog(catalogId: string): void;
118119
sessionSortMode: SidebarSessionSortMode;
119120
effectiveSessionSortMode(): SidebarSessionSortMode;
121+
effectiveSessionsGrouping(): SidebarSessionsGrouping;
120122
sessionPeopleSortAvailable(): boolean;
121123
setSessionSortMode(mode: SidebarSessionSortMode): void;
122124
readonly terminalAvailable: boolean;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export function renderSidebarSessionSortMenuForController(controller: SidebarMen
380380
return renderSidebarSessionSortMenu({
381381
position,
382382
trigger: controller.sessionSortMenuTrigger,
383-
grouping: host.sessionsGrouping,
383+
grouping: host.effectiveSessionsGrouping(),
384384
sortMode: host.effectiveSessionSortMode(),
385385
peopleSortAvailable: host.sessionPeopleSortAvailable(),
386386
statusFilter: host.sessionsStatusFilter,

‎ui/src/i18n/locales/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ export const en: TranslationMap = {
11641164
groupBy: "Group by",
11651165
groupByNone: "None",
11661166
groupByCategory: "Custom groups",
1167+
groupByPerson: "Person",
11671168
showSessionPreview: "Show message preview",
11681169
showCronSessions: "Show automation sessions",
11691170
showSystemSessions: "Show system sessions",

0 commit comments

Comments
 (0)