@pi-chamber/web 0.4.0 → 0.5.1

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.
Files changed (87) hide show
  1. package/dist/assets/{CommitSection-0zl1puqf.js → CommitSection-MZJqMxUT.js} +1 -1
  2. package/dist/assets/DiagramEditor-DmDE7OFs.js +1 -0
  3. package/dist/assets/DiagramView-DjMwKAR1.js +1 -0
  4. package/dist/assets/{DiffView-BoTz2Zqe.js → DiffView-C3F9al7D.js} +2 -2
  5. package/dist/assets/{FilesView-CVMNE9Pr.js → FilesView-DzboGeAe.js} +6 -6
  6. package/dist/assets/{GitView-DnsbCAWl.js → GitView-BfyNIPaR.js} +4 -4
  7. package/dist/assets/{JsonTreeView-Cn1Mk0Wf.js → JsonTreeView-CGH92Uqo.js} +1 -1
  8. package/dist/assets/{MarkdownRendererImpl-DJKD8tNq.js → MarkdownRendererImpl-DAV0eoSb.js} +2 -2
  9. package/dist/assets/{PatchDiff-GdGq3IlM.js → PatchDiff-Dux9rNuF.js} +1 -1
  10. package/dist/assets/{PierreDiffViewer-CdkAUt-S.js → PierreDiffViewer-9imQKDgh.js} +2 -2
  11. package/dist/assets/{SessionSwitcherContent-BTzVmIop.js → SessionSwitcherContent-BL7f43TK.js} +1 -1
  12. package/dist/assets/SessionSwitcherDropdown-D86K7VFR.js +2 -0
  13. package/dist/assets/SessionUnreadDot-BfH_vRW9.js +1 -0
  14. package/dist/assets/SettingsView-CRYyy2nz.js +4 -0
  15. package/dist/assets/SettingsWindow-CAMrbwzB.js +1 -0
  16. package/dist/assets/{ToolOutputDialog-BHaf293m.js → ToolOutputDialog-D6AeevDV.js} +6 -6
  17. package/dist/assets/{ToolPartDiffPreview-BTMXNcqG.js → ToolPartDiffPreview-Bkjc2WKO.js} +2 -2
  18. package/dist/assets/{VirtualizedFileDiff-CRVvv23V.js → VirtualizedFileDiff-B2HHw9NH.js} +4 -4
  19. package/dist/assets/{WindowsWindowControls-CTtxXnD1.js → WindowsWindowControls-D1V7M-q1.js} +131 -126
  20. package/dist/assets/collapsible-IV1T6v7c.js +1 -0
  21. package/dist/assets/{computeVirtualFileMetrics-D1I8YrPV.js → computeVirtualFileMetrics-BxQbLxY-.js} +1 -1
  22. package/dist/assets/contextFileOpenGuard-xvnEr8Go.js +1 -0
  23. package/dist/assets/index--5Zr-fSk.js +8 -0
  24. package/dist/assets/index--zDkVFU6.css +1 -0
  25. package/dist/assets/{index-DbghctxK.js → index-Jd0py_uf.js} +1 -1
  26. package/dist/assets/{isDiffPlainText-BK9bF1l5.js → isDiffPlainText-BEflvkV4.js} +1 -1
  27. package/dist/assets/{isFilePlainText-Cua0RCRz.js → isFilePlainText-Byt9dFxj.js} +1 -1
  28. package/dist/assets/{main-CoA--JT-.js → main-DLedH1mh.js} +7 -7
  29. package/dist/assets/main-DOqxJvVh.js +2 -0
  30. package/dist/assets/markdownCore-U_gf0I8i.js +3 -0
  31. package/dist/assets/miniChat-BkwDDO9w.js +2 -0
  32. package/dist/assets/mobile-BrrYaFh4.js +2 -0
  33. package/dist/assets/renderElectronMiniChatApp-IM1L48Ek.js +2 -0
  34. package/dist/assets/renderMobileApp-ChddJ_wj.js +14 -0
  35. package/dist/assets/{runtimeSurface-UriLeO95.js → runtimeSurface-D3p7a-uO.js} +1 -1
  36. package/dist/assets/{useInlineCommentController-5XANmO1k.js → useInlineCommentController-BASCWgsn.js} +2 -2
  37. package/dist/assets/usePanelSlide-UOz-oH7E.js +56 -0
  38. package/dist/assets/usePushVisibilityBeacon-DAaVsdjo.js +10 -0
  39. package/dist/assets/{useSwitcherItems-Cc6Tx-LO.js → useSwitcherItems-CAx_SuxF.js} +1 -1
  40. package/dist/assets/{vendor-codemirror-language-data-DxpwplIe.js → vendor-codemirror-language-data-UQYGQ5y2.js} +2 -2
  41. package/dist/assets/{web-components-g7DKkne_.js → web-components-D08z3xzy.js} +4 -4
  42. package/dist/index.html +7 -4
  43. package/dist/mini-chat.html +6 -3
  44. package/dist/mobile.html +6 -3
  45. package/package.json +1 -1
  46. package/server/lib/git/DOCUMENTATION.md +2 -2
  47. package/server/lib/git/issue-2746-longpaths.test.js +11 -11
  48. package/server/lib/git/service.js +16 -53
  49. package/server/lib/git/service.test.js +40 -40
  50. package/server/lib/pi/extension-protocol.js +62 -0
  51. package/server/lib/pi/extension-protocol.test.js +34 -0
  52. package/server/lib/pi/fixtures/pichamber-gui-demo.ts +251 -0
  53. package/server/lib/pi/routes-extension-events.test.js +152 -0
  54. package/server/lib/pi/routes.js +278 -5
  55. package/server/lib/pi/routes.test.js +0 -25
  56. package/server/lib/pi/session-daemon/DOCUMENTATION.md +6 -3
  57. package/server/lib/pi/session-daemon/extension-bridge.js +488 -0
  58. package/server/lib/pi/session-daemon/session-daemon-extensions.e2e.test.js +215 -0
  59. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +559 -0
  60. package/server/lib/pi/session-daemon/session-daemon.js +304 -34
  61. package/server/lib/pi/session-daemon/session-daemon.test.js +89 -1
  62. package/server/lib/pi/small-model-generation.js +14 -1
  63. package/server/lib/pi/small-model-generation.test.js +20 -5
  64. package/server/lib/server/cors.js +0 -2
  65. package/server/lib/server/cors.test.js +4 -4
  66. package/server/lib/stt/providers/openai-compatible-provider.test.js +1 -1
  67. package/server/lib/workspace/host.js +1 -1
  68. package/dist/assets/DiagramEditor-CFV_TjE2.js +0 -1
  69. package/dist/assets/DiagramView-0I4PZUpw.js +0 -1
  70. package/dist/assets/SessionSwitcherDropdown-DuPmnk3k.js +0 -2
  71. package/dist/assets/SessionUnreadDot-ogHL0INY.js +0 -1
  72. package/dist/assets/SettingsView-SHhVrRdh.js +0 -4
  73. package/dist/assets/SettingsWindow-D_D1qqLF.js +0 -1
  74. package/dist/assets/collapsible-BO4qEdib.js +0 -1
  75. package/dist/assets/contextFileOpenGuard-w5xG9Qz2.js +0 -1
  76. package/dist/assets/index-3zee2IYy.css +0 -1
  77. package/dist/assets/index-CI-cd-mw.js +0 -8
  78. package/dist/assets/main-BNJQ6mSF.js +0 -2
  79. package/dist/assets/markdownCore-BGlLZrb8.js +0 -3
  80. package/dist/assets/miniChat-DU2jFhXq.js +0 -2
  81. package/dist/assets/mobile-B3lJ_CJR.js +0 -2
  82. package/dist/assets/renderElectronMiniChatApp-BfXYv3zl.js +0 -2
  83. package/dist/assets/renderMobileApp-Cd_F7yMe.js +0 -14
  84. package/dist/assets/usePanelSlide-CBZw2Cjo.js +0 -56
  85. package/dist/assets/useWindowTitle-Bf8ZNN_R.js +0 -10
  86. package/server/lib/pi/legacy-ui-model-defaults.js +0 -57
  87. package/server/lib/pi/legacy-ui-model-defaults.test.js +0 -65
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Reference pi extension that works in plain pi CLI via normal pi APIs and
3
+ * optionally renders rich UI in PiChamber.
4
+ *
5
+ * Drop this file into `~/.pi/agent/extensions/pichamber-gui-demo.ts` to try it:
6
+ *
7
+ * pi -e ./pichamber-gui-demo.ts
8
+ *
9
+ * Or place it under `.pi/extensions/` for a single project.
10
+ *
11
+ * PiChamber detection is optional and never required: the tool, commands,
12
+ * and hooks work without PiChamber, and the `pichamber.ui` card degrades to a
13
+ * generic JSON card in the CLI transcript.
14
+ */
15
+
16
+ import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
17
+ import { Type } from 'typebox';
18
+
19
+ // Inline helpers keep the extension independent of PiChamber packages. Copy
20
+ // the same detection and descriptor shape into extensions that opt into the GUI.
21
+ const isPiChamber = (ctx: { mode: string; hasUI: boolean }): boolean => {
22
+ const marker = (globalThis as unknown as Record<string, unknown>).__PICHAMBER__ as
23
+ | { version?: number }
24
+ | undefined;
25
+ if (marker?.version) return true;
26
+ try {
27
+ if (typeof process !== 'undefined' && (process as unknown as { env?: Record<string, string> }).env?.PICHAMBER === '1') return true;
28
+ } catch {}
29
+ return ctx.mode === 'rpc' && ctx.hasUI === true;
30
+ };
31
+
32
+ const publishUi = (
33
+ pi: Pick<ExtensionAPI, 'appendEntry'>,
34
+ payload: Record<string, unknown>,
35
+ ) => {
36
+ pi.appendEntry('pichamber.ui', {
37
+ protocol: 'pichamber-extension-ui',
38
+ version: 1,
39
+ ...payload,
40
+ });
41
+ };
42
+
43
+ const publishApp = (
44
+ pi: Pick<ExtensionAPI, 'appendEntry'>,
45
+ payload: Record<string, unknown>,
46
+ ) => {
47
+ pi.appendEntry('pichamber.app', {
48
+ protocol: 'pichamber-extension-ui',
49
+ version: 1,
50
+ ...payload,
51
+ });
52
+ };
53
+
54
+ type SubagentRecord = {
55
+ id: string;
56
+ name: string;
57
+ status: 'running' | 'done' | 'error';
58
+ task: string;
59
+ };
60
+
61
+ export default function (pi: ExtensionAPI): void {
62
+ // In-memory state owned by the extension. PiChamber mirrors the `subagents`
63
+ // snapshot as a server-side normalized map (statuses/widgets) so a phone
64
+ // that connects later sees the current list without the extension resending.
65
+ const subagents = new Map<string, SubagentRecord>();
66
+ let appVisible = false;
67
+
68
+ const renderSubagents = () => {
69
+ const agents = [...subagents.values()];
70
+ if (agents.length === 0) {
71
+ publishUi(pi, {
72
+ id: 'pichamber-demo-subagents',
73
+ title: 'Sub-agents',
74
+ component: 'markdown',
75
+ props: { body: '_No sub-agents running._' },
76
+ });
77
+ return;
78
+ }
79
+
80
+ publishUi(pi, {
81
+ id: 'pichamber-demo-subagents',
82
+ title: 'Sub-agents',
83
+ component: 'table',
84
+ props: {
85
+ columns: ['Agent', 'Status', 'Task'],
86
+ rows: agents.map((agent) => [agent.name, agent.status, agent.task]),
87
+ },
88
+ actions: [
89
+ { label: 'Clear finished', command: 'pichamber-demo-clear', variant: 'ghost' as const },
90
+ { label: 'Spawn…', command: 'pichamber-demo-spawn', promptForArgs: { label: 'Agent name' } },
91
+ ],
92
+ });
93
+ };
94
+
95
+ // Standard pi tool: callable by the model from any host.
96
+ pi.registerTool({
97
+ name: 'pichamber_demo_spawn',
98
+ label: 'Demo: spawn sub-agent',
99
+ description: 'Demo tool that pretends to spawn a sub-agent and publishes PiChamber GUI state.',
100
+ parameters: Type.Object({
101
+ name: Type.String({ description: 'Sub-agent name' }),
102
+ task: Type.String({ description: 'Task description' }),
103
+ }),
104
+ async execute(_toolCallId, params) {
105
+ const id = `agent-${Date.now().toString(36)}`;
106
+ subagents.set(id, { id, name: params.name, status: 'running', task: params.task });
107
+
108
+ // Optional PiChamber enhancement: publish a table that updates in place
109
+ // (same `id` replaces the previous card; transcript history stays as fallback).
110
+ renderSubagents();
111
+
112
+ // Simulate async completion without actually spawning work, so the demo
113
+ // remains useful without credentials or side effects.
114
+ setTimeout(() => {
115
+ const existing = subagents.get(id);
116
+ if (existing) {
117
+ existing.status = 'done';
118
+ renderSubagents();
119
+ }
120
+ }, 800).unref?.();
121
+
122
+ return {
123
+ content: [{ type: 'text', text: `Spawned demo sub-agent "${params.name}" (${id}) for: ${params.task}` }],
124
+ details: { subagentId: id, name: params.name, task: params.task },
125
+ };
126
+ },
127
+ });
128
+
129
+ // Standard slash commands: discoverable via `extensions.list` and invokable
130
+ // through PiChamber's prompt path (action buttons also use this path).
131
+ pi.registerCommand('pichamber-demo-subagents', {
132
+ description: 'Show demo sub-agents',
133
+ handler: async (_args, ctx) => {
134
+ if (isPiChamber(ctx)) {
135
+ renderSubagents();
136
+ ctx.ui.notify(`Demo sub-agents: ${subagents.size} tracked`, 'info');
137
+ return;
138
+ }
139
+ // CLI fallback: plain notification, no PiChamber card needed.
140
+ ctx.ui.notify(`Demo sub-agents (${subagents.size}): ${[...subagents.values()].map((agent) => `${agent.name}:${agent.status}`).join(', ') || 'none'}`, 'info');
141
+ },
142
+ });
143
+
144
+ pi.registerCommand('pichamber-demo-clear', {
145
+ description: 'Clear finished demo sub-agents',
146
+ handler: async (_args, ctx) => {
147
+ for (const [id, agent] of subagents) {
148
+ if (agent.status === 'done') subagents.delete(id);
149
+ }
150
+ if (isPiChamber(ctx)) renderSubagents();
151
+ ctx.ui.notify('Cleared finished demo sub-agents', 'info');
152
+ },
153
+ });
154
+
155
+ pi.registerCommand('pichamber-demo-progress', {
156
+ description: 'Show a progress demo card',
157
+ handler: async (args) => {
158
+ const value = Math.max(0, Math.min(100, Number(args) || 40));
159
+ publishUi(pi, {
160
+ id: 'pichamber-demo-progress',
161
+ title: 'Demo progress',
162
+ component: 'progress',
163
+ props: { label: 'Indexing', value, max: 100 },
164
+ actions: [{ label: 'Reset', command: 'pichamber-demo-progress', args: '0' }],
165
+ });
166
+ },
167
+ });
168
+
169
+ // Structured multi-input dialog. PiChamber renders a native form and
170
+ // resolves with a values object; plain pi falls back to sequential prompts.
171
+ type FormCtx = Parameters<NonNullable<Parameters<ExtensionAPI['registerCommand']>[1]['handler']>>[1];
172
+ const askAgent = async (ctx: FormCtx): Promise<{ name: string; task: string } | undefined> => {
173
+ if (isPiChamber(ctx)) {
174
+ const uiWithForm = ctx.ui as typeof ctx.ui & {
175
+ form?: (title: string, fields: Array<Record<string, unknown>>, opts?: Record<string, unknown>) => Promise<Record<string, string> | undefined>;
176
+ };
177
+ if (typeof uiWithForm.form === 'function') {
178
+ const values = await uiWithForm.form('Spawn sub-agent', [
179
+ { id: 'name', label: 'Name', type: 'text', required: true, placeholder: 'research' },
180
+ { id: 'task', label: 'Task', type: 'textarea', required: true },
181
+ { id: 'priority', label: 'Priority', type: 'select', options: ['low', 'normal', 'high'], initial: 'normal' },
182
+ ]);
183
+ if (!values?.name || !values.task) return undefined;
184
+ return { name: values.name, task: values.task };
185
+ }
186
+ }
187
+ const name = await ctx.ui.input('Sub-agent name');
188
+ if (!name) return undefined;
189
+ const task = await ctx.ui.input('Task description');
190
+ if (!task) return undefined;
191
+ return { name, task };
192
+ };
193
+
194
+ pi.registerCommand('pichamber-demo-spawn', {
195
+ description: 'Spawn a demo sub-agent interactively (form dialog in PiChamber)',
196
+ handler: async (args, ctx) => {
197
+ let name = args?.trim() ?? '';
198
+ let task = name ? `demo task for ${name}` : '';
199
+ if (!name) {
200
+ const answers = await askAgent(ctx);
201
+ if (!answers) return;
202
+ ({ name, task } = answers);
203
+ }
204
+ const id = `agent-${Date.now().toString(36)}`;
205
+ subagents.set(id, { id, name, status: 'running', task });
206
+ renderSubagents();
207
+ ctx.ui.notify(`Spawned ${name}`, 'info');
208
+ },
209
+ });
210
+
211
+ // Sandboxed app surface: self-contained HTML rendered in an iframe that can
212
+ // only invoke registered commands through data-pichamber-command buttons.
213
+ pi.registerCommand('pichamber-demo-app', {
214
+ description: 'Toggle a sandboxed demo app surface (PiChamber only)',
215
+ handler: async (_args, ctx) => {
216
+ if (!isPiChamber(ctx)) {
217
+ ctx.ui.notify('App surfaces are a PiChamber feature', 'warning');
218
+ return;
219
+ }
220
+ if (appVisible) {
221
+ publishApp(pi, { appId: 'demo-board', removed: true });
222
+ appVisible = false;
223
+ return;
224
+ }
225
+ publishApp(pi, {
226
+ appId: 'demo-board',
227
+ title: 'Demo board',
228
+ html: `<!doctype html><html><body style="font-family:system-ui;padding:12px">
229
+ <h3 style="margin:0 0 8px">Demo board</h3>
230
+ <button data-pichamber-command="pichamber-demo-subagents">Refresh panel</button>
231
+ <button data-pichamber-command="pichamber-demo-clear">Clear finished</button>
232
+ <p style="color:#666">Buttons fire slash commands through PiChamber's authenticated prompt path.</p>
233
+ </body></html>`,
234
+ });
235
+ appVisible = true;
236
+ },
237
+ });
238
+
239
+ // Lifecycle hooks run identically inside PiChamber and plain pi. They do not
240
+ // need PiChamber-specific branching, but can optionally publish UI when that
241
+ // capability is present.
242
+ pi.on('session_start', async (_event, ctx) => {
243
+ if (isPiChamber(ctx)) {
244
+ ctx.ui.setStatus('pichamber-demo', 'Demo extension active');
245
+ }
246
+ });
247
+
248
+ pi.on('session_shutdown', async () => {
249
+ subagents.clear();
250
+ });
251
+ }
@@ -0,0 +1,152 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { projectEventFrame, projectExtensionList } from './routes.js';
4
+
5
+ const frame = (event, payload, sequence = 1) => ({
6
+ protocolVersion: 1,
7
+ kind: 'event',
8
+ event,
9
+ sequence,
10
+ payload: { sessionId: 'sess-1', directory: '/work', ...payload },
11
+ });
12
+
13
+ describe('extension public projections', () => {
14
+ it('whitelists extension list fields and rejects path-shaped identities', () => {
15
+ expect(projectExtensionList({
16
+ directory: '/work',
17
+ extensions: [{ id: '0123456789abcdef', name: 'economy', path: '/secret/economy.ts' }],
18
+ commands: [{ name: 'balance', description: 'Switch mode', source: 'daemon-value', scope: 'global', path: '/secret' }],
19
+ })).toEqual({
20
+ directory: '/work',
21
+ extensions: [{ id: '0123456789abcdef', name: 'economy' }],
22
+ commands: [{ name: 'balance', description: 'Switch mode', source: 'extension', scope: 'global' }],
23
+ });
24
+
25
+ expect(() => projectExtensionList({
26
+ directory: '/work',
27
+ extensions: [{ id: '/secret/extension.ts', name: 'extension' }],
28
+ commands: [],
29
+ })).toThrow();
30
+ expect(() => projectExtensionList({
31
+ directory: '/work',
32
+ extensions: [{ id: '0123456789abcdef', name: '../extension' }],
33
+ commands: [],
34
+ })).toThrow();
35
+ });
36
+ it('projects extension.ui panels with caps and removals', () => {
37
+ const projected = projectEventFrame(frame('extension.ui', {
38
+ id: 'subagents',
39
+ title: 'Sub-agents',
40
+ component: 'table',
41
+ props: { columns: ['Agent'], rows: [['research']] },
42
+ actions: [{ label: 'Clear', command: 'agents-clear' }],
43
+ }));
44
+ expect(projected).toMatchObject({
45
+ name: 'extension.ui',
46
+ payload: { id: 'subagents', title: 'Sub-agents', component: 'table' },
47
+ });
48
+
49
+ // Missing component and title is treated as an unregister.
50
+ expect(projectEventFrame(frame('extension.ui', { id: 'gone' }))).toMatchObject({
51
+ payload: { id: 'gone', removed: true },
52
+ });
53
+
54
+ // Invalid ids are dropped entirely.
55
+ expect(projectEventFrame(frame('extension.ui', { id: '' }))).toBeNull();
56
+ expect(projectEventFrame(frame('extension.ui', { id: `${'x'.repeat(200)}` }))).toBeNull();
57
+ });
58
+
59
+ it('projects extension.app payloads and rejects oversized html', () => {
60
+ const projected = projectEventFrame(frame('extension.app', {
61
+ appId: 'board',
62
+ title: 'Board',
63
+ html: '<button data-pichamber-command="run">Run</button>',
64
+ }));
65
+ expect(projected?.payload).toMatchObject({ appId: 'board', title: 'Board' });
66
+ expect(projected?.payload.html).toContain('data-pichamber-command');
67
+
68
+ expect(projectEventFrame(frame('extension.app', {
69
+ appId: 'big',
70
+ html: `${'<a>'.repeat(70_000)}`,
71
+ }))).toBeNull();
72
+
73
+ expect(projectEventFrame(frame('extension.app', { appId: 'gone', removed: true }))?.payload).toMatchObject({
74
+ appId: 'gone',
75
+ removed: true,
76
+ });
77
+ });
78
+
79
+ it('projects bounded editor/title/catalog and tree invalidation events', () => {
80
+ expect(projectEventFrame(frame('extension.editor', { text: 'draft' }))).toMatchObject({
81
+ name: 'extension.editor', payload: { text: 'draft' },
82
+ });
83
+ expect(projectEventFrame(frame('extension.editor', { text: 'x'.repeat(100_001) }))).toBeNull();
84
+ expect(projectEventFrame(frame('extension.title', { title: 'Mode\u0000 Picker' }))).toMatchObject({
85
+ payload: { title: 'Mode Picker' },
86
+ });
87
+ expect(projectEventFrame(frame('extension.title', {}))).toMatchObject({ payload: {} });
88
+ expect(projectEventFrame(frame('extension.catalog', { providers: true, resources: true }))).toMatchObject({
89
+ payload: { providers: true, resources: true },
90
+ });
91
+ expect(projectEventFrame(frame('extension.catalog', {}))).toBeNull();
92
+ expect(projectEventFrame(frame('session.tree.updated', {}))).toMatchObject({ payload: {} });
93
+ });
94
+
95
+ it('projects form dialogs with sanitized fields', () => {
96
+ const projected = projectEventFrame(frame('extension.dialog', {
97
+ requestId: 'form-1',
98
+ method: 'form',
99
+ title: 'Spawn agent',
100
+ fields: [
101
+ { id: 'name', label: 'Name', type: 'text', required: true },
102
+ { id: 'level', label: 'Level', type: 'select', options: ['low', 'high'], initial: 'high' },
103
+ { id: 'bad' },
104
+ null,
105
+ ],
106
+ }));
107
+ expect(projected?.payload.method).toBe('form');
108
+ expect(projected?.payload.fields).toHaveLength(2);
109
+ expect(projected?.payload.fields[0]).toMatchObject({ id: 'name', type: 'text', required: true });
110
+ expect(projected?.payload.fields[1]).toMatchObject({ id: 'level', initial: 'high', options: ['low', 'high'] });
111
+
112
+ expect(projectEventFrame(frame('extension.dialog.dismiss', {
113
+ requestId: 'form-1',
114
+ reason: 'timeout',
115
+ }))?.payload).toEqual({ requestId: 'form-1', reason: 'timeout' });
116
+ expect(projectEventFrame(frame('extension.dialog.dismiss', {
117
+ requestId: 'form-1',
118
+ reason: 'invented',
119
+ }))).toBeNull();
120
+
121
+ // Unknown dialog methods fail closed: the frame is dropped.
122
+ expect(projectEventFrame(frame('extension.dialog', {
123
+ requestId: 'r1',
124
+ method: 'hologram',
125
+ title: '?',
126
+ }))).toBeNull();
127
+ });
128
+
129
+ it('projects snapshot extensionPanels/extensionApps for reconnect', () => {
130
+ const projected = projectEventFrame(frame('session.snapshot', {
131
+ isStreaming: false,
132
+ lifecycle: 'idle',
133
+ queue: { steering: 0, followUp: 0 },
134
+ lastSequence: 5,
135
+ extensionStatuses: [{ key: 'mode', text: 'economy' }],
136
+ extensionPanels: [{ id: 'panel-1', component: 'progress', props: { value: 50 } }],
137
+ extensionApps: [{ appId: 'app-1', html: '<p>x</p>' }],
138
+ extensionTitle: 'Build mode',
139
+ extensionDialogs: [{
140
+ requestId: 'form-1',
141
+ method: 'form',
142
+ title: 'Form',
143
+ fields: [{ id: 'a', label: 'A', type: 'text' }],
144
+ }],
145
+ }));
146
+ const snapshot = projected?.payload.snapshot;
147
+ expect(snapshot.extensionPanels).toHaveLength(1);
148
+ expect(snapshot.extensionApps).toHaveLength(1);
149
+ expect(snapshot.extensionDialogs[0].fields).toHaveLength(1);
150
+ expect(snapshot.extensionTitle).toBe('Build mode');
151
+ });
152
+ });