Skip to content

Commit d2f84af

Browse files
committed
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 66aaf87 commit d2f84af

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎ui/src/pages/sessions/sessions-page.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,8 @@ class SessionsPage extends OpenClawLightDomElement {
15101510

15111511
override render() {
15121512
const context = this.context;
1513+
const personGroupingAvailable =
1514+
context?.gateway.snapshot.hello?.policy?.hasMultipleSessionSharingIdentities === true;
15131515
if (!context) {
15141516
return html``;
15151517
}
@@ -1559,7 +1561,10 @@ class SessionsPage extends OpenClawLightDomElement {
15591561
),
15601562
sortColumn: this.sortColumn,
15611563
sortDir: this.sortDir,
1562-
groupBy: this.groupBy,
1564+
// Same reconnect resilience as the sidebar: the stored Person
1565+
// preference survives a temporarily hidden identity capability.
1566+
groupBy: personGroupingAvailable || this.groupBy !== "person" ? this.groupBy : "none",
1567+
personGroupingAvailable,
15631568
knownCategories: this.knownCategories(),
15641569
page: this.page,
15651570
pageSize: this.pageSize,

‎ui/src/pages/sessions/view.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function buildProps(result: SessionsListResult): SessionsProps {
4949
sortColumn: "updated",
5050
sortDir: "desc",
5151
groupBy: "none",
52+
personGroupingAvailable: true,
5253
knownCategories: [],
5354
page: 0,
5455
pageSize: 10,
@@ -515,6 +516,24 @@ describe("sessions view", () => {
515516
).toEqual(["Ada Lovelace", "Ungrouped"]);
516517
});
517518

519+
it("hides the person grouping option without the identity capability", async () => {
520+
const container = document.createElement("div");
521+
render(
522+
renderSessions({
523+
...buildProps(buildResult({ key: "agent:main:a", kind: "direct", updatedAt: 1 })),
524+
personGroupingAvailable: false,
525+
}),
526+
container,
527+
);
528+
await Promise.resolve();
529+
530+
const modes = [
531+
...container.querySelectorAll<HTMLOptionElement>(".session-groupby__select option"),
532+
].map((option) => option.value);
533+
expect(modes).not.toContain("person");
534+
expect(modes).toContain("category");
535+
});
536+
518537
it("selects and names the current page size on first render", async () => {
519538
const container = document.createElement("div");
520539
render(

‎ui/src/pages/sessions/view.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export type SessionsProps = {
9090
sortColumn: "key" | "kind" | "updated" | "tokens";
9191
sortDir: "asc" | "desc";
9292
groupBy: SessionsGroupBy;
93+
/** Multi-identity gateways only; hides the Person mode elsewhere. */
94+
personGroupingAvailable: boolean;
9395
knownCategories: string[];
9496
page: number;
9597
pageSize: number;
@@ -1220,7 +1222,9 @@ function renderSessionsTable(props: SessionsProps, ctx: SessionsTableContext) {
12201222
@change=${(e: Event) =>
12211223
props.onGroupByChange((e.target as HTMLSelectElement).value as SessionsGroupBy)}
12221224
>
1223-
${SESSION_GROUP_MODES.map(
1225+
${SESSION_GROUP_MODES.filter(
1226+
(mode) => mode !== "person" || props.personGroupingAvailable,
1227+
).map(
12241228
(mode) =>
12251229
html`<option value=${mode} ?selected=${props.groupBy === mode}>
12261230
${groupModeLabel(mode)}

0 commit comments

Comments
 (0)