Skip to content

Commit 88e5af7

Browse files
authored
feat(ui): interleaved sidebar zone with custom session icons and drag ordering (#110682)
* feat(ui): custom session icons with agent-drawable SVG and nav-parity pinned rows * wip: slice-2 interleaved sidebar zone (pre-review) * fix(ui): trim icon exports, bypass protocol barrel in startup bundle, regen Swift protocol client * fix(ui): preserve unknown-agent zone entries on writes, prune entries on any unpin * fix(ui): reset keeps unloaded session slots; enforce SVG byte cap on canonical form * fix(ui): archiving a pinned session retires its sidebar zone slot * fix(ui): persist drag-pinned zone slot only after the pin patch lands * fix(ui): recompute drop insertion against freshest zone order on pin ack * fix(ui): consume self-drop events before the zone bailout * docs(ui): note the non-sidebar unpin pruning contract on pruneSidebarSessionEntry * refactor(ui): extract pure session-tree projection; drop unused zone type export
1 parent 3e8f1c6 commit 88e5af7

68 files changed

Lines changed: 2330 additions & 350 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5268,6 +5268,7 @@ public struct SessionsPatchParams: Codable, Sendable {
52685268
public let agentid: String?
52695269
public let label: AnyCodable?
52705270
public let category: AnyCodable?
5271+
public let icon: AnyCodable?
52715272
public let archived: Bool?
52725273
public let pinned: Bool?
52735274
public let unread: Bool?
@@ -5299,6 +5300,7 @@ public struct SessionsPatchParams: Codable, Sendable {
52995300
agentid: String? = nil,
53005301
label: AnyCodable? = nil,
53015302
category: AnyCodable? = nil,
5303+
icon: AnyCodable? = nil,
53025304
archived: Bool? = nil,
53035305
pinned: Bool? = nil,
53045306
unread: Bool? = nil,
@@ -5329,6 +5331,7 @@ public struct SessionsPatchParams: Codable, Sendable {
53295331
self.agentid = agentid
53305332
self.label = label
53315333
self.category = category
5334+
self.icon = icon
53325335
self.archived = archived
53335336
self.pinned = pinned
53345337
self.unread = unread
@@ -5361,6 +5364,7 @@ public struct SessionsPatchParams: Codable, Sendable {
53615364
case agentid = "agentId"
53625365
case label
53635366
case category
5367+
case icon
53645368
case archived
53655369
case pinned
53665370
case unread

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./clawhub-trust-error-details.js";
2+
export * from "./session-icon.js";
23
export * from "./terminal-validators.js";
34
export {
45
validateApprovalGetResult,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ export const SessionsPatchParamsSchema = closedObject({
364364
label: Type.Optional(Type.Union([SessionLabelString, Type.Null()])),
365365
/** User-defined organization bucket ("category", not chat-group); null clears it. */
366366
category: Type.Optional(Type.Union([SessionLabelString, Type.Null()])),
367+
icon: Type.Optional(
368+
Type.Union([NonEmptyString, Type.Null()], {
369+
description: "Sidebar icon: one emoji, name:<id>, or svg:<svg ...>...</svg>.",
370+
}),
371+
),
367372
archived: Type.Optional(Type.Boolean()),
368373
pinned: Type.Optional(Type.Boolean()),
369374
unread: Type.Optional(
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { describe, expect, it } from "vitest";
2+
import { normalizeSessionIconInput, parseSessionIcon } from "./session-icon.js";
3+
4+
describe("session icons", () => {
5+
it("parses named and single-grapheme emoji forms", () => {
6+
expect(parseSessionIcon("name:lobster")).toEqual({ kind: "named", name: "lobster" });
7+
expect(parseSessionIcon("🦞")).toEqual({ kind: "emoji", emoji: "🦞" });
8+
expect(parseSessionIcon("👩🏽‍💻")).toEqual({ kind: "emoji", emoji: "👩🏽‍💻" });
9+
expect(parseSessionIcon("name:Nope")).toBeNull();
10+
expect(parseSessionIcon("🦞🚀")).toBeNull();
11+
expect(parseSessionIcon("A")).toBeNull();
12+
});
13+
14+
it("trims inputs and canonicalizes safe SVG markup", () => {
15+
expect(
16+
normalizeSessionIconInput(
17+
" svg:<svg viewBox='0 0 24 24'><g transform='translate(1 2)'><path d='M1 2' fill='currentColor'/></g></svg> ",
18+
),
19+
).toEqual({
20+
ok: true,
21+
value:
22+
'svg:<svg viewBox="0 0 24 24"><g transform="translate(1 2)"><path d="M1 2" fill="currentColor"/></g></svg>',
23+
});
24+
});
25+
26+
it.each([
27+
"svg:<svg><script>alert(1)</script></svg>",
28+
'svg:<svg onload="alert(1)"></svg>',
29+
'svg:<svg xmlns:xlink="http://www.w3.org/1999/xlink"><path xlink:href="#x"/></svg>',
30+
'svg:<svg><path fill="url(#paint)"/></svg>',
31+
"svg:<!DOCTYPE svg><svg></svg>",
32+
"svg:<svg></svg><svg></svg>",
33+
'svg:<svg><use href="#x"/></svg>',
34+
'svg:<svg><path style="fill:red"/></svg>',
35+
])("rejects hostile SVG: %s", (value) => {
36+
expect(normalizeSessionIconInput(value).ok).toBe(false);
37+
});
38+
39+
it("rejects SVG icons over 4096 bytes", () => {
40+
const value = `svg:<svg><title>${"x".repeat(4096)}</title></svg>`;
41+
expect(normalizeSessionIconInput(value)).toMatchObject({ ok: false });
42+
});
43+
44+
it("rejects SVG whose canonical entity re-encoding exceeds the byte cap", () => {
45+
// 900 double quotes inside a single-quoted attribute fit the raw cap but
46+
// reserialize as &quot; (6 bytes each), overflowing the stored form.
47+
const svg = `svg:<svg viewBox='0 0 16 16'><path d='${'"'.repeat(900)}'/></svg>`;
48+
expect(new TextEncoder().encode(svg).byteLength).toBeLessThanOrEqual(4096);
49+
expect(normalizeSessionIconInput(svg).ok).toBe(false);
50+
});
51+
});

0 commit comments

Comments
 (0)