Skip to content

Commit aa85f6d

Browse files
fix(ui): make sidebar session pagination global
Co-authored-by: jesse-merhi <[email protected]>
1 parent ac652ba commit aa85f6d

16 files changed

Lines changed: 109 additions & 243 deletions

File tree

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5308,7 +5308,6 @@ public struct SessionsListParams: Codable, Sendable {
53085308
public let includederivedtitles: Bool?
53095309
public let includelastmessage: Bool?
53105310
public let label: String?
5311-
public let category: String?
53125311
public let boardface: AnyCodable?
53135312
public let creatorid: String?
53145313
public let ownerid: String?
@@ -5330,7 +5329,6 @@ public struct SessionsListParams: Codable, Sendable {
53305329
includederivedtitles: Bool? = nil,
53315330
includelastmessage: Bool? = nil,
53325331
label: String? = nil,
5333-
category: String? = nil,
53345332
boardface: AnyCodable? = nil,
53355333
creatorid: String? = nil,
53365334
ownerid: String? = nil,
@@ -5351,7 +5349,6 @@ public struct SessionsListParams: Codable, Sendable {
53515349
self.includederivedtitles = includederivedtitles
53525350
self.includelastmessage = includelastmessage
53535351
self.label = label
5354-
self.category = category
53555352
self.boardface = boardface
53565353
self.creatorid = creatorid
53575354
self.ownerid = ownerid
@@ -5374,7 +5371,6 @@ public struct SessionsListParams: Codable, Sendable {
53745371
case includederivedtitles = "includeDerivedTitles"
53755372
case includelastmessage = "includeLastMessage"
53765373
case label
5377-
case category
53785374
case boardface = "boardFace"
53795375
case creatorid = "creatorId"
53805376
case ownerid = "ownerId"

‎docs/gateway/protocol.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ methods. Treat this as feature discovery, not a full enumeration of
643643
</Accordion>
644644

645645
<Accordion title="Session control">
646-
- `sessions.list` returns the current session index, including per-row `agentRuntime` metadata when an agent runtime backend is configured. `hasActiveRun` is the authoritative aggregate direct-session activity fact. When projected, `activeRunIds` is the complete exact active set; an empty array proves the session is idle. If aggregate activity is true while the field is omitted, another runtime owner is active but its exact identities are unavailable. Snapshot omission means identities unavailable. On incremental events, omission means no change, `null` is the event-only tombstone that clears cached exact IDs to unavailable, and an array replaces the cache. Clients correlate only exact IDs they own locally or received from requests, history, or events and never select the first list entry as an owner. When cloud-worker placement is enabled or durable recovery state exists, session rows also include a closed `placement` state (`local`, `requested`, `provisioning`, `syncing`, `starting`, `active`, `draining`, `reconciling`, `reclaimed`, or `failed`) plus state-specific environment, owner-epoch, workspace, bundle, ACK-cursor, or recovery fields. Active placements may include an advisory `diskSpace` sample with `status` (`ok`, `warning`, or `critical`), `availableBytes`, `totalBytes`, and `observedAtMs`. Rows carry ownership projections — write-once `createdActor`, the mutable `owner` (actor plus `assignedBy`/`assignedAt`), a bounded `participants` list (owner excluded, up to 4 actors), and the full `participantCount`; actor display labels and avatars are resolved from current profiles and agent identities at read time. Pass `category` to filter by exact custom group, `creatorId` to filter by immutable `createdActor.id`, or `ownerId` to filter by the current assignable owner, falling back to `createdActor` when no owner is assigned. The complete `owners` facet is independent of pagination and remains unfiltered by the category or ownership predicates, so clients can render the full owner picker. Authenticated callers can pass `involvingMe: true` to keep only sessions the caller owns or has prompted, evaluated against the full participant history (profile-backed human participants only).
646+
- `sessions.list` returns the current session index, including per-row `agentRuntime` metadata when an agent runtime backend is configured. `hasActiveRun` is the authoritative aggregate direct-session activity fact. When projected, `activeRunIds` is the complete exact active set; an empty array proves the session is idle. If aggregate activity is true while the field is omitted, another runtime owner is active but its exact identities are unavailable. Snapshot omission means identities unavailable. On incremental events, omission means no change, `null` is the event-only tombstone that clears cached exact IDs to unavailable, and an array replaces the cache. Clients correlate only exact IDs they own locally or received from requests, history, or events and never select the first list entry as an owner. When cloud-worker placement is enabled or durable recovery state exists, session rows also include a closed `placement` state (`local`, `requested`, `provisioning`, `syncing`, `starting`, `active`, `draining`, `reconciling`, `reclaimed`, or `failed`) plus state-specific environment, owner-epoch, workspace, bundle, ACK-cursor, or recovery fields. Active placements may include an advisory `diskSpace` sample with `status` (`ok`, `warning`, or `critical`), `availableBytes`, `totalBytes`, and `observedAtMs`. Rows carry ownership projections — write-once `createdActor`, the mutable `owner` (actor plus `assignedBy`/`assignedAt`), a bounded `participants` list (owner excluded, up to 4 actors), and the full `participantCount`; actor display labels and avatars are resolved from current profiles and agent identities at read time. Pass `creatorId` to filter by immutable `createdActor.id`; pass `ownerId` to filter by the current assignable owner, falling back to `createdActor` when no owner is assigned. The complete `owners` facet is independent of pagination and remains unfiltered by either query, so clients can render the full owner picker. Authenticated callers can pass `involvingMe: true` to keep only sessions the caller owns or has prompted, evaluated against the full participant history (profile-backed human participants only).
647647
- `sessions.subscribe` enables session change events for the current WebSocket client. The subscription ends when that client disconnects.
648648
- `sessions.messages.subscribe` and `sessions.messages.unsubscribe` toggle transcript/message event subscriptions for one session. Pass `includeApprovals: true` to also receive sanitized `session.approval` lifecycle events for approvals whose persisted audience includes that exact session and whose reviewer binding authorizes the subscribing client. The subscribe response then includes a bounded pending `approvalReplay`; it is authoritative when `truncated` is false. The opt-in is per subscribe call, not sticky: re-subscribing to the same session without `includeApprovals: true` removes an existing approval subscription. In addition to normal session-read authority, this opt-in requires `operator.admin`, or `operator.approvals` on a paired device.
649649
- `sessions.preview` returns bounded transcript previews for specific session keys.

‎packages/gateway-protocol/src/index.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe("lazy protocol validators", () => {
166166
{ archived: false },
167167
{ archived: true },
168168
{ archived: "all" },
169-
{ involvingMe: true, category: "Jesse" },
169+
{ involvingMe: true },
170170
]);
171171
expectRejected(validateSessionsListParams, [{ archived: "archived" }, { involvingMe: "yes" }]);
172172
});

‎packages/gateway-protocol/src/schema/sessions.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,6 @@ export const SessionsListParamsSchema = closedObject({
413413
*/
414414
includeLastMessage: Type.Optional(Type.Boolean()),
415415
label: Type.Optional(SessionLabelString),
416-
/** Filter rows by their exact custom group. */
417-
category: Type.Optional(SessionLabelString),
418416
/** Limit rows to sessions with an explicitly stored Control UI face preference. */
419417
boardFace: Type.Optional(Type.Union([Type.Literal("chat"), Type.Literal("dashboard")])),
420418
/** Filter rows by their immutable creator provenance. */

‎src/gateway/session-utils-list.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ function filterSessionEntries(params: {
186186
const includeUnknown = opts.includeUnknown === true;
187187
const spawnedBy = typeof opts.spawnedBy === "string" ? opts.spawnedBy : "";
188188
const label = normalizeOptionalString(opts.label) ?? "";
189-
const category = normalizeOptionalString(opts.category);
190189
const boardFace = opts.boardFace;
191190
const agentId = typeof opts.agentId === "string" ? normalizeAgentId(opts.agentId) : "";
192191
const search = normalizeLowercaseStringOrEmpty(opts.search);
@@ -272,11 +271,7 @@ function filterSessionEntries(params: {
272271
) {
273272
continue;
274273
}
275-
if (
276-
(label && entry.label !== label) ||
277-
(category && normalizeOptionalString(entry.category) !== category) ||
278-
(boardFace && entry.boardFace !== boardFace)
279-
) {
274+
if ((label && entry.label !== label) || (boardFace && entry.boardFace !== boardFace)) {
280275
continue;
281276
}
282277
if (search) {

‎src/gateway/session-utils-owners.test.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,11 @@ it("projects only durable profiles and configured agents as effective owners", (
198198
it("filters immutable creator and effective owner separately while preserving projections", () => {
199199
const store: Record<string, SessionEntry> = {
200200
"agent:main:default-owner": {
201-
category: "Jesse",
202201
createdActor: { type: "human", id: "profile-ada" },
203202
sessionId: "session-default-owner",
204203
updatedAt: 2,
205204
},
206205
"agent:main:assigned-owner": {
207-
category: "Jesse",
208206
createdActor: { type: "human", id: "profile-ada" },
209207
owner: {
210208
actor: { type: "human", id: "profile-bob" },
@@ -215,7 +213,6 @@ it("filters immutable creator and effective owner separately while preserving pr
215213
updatedAt: 1,
216214
},
217215
"agent:main:other-creator": {
218-
category: "Other",
219216
createdActor: { type: "human", id: "profile-bob" },
220217
owner: { actor: { type: "human", id: "profile-ada" } },
221218
sessionId: "session-other-creator",
@@ -277,15 +274,6 @@ it("filters immutable creator and effective owner separately while preserving pr
277274
createdActor: { id: "profile-ada", label: "Ada" },
278275
owner: { actor: { id: "profile-bob", label: "Bob" } },
279276
});
280-
const categoryFiltered = listSessionsFromStore({
281-
cfg: {} as OpenClawConfig,
282-
storePath: "/tmp/openclaw-session-owners",
283-
store,
284-
opts: { archived: "all", category: "Jesse", limit: 1 },
285-
});
286-
expect(categoryFiltered.sessions.map((row) => row.key)).toEqual(["agent:main:default-owner"]);
287-
expect(categoryFiltered.totalCount).toBe(2);
288-
expect(categoryFiltered.hasMore).toBe(true);
289277
});
290278

291279
it("projects participant identities and filters sessions involving the viewer", () => {

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

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type RenderableSessionSection = SidebarSessionSection<SidebarRecentSession> & {
3232
};
3333

3434
type SidebarSessionListHost = SessionListHost & {
35-
loadMoreSidebarSessions(category?: string, limit?: number): Promise<void>;
35+
loadMoreSidebarSessions(): Promise<void>;
3636
};
3737

3838
type SessionCatalogRenderSnapshot = {
@@ -54,7 +54,6 @@ type SessionCatalogRenderSnapshot = {
5454
function renderSessionSection(params: {
5555
host: SidebarSessionListHost;
5656
section: RenderableSessionSection;
57-
nativeSessionsHaveMore?: boolean;
5857
}) {
5958
const { host, section } = params;
6059
const totalRowCount = section.totalRowCount;
@@ -210,11 +209,7 @@ function renderSessionSection(params: {
210209
${section.rows.map((session) => renderSessionTree({ host, session }))}
211210
</div>`
212211
: nothing}
213-
${renderSessionPagination({
214-
host,
215-
section,
216-
nativeSessionsHaveMore: params.nativeSessionsHaveMore ?? false,
217-
})}
212+
${renderSessionPagination({ host, section })}
218213
`}
219214
</div>
220215
`;
@@ -223,11 +218,9 @@ function renderSessionSection(params: {
223218
function renderSessionPagination(params: {
224219
host: SidebarSessionListHost;
225220
section: RenderableSessionSection;
226-
nativeSessionsHaveMore: boolean;
227221
}) {
228222
const { host, section } = params;
229-
const canLoadMore = params.nativeSessionsHaveMore;
230-
const canShowMore = section.visibleRowCount < section.totalRowCount || canLoadMore;
223+
const canShowMore = section.visibleRowCount < section.totalRowCount;
231224
const canShowLess =
232225
section.visibleRowCount > SIDEBAR_SESSION_SEE_LESS_THRESHOLD &&
233226
section.visibleRowCount > section.collapsedVisibleRowCount;
@@ -244,9 +237,6 @@ function renderSessionPagination(params: {
244237
@click=${() => {
245238
const nextLimit = section.visibleLimit + SIDEBAR_SESSION_PAGE_SIZE;
246239
host.setVisibleSessionLimit(section.id, nextLimit);
247-
if (canLoadMore && nextLimit > section.totalRowCount) {
248-
void host.loadMoreSidebarSessions(section.category, nextLimit);
249-
}
250240
}}
251241
>
252242
${t("chat.selectors.loadMoreSessions")}
@@ -333,8 +323,6 @@ function renderSessionCatalog(params: {
333323
function renderSessionListBody(params: {
334324
host: SidebarSessionListHost;
335325
sections: RenderableSessionSection[];
336-
nativeSessionsHaveMore: boolean;
337-
categorySessionsHaveMore: (category: string) => boolean;
338326
catalogs: SessionCatalogRenderSnapshot;
339327
catalogRenderer: SessionCatalogGroupsRenderer | null;
340328
}) {
@@ -378,25 +366,33 @@ function renderSessionListBody(params: {
378366
if (
379367
section.id === "ungrouped" &&
380368
section.totalRowCount === 0 &&
381-
!params.nativeSessionsHaveMore &&
382369
!host.sessionOwnershipVisible &&
383370
host.sessionsStatusFilter === "active" &&
384371
host.sessionOrganizer.draggingSessionKey === null
385372
) {
386373
return nothing;
387374
}
388-
return renderSessionSection({
389-
host,
390-
section,
391-
nativeSessionsHaveMore: section.category
392-
? params.categorySessionsHaveMore(section.category)
393-
: params.nativeSessionsHaveMore,
394-
});
375+
return renderSessionSection({ host, section });
395376
})}
396377
${firstCatalogSectionIndex < 0 ? catalogStatus : nothing}
397378
`;
398379
}
399380

381+
function renderGlobalSessionPagination(host: SidebarSessionListHost) {
382+
const label = t("chat.sidebar.loadMoreSessions");
383+
return html`
384+
<div class="sidebar-session-pagination">
385+
<button
386+
type="button"
387+
class="sidebar-session-pagination__button"
388+
@click=${() => void host.loadMoreSidebarSessions()}
389+
>
390+
${label}
391+
</button>
392+
</div>
393+
`;
394+
}
395+
400396
function renderSessionListToolbar(host: SidebarSessionListHost) {
401397
const newSessionAccess = host.readNewSessionAccess();
402398
const filtered = host.sessionOwnerFilterActive || host.sessionsStatusFilter !== "active";
@@ -438,7 +434,6 @@ export function renderSessionList(params: {
438434
empty: boolean;
439435
sections: RenderableSessionSection[];
440436
nativeSessionsHaveMore: boolean;
441-
categorySessionsHaveMore: (category: string) => boolean;
442437
catalogs: SessionCatalogRenderSnapshot;
443438
catalogRenderer: SessionCatalogGroupsRenderer | null;
444439
}) {
@@ -478,11 +473,10 @@ export function renderSessionList(params: {
478473
${renderSessionListBody({
479474
host,
480475
sections: params.sections,
481-
nativeSessionsHaveMore: params.nativeSessionsHaveMore,
482-
categorySessionsHaveMore: params.categorySessionsHaveMore,
483476
catalogs: params.catalogs,
484477
catalogRenderer: params.catalogRenderer,
485478
})}
479+
${params.nativeSessionsHaveMore ? renderGlobalSessionPagination(host) : nothing}
486480
${host.sessionsStatusFilter === "archived" && params.empty
487481
? html`<span class="sidebar-session-empty-hint"
488482
>${t("sessionsView.noArchivedSessions")}</span

0 commit comments

Comments
 (0)