@log0u7/opencode-mesh 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.9.0] - 2026-11-22
9
+
10
+ ### Added
11
+
12
+ - Sidebar v2 (quota-style): collapsible header with toggle (click or
13
+ `mesh.toggleSidebar`), collapsed by default showing `N unread · M agents ·
14
+ K pools`; expanded shows my mailbox with unread count, one line per pool
15
+ with per-member presence (`●` fresh < 2 min, `○` warm < 15 min), peers and
16
+ locks. The snapshot RPC takes an optional `sessionID` (from the
17
+ `sidebar.content` slot input) and resolves the asking session's mailbox,
18
+ per-mailbox presence ages and the pool membership map.
19
+
20
+ ## [0.8.1] - 2026-11-22
21
+
22
+ ### Fixed
23
+
24
+ - Sidebar collapse state survives TUI restarts even for scoped plugin ids
25
+ (`@scope/name`): the host's storage segment validation rejects them
26
+ (anomalyco/opencode#62634, fix pending in PR #62638), so the collapse state
27
+ is now persisted by the setup side through the raw storage domain under an
28
+ escaped key (`plugin.<escaped-id>.mesh-sidebar`) and synced to the TUI over
29
+ RPC. In-memory remains the last resort on hosts without RPC.
30
+
8
31
  ## [0.8.0] - 2026-11-22
9
32
 
10
33
  ### Added
@@ -80,8 +103,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
80
103
 
81
104
  - TUI plugin (phase 0+1): toast, `/mesh` slash command, sidebar slot.
82
105
 
83
- ## [0.8.0] - 2026-11-22
84
-
85
106
  ## [0.4.1] - 2026-10-24
86
107
 
87
108
  ### Fixed
@@ -0,0 +1,13 @@
1
+ export declare function escapeSegment(id: string): string;
2
+ export type RawStorage = {
3
+ get(key: string): Promise<unknown>;
4
+ set(key: string, value: unknown): Promise<void>;
5
+ };
6
+ export type DurableStore = {
7
+ /** The composed, host-safe storage key (exposed for tests). */
8
+ key(): string;
9
+ load<T>(): Promise<T | null>;
10
+ save<T>(value: T): Promise<void>;
11
+ };
12
+ export declare function createDurableStore(raw: RawStorage, pluginId: string, name: string): DurableStore;
13
+ //# sourceMappingURL=persist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/lib/persist.ts"],"names":[],"mappings":"AAUA,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAiBhD;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,+DAA+D;IAC/D,GAAG,IAAI,MAAM,CAAC;IACd,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAiBhG"}
@@ -0,0 +1,48 @@
1
+ // Workaround for anomalyco/opencode#62634: the host composes TUI storage keys
2
+ // as `plugin.<id>.<key>` and its segment() validation rejects scoped npm ids,
3
+ // so TUI-side storage.store() throws for any @scope/name plugin. Until the
4
+ // host fix (PR #62638) ships, the setup side persists durable state itself
5
+ // through the raw storage domain, under a key whose id segment is escaped
6
+ // injectively (every distinct id maps to a distinct segment, so no collision).
7
+ const SAFE = /^[a-zA-Z0-9._-]+$/;
8
+ const SAFE_CHAR = /^[a-zA-Z0-9._-]$/;
9
+ export function escapeSegment(id) {
10
+ if (SAFE.test(id)) {
11
+ return id;
12
+ }
13
+ let out = "";
14
+ for (const ch of id) {
15
+ if (SAFE_CHAR.test(ch)) {
16
+ out += ch;
17
+ }
18
+ else if (ch === "_") {
19
+ out += "__";
20
+ }
21
+ else {
22
+ for (const unit of ch) {
23
+ out += `_${unit.codePointAt(0).toString(16).padStart(4, "0")}`;
24
+ }
25
+ }
26
+ }
27
+ return out;
28
+ }
29
+ export function createDurableStore(raw, pluginId, name) {
30
+ const fullKey = `plugin.${escapeSegment(pluginId)}.${name}`;
31
+ return {
32
+ key: () => fullKey,
33
+ async load() {
34
+ try {
35
+ const value = await raw.get(fullKey);
36
+ return value ?? null;
37
+ }
38
+ catch {
39
+ // Unreadable host storage: behave like an empty store.
40
+ return null;
41
+ }
42
+ },
43
+ async save(value) {
44
+ await raw.set(fullKey, value);
45
+ },
46
+ };
47
+ }
48
+ //# sourceMappingURL=persist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist.js","sourceRoot":"","sources":["../../src/lib/persist.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,+EAA+E;AAE/E,MAAM,IAAI,GAAG,mBAAmB,CAAC;AACjC,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;QACpB,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACvB,GAAG,IAAI,EAAE,CAAC;QACZ,CAAC;aAAM,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACtB,GAAG,IAAI,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,IAAI,IAAI,EAAE,EAAE,CAAC;gBACtB,GAAG,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAcD,MAAM,UAAU,kBAAkB,CAAC,GAAe,EAAE,QAAgB,EAAE,IAAY;IAChF,MAAM,OAAO,GAAG,UAAU,aAAa,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;IAC5D,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO;QAClB,KAAK,CAAC,IAAI;YACR,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACrC,OAAQ,KAA8B,IAAI,IAAI,CAAC;YACjD,CAAC;YAAC,MAAM,CAAC;gBACP,uDAAuD;gBACvD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,KAAK,CAAC,IAAI,CAAI,KAAQ;YACpB,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-v2.d.ts","sourceRoot":"","sources":["../src/plugin-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA8B1C,eAAO,MAAM,MAAM,eAgHjB,CAAC"}
1
+ {"version":3,"file":"plugin-v2.d.ts","sourceRoot":"","sources":["../src/plugin-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAgC1C,eAAO,MAAM,MAAM,eAgKjB,CAAC"}
package/dist/plugin-v2.js CHANGED
@@ -3,12 +3,14 @@ import { Bonjour } from "bonjour-service";
3
3
  import { openMeshDb } from "./lib/db.js";
4
4
  import { advertiseMesh, browseMesh } from "./lib/discovery.js";
5
5
  import { listLocks } from "./lib/locks.js";
6
+ import { listMailboxes, mailboxBySession, unreadBoxCount } from "./lib/mail.js";
6
7
  import { listPeers, upsertDiscoveredPeer } from "./lib/peers.js";
7
8
  import { loadOrCreateIdentity } from "./lib/identity.js";
8
9
  import { nodeSpawn, stopAllWorkers } from "./lib/spawn.js";
9
10
  import { v2WorktreeDomainClient } from "./lib/worktree.js";
10
11
  import { reconcileWorkers } from "./lib/workers.js";
11
12
  import { startMeshServer } from "./lib/serve.js";
13
+ import { createDurableStore } from "./lib/persist.js";
12
14
  import { startWakeLoop } from "./lib/wake.js";
13
15
  import { MeshRpc, snapshotFromMesh } from "./rpc.js";
14
16
  import { buildToolSpecs } from "./tools.js";
@@ -106,13 +108,59 @@ export const MeshV2 = Plugin.define({
106
108
  }),
107
109
  });
