@narumitw/pi-chat 0.1.2 → 0.1.4

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.
@@ -0,0 +1,487 @@
1
+ // @generated by scripts/build-runtime.mjs; do not edit.
2
+ // @ts-nocheck -- the generated entry uses a .ts extension for Pi's Jiti loader.
3
+ import {
4
+ descriptorFromRememberedRoom
5
+ } from "./chunk-OQLAKS7O.js";
6
+ import {
7
+ sortDirectoryRooms
8
+ } from "./chunk-XYZZR6DW.js";
9
+ import {
10
+ createPublicRoom,
11
+ normalizeNickname,
12
+ parseInvite
13
+ } from "./chunk-ZR2JESR5.js";
14
+ import {
15
+ sanitizeSingleLine
16
+ } from "./chunk-UQPD3L6X.js";
17
+
18
+ // src/menu.ts
19
+ function createChatMenu(source) {
20
+ let pendingRoom;
21
+ let directoryResult;
22
+ let directoryError;
23
+ const getState = async () => ({
24
+ settings: source.getSettings(),
25
+ snapshot: source.getSnapshot(),
26
+ pendingRoom,
27
+ ...source.getRestoreError() ? { restoreError: source.getRestoreError() } : {},
28
+ ...directoryResult ? { directoryResult } : {},
29
+ ...directoryError ? { directoryError } : {}
30
+ });
31
+ const browseRooms = async (signal) => {
32
+ try {
33
+ const result = await source.browsePublicRooms(signal);
34
+ if (signal.aborted) return { kind: "stay" };
35
+ directoryResult = { ...result, rooms: sortDirectoryRooms(result.rooms) };
36
+ directoryError = void 0;
37
+ } catch (error) {
38
+ if (signal.aborted) return { kind: "stay" };
39
+ directoryResult = void 0;
40
+ directoryError = sanitizeSingleLine(error instanceof Error ? error.message : String(error));
41
+ }
42
+ return { kind: "to", screen: "publicRooms" };
43
+ };
44
+ const joinPublic = async (slug, ctx, signal) => {
45
+ let room;
46
+ try {
47
+ room = createPublicRoom(slug.replace(/^#/u, ""));
48
+ } catch (error) {
49
+ return { kind: "rejected", error };
50
+ }
51
+ const confirmed = await ctx.ui.confirm(
52
+ "Join public room?",
53
+ "Anyone can join or record it. DHT and direct peers may observe network metadata.",
54
+ { signal }
55
+ );
56
+ if (!confirmed || signal.aborted) return { kind: "stay" };
57
+ if (!await source.joinRoom(room, ctx, signal, { remember: true }) || signal.aborted) {
58
+ return { kind: "stay" };
59
+ }
60
+ await source.openChat(ctx);
61
+ return { kind: "close" };
62
+ };
63
+ const menu = {
64
+ start: "main",
65
+ screens: {
66
+ main: ({ state }) => mainScreen(state),
67
+ invite: ({ state }) => {
68
+ const room = state.pendingRoom ?? state.snapshot?.room;
69
+ return {
70
+ kind: "review",
71
+ title: "Private room invite",
72
+ lines: [
73
+ "Anyone with this bearer invite can join.",
74
+ "After confirmation, choose whether to save it privately for restart restore."
75
+ ],
76
+ content: room?.invite ?? "Invite is unavailable.",
77
+ format: { kind: "text" },
78
+ viewportSize: "adaptive",
79
+ ...state.pendingRoom ? {
80
+ confirm: {
81
+ id: "join-private",
82
+ label: "Join private room",
83
+ action: "joinPending"
84
+ }
85
+ } : {},
86
+ hint: "back"
87
+ };
88
+ },
89
+ joinInvite: () => ({
90
+ kind: "input",
91
+ title: "Join with invite",
92
+ lines: [
93
+ "Paste a pichat:v1 or pichat:v2 invite. It grants access to the private room.",
94
+ "You will choose Join and remember, Join once, or Cancel before networking starts."
95
+ ],
96
+ placeholder: "pichat:v2:\u2026",
97
+ action: "joinInvite",
98
+ hint: "back"
99
+ }),
100
+ joinPublic: () => ({
101
+ kind: "input",
102
+ title: "Join public room",
103
+ lines: ["Use a lowercase room slug. Public rooms are guessable and open to anyone."],
104
+ placeholder: "pi-dev",
105
+ action: "joinPublic",
106
+ hint: "back"
107
+ }),
108
+ publicRooms: ({ state }) => {
109
+ const rooms = state.directoryResult?.rooms ?? [];
110
+ const lines = state.directoryError ? [
111
+ `Discovery failed: ${sanitizeSingleLine(state.directoryError)}`,
112
+ "Retry or enter a known public room slug."
113
+ ] : rooms.length === 0 ? ["No active public rooms were discovered. Counts are best-effort estimates."] : [
114
+ state.directoryResult?.partial ? "Estimated active participants \xB7 partial discovered results." : "Estimated active participants \xB7 currently discovered results.",
115
+ "Select a room to review the public-room warning before joining."
116
+ ];
117
+ return {
118
+ kind: "choice",
119
+ title: "Public rooms",
120
+ lines,
121
+ items: [
122
+ ...rooms.map((room) => ({
123
+ id: `room:${room.slug}`,
124
+ label: `#${room.slug}`,
125
+ description: `~${room.estimatedParticipants} active`,
126
+ details: ["Estimated from recent signed P2P directory presence."]
127
+ })),
128
+ {
129
+ id: "route:refresh",
130
+ label: state.directoryError ? "Retry discovery" : "Refresh discovery",
131
+ description: "Query the P2P directory again"
132
+ },
133
+ {
134
+ id: "route:manual",
135
+ label: "Enter room slug",
136
+ description: "Join a known public room manually"
137
+ }
138
+ ],
139
+ action: "selectPublicRoom",
140
+ viewportSize: 10,
141
+ hint: "back"
142
+ };
143
+ },
144
+ joinAnother: () => ({
145
+ kind: "actions",
146
+ title: "Join another room",
147
+ lines: ["A successfully remembered join replaces the room restored at startup."],
148
+ items: [
149
+ {
150
+ id: "browse",
151
+ label: "Browse public rooms",
152
+ action: "browse",
153
+ busyLabel: "Discovering rooms"
154
+ },
155
+ { id: "public", label: "Join public room", to: "joinPublic" },
156
+ { id: "invite", label: "Join with invite", to: "joinInvite" },
157
+ { id: "create", label: "Create private room", action: "createPrivate" }
158
+ ],
159
+ hint: "back"
160
+ }),
161
+ participants: ({ state }) => ({
162
+ kind: "choice",
163
+ title: "Active participants",
164
+ lines: state.snapshot?.participants.length ? ["Select an origin to toggle local mute. Full public keys are shown in details."] : ["No other active participants are currently discovered."],
165
+ items: state.snapshot?.participants.map((peer) => ({
166
+ id: peer.publicKey,
167
+ label: sanitizeSingleLine(peer.label),
168
+ description: peer.muted ? "Muted locally" : "Receiving messages",
169
+ details: [peer.publicKey]
170
+ })) ?? [],
171
+ action: "toggleMute",
172
+ viewportSize: 10,
173
+ hint: "back"
174
+ }),
175
+ settings: ({ state }) => ({
176
+ kind: "actions",
177
+ title: "Pi Chat settings",
178
+ lines: [
179
+ `Nickname: ${sanitizeSingleLine(state.settings.nickname ?? "not set")}`,
180
+ `Joined room display: ${state.settings.widgetMode ?? "count"}`,
181
+ `Restart: ${restartDescription(state.settings)}`,
182
+ `User settings \xB7 ${sanitizeSingleLine(source.settingsPath)}`
183
+ ],
184
+ items: [
185
+ { id: "nickname", label: "Change nickname", to: "changeNickname" },
186
+ { id: "widget", label: "Joined room display", to: "widget" },
187
+ { id: "reset", label: "Reset identity\u2026", to: "resetIdentity" }
188
+ ],
189
+ hint: "back"
190
+ }),
191
+ changeNickname: () => ({
192
+ kind: "input",
193
+ title: "Change nickname",
194
+ lines: ["The immutable fingerprint remains attached to the new nickname."],
195
+ placeholder: "Mika",
196
+ action: "changeNickname",
197
+ hint: "back"
198
+ }),
199
+ widget: ({ state }) => ({
200
+ kind: "choice",
201
+ title: "Joined room display",
202
+ lines: ["Choose how much room content remains visible above the Pi editor."],
203
+ items: [
204
+ {
205
+ id: "dock",
206
+ label: "Room dock",
207
+ description: "Status, input target, and up to three recent messages"
208
+ },
209
+ { id: "latest", label: "Latest message", description: "Show one recent message" },
210
+ { id: "count", label: "Status only", description: "Hide message text" },
211
+ { id: "off", label: "Hidden", description: "Show no persistent room widget" }
212
+ ],
213
+ action: "setWidget",
214
+ currentItemId: state.settings.widgetMode ?? "count",
215
+ initialItemId: state.settings.widgetMode ?? "count",
216
+ hint: "back"
217
+ }),
218
+ resetIdentity: () => {
219
+ const preview = source.getIdentityResetPreview();
220
+ return {
221
+ kind: "review",
222
+ title: "Reset Pi Chat identity?",
223
+ lines: [
224
+ `Current: ${preview.current}`,
225
+ `New: ${preview.next}`,
226
+ "Resetting changes your fingerprint, forgets startup restore, and leaves the room."
227
+ ],
228
+ content: "This cannot restore trust or blocked state associated with the old public key.",
229
+ format: { kind: "text" },
230
+ confirm: { id: "reset", label: "Reset identity", action: "resetIdentity" },
231
+ hint: "back"
232
+ };
233
+ },
234
+ leave: ({ state }) => {
235
+ const forgetsCurrent = state.settings.resume?.activeRoomId === state.snapshot?.room.id;
236
+ return {
237
+ kind: "review",
238
+ title: forgetsCurrent ? "Leave and forget room?" : "Leave room?",
239
+ lines: [
240
+ `Room: ${sanitizeSingleLine(state.snapshot?.room.label ?? "unknown")}`,
241
+ forgetsCurrent ? "Leaving disconnects peers, clears this transcript, and disables startup restore." : "Leaving disconnects peers and clears this ephemeral transcript."
242
+ ],
243
+ content: "Messages already received by other peers cannot be withdrawn.",
244
+ format: { kind: "text" },
245
+ confirm: {
246
+ id: "leave",
247
+ label: forgetsCurrent ? "Leave and forget room" : "Leave room",
248
+ action: "leave"
249
+ },
250
+ hint: "back"
251
+ };
252
+ },
253
+ forget: ({ state }) => {
254
+ const room = rememberedRoom(state.settings);
255
+ return {
256
+ kind: "review",
257
+ title: "Forget saved room?",
258
+ lines: [
259
+ `Room: ${sanitizeSingleLine(room?.label ?? "unknown")}`,
260
+ "Pi Chat will not reconnect to this room at startup."
261
+ ],
262
+ content: "This does not withdraw messages already received by peers.",
263
+ format: { kind: "text" },
264
+ confirm: { id: "forget", label: "Forget saved room", action: "forget" },
265
+ hint: "back"
266
+ };
267
+ },
268
+ status: ({ state }) => ({
269
+ kind: "detail",
270
+ title: "Pi Chat status",
271
+ lines: state.snapshot ? [
272
+ `State: ${state.snapshot.state}`,
273
+ `Room: ${sanitizeSingleLine(state.snapshot.room.label)}`,
274
+ `Identity: ${sanitizeSingleLine(state.snapshot.localLabel)}`,
275
+ `Active participants: ${state.snapshot.participants.length}`,
276
+ `Direct neighbors: ${state.snapshot.directNeighbors}`,
277
+ `Unread: ${state.snapshot.unread}`,
278
+ `Restart: ${restartDescription(state.settings)}`,
279
+ ...state.snapshot.lastError ? [`Attention: ${sanitizeSingleLine(state.snapshot.lastError)}`] : []
280
+ ] : [
281
+ "State: disconnected",
282
+ `Restart: ${restartDescription(state.settings)}`,
283
+ ...state.restoreError ? [`Attention: ${sanitizeSingleLine(state.restoreError)}`] : [],
284
+ `Settings: ${sanitizeSingleLine(source.settingsPath)}`
285
+ ],
286
+ hint: "back"
287
+ }),
288
+ help: () => ({
289
+ kind: "detail",
290
+ title: "Pi Chat help",
291
+ lines: [
292
+ "Pi Chat is experimental and TUI-only.",
293
+ "Chat stays outside Pi sessions, prompts, model context, and repository files.",
294
+ "Private invites are bearer secrets. Public rooms are guessable.",
295
+ "Noise encrypts direct streams, but peers and DHT infrastructure may observe network metadata.",
296
+ "Public-room discovery and participant counts are approximate P2P observations.",
297
+ "There is no offline delivery, global ordering, delivery receipt, or message withdrawal."
298
+ ],
299
+ hint: "back"
300
+ })
301
+ },
302
+ actions: {
303
+ createPrivate: () => {
304
+ pendingRoom = source.createPrivateRoom();
305
+ return { kind: "to", screen: "invite" };
306
+ },
307
+ joinPending: async ({ ctx, signal }) => {
308
+ if (!pendingRoom) return { kind: "rejected", error: new Error("Invite is unavailable") };
309
+ if (!await source.joinRoom(pendingRoom, ctx, signal) || signal.aborted) {
310
+ return { kind: "stay" };
311
+ }
312
+ await source.openChat(ctx);
313
+ return { kind: "close" };
314
+ },
315
+ joinInvite: async ({ ctx, signal, value }) => {
316
+ let room;
317
+ try {
318
+ room = parseInvite(value ?? "");
319
+ } catch (error) {
320
+ return { kind: "rejected", error };
321
+ }
322
+ if (!await source.joinRoom(room, ctx, signal) || signal.aborted) return { kind: "stay" };
323
+ await source.openChat(ctx);
324
+ return { kind: "close" };
325
+ },
326
+ joinPublic: ({ ctx, signal, value }) => joinPublic(value ?? "", ctx, signal),
327
+ browse: ({ signal }) => browseRooms(signal),
328
+ selectPublicRoom: async ({ ctx, signal, itemId }) => {
329
+ if (itemId === "route:refresh") return browseRooms(signal);
330
+ if (itemId === "route:manual") return { kind: "to", screen: "joinPublic" };
331
+ if (!itemId.startsWith("room:")) {
332
+ return { kind: "rejected", error: new Error("Public room selection is invalid") };
333
+ }
334
+ return joinPublic(itemId.slice("room:".length), ctx, signal);
335
+ },
336
+ retry: async ({ ctx, signal }) => {
337
+ await source.retryRememberedRoom(ctx, signal);
338
+ return { kind: "close" };
339
+ },
340
+ forget: async ({ signal }) => {
341
+ await source.forgetRememberedRoom(signal);
342
+ return { kind: "to", screen: "main" };
343
+ },
344
+ open: async ({ ctx }) => {
345
+ await source.openChat(ctx);
346
+ return { kind: "close" };
347
+ },
348
+ leave: async ({ signal }) => {
349
+ await source.leaveRoom(signal);
350
+ return { kind: "to", screen: "main" };
351
+ },
352
+ toggleMute: ({ itemId }) => {
353
+ const muted = source.toggleMute(itemId);
354
+ return muted === void 0 ? { kind: "rejected", error: new Error("Peer is no longer connected") } : { kind: "to", screen: "participants" };
355
+ },
356
+ changeNickname: async ({ signal, value }) => {
357
+ const nickname = normalizeNickname(value);
358
+ if (!nickname) return { kind: "rejected", error: new Error("Nickname is invalid") };
359
+ await source.updateNickname(nickname, signal);
360
+ return { kind: "to", screen: "settings" };
361
+ },
362
+ setWidget: async ({ signal, itemId }) => {
363
+ if (itemId !== "dock" && itemId !== "count" && itemId !== "latest" && itemId !== "off") {
364
+ return { kind: "rejected", error: new Error("Widget mode is invalid") };
365
+ }
366
+ await source.updateWidgetMode(itemId, signal);
367
+ return { kind: "to", screen: "settings" };
368
+ },
369
+ resetIdentity: async ({ signal }) => {
370
+ await source.resetIdentity(signal);
371
+ return { kind: "to", screen: "settings" };
372
+ }
373
+ }
374
+ };
375
+ return { menu, getState };
376
+ }
377
+ async function showChatMenu(ctx, source, ownership) {
378
+ const { runMenu } = await import("@narumitw/pi-tui-kit");
379
+ if (ownership.signal.aborted || !ownership.isCurrent()) return;
380
+ const controller = createChatMenu(source);
381
+ await runMenu(ctx, controller.menu, {
382
+ getState: controller.getState,
383
+ signal: ownership.signal,
384
+ isCurrent: ownership.isCurrent,
385
+ onError: (_ctx, error) => {
386
+ if (ownership.isCurrent() && !ownership.signal.aborted) {
387
+ ctx.ui.notify(`Pi Chat failed: ${sanitizeSingleLine(safeError(error))}`, "error");
388
+ }
389
+ }
390
+ });
391
+ }
392
+ function mainScreen(state) {
393
+ const remembered = rememberedRoom(state.settings);
394
+ if (!state.snapshot || state.snapshot.state === "disconnected") {
395
+ if (remembered) {
396
+ return {
397
+ kind: "actions",
398
+ title: state.restoreError ? `Pi Chat \xB7 could not restore ${sanitizeSingleLine(remembered.label)}` : `Pi Chat \xB7 ${sanitizeSingleLine(remembered.label)} remembered`,
399
+ lines: [
400
+ state.restoreError ? `Attention: ${sanitizeSingleLine(state.restoreError)}` : "Disconnected. This room is configured to reconnect at startup.",
401
+ `Restart surface: ${state.settings.resume?.surface === "chat" ? "open chat" : "Pi/LLM"}`
402
+ ],
403
+ items: [
404
+ { id: "retry", label: `Retry ${remembered.label}`, action: "retry" },
405
+ { id: "another", label: "Join another room", to: "joinAnother" },
406
+ { id: "forget", label: `Forget ${remembered.label}\u2026`, to: "forget" },
407
+ { id: "settings", label: "Settings", to: "settings" },
408
+ { id: "status", label: "Status", to: "status" },
409
+ { id: "help", label: "Help", to: "help" }
410
+ ],
411
+ hint: "close"
412
+ };
413
+ }
414
+ return {
415
+ kind: "actions",
416
+ title: "Pi Chat \xB7 disconnected",
417
+ lines: ["Experimental peer-to-peer chat. Messages never enter model context."],
418
+ items: [
419
+ {
420
+ id: "browse",
421
+ label: "Browse public rooms",
422
+ action: "browse",
423
+ busyLabel: "Discovering rooms"
424
+ },
425
+ { id: "public", label: "Join public room", to: "joinPublic" },
426
+ { id: "invite", label: "Join with invite", to: "joinInvite" },
427
+ { id: "create", label: "Create private room", action: "createPrivate" },
428
+ { id: "settings", label: "Settings", to: "settings" },
429
+ { id: "status", label: "Status", to: "status" },
430
+ { id: "help", label: "Help", to: "help" }
431
+ ],
432
+ hint: "close"
433
+ };
434
+ }
435
+ const restoresCurrent = remembered?.id === state.snapshot.room.id;
436
+ return {
437
+ kind: "actions",
438
+ title: `Pi Chat \xB7 ${sanitizeSingleLine(state.snapshot.room.label)}`,
439
+ lines: [
440
+ `${state.snapshot.state} \xB7 ${state.snapshot.participants.length} active \xB7 ${state.snapshot.directNeighbors} direct neighbors \xB7 ${state.snapshot.unread} unread`,
441
+ `Current input: ${state.snapshot.composerOpen ? state.snapshot.room.label : "Pi/LLM"}`,
442
+ restoresCurrent ? `Restart: restore this room and ${state.settings.resume?.surface === "chat" ? "open chat" : "stay in Pi/LLM"}` : "Restart: this room will not reconnect",
443
+ state.snapshot.localLabel
444
+ ],
445
+ items: [
446
+ {
447
+ id: "open",
448
+ label: `Open chat in ${sanitizeSingleLine(state.snapshot.room.label)}`,
449
+ action: "open"
450
+ },
451
+ { id: "participants", label: "Show active participants", to: "participants" },
452
+ ...state.snapshot.room.invite ? [{ id: "invite", label: "Show room invite", to: "invite" }] : [],
453
+ { id: "settings", label: "Settings", to: "settings" },
454
+ { id: "status", label: "Status", to: "status" },
455
+ { id: "help", label: "Help", to: "help" },
456
+ {
457
+ id: "leave",
458
+ label: restoresCurrent ? "Leave and forget room\u2026" : "Leave room\u2026",
459
+ to: "leave"
460
+ }
461
+ ],
462
+ hint: "close"
463
+ };
464
+ }
465
+ function rememberedRoom(settings) {
466
+ const resume = settings.resume;
467
+ const remembered = resume?.rooms.find(({ id }) => id === resume.activeRoomId);
468
+ if (!remembered) return void 0;
469
+ try {
470
+ return descriptorFromRememberedRoom(remembered);
471
+ } catch {
472
+ return void 0;
473
+ }
474
+ }
475
+ function restartDescription(settings) {
476
+ const room = rememberedRoom(settings);
477
+ if (!room) return "no room remembered";
478
+ return `${room.label} \xB7 ${settings.resume?.surface === "chat" ? "open chat" : "stay in Pi/LLM"}`;
479
+ }
480
+ function safeError(error) {
481
+ return error instanceof Error ? error.message : String(error);
482
+ }
483
+ export {
484
+ createChatMenu,
485
+ showChatMenu
486
+ };
487
+ //# sourceMappingURL=menu-2XYZAYXF.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/menu.ts"],
4
+ "sourcesContent": ["import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport type { MenuDefinition } from \"@narumitw/pi-tui-kit\";\nimport type { ChatSnapshot } from \"./chat-session.js\";\nimport { normalizeNickname } from \"./nickname.js\";\nimport { type PublicRoomBrowseResult, sortDirectoryRooms } from \"./public-room-directory.js\";\nimport { createPublicRoom, parseInvite, type RoomDescriptor } from \"./room.js\";\nimport { type ChatSettings, descriptorFromRememberedRoom, type WidgetMode } from \"./settings.js\";\nimport { sanitizeSingleLine } from \"./text.js\";\n\nexport interface JoinRoomOptions {\n\tremember: boolean;\n}\n\nexport interface ChatMenuSource {\n\tsettingsPath: string;\n\tgetSettings(): ChatSettings;\n\tgetSnapshot(): ChatSnapshot | undefined;\n\tgetRestoreError(): string | undefined;\n\tcreatePrivateRoom(): RoomDescriptor;\n\tbrowsePublicRooms(signal: AbortSignal): Promise<PublicRoomBrowseResult>;\n\tjoinRoom(\n\t\troom: RoomDescriptor,\n\t\tctx: ExtensionCommandContext,\n\t\tsignal: AbortSignal,\n\t\toptions?: JoinRoomOptions,\n\t): Promise<boolean>;\n\topenChat(ctx: ExtensionCommandContext): Promise<void>;\n\tretryRememberedRoom(ctx: ExtensionCommandContext, signal: AbortSignal): Promise<void>;\n\tforgetRememberedRoom(signal: AbortSignal): Promise<void>;\n\tleaveRoom(signal: AbortSignal): Promise<void>;\n\ttoggleMute(publicKey: string): boolean | undefined;\n\tupdateNickname(value: string, signal: AbortSignal): Promise<void>;\n\tupdateWidgetMode(value: WidgetMode, signal: AbortSignal): Promise<void>;\n\tgetIdentityResetPreview(): { current: string; next: string };\n\tresetIdentity(signal: AbortSignal): Promise<void>;\n}\n\ninterface ChatMenuState {\n\tsettings: ChatSettings;\n\tsnapshot?: ChatSnapshot;\n\tpendingRoom?: RoomDescriptor;\n\trestoreError?: string;\n\tdirectoryResult?: PublicRoomBrowseResult;\n\tdirectoryError?: string;\n}\n\ntype Screen =\n\t| \"main\"\n\t| \"invite\"\n\t| \"joinInvite\"\n\t| \"joinPublic\"\n\t| \"publicRooms\"\n\t| \"joinAnother\"\n\t| \"participants\"\n\t| \"settings\"\n\t| \"changeNickname\"\n\t| \"widget\"\n\t| \"resetIdentity\"\n\t| \"leave\"\n\t| \"forget\"\n\t| \"status\"\n\t| \"help\";\ntype Action =\n\t| \"createPrivate\"\n\t| \"joinPending\"\n\t| \"joinInvite\"\n\t| \"joinPublic\"\n\t| \"browse\"\n\t| \"selectPublicRoom\"\n\t| \"retry\"\n\t| \"forget\"\n\t| \"open\"\n\t| \"leave\"\n\t| \"toggleMute\"\n\t| \"changeNickname\"\n\t| \"setWidget\"\n\t| \"resetIdentity\";\n\nexport function createChatMenu(source: ChatMenuSource) {\n\tlet pendingRoom: RoomDescriptor | undefined;\n\tlet directoryResult: PublicRoomBrowseResult | undefined;\n\tlet directoryError: string | undefined;\n\tconst getState = async (): Promise<ChatMenuState> => ({\n\t\tsettings: source.getSettings(),\n\t\tsnapshot: source.getSnapshot(),\n\t\tpendingRoom,\n\t\t...(source.getRestoreError() ? { restoreError: source.getRestoreError() } : {}),\n\t\t...(directoryResult ? { directoryResult } : {}),\n\t\t...(directoryError ? { directoryError } : {}),\n\t});\n\tconst browseRooms = async (signal: AbortSignal) => {\n\t\ttry {\n\t\t\tconst result = await source.browsePublicRooms(signal);\n\t\t\tif (signal.aborted) return { kind: \"stay\" as const };\n\t\t\tdirectoryResult = { ...result, rooms: sortDirectoryRooms(result.rooms) };\n\t\t\tdirectoryError = undefined;\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) return { kind: \"stay\" as const };\n\t\t\tdirectoryResult = undefined;\n\t\t\tdirectoryError = sanitizeSingleLine(error instanceof Error ? error.message : String(error));\n\t\t}\n\t\treturn { kind: \"to\" as const, screen: \"publicRooms\" as const };\n\t};\n\tconst joinPublic = async (slug: string, ctx: ExtensionCommandContext, signal: AbortSignal) => {\n\t\tlet room: RoomDescriptor;\n\t\ttry {\n\t\t\troom = createPublicRoom(slug.replace(/^#/u, \"\"));\n\t\t} catch (error) {\n\t\t\treturn { kind: \"rejected\" as const, error };\n\t\t}\n\t\tconst confirmed = await ctx.ui.confirm(\n\t\t\t\"Join public room?\",\n\t\t\t\"Anyone can join or record it. DHT and direct peers may observe network metadata.\",\n\t\t\t{ signal },\n\t\t);\n\t\tif (!confirmed || signal.aborted) return { kind: \"stay\" as const };\n\t\tif (!(await source.joinRoom(room, ctx, signal, { remember: true })) || signal.aborted) {\n\t\t\treturn { kind: \"stay\" as const };\n\t\t}\n\t\tawait source.openChat(ctx);\n\t\treturn { kind: \"close\" as const };\n\t};\n\tconst menu: MenuDefinition<ChatMenuState, Screen, Action> = {\n\t\tstart: \"main\",\n\t\tscreens: {\n\t\t\tmain: ({ state }) => mainScreen(state),\n\t\t\tinvite: ({ state }) => {\n\t\t\t\tconst room = state.pendingRoom ?? state.snapshot?.room;\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"review\",\n\t\t\t\t\ttitle: \"Private room invite\",\n\t\t\t\t\tlines: [\n\t\t\t\t\t\t\"Anyone with this bearer invite can join.\",\n\t\t\t\t\t\t\"After confirmation, choose whether to save it privately for restart restore.\",\n\t\t\t\t\t],\n\t\t\t\t\tcontent: room?.invite ?? \"Invite is unavailable.\",\n\t\t\t\t\tformat: { kind: \"text\" },\n\t\t\t\t\tviewportSize: \"adaptive\",\n\t\t\t\t\t...(state.pendingRoom\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tconfirm: {\n\t\t\t\t\t\t\t\t\tid: \"join-private\",\n\t\t\t\t\t\t\t\t\tlabel: \"Join private room\",\n\t\t\t\t\t\t\t\t\taction: \"joinPending\" as const,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t\thint: \"back\",\n\t\t\t\t};\n\t\t\t},\n\t\t\tjoinInvite: () => ({\n\t\t\t\tkind: \"input\",\n\t\t\t\ttitle: \"Join with invite\",\n\t\t\t\tlines: [\n\t\t\t\t\t\"Paste a pichat:v1 or pichat:v2 invite. It grants access to the private room.\",\n\t\t\t\t\t\"You will choose Join and remember, Join once, or Cancel before networking starts.\",\n\t\t\t\t],\n\t\t\t\tplaceholder: \"pichat:v2:\u2026\",\n\t\t\t\taction: \"joinInvite\",\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\tjoinPublic: () => ({\n\t\t\t\tkind: \"input\",\n\t\t\t\ttitle: \"Join public room\",\n\t\t\t\tlines: [\"Use a lowercase room slug. Public rooms are guessable and open to anyone.\"],\n\t\t\t\tplaceholder: \"pi-dev\",\n\t\t\t\taction: \"joinPublic\",\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\tpublicRooms: ({ state }) => {\n\t\t\t\tconst rooms = state.directoryResult?.rooms ?? [];\n\t\t\t\tconst lines = state.directoryError\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t`Discovery failed: ${sanitizeSingleLine(state.directoryError)}`,\n\t\t\t\t\t\t\t\"Retry or enter a known public room slug.\",\n\t\t\t\t\t\t]\n\t\t\t\t\t: rooms.length === 0\n\t\t\t\t\t\t? [\"No active public rooms were discovered. Counts are best-effort estimates.\"]\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tstate.directoryResult?.partial\n\t\t\t\t\t\t\t\t\t? \"Estimated active participants \u00B7 partial discovered results.\"\n\t\t\t\t\t\t\t\t\t: \"Estimated active participants \u00B7 currently discovered results.\",\n\t\t\t\t\t\t\t\t\"Select a room to review the public-room warning before joining.\",\n\t\t\t\t\t\t\t];\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"choice\",\n\t\t\t\t\ttitle: \"Public rooms\",\n\t\t\t\t\tlines,\n\t\t\t\t\titems: [\n\t\t\t\t\t\t...rooms.map((room) => ({\n\t\t\t\t\t\t\tid: `room:${room.slug}`,\n\t\t\t\t\t\t\tlabel: `#${room.slug}`,\n\t\t\t\t\t\t\tdescription: `~${room.estimatedParticipants} active`,\n\t\t\t\t\t\t\tdetails: [\"Estimated from recent signed P2P directory presence.\"],\n\t\t\t\t\t\t})),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"route:refresh\",\n\t\t\t\t\t\t\tlabel: state.directoryError ? \"Retry discovery\" : \"Refresh discovery\",\n\t\t\t\t\t\t\tdescription: \"Query the P2P directory again\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"route:manual\",\n\t\t\t\t\t\t\tlabel: \"Enter room slug\",\n\t\t\t\t\t\t\tdescription: \"Join a known public room manually\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\taction: \"selectPublicRoom\",\n\t\t\t\t\tviewportSize: 10,\n\t\t\t\t\thint: \"back\",\n\t\t\t\t};\n\t\t\t},\n\t\t\tjoinAnother: () => ({\n\t\t\t\tkind: \"actions\",\n\t\t\t\ttitle: \"Join another room\",\n\t\t\t\tlines: [\"A successfully remembered join replaces the room restored at startup.\"],\n\t\t\t\titems: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"browse\",\n\t\t\t\t\t\tlabel: \"Browse public rooms\",\n\t\t\t\t\t\taction: \"browse\",\n\t\t\t\t\t\tbusyLabel: \"Discovering rooms\",\n\t\t\t\t\t},\n\t\t\t\t\t{ id: \"public\", label: \"Join public room\", to: \"joinPublic\" },\n\t\t\t\t\t{ id: \"invite\", label: \"Join with invite\", to: \"joinInvite\" },\n\t\t\t\t\t{ id: \"create\", label: \"Create private room\", action: \"createPrivate\" },\n\t\t\t\t],\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\tparticipants: ({ state }) => ({\n\t\t\t\tkind: \"choice\",\n\t\t\t\ttitle: \"Active participants\",\n\t\t\t\tlines: state.snapshot?.participants.length\n\t\t\t\t\t? [\"Select an origin to toggle local mute. Full public keys are shown in details.\"]\n\t\t\t\t\t: [\"No other active participants are currently discovered.\"],\n\t\t\t\titems:\n\t\t\t\t\tstate.snapshot?.participants.map((peer) => ({\n\t\t\t\t\t\tid: peer.publicKey,\n\t\t\t\t\t\tlabel: sanitizeSingleLine(peer.label),\n\t\t\t\t\t\tdescription: peer.muted ? \"Muted locally\" : \"Receiving messages\",\n\t\t\t\t\t\tdetails: [peer.publicKey],\n\t\t\t\t\t})) ?? [],\n\t\t\t\taction: \"toggleMute\",\n\t\t\t\tviewportSize: 10,\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\tsettings: ({ state }) => ({\n\t\t\t\tkind: \"actions\",\n\t\t\t\ttitle: \"Pi Chat settings\",\n\t\t\t\tlines: [\n\t\t\t\t\t`Nickname: ${sanitizeSingleLine(state.settings.nickname ?? \"not set\")}`,\n\t\t\t\t\t`Joined room display: ${state.settings.widgetMode ?? \"count\"}`,\n\t\t\t\t\t`Restart: ${restartDescription(state.settings)}`,\n\t\t\t\t\t`User settings \u00B7 ${sanitizeSingleLine(source.settingsPath)}`,\n\t\t\t\t],\n\t\t\t\titems: [\n\t\t\t\t\t{ id: \"nickname\", label: \"Change nickname\", to: \"changeNickname\" },\n\t\t\t\t\t{ id: \"widget\", label: \"Joined room display\", to: \"widget\" },\n\t\t\t\t\t{ id: \"reset\", label: \"Reset identity\u2026\", to: \"resetIdentity\" },\n\t\t\t\t],\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\tchangeNickname: () => ({\n\t\t\t\tkind: \"input\",\n\t\t\t\ttitle: \"Change nickname\",\n\t\t\t\tlines: [\"The immutable fingerprint remains attached to the new nickname.\"],\n\t\t\t\tplaceholder: \"Mika\",\n\t\t\t\taction: \"changeNickname\",\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\twidget: ({ state }) => ({\n\t\t\t\tkind: \"choice\",\n\t\t\t\ttitle: \"Joined room display\",\n\t\t\t\tlines: [\"Choose how much room content remains visible above the Pi editor.\"],\n\t\t\t\titems: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dock\",\n\t\t\t\t\t\tlabel: \"Room dock\",\n\t\t\t\t\t\tdescription: \"Status, input target, and up to three recent messages\",\n\t\t\t\t\t},\n\t\t\t\t\t{ id: \"latest\", label: \"Latest message\", description: \"Show one recent message\" },\n\t\t\t\t\t{ id: \"count\", label: \"Status only\", description: \"Hide message text\" },\n\t\t\t\t\t{ id: \"off\", label: \"Hidden\", description: \"Show no persistent room widget\" },\n\t\t\t\t],\n\t\t\t\taction: \"setWidget\",\n\t\t\t\tcurrentItemId: state.settings.widgetMode ?? \"count\",\n\t\t\t\tinitialItemId: state.settings.widgetMode ?? \"count\",\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\tresetIdentity: () => {\n\t\t\t\tconst preview = source.getIdentityResetPreview();\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"review\",\n\t\t\t\t\ttitle: \"Reset Pi Chat identity?\",\n\t\t\t\t\tlines: [\n\t\t\t\t\t\t`Current: ${preview.current}`,\n\t\t\t\t\t\t`New: ${preview.next}`,\n\t\t\t\t\t\t\"Resetting changes your fingerprint, forgets startup restore, and leaves the room.\",\n\t\t\t\t\t],\n\t\t\t\t\tcontent: \"This cannot restore trust or blocked state associated with the old public key.\",\n\t\t\t\t\tformat: { kind: \"text\" },\n\t\t\t\t\tconfirm: { id: \"reset\", label: \"Reset identity\", action: \"resetIdentity\" },\n\t\t\t\t\thint: \"back\",\n\t\t\t\t};\n\t\t\t},\n\t\t\tleave: ({ state }) => {\n\t\t\t\tconst forgetsCurrent = state.settings.resume?.activeRoomId === state.snapshot?.room.id;\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"review\",\n\t\t\t\t\ttitle: forgetsCurrent ? \"Leave and forget room?\" : \"Leave room?\",\n\t\t\t\t\tlines: [\n\t\t\t\t\t\t`Room: ${sanitizeSingleLine(state.snapshot?.room.label ?? \"unknown\")}`,\n\t\t\t\t\t\tforgetsCurrent\n\t\t\t\t\t\t\t? \"Leaving disconnects peers, clears this transcript, and disables startup restore.\"\n\t\t\t\t\t\t\t: \"Leaving disconnects peers and clears this ephemeral transcript.\",\n\t\t\t\t\t],\n\t\t\t\t\tcontent: \"Messages already received by other peers cannot be withdrawn.\",\n\t\t\t\t\tformat: { kind: \"text\" },\n\t\t\t\t\tconfirm: {\n\t\t\t\t\t\tid: \"leave\",\n\t\t\t\t\t\tlabel: forgetsCurrent ? \"Leave and forget room\" : \"Leave room\",\n\t\t\t\t\t\taction: \"leave\",\n\t\t\t\t\t},\n\t\t\t\t\thint: \"back\",\n\t\t\t\t};\n\t\t\t},\n\t\t\tforget: ({ state }) => {\n\t\t\t\tconst room = rememberedRoom(state.settings);\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"review\",\n\t\t\t\t\ttitle: \"Forget saved room?\",\n\t\t\t\t\tlines: [\n\t\t\t\t\t\t`Room: ${sanitizeSingleLine(room?.label ?? \"unknown\")}`,\n\t\t\t\t\t\t\"Pi Chat will not reconnect to this room at startup.\",\n\t\t\t\t\t],\n\t\t\t\t\tcontent: \"This does not withdraw messages already received by peers.\",\n\t\t\t\t\tformat: { kind: \"text\" },\n\t\t\t\t\tconfirm: { id: \"forget\", label: \"Forget saved room\", action: \"forget\" },\n\t\t\t\t\thint: \"back\",\n\t\t\t\t};\n\t\t\t},\n\t\t\tstatus: ({ state }) => ({\n\t\t\t\tkind: \"detail\",\n\t\t\t\ttitle: \"Pi Chat status\",\n\t\t\t\tlines: state.snapshot\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t`State: ${state.snapshot.state}`,\n\t\t\t\t\t\t\t`Room: ${sanitizeSingleLine(state.snapshot.room.label)}`,\n\t\t\t\t\t\t\t`Identity: ${sanitizeSingleLine(state.snapshot.localLabel)}`,\n\t\t\t\t\t\t\t`Active participants: ${state.snapshot.participants.length}`,\n\t\t\t\t\t\t\t`Direct neighbors: ${state.snapshot.directNeighbors}`,\n\t\t\t\t\t\t\t`Unread: ${state.snapshot.unread}`,\n\t\t\t\t\t\t\t`Restart: ${restartDescription(state.settings)}`,\n\t\t\t\t\t\t\t...(state.snapshot.lastError\n\t\t\t\t\t\t\t\t? [`Attention: ${sanitizeSingleLine(state.snapshot.lastError)}`]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t\"State: disconnected\",\n\t\t\t\t\t\t\t`Restart: ${restartDescription(state.settings)}`,\n\t\t\t\t\t\t\t...(state.restoreError\n\t\t\t\t\t\t\t\t? [`Attention: ${sanitizeSingleLine(state.restoreError)}`]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t`Settings: ${sanitizeSingleLine(source.settingsPath)}`,\n\t\t\t\t\t\t],\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t\thelp: () => ({\n\t\t\t\tkind: \"detail\",\n\t\t\t\ttitle: \"Pi Chat help\",\n\t\t\t\tlines: [\n\t\t\t\t\t\"Pi Chat is experimental and TUI-only.\",\n\t\t\t\t\t\"Chat stays outside Pi sessions, prompts, model context, and repository files.\",\n\t\t\t\t\t\"Private invites are bearer secrets. Public rooms are guessable.\",\n\t\t\t\t\t\"Noise encrypts direct streams, but peers and DHT infrastructure may observe network metadata.\",\n\t\t\t\t\t\"Public-room discovery and participant counts are approximate P2P observations.\",\n\t\t\t\t\t\"There is no offline delivery, global ordering, delivery receipt, or message withdrawal.\",\n\t\t\t\t],\n\t\t\t\thint: \"back\",\n\t\t\t}),\n\t\t},\n\t\tactions: {\n\t\t\tcreatePrivate: () => {\n\t\t\t\tpendingRoom = source.createPrivateRoom();\n\t\t\t\treturn { kind: \"to\", screen: \"invite\" };\n\t\t\t},\n\t\t\tjoinPending: async ({ ctx, signal }) => {\n\t\t\t\tif (!pendingRoom) return { kind: \"rejected\", error: new Error(\"Invite is unavailable\") };\n\t\t\t\tif (!(await source.joinRoom(pendingRoom, ctx, signal)) || signal.aborted) {\n\t\t\t\t\treturn { kind: \"stay\" };\n\t\t\t\t}\n\t\t\t\tawait source.openChat(ctx);\n\t\t\t\treturn { kind: \"close\" };\n\t\t\t},\n\t\t\tjoinInvite: async ({ ctx, signal, value }) => {\n\t\t\t\tlet room: RoomDescriptor;\n\t\t\t\ttry {\n\t\t\t\t\troom = parseInvite(value ?? \"\");\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn { kind: \"rejected\", error };\n\t\t\t\t}\n\t\t\t\tif (!(await source.joinRoom(room, ctx, signal)) || signal.aborted) return { kind: \"stay\" };\n\t\t\t\tawait source.openChat(ctx);\n\t\t\t\treturn { kind: \"close\" };\n\t\t\t},\n\t\t\tjoinPublic: ({ ctx, signal, value }) => joinPublic(value ?? \"\", ctx, signal),\n\t\t\tbrowse: ({ signal }) => browseRooms(signal),\n\t\t\tselectPublicRoom: async ({ ctx, signal, itemId }) => {\n\t\t\t\tif (itemId === \"route:refresh\") return browseRooms(signal);\n\t\t\t\tif (itemId === \"route:manual\") return { kind: \"to\", screen: \"joinPublic\" };\n\t\t\t\tif (!itemId.startsWith(\"room:\")) {\n\t\t\t\t\treturn { kind: \"rejected\", error: new Error(\"Public room selection is invalid\") };\n\t\t\t\t}\n\t\t\t\treturn joinPublic(itemId.slice(\"room:\".length), ctx, signal);\n\t\t\t},\n\t\t\tretry: async ({ ctx, signal }) => {\n\t\t\t\tawait source.retryRememberedRoom(ctx, signal);\n\t\t\t\treturn { kind: \"close\" };\n\t\t\t},\n\t\t\tforget: async ({ signal }) => {\n\t\t\t\tawait source.forgetRememberedRoom(signal);\n\t\t\t\treturn { kind: \"to\", screen: \"main\" };\n\t\t\t},\n\t\t\topen: async ({ ctx }) => {\n\t\t\t\tawait source.openChat(ctx);\n\t\t\t\treturn { kind: \"close\" };\n\t\t\t},\n\t\t\tleave: async ({ signal }) => {\n\t\t\t\tawait source.leaveRoom(signal);\n\t\t\t\treturn { kind: \"to\", screen: \"main\" };\n\t\t\t},\n\t\t\ttoggleMute: ({ itemId }) => {\n\t\t\t\tconst muted = source.toggleMute(itemId);\n\t\t\t\treturn muted === undefined\n\t\t\t\t\t? { kind: \"rejected\", error: new Error(\"Peer is no longer connected\") }\n\t\t\t\t\t: { kind: \"to\", screen: \"participants\" };\n\t\t\t},\n\t\t\tchangeNickname: async ({ signal, value }) => {\n\t\t\t\tconst nickname = normalizeNickname(value);\n\t\t\t\tif (!nickname) return { kind: \"rejected\", error: new Error(\"Nickname is invalid\") };\n\t\t\t\tawait source.updateNickname(nickname, signal);\n\t\t\t\treturn { kind: \"to\", screen: \"settings\" };\n\t\t\t},\n\t\t\tsetWidget: async ({ signal, itemId }) => {\n\t\t\t\tif (itemId !== \"dock\" && itemId !== \"count\" && itemId !== \"latest\" && itemId !== \"off\") {\n\t\t\t\t\treturn { kind: \"rejected\", error: new Error(\"Widget mode is invalid\") };\n\t\t\t\t}\n\t\t\t\tawait source.updateWidgetMode(itemId, signal);\n\t\t\t\treturn { kind: \"to\", screen: \"settings\" };\n\t\t\t},\n\t\t\tresetIdentity: async ({ signal }) => {\n\t\t\t\tawait source.resetIdentity(signal);\n\t\t\t\treturn { kind: \"to\", screen: \"settings\" };\n\t\t\t},\n\t\t},\n\t};\n\treturn { menu, getState };\n}\n\nexport async function showChatMenu(\n\tctx: ExtensionCommandContext,\n\tsource: ChatMenuSource,\n\townership: { signal: AbortSignal; isCurrent: () => boolean },\n): Promise<void> {\n\tconst { runMenu } = await import(\"@narumitw/pi-tui-kit\");\n\tif (ownership.signal.aborted || !ownership.isCurrent()) return;\n\tconst controller = createChatMenu(source);\n\tawait runMenu(ctx, controller.menu, {\n\t\tgetState: controller.getState,\n\t\tsignal: ownership.signal,\n\t\tisCurrent: ownership.isCurrent,\n\t\tonError: (_ctx, error) => {\n\t\t\tif (ownership.isCurrent() && !ownership.signal.aborted) {\n\t\t\t\tctx.ui.notify(`Pi Chat failed: ${sanitizeSingleLine(safeError(error))}`, \"error\");\n\t\t\t}\n\t\t},\n\t});\n}\n\nfunction mainScreen(state: ChatMenuState) {\n\tconst remembered = rememberedRoom(state.settings);\n\tif (!state.snapshot || state.snapshot.state === \"disconnected\") {\n\t\tif (remembered) {\n\t\t\treturn {\n\t\t\t\tkind: \"actions\" as const,\n\t\t\t\ttitle: state.restoreError\n\t\t\t\t\t? `Pi Chat \u00B7 could not restore ${sanitizeSingleLine(remembered.label)}`\n\t\t\t\t\t: `Pi Chat \u00B7 ${sanitizeSingleLine(remembered.label)} remembered`,\n\t\t\t\tlines: [\n\t\t\t\t\tstate.restoreError\n\t\t\t\t\t\t? `Attention: ${sanitizeSingleLine(state.restoreError)}`\n\t\t\t\t\t\t: \"Disconnected. This room is configured to reconnect at startup.\",\n\t\t\t\t\t`Restart surface: ${state.settings.resume?.surface === \"chat\" ? \"open chat\" : \"Pi/LLM\"}`,\n\t\t\t\t],\n\t\t\t\titems: [\n\t\t\t\t\t{ id: \"retry\", label: `Retry ${remembered.label}`, action: \"retry\" as const },\n\t\t\t\t\t{ id: \"another\", label: \"Join another room\", to: \"joinAnother\" as const },\n\t\t\t\t\t{ id: \"forget\", label: `Forget ${remembered.label}\u2026`, to: \"forget\" as const },\n\t\t\t\t\t{ id: \"settings\", label: \"Settings\", to: \"settings\" as const },\n\t\t\t\t\t{ id: \"status\", label: \"Status\", to: \"status\" as const },\n\t\t\t\t\t{ id: \"help\", label: \"Help\", to: \"help\" as const },\n\t\t\t\t],\n\t\t\t\thint: \"close\" as const,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tkind: \"actions\" as const,\n\t\t\ttitle: \"Pi Chat \u00B7 disconnected\",\n\t\t\tlines: [\"Experimental peer-to-peer chat. Messages never enter model context.\"],\n\t\t\titems: [\n\t\t\t\t{\n\t\t\t\t\tid: \"browse\",\n\t\t\t\t\tlabel: \"Browse public rooms\",\n\t\t\t\t\taction: \"browse\" as const,\n\t\t\t\t\tbusyLabel: \"Discovering rooms\",\n\t\t\t\t},\n\t\t\t\t{ id: \"public\", label: \"Join public room\", to: \"joinPublic\" as const },\n\t\t\t\t{ id: \"invite\", label: \"Join with invite\", to: \"joinInvite\" as const },\n\t\t\t\t{ id: \"create\", label: \"Create private room\", action: \"createPrivate\" as const },\n\t\t\t\t{ id: \"settings\", label: \"Settings\", to: \"settings\" as const },\n\t\t\t\t{ id: \"status\", label: \"Status\", to: \"status\" as const },\n\t\t\t\t{ id: \"help\", label: \"Help\", to: \"help\" as const },\n\t\t\t],\n\t\t\thint: \"close\" as const,\n\t\t};\n\t}\n\tconst restoresCurrent = remembered?.id === state.snapshot.room.id;\n\treturn {\n\t\tkind: \"actions\" as const,\n\t\ttitle: `Pi Chat \u00B7 ${sanitizeSingleLine(state.snapshot.room.label)}`,\n\t\tlines: [\n\t\t\t`${state.snapshot.state} \u00B7 ${state.snapshot.participants.length} active \u00B7 ${state.snapshot.directNeighbors} direct neighbors \u00B7 ${state.snapshot.unread} unread`,\n\t\t\t`Current input: ${state.snapshot.composerOpen ? state.snapshot.room.label : \"Pi/LLM\"}`,\n\t\t\trestoresCurrent\n\t\t\t\t? `Restart: restore this room and ${state.settings.resume?.surface === \"chat\" ? \"open chat\" : \"stay in Pi/LLM\"}`\n\t\t\t\t: \"Restart: this room will not reconnect\",\n\t\t\tstate.snapshot.localLabel,\n\t\t],\n\t\titems: [\n\t\t\t{\n\t\t\t\tid: \"open\",\n\t\t\t\tlabel: `Open chat in ${sanitizeSingleLine(state.snapshot.room.label)}`,\n\t\t\t\taction: \"open\" as const,\n\t\t\t},\n\t\t\t{ id: \"participants\", label: \"Show active participants\", to: \"participants\" as const },\n\t\t\t...(state.snapshot.room.invite\n\t\t\t\t? [{ id: \"invite\", label: \"Show room invite\", to: \"invite\" as const }]\n\t\t\t\t: []),\n\t\t\t{ id: \"settings\", label: \"Settings\", to: \"settings\" as const },\n\t\t\t{ id: \"status\", label: \"Status\", to: \"status\" as const },\n\t\t\t{ id: \"help\", label: \"Help\", to: \"help\" as const },\n\t\t\t{\n\t\t\t\tid: \"leave\",\n\t\t\t\tlabel: restoresCurrent ? \"Leave and forget room\u2026\" : \"Leave room\u2026\",\n\t\t\t\tto: \"leave\" as const,\n\t\t\t},\n\t\t],\n\t\thint: \"close\" as const,\n\t};\n}\n\nfunction rememberedRoom(settings: ChatSettings): RoomDescriptor | undefined {\n\tconst resume = settings.resume;\n\tconst remembered = resume?.rooms.find(({ id }) => id === resume.activeRoomId);\n\tif (!remembered) return undefined;\n\ttry {\n\t\treturn descriptorFromRememberedRoom(remembered);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction restartDescription(settings: ChatSettings): string {\n\tconst room = rememberedRoom(settings);\n\tif (!room) return \"no room remembered\";\n\treturn `${room.label} \u00B7 ${settings.resume?.surface === \"chat\" ? \"open chat\" : \"stay in Pi/LLM\"}`;\n}\n\nfunction safeError(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AA8EO,SAAS,eAAe,QAAwB;AACtD,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,WAAW,aAAqC;AAAA,IACrD,UAAU,OAAO,YAAY;AAAA,IAC7B,UAAU,OAAO,YAAY;AAAA,IAC7B;AAAA,IACA,GAAI,OAAO,gBAAgB,IAAI,EAAE,cAAc,OAAO,gBAAgB,EAAE,IAAI,CAAC;AAAA,IAC7E,GAAI,kBAAkB,EAAE,gBAAgB,IAAI,CAAC;AAAA,IAC7C,GAAI,iBAAiB,EAAE,eAAe,IAAI,CAAC;AAAA,EAC5C;AACA,QAAM,cAAc,OAAO,WAAwB;AAClD,QAAI;AACH,YAAM,SAAS,MAAM,OAAO,kBAAkB,MAAM;AACpD,UAAI,OAAO,QAAS,QAAO,EAAE,MAAM,OAAgB;AACnD,wBAAkB,EAAE,GAAG,QAAQ,OAAO,mBAAmB,OAAO,KAAK,EAAE;AACvE,uBAAiB;AAAA,IAClB,SAAS,OAAO;AACf,UAAI,OAAO,QAAS,QAAO,EAAE,MAAM,OAAgB;AACnD,wBAAkB;AAClB,uBAAiB,mBAAmB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC3F;AACA,WAAO,EAAE,MAAM,MAAe,QAAQ,cAAuB;AAAA,EAC9D;AACA,QAAM,aAAa,OAAO,MAAc,KAA8B,WAAwB;AAC7F,QAAI;AACJ,QAAI;AACH,aAAO,iBAAiB,KAAK,QAAQ,OAAO,EAAE,CAAC;AAAA,IAChD,SAAS,OAAO;AACf,aAAO,EAAE,M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