108
110
  // Live snapshot for the TUI sidebar: one compact read over the mesh state.
111
+ // Sidebar collapse state is persisted HERE (raw storage domain, escaped
112
+ // key) because the TUI-side storage.store() throws for scoped plugin ids
113
+ // (anomalyco/opencode#62634).
114
+ const sidebarPersist = createDurableStore(ctx.storage, "@log0u7/opencode-mesh", "mesh-sidebar");
109
115
  const rpc = await ctx.rpc.register(MeshRpc, {
110
- snapshot: async () => snapshotFromMesh({
111
- identity,
112
- peers: listPeers(db),
113
- locks: listLocks(db, { now: Date.now() }),
114
- server: `${address}:${port}`,
115
- }),
116
+ snapshot: async (input) => {
117
+ const sessionID = typeof input === "object" && input !== null && "sessionID" in input
118
+ ? input.sessionID
119
+ : undefined;
120
+ const myBox = typeof sessionID === "string" && sessionID.length > 0
121
+ ? mailboxBySession(db, sessionID)
122
+ : null;
123
+ const boxes = listMailboxes(db);
124
+ const pools = {};
125
+ for (const box of boxes) {
126
+ for (const pool of box.pools) {
127
+ const members = pools[pool] ?? [];
128
+ members.push(box.name);
129
+ pools[pool] = members;
130
+ }
131
+ }
132
+ return snapshotFromMesh({
133
+ identity,
134
+ peers: listPeers(db),
135
+ locks: listLocks(db, { now: Date.now() }),
136
+ server: `${address}:${port}`,
137
+ my: myBox
138
+ ? {
139
+ name: myBox.name,
140
+ role: myBox.role,
141
+ unread: unreadBoxCount(db, myBox.name),
142
+ }
143
+ : null,
144
+ mailboxes: boxes.map((box) => ({
145
+ name: box.name,
146
+ role: box.role,
147
+ pools: [...box.pools],
148
+ age_s: Math.max(0, Math.round((Date.now() - box.last_seen) / 1000)),
149
+ })),
150
+ pools,
151
+ });
152
+ },
153
+ sidebar: async () => {
154
+ const state = await sidebarPersist.load();
155
+ return { collapsed: state?.collapsed === true };
156
+ },
157
+ set_sidebar: async (input) => {
158
+ const collapsed = typeof input === "object" && input !== null && "collapsed" in input
159
+ ? input.collapsed === true
160
+ : false;
161
+ await sidebarPersist.save({ collapsed });
162
+ return { collapsed };
163
+ },
116
164
  });
117
165
  const cleanup = async () => {
118
166
  wake.stop();
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-v2.js","sourceRoot":"","sources":["../src/plugin-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAwB,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAqB,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAgB,MAAM,gBAAgB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AE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,IAAc;IAMhC,MAAM,UAAU,GAA0D,EAAE,CAAC;IAC7E,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;IAChF,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1E,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC"}
package/dist/rpc.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export type MailboxInfo = {
2
+ name: string;
3
+ role: string | null;
4
+ pools: string[];
5
+ age_s: number;
6
+ };
1
7
  export type MeshSnapshot = {
2
8
  node_id: string;
3
9
  hostname: string;
@@ -7,6 +13,16 @@ export type MeshSnapshot = {
7
13
  hostname: string;
8
14
  }>;
9
15
  active_locks: number;
16
+ /** The mailbox bound to the session that asked (null when unregistered). */
17
+ me: {
18
+ name: string;
19
+ role: string | null;
20
+ unread: number;
21
+ } | null;
22
+ /** Every registered mailbox on this node, oldest first. */
23
+ mailboxes: MailboxInfo[];
24
+ /** pool id -> member mailbox names. */
25
+ pools: Record<string, string[]>;
10
26
  };
11
27
  /** Structural input: the mesh context (identity, listPeers, listLocks) satisfies this. */
12
28
  export type SnapshotInput = {
@@ -21,11 +37,23 @@ export type SnapshotInput = {
21
37
  }>;
22
38
  locks: ReadonlyArray<unknown>;
23
39
  server: string;
40
+ my: {
41
+ name: string;
42
+ role: string | null;
43
+ unread: number;
44
+ } | null;
45
+ mailboxes: ReadonlyArray<MailboxInfo>;
46
+ pools: Record<string, string[]>;
24
47
  };
25
48
  export declare function snapshotFromMesh(data: SnapshotInput): MeshSnapshot;
26
- /** Sidebar lines: the node, one line per paired peer, the active lock count. */
49
+ export declare const PRESENCE_FRESH_S = 120;
50
+ export declare const PRESENCE_WARM_S = 900;
51
+ export declare function presenceMark(age_s: number): string;
52
+ export declare function formatAge(age_s: number): string;
53
+ /** Sidebar lines: my mailbox (unread first), one line per pool, peers, locks. */
27
54
  export declare function formatMeshLines(s: MeshSnapshot): string[];
28
- /** Collapsible sidebar: when collapsed, one header line with the peer count (plus locks). */
55
+ /** Collapsed: header summary is rendered by the component; this returns the
56
+ * counts it needs (unread, agents, pools) as one muted line. */
29
57
  export declare function formatMeshSidebar(s: MeshSnapshot, collapsed: boolean): string[];
30
58
  export declare const MeshRpc: {
31
59
  readonly id: "mesh";
@@ -33,7 +61,12 @@ export declare const MeshRpc: {
33
61
  readonly snapshot: {
34
62
  readonly input: {
35
63
  readonly type: "object";
36
- readonly properties: {};
64
+ readonly properties: {
65
+ readonly sessionID: {
66
+ readonly type: "string";
67
+ readonly description: "The session asking (resolves its mailbox)";
68
+ };
69
+ };
37
70
  readonly additionalProperties: false;
38
71
  };
39
72
  readonly output: {
@@ -68,8 +101,103 @@ export declare const MeshRpc: {
68
101
  readonly type: "number";
69
102
  readonly description: "Active local file locks";
70
103
  };
104
+ readonly me: {
105
+ readonly type: readonly ["object", "null"];
106
+ readonly properties: {
107
+ readonly name: {
108
+ readonly type: "string";
109
+ };
110
+ readonly role: {
111
+ readonly type: readonly ["string", "null"];
112
+ };
113
+ readonly unread: {
114
+ readonly type: "number";
115
+ };
116
+ };
117
+ readonly required: readonly ["name", "role", "unread"];
118
+ readonly additionalProperties: false;
119
+ readonly description: "The asking session's mailbox, null when unregistered";
120
+ };
121
+ readonly mailboxes: {
122
+ readonly type: "array";
123
+ readonly items: {
124
+ readonly type: "object";
125
+ readonly properties: {
126
+ readonly name: {
127
+ readonly type: "string";
128
+ };
129
+ readonly role: {
130
+ readonly type: readonly ["string", "null"];
131
+ };
132
+ readonly pools: {
133
+ readonly type: "array";
134
+ readonly items: {
135
+ readonly type: "string";
136
+ };
137
+ };
138
+ readonly age_s: {
139
+ readonly type: "number";
140
+ };
141
+ };
142
+ readonly required: readonly ["name", "role", "pools", "age_s"];
143
+ readonly additionalProperties: false;
144
+ };
145
+ readonly description: "Registered mailboxes on this node";
146
+ };
147
+ readonly pools: {
148
+ readonly type: "object";
149
+ readonly additionalProperties: {
150
+ readonly type: "array";
151
+ readonly items: {
152
+ readonly type: "string";
153
+ };
154
+ };
155
+ readonly description: "Pool id -> member mailbox names";
156
+ };
157
+ };
158
+ readonly required: readonly ["node_id", "hostname", "peers", "active_locks", "me", "mailboxes", "pools"];
159
+ readonly additionalProperties: false;
160
+ };
161
+ };
162
+ readonly sidebar: {
163
+ readonly input: {
164
+ readonly type: "object";
165
+ readonly properties: {};
166
+ readonly additionalProperties: false;
167
+ };
168
+ readonly output: {
169
+ readonly type: "object";
170
+ readonly properties: {
171
+ readonly collapsed: {
172
+ readonly type: "boolean";
173
+ readonly description: "Sidebar collapsed state";
174
+ };
175
+ };
176
+ readonly required: readonly ["collapsed"];
177
+ readonly additionalProperties: false;
178
+ };
179
+ };
180
+ readonly set_sidebar: {
181
+ readonly input: {
182
+ readonly type: "object";
183
+ readonly properties: {
184
+ readonly collapsed: {
185
+ readonly type: "boolean";
186
+ readonly description: "Sidebar collapsed state";
187
+ };
188
+ };
189
+ readonly required: readonly ["collapsed"];
190
+ readonly additionalProperties: false;
191
+ };
192
+ readonly output: {
193
+ readonly type: "object";
194
+ readonly properties: {
195
+ readonly collapsed: {
196
+ readonly type: "boolean";
197
+ readonly description: "Sidebar collapsed state";
198
+ };
71
199
  };
72
- readonly required: readonly ["node_id", "hostname", "peers", "active_locks"];
200
+ readonly required: readonly ["collapsed"];
73
201
  readonly additionalProperties: false;
74
202
  };
75
203
  };
package/dist/rpc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,0FAA0F;AAC1F,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,KAAK,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7E,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,CASlE;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,CAczD;AAED,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,EAAE,CAU/E;AAED,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;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AAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjE,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACjC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,CAYlE;AAGD,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/C;AAoBD,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,CAyBzD;AAED;gEACgE;AAChE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,EAAE,CAU/E;AAED,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGlB,CAAC"}
package/dist/rpc.js CHANGED
@@ -7,12 +7,59 @@ export function snapshotFromMesh(data) {
7
7
  .filter((p) => p.paired)
8
8
  .map((p) => ({ node_id: p.node_id, hostname: p.hostname })),
9
9
  active_locks: data.locks.length,
10
+ me: data.my,
11
+ mailboxes: [...data.mailboxes],
12
+ pools: { ...data.pools },
10
13
  };
11
14
  }
12
- /** Sidebar lines: the node, one line per paired peer, the active lock count. */
15
+ // Presence thresholds: fresh under 2 minutes, warm under 15.
16
+ export const PRESENCE_FRESH_S = 120;
17
+ export const PRESENCE_WARM_S = 900;
18
+ export function presenceMark(age_s) {
19
+ if (age_s <= PRESENCE_FRESH_S)
20
+ return "●";
21
+ if (age_s <= PRESENCE_WARM_S)
22
+ return "○";
23
+ return "";
24
+ }
25
+ export function formatAge(age_s) {
26
+ if (age_s < 60)
27
+ return `${age_s}s`;
28
+ return `${Math.floor(age_s / 60)}m`;
29
+ }
30
+ function formatMember(m) {
31
+ const mark = presenceMark(m.age_s);
32
+ const age = formatAge(m.age_s);
33
+ return mark ? `${mark} ${m.name} ${age}` : `${m.name} ${age}`;
34
+ }
35
+ function formatPoolLine(pool, members, byName) {
36
+ const parts = [];
37
+ for (const name of members.slice(0, 4)) {
38
+ const box = byName.get(name);
39
+ parts.push(box ? formatMember(box) : name);
40
+ }
41
+ if (members.length > 4) {
42
+ parts.push(`+${members.length - 4}`);
43
+ }
44
+ return `${pool}: ${parts.join(" · ")}`;
45
+ }
46
+ /** Sidebar lines: my mailbox (unread first), one line per pool, peers, locks. */
13
47
  export function formatMeshLines(s) {
14
- const self = s.hostname.length > 0 ? s.hostname : s.node_id;
15
- const lines = [`mesh: ${self}`];
48
+ const lines = [];
49
+ if (s.me) {
50
+ const role = s.me.role ? ` (${s.me.role})` : "";
51
+ const unread = s.me.unread > 0 ? ` ● ${s.me.unread} unread` : "";
52
+ lines.push(`${s.me.name}${role}${unread}`);
53
+ }
54
+ else {
55
+ lines.push("no mailbox — mesh_register");
56
+ }
57
+ const byName = new Map(s.mailboxes.map((m) => [m.name, m]));
58
+ for (const [pool, members] of Object.entries(s.pools)) {
59
+ if (members.length === 0)
60
+ continue;
61
+ lines.push(formatPoolLine(pool, members, byName));
62
+ }
16
63
  if (s.peers.length === 0) {
17
64
  lines.push("no paired peers");
18
65
  }
@@ -26,23 +73,31 @@ export function formatMeshLines(s) {
26
73
  }
27
74
  return lines;
28
75
  }
29
- /** Collapsible sidebar: when collapsed, one header line with the peer count (plus locks). */
76
+ /** Collapsed: header summary is rendered by the component; this returns the
77
+ * counts it needs (unread, agents, pools) as one muted line. */
30
78
  export function formatMeshSidebar(s, collapsed) {
31
79
  if (!collapsed) {
32
80
  return formatMeshLines(s);
33
81
  }
34
- const self = s.hostname.length > 0 ? s.hostname : s.node_id;
35
- const lines = [`mesh: ${self} (${s.peers.length} peers)`];
36
- if (s.active_locks > 0) {
37
- lines.push(`${s.active_locks} active lock(s)`);
38
- }
39
- return lines;
82
+ const unread = s.me?.unread ?? 0;
83
+ const parts = [];
84
+ if (unread > 0)
85
+ parts.push(`${unread} unread`);
86
+ parts.push(`${s.mailboxes.length} agents`);
87
+ parts.push(`${Object.keys(s.pools).length} pools`);
88
+ return [parts.join(" · ")];
40
89
  }
41
90
  export const MeshRpc = Rpc.define({
42
91
  id: "mesh",
43
92
  methods: {
44
93
  snapshot: {
45
- input: { type: "object", properties: {}, additionalProperties: false },
94
+ input: {
95
+ type: "object",
96
+ properties: {
97
+ sessionID: { type: "string", description: "The session asking (resolves its mailbox)" },
98
+ },
99
+ additionalProperties: false,
100
+ },
46
101
  output: {
47
102
  type: "object",
48
103
  properties: {
@@ -62,8 +117,71 @@ export const MeshRpc = Rpc.define({
62
117
  description: "Paired peers",
63
118
  },
64
119
  active_locks: { type: "number", description: "Active local file locks" },
120
+ me: {
121
+ type: ["object", "null"],
122
+ properties: {
123
+ name: { type: "string" },
124
+ role: { type: ["string", "null"] },
125
+ unread: { type: "number" },
126
+ },
127
+ required: ["name", "role", "unread"],
128
+ additionalProperties: false,
129
+ description: "The asking session's mailbox, null when unregistered",
130
+ },
131
+ mailboxes: {
132
+ type: "array",
133
+ items: {
134
+ type: "object",
135
+ properties: {
136
+ name: { type: "string" },
137
+ role: { type: ["string", "null"] },
138
+ pools: { type: "array", items: { type: "string" } },
139
+ age_s: { type: "number" },
140
+ },
141
+ required: ["name", "role", "pools", "age_s"],
142
+ additionalProperties: false,
143
+ },
144
+ description: "Registered mailboxes on this node",
145
+ },
146
+ pools: {
147
+ type: "object",
148
+ additionalProperties: { type: "array", items: { type: "string" } },
149
+ description: "Pool id -> member mailbox names",
150
+ },
151
+ },
152
+ required: ["node_id", "hostname", "peers", "active_locks", "me", "mailboxes", "pools"],
153
+ additionalProperties: false,
154
+ },
155
+ },
156
+ // Sidebar collapse state, persisted by the setup side through the raw
157
+ // storage domain: the TUI-side storage.store() throws for scoped plugin
158
+ // ids (anomalyco/opencode#62634).
159
+ sidebar: {
160
+ input: { type: "object", properties: {}, additionalProperties: false },
161
+ output: {
162
+ type: "object",
163
+ properties: {
164
+ collapsed: { type: "boolean", description: "Sidebar collapsed state" },
165
+ },
166
+ required: ["collapsed"],
167
+ additionalProperties: false,
168
+ },
169
+ },
170
+ set_sidebar: {
171
+ input: {
172
+ type: "object",
173
+ properties: {
174
+ collapsed: { type: "boolean", description: "Sidebar collapsed state" },
175
+ },
176
+ required: ["collapsed"],
177
+ additionalProperties: false,
178
+ },
179
+ output: {
180
+ type: "object",
181
+ properties: {
182
+ collapsed: { type: "boolean", description: "Sidebar collapsed state" },
65
183
  },
66
- required: ["node_id", "hostname", "peers", "active_locks"],
184
+ required: ["collapsed"],
67
185
  additionalProperties: false,
68
186
  },
69
187
  },
package/dist/rpc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAsB3C,MAAM,UAAU,gBAAgB,CAAC,IAAmB;IAClD,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO;QAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;QAChC,KAAK,EAAE,IAAI,CAAC,KAAK;aACd,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;aACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAA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EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,yBAAyB,EAAE;iBACvE;gBACD,QAAQ,EAAE,CAAC,WAAW,CAAC;gBACvB,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,MAAM,EAAE,EAAE;CACX,CAAC,CAAC"}
@@ -2,16 +2,31 @@ import type { Plugin } from "@opencode/plugin/tui";
2
2
  type SidebarState = {
3
3
  collapsed: boolean;
4
4
  };
5
+ /** RPC client subset used for the durable fallback (see below). */
6
+ export type SidebarRpc = {
7
+ sidebar: (input: Record<string, never>) => Promise<{
8
+ collapsed: boolean;
9
+ }>;
10
+ set_sidebar: (input: {
11
+ collapsed: boolean;
12
+ }) => Promise<{
13
+ collapsed: boolean;
14
+ }>;
15
+ };
5
16
  /** Collapse state for the mesh sidebar: durable via the host's TUI storage when
6
- * available, in-memory fallback when it is not. The host composes storage keys
7
- * as `plugin.<id>.<key>` and its segment() validation rejects scoped npm ids
8
- * (`@scope/name.tui`), so `storage.store()` throws on first use for any plugin
9
- * installed from a scoped package (anomalyco/opencode#62634). The upstream fix
10
- * removes the throw; until then the fallback keeps the sidebar functional, at
11
- * the cost of not persisting the collapse state across TUI restarts.
12
- * Returns the same `[store, mutate]` shape as `storage.store` either way. */
13
- export declare function createSidebarState(storage: Plugin.Context["storage"]): readonly [{
14
- readonly collapsed: boolean;
15
- }, (mutation: (draft: SidebarState) => void) => Promise<void>];
17
+ * available. The host composes storage keys as `plugin.<id>.<key>` and its
18
+ * segment() validation rejects scoped npm ids (`@scope/name.tui`), so
19
+ * `storage.store()` throws on first use for any plugin installed from a scoped
20
+ * package (anomalyco/opencode#62634; upstream fix in PR #62638). The fallback
21
+ * persists the state through the setup side over RPC (raw storage domain under
22
+ * an escaped key, see src/lib/persist.ts), degrading to in-memory when no RPC
23
+ * is available. Returns the same `[store, mutate]` shape as `storage.store`
24
+ * either way. */
25
+ export declare function createSidebarState(storage: Plugin.Context["storage"], mesh?: SidebarRpc): readonly [
26
+ {
27
+ readonly collapsed: boolean;
28
+ },
29
+ (mutation: (draft: SidebarState) => void) => Promise<void>
30
+ ];
16
31
  export {};
17
32
  //# sourceMappingURL=sidebar-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-state.d.ts","sourceRoot":"","sources":["../src/sidebar-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,KAAK,YAAY,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3C;;;;;;;6EAO6E;AAC7E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;wBAYzC,OAAO;cAClB,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,EAG/D"}
1
+ {"version":3,"file":"sidebar-state.d.ts","sourceRoot":"","sources":["../src/sidebar-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,KAAK,YAAY,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3C,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC3E,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACjF,CAAC;AAEF;;;;;;;;iBAQiB;AACjB,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAClC,IAAI,CAAC,EAAE,UAAU,GAChB,SAAS;IACV;QAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;KAAE;IAC/B,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;CAC3D,CAiCA"}
@@ -1,22 +1,41 @@
1
1
  import { createStore, produce } from "solid-js/store";
2
2
  /** Collapse state for the mesh sidebar: durable via the host's TUI storage when
3
- * available, in-memory fallback when it is not. The host composes storage keys
4
- * as `plugin.<id>.<key>` and its segment() validation rejects scoped npm ids
5
- * (`@scope/name.tui`), so `storage.store()` throws on first use for any plugin
6
- * installed from a scoped package (anomalyco/opencode#62634). The upstream fix
7
- * removes the throw; until then the fallback keeps the sidebar functional, at
8
- * the cost of not persisting the collapse state across TUI restarts.
9
- * Returns the same `[store, mutate]` shape as `storage.store` either way. */
10
- export function createSidebarState(storage) {
3
+ * available. The host composes storage keys as `plugin.<id>.<key>` and its
4
+ * segment() validation rejects scoped npm ids (`@scope/name.tui`), so
5
+ * `storage.store()` throws on first use for any plugin installed from a scoped
6
+ * package (anomalyco/opencode#62634; upstream fix in PR #62638). The fallback
7
+ * persists the state through the setup side over RPC (raw storage domain under
8
+ * an escaped key, see src/lib/persist.ts), degrading to in-memory when no RPC
9
+ * is available. Returns the same `[store, mutate]` shape as `storage.store`
10
+ * either way. */
11
+ export function createSidebarState(storage, mesh) {
11
12
  try {
12
- return storage.store("mesh-sidebar", { initial: { collapsed: false } });
13
+ return storage.store("mesh-sidebar", { initial: { collapsed: true } });
13
14
  }
14
15
  catch {
15
- const [store, setStore] = createStore({ collapsed: false });
16
+ const [store, setStore] = createStore({ collapsed: true });
17
+ if (mesh) {
18
+ // Adopt the persisted state once it arrives; the sidebar renders
19
+ // expanded for the first frames, which is harmless.
20
+ void mesh
21
+ .sidebar({})
22
+ .then((state) => {
23
+ if (state.collapsed !== store.collapsed) {
24
+ setStore(produce((draft) => {
25
+ draft.collapsed = state.collapsed;
26
+ }));
27
+ }
28
+ })
29
+ .catch(() => { });
30
+ }
16
31
  return [
17
32
  store,
18
33
  (mutation) => {
19
34
  setStore(produce(mutation));
35
+ // Fire and forget: a failed save only loses one toggle.
36
+ if (mesh) {
37
+ void mesh.set_sidebar({ collapsed: store.collapsed }).catch(() => { });
38
+ }
20
39
  return Promise.resolve();
21
40
  },
22
41
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-state.js","sourceRoot":"","sources":["../src/sidebar-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAItD;;;;;;;6EAO6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,OAAkC;IACnE,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAe,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1E,OAAO;YACL,KAAK;YACL,CAAC,QAAuC,EAAE,EAAE;gBAC1C,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;SAIF,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"sidebar-state.js","sourceRoot":"","sources":["../src/sidebar-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAUtD;;;;;;;;iBAQiB;AACjB,MAAM,UAAU,kBAAkB,CAChC,OAAkC,EAClC,IAAiB;IAKjB,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,WAAW,CAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,IAAI,IAAI,EAAE,CAAC;YACT,iEAAiE;YACjE,oDAAoD;YACpD,KAAK,IAAI;iBACN,OAAO,CAAC,EAAE,CAAC;iBACX,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACd,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,EAAE,CAAC;oBACxC,QAAQ,CACN,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;wBAChB,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;oBACpC,CAAC,CAAC,CACH,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,OAAO;YACL,KAAK;YACL,CAAC,QAAuC,EAAE,EAAE;gBAC1C,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC5B,wDAAwD;gBACxD,IAAI,IAAI,EAAE,CAAC;oBACT,KAAK,IAAI,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;gBACxE,CAAC;gBACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;SACO,CAAC;IACb,CAAC;AACH,CAAC"}
package/dist/tui.js CHANGED
@@ -2,8 +2,8 @@ import { memo as _$memo } from "@opentui/solid";
2
2
  import { createTextNode as _$createTextNode } from "@opentui/solid";
3
3
  import { insertNode as _$insertNode } from "@opentui/solid";
4
4
  import { effect as _$effect } from "@opentui/solid";
5
- import { setProp as _$setProp } from "@opentui/solid";
6
5
  import { insert as _$insert } from "@opentui/solid";
6
+ import { setProp as _$setProp } from "@opentui/solid";
7
7
  import { createElement as _$createElement } from "@opentui/solid";
8
8
  import { createComponent as _$createComponent } from "@opentui/solid";
9
9
  /** @jsxImportSource @opentui/solid */
@@ -15,7 +15,7 @@ import { createSidebarState } from "./sidebar-state.js";
15
15
  const REFRESH_MS = 15_000;
16
16
  /** quota-style event refresh: debounced immediate refresh after activity. */
17
17
  const EVENT_DEBOUNCE_MS = 150;
18
- function themedSidebar(theme, lines) {
18
+ function themedBody(theme, lines, unread) {
19
19
  return _$createComponent(Show, {
20
20
  get when() {
21
21
  return lines();
@@ -23,13 +23,14 @@ function themedSidebar(theme, lines) {
23
23
  keyed: true,
24
24
  children: current => (() => {
25
25
  var _el$ = _$createElement("box");
26
+ _$setProp(_el$, "gap", 0);
26
27
  _$insert(_el$, _$createComponent(For, {
27
28
  each: current,
28
29
  children: (line, index) => (() => {
29
30
  var _el$2 = _$createElement("text");
30
31
  _$setProp(_el$2, "wrapMode", "none");
31
32
  _$insert(_el$2, line);
32
- _$effect(_$p => _$setProp(_el$2, "fg", index() === 0 ? theme.text.base : theme.text.muted, _$p));
33
+ _$effect(_$p => _$setProp(_el$2, "fg", index() === 0 && unread > 0 ? theme.text.base : theme.text.muted, _$p));
33
34
  return _el$2;
34
35
  })()
35
36
  }));
@@ -99,18 +100,28 @@ export default Plugin.define({
99
100
  });
100
101
 
101
102
  // Durable collapse state when the host allows it (scoped plugin ids hit a
102
- // host-side segment validation error — anomalyco/opencode#62634); in-memory
103
- // fallback otherwise: sidebar works, collapse not persisted across restarts.
104
- const [store, mutate] = createSidebarState(context.storage);
103
+ // host-side segment validation error — anomalyco/opencode#62634); RPC
104
+ // fallback persists through the setup side; pure in-memory as last resort.
105
+ // The RPC client output is untyped (Promise<unknown>): narrow to the
106
+ // sidebar subset we consume.
107
+ const meshRpc = context.client.rpc(MeshRpc);
108
+ const [store, mutate] = createSidebarState(context.storage, meshRpc);
105
109
  const [snapshot, setSnapshot] = createSignal(null);
106
110
  const [lines, setLines] = createSignal(null);
107
111
 
108
112
  // Live sidebar: poll the server-side snapshot over RPC. On a v1 host (no
109
- // RPC) or while the server is unreachable, the slot stays hidden.
113
+ // RPC) or while the server is unreachable, the slot stays hidden. The
114
+ // sessionID arrives with the slot input (see register below).
110
115
  const mesh = context.client.rpc(MeshRpc);
116
+ const sessionId = createSignal(null);
111
117
  const refresh = async () => {
112
118
  try {
113
- const snap = await mesh.snapshot({});
119
+ const sid = sessionId[0]();
120
+ const snap = await mesh.snapshot({
121
+ ...(sid !== null ? {
122
+ sessionID: sid
123
+ } : {})
124
+ });
114
125
  setSnapshot(snap);
115
126
  setLines(formatMeshSidebar(snap, store.collapsed));
116
127
  } catch {
@@ -139,7 +150,47 @@ export default Plugin.define({
139
150
  })();
140
151
  const unregister = context.ui.slot({
141
152
  append: "sidebar.content",
142
- render: () => themedSidebar(theme, lines)
153
+ render: input => {
154
+ if (input.sessionID !== sessionId[0]()) {
155
+ sessionId[1](input.sessionID);
156
+ schedule();
157
+ }
158
+ const unread = snapshot()?.me?.unread ?? 0;
159
+ return (() => {
160
+ var _el$11 = _$createElement("box"),
161
+ _el$12 = _$createElement("box"),
162
+ _el$13 = _$createElement("text"),
163
+ _el$14 = _$createElement("b"),
164
+ _el$16 = _$createElement("box");
165
+ _$insertNode(_el$11, _el$12);
166
+ _$insertNode(_el$11, _el$16);
167
+ _$setProp(_el$11, "gap", 0);
168
+ _$insertNode(_el$12, _el$13);
169
+ _$setProp(_el$12, "flexDirection", "row");
170
+ _$insertNode(_el$13, _el$14);
171
+ _$setProp(_el$13, "onMouseDown", () => {
172
+ void mutate(draft => {
173
+ draft.collapsed = !draft.collapsed;
174
+ }).then(() => void refresh());
175
+ });
176
+ _$insert(_el$14, () => store.collapsed ? "▶ Mesh" : "▼ Mesh");
177
+ _$insert(_el$12, _$createComponent(Show, {
178
+ get when() {
179
+ return store.collapsed;
180
+ },
181
+ get children() {
182
+ var _el$15 = _$createElement("text");
183
+ _$insert(_el$15, () => unread > 0 ? ` (${unread} unread)` : ` (${snapshot()?.mailboxes.length ?? 0} agents)`);
184
+ _$effect(_$p => _$setProp(_el$15, "fg", theme.text.muted, _$p));
185
+ return _el$15;
186
+ }
187
+ }), null);
188
+ _$setProp(_el$16, "gap", 0);
189
+ _$insert(_el$16, () => themedBody(theme, lines, unread));
190
+ _$effect(_$p => _$setProp(_el$13, "fg", theme.text.base, _$p));
191
+ return _el$11;
192
+ })();
193
+ }
143
194
  });
144
195
 
145
196
  // Keymap layers are disposed with the plugin; no manual disposer here.
package/dist/tui.tsx CHANGED
@@ -8,20 +8,23 @@ type Context = Plugin.Context;
8
8
  type Theme = Context["theme"];
9
9
 
10
10
  import { MeshRpc, formatMeshSidebar, type MeshSnapshot } from "./rpc.js";
11
- import { createSidebarState } from "./sidebar-state.js";
11
+ import { createSidebarState, type SidebarRpc } from "./sidebar-state.js";
12
12
 
13
13
  const REFRESH_MS = 15_000;
14
14
  /** quota-style event refresh: debounced immediate refresh after activity. */
15
15
  const EVENT_DEBOUNCE_MS = 150;
16
16
 
17
- function themedSidebar(theme: Theme, lines: () => string[] | null): JSX.Element {
17
+ function themedBody(theme: Theme, lines: () => string[] | null, unread: number): JSX.Element {
18
18
  return (
19
19
  <Show when={lines()} keyed>
20
20
  {(current) => (
21
- <box>
21
+ <box gap={0}>
22
22
  <For each={current}>
23
23
  {(line, index) => (
24
- <text fg={index() === 0 ? theme.text.base : theme.text.muted} wrapMode="none">
24
+ <text
25
+ fg={index() === 0 && unread > 0 ? theme.text.base : theme.text.muted}
26
+ wrapMode="none"
27
+ >
25
28
  {line}
26
29
  </text>
27
30
  )}
@@ -56,18 +59,26 @@ export default Plugin.define({
56
59
  context.ui.toast.show({ message: "opencode-mesh loaded", variant: "info", duration: 2000 });
57
60
 
58
61
  // Durable collapse state when the host allows it (scoped plugin ids hit a
59
- // host-side segment validation error — anomalyco/opencode#62634); in-memory
60
- // fallback otherwise: sidebar works, collapse not persisted across restarts.
61
- const [store, mutate] = createSidebarState(context.storage);
62
+ // host-side segment validation error — anomalyco/opencode#62634); RPC
63
+ // fallback persists through the setup side; pure in-memory as last resort.
64
+ // The RPC client output is untyped (Promise<unknown>): narrow to the
65
+ // sidebar subset we consume.
66
+ const meshRpc = context.client.rpc(MeshRpc) as unknown as SidebarRpc;
67
+ const [store, mutate] = createSidebarState(context.storage, meshRpc);
62
68
  const [snapshot, setSnapshot] = createSignal<MeshSnapshot | null>(null);
63
69
  const [lines, setLines] = createSignal<string[] | null>(null);
64
70
 
65
71
  // Live sidebar: poll the server-side snapshot over RPC. On a v1 host (no
66
- // RPC) or while the server is unreachable, the slot stays hidden.
72
+ // RPC) or while the server is unreachable, the slot stays hidden. The
73
+ // sessionID arrives with the slot input (see register below).
67
74
  const mesh = context.client.rpc(MeshRpc);
75
+ const sessionId = createSignal<string | null>(null);
68
76
  const refresh = async () => {
69
77
  try {
70
- const snap = (await mesh.snapshot({})) as MeshSnapshot;
78
+ const sid = sessionId[0]();
79
+ const snap = (await mesh.snapshot({
80
+ ...(sid !== null ? { sessionID: sid } : {}),
81
+ })) as MeshSnapshot;
71
82
  setSnapshot(snap);
72
83
  setLines(formatMeshSidebar(snap, store.collapsed));
73
84
  } catch {
@@ -97,7 +108,37 @@ export default Plugin.define({
97
108
 
98
109
  const unregister = context.ui.slot({
99
110
  append: "sidebar.content",
100
- render: () => themedSidebar(theme, lines),
111
+ render: (input) => {
112
+ if (input.sessionID !== sessionId[0]()) {
113
+ sessionId[1](input.sessionID);
114
+ schedule();
115
+ }
116
+ const unread = snapshot()?.me?.unread ?? 0;
117
+ return (
118
+ <box gap={0}>
119
+ <box flexDirection="row">
120
+ <text
121
+ fg={theme.text.base}
122
+ onMouseDown={() => {
123
+ void mutate((draft) => {
124
+ draft.collapsed = !draft.collapsed;
125
+ }).then(() => void refresh());
126
+ }}
127
+ >
128
+ <b>{store.collapsed ? "▶ Mesh" : "▼ Mesh"}</b>
129
+ </text>
130
+ <Show when={store.collapsed}>
131
+ <text fg={theme.text.muted}>
132
+ {unread > 0
133
+ ? ` (${unread} unread)`
134
+ : ` (${snapshot()?.mailboxes.length ?? 0} agents)`}
135
+ </text>
136
+ </Show>
137
+ </box>
138
+ <box gap={0}>{themedBody(theme, lines, unread)}</box>
139
+ </box>
140
+ );
141
+ },
101
142
  });
102
143
 
103
144
  // Keymap layers are disposed with the plugin; no manual disposer here.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@log0u7/opencode-mesh",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Multi-session coordination for OpenCode: session coordination on one machine and a peer pool across LAN or Tailscale, with pairing, mailbox, and worktree locks.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",