pith-ui 0.1.0 → 0.1.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.
- package/AI.md +8 -0
- package/API.md +656 -249
- package/README.md +1 -1
- package/dist/composer.d.ts.map +1 -1
- package/dist/composer.js +13 -4
- package/dist/composer.js.map +1 -1
- package/dist/content/conversation-view.d.ts +21 -4
- package/dist/content/conversation-view.d.ts.map +1 -1
- package/dist/content/conversation-view.js +38 -5
- package/dist/content/conversation-view.js.map +1 -1
- package/dist/content/image-viewer.d.ts +4 -2
- package/dist/content/image-viewer.d.ts.map +1 -1
- package/dist/content/image-viewer.js +25 -12
- package/dist/content/image-viewer.js.map +1 -1
- package/dist/content/paged-preview.d.ts.map +1 -1
- package/dist/content/paged-preview.js +6 -3
- package/dist/content/paged-preview.js.map +1 -1
- package/dist/content/welcome.d.ts.map +1 -1
- package/dist/content/welcome.js +14 -5
- package/dist/content/welcome.js.map +1 -1
- package/dist/files/panels.d.ts +6 -1
- package/dist/files/panels.d.ts.map +1 -1
- package/dist/files/panels.js +48 -7
- package/dist/files/panels.js.map +1 -1
- package/dist/files/systems.d.ts.map +1 -1
- package/dist/files/systems.js +47 -30
- package/dist/files/systems.js.map +1 -1
- package/dist/forms/actions.d.ts +7 -7
- package/dist/forms/actions.d.ts.map +1 -1
- package/dist/forms/actions.js +28 -8
- package/dist/forms/actions.js.map +1 -1
- package/dist/forms/custom-connection.d.ts +2 -1
- package/dist/forms/custom-connection.d.ts.map +1 -1
- package/dist/forms/custom-connection.js +34 -27
- package/dist/forms/custom-connection.js.map +1 -1
- package/dist/forms/dialog-frame.d.ts +2 -0
- package/dist/forms/dialog-frame.d.ts.map +1 -1
- package/dist/forms/dialog-frame.js +46 -26
- package/dist/forms/dialog-frame.js.map +1 -1
- package/dist/forms/identity.d.ts +12 -0
- package/dist/forms/identity.d.ts.map +1 -1
- package/dist/forms/identity.js +32 -0
- package/dist/forms/identity.js.map +1 -1
- package/dist/forms/model-editor.d.ts +8 -3
- package/dist/forms/model-editor.d.ts.map +1 -1
- package/dist/forms/model-editor.js +73 -62
- package/dist/forms/model-editor.js.map +1 -1
- package/dist/forms/panels.d.ts +95 -6
- package/dist/forms/panels.d.ts.map +1 -1
- package/dist/forms/panels.js +142 -27
- package/dist/forms/panels.js.map +1 -1
- package/dist/forms/provider-login.d.ts.map +1 -1
- package/dist/forms/provider-login.js +9 -7
- package/dist/forms/provider-login.js.map +1 -1
- package/dist/forms/resource-editor.d.ts +9 -5
- package/dist/forms/resource-editor.d.ts.map +1 -1
- package/dist/forms/resource-editor.js +18 -8
- package/dist/forms/resource-editor.js.map +1 -1
- package/dist/foundations.d.ts +95 -0
- package/dist/foundations.d.ts.map +1 -0
- package/dist/foundations.js +315 -0
- package/dist/foundations.js.map +1 -0
- package/dist/navigation/context-menu.d.ts +1 -0
- package/dist/navigation/context-menu.d.ts.map +1 -1
- package/dist/navigation/context-menu.js +48 -34
- package/dist/navigation/context-menu.js.map +1 -1
- package/dist/navigation/navigation.d.ts +42 -7
- package/dist/navigation/navigation.d.ts.map +1 -1
- package/dist/navigation/navigation.js +197 -14
- package/dist/navigation/navigation.js.map +1 -1
- package/dist/primitives.d.ts +3 -0
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +60 -168
- package/dist/primitives.js.map +1 -1
- package/dist/styles.css +32 -28
- package/dist/surface.d.ts +29 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +154 -0
- package/dist/surface.js.map +1 -0
- package/dist/tasks/approval.d.ts.map +1 -1
- package/dist/tasks/approval.js +5 -2
- package/dist/tasks/approval.js.map +1 -1
- package/dist/tasks/permission.d.ts +5 -3
- package/dist/tasks/permission.d.ts.map +1 -1
- package/dist/tasks/permission.js +11 -5
- package/dist/tasks/permission.js.map +1 -1
- package/dist/workspace.d.ts +58 -4
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +120 -15
- package/dist/workspace.js.map +1 -1
- package/package.json +1 -1
package/dist/workspace.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Generation } from './core.js';
|
|
2
2
|
import { icon } from './dom.js';
|
|
3
|
+
import { controlDisabled } from './core.js';
|
|
4
|
+
import { adoptProductParts, reconcileSelectOptions } from './foundations.js';
|
|
5
|
+
import { installDialogLifecycle } from './surface.js';
|
|
3
6
|
let sequence = 0;
|
|
4
7
|
function identify(root, prefix) {
|
|
5
8
|
if (!prefix)
|
|
@@ -29,8 +32,13 @@ export function createComposerView(options = {}) {
|
|
|
29
32
|
const element = holder.firstElementChild;
|
|
30
33
|
const input = element.querySelector('textarea');
|
|
31
34
|
const action = element.querySelector('[type="submit"]');
|
|
35
|
+
const model = element.querySelector('[data-action="model"]');
|
|
36
|
+
const thinking = element.querySelector('[aria-label="Thinking effort"]');
|
|
37
|
+
const imagePicker = element.querySelector('[type="file"]');
|
|
32
38
|
identify(element, options.prefix ?? 'pui-composer-' + ++sequence + '-');
|
|
33
39
|
const generation = new Generation();
|
|
40
|
+
const parts = adoptProductParts(element);
|
|
41
|
+
let destroyed = false;
|
|
34
42
|
let pending = false, last = {}, lastAction = 'send';
|
|
35
43
|
const error = document.createElement('div');
|
|
36
44
|
error.className = 'pui-form-error';
|
|
@@ -39,23 +47,34 @@ export function createComposerView(options = {}) {
|
|
|
39
47
|
element.insertBefore(error, element.firstChild);
|
|
40
48
|
const resize = () => { input.style.height = 'auto'; input.style.height = Math.min(input.scrollHeight, 180) + 'px'; };
|
|
41
49
|
const update = (state) => {
|
|
50
|
+
if (destroyed)
|
|
51
|
+
return;
|
|
42
52
|
last = state;
|
|
43
|
-
|
|
44
|
-
input.placeholder = state.placeholder;
|
|
45
|
-
input.disabled = !!state.disabled;
|
|
46
|
-
input.readOnly = !!state.readOnly;
|
|
53
|
+
parts.control(input).update({ disabled: !!state.disabled, readOnly: !!state.readOnly, ...(state.placeholder !== undefined ? { placeholder: state.placeholder } : {}) });
|
|
47
54
|
if (state.action && state.action !== lastAction) {
|
|
48
55
|
lastAction = state.action;
|
|
49
56
|
action.type = state.action === 'stop' ? 'button' : 'submit';
|
|
50
57
|
action.innerHTML = icon(state.action === 'stop' ? 'stop' : 'arrow');
|
|
51
58
|
action.classList.toggle('pui-is-stop', state.action === 'stop');
|
|
52
|
-
action.setAttribute('aria-label', state.action === 'stop' ? 'Stop agent' : state.action === 'queue' ? 'Queue message' : 'Send message');
|
|
53
59
|
}
|
|
54
|
-
|
|
60
|
+
const actionLabel = lastAction === 'stop' ? 'Stop agent' : lastAction === 'queue' ? 'Queue message' : 'Send message';
|
|
61
|
+
action.setAttribute('aria-label', actionLabel);
|
|
62
|
+
action.title = actionLabel;
|
|
63
|
+
parts.action(action).update({ disabled: !!(state.actionDisabled || state.disabled), pending });
|
|
64
|
+
if (state.model) {
|
|
65
|
+
parts.action(model).update({ label: state.model.label, title: state.model.description, disabled: !!state.model.disabled });
|
|
66
|
+
}
|
|
67
|
+
if (state.thinking) {
|
|
68
|
+
const { options: choices, value, disabled } = state.thinking;
|
|
69
|
+
reconcileSelectOptions(thinking, choices, value);
|
|
70
|
+
parts.control(thinking).update({ disabled: !!disabled });
|
|
71
|
+
thinking.parentElement.hidden = choices.length < 2;
|
|
72
|
+
}
|
|
73
|
+
parts.update();
|
|
55
74
|
};
|
|
56
75
|
const onInput = () => { resize(); options.onInput?.(input.value); };
|
|
57
|
-
const run = async (callback) => {
|
|
58
|
-
if (!callback || pending || action.disabled || input.disabled || input.readOnly)
|
|
76
|
+
const run = async (callback, textSubmission = true) => {
|
|
77
|
+
if (!callback || pending || action.disabled || (textSubmission && (input.disabled || input.readOnly)))
|
|
59
78
|
return;
|
|
60
79
|
const seq = generation.next();
|
|
61
80
|
pending = true;
|
|
@@ -88,20 +107,41 @@ export function createComposerView(options = {}) {
|
|
|
88
107
|
void run(() => options.onSubmit(text));
|
|
89
108
|
} };
|
|
90
109
|
const stop = () => { if (action.type === 'button')
|
|
91
|
-
void run(options.onStop); };
|
|
110
|
+
void run(options.onStop, false); };
|
|
92
111
|
const keydown = (event) => {
|
|
93
|
-
if (options.onSubmit && event.key === 'Enter' && !event.shiftKey && !event.isComposing
|
|
112
|
+
if (options.onSubmit && event.key === 'Enter' && !event.shiftKey && !event.isComposing) {
|
|
94
113
|
event.preventDefault();
|
|
95
|
-
|
|
114
|
+
if (action.type === 'submit')
|
|
115
|
+
element.requestSubmit();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const click = (event) => {
|
|
119
|
+
const button = event.target.closest('button');
|
|
120
|
+
if (!button || button.disabled)
|
|
121
|
+
return;
|
|
122
|
+
const callback = button === model ? options.onModel : button.hasAttribute('data-action') && button.dataset.action === 'attach-images' ? options.onAttach : undefined;
|
|
123
|
+
if (callback) {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
callback();
|
|
96
126
|
}
|
|
97
127
|
};
|
|
128
|
+
const chooseThinking = () => options.onThinkingChange?.(thinking.value);
|
|
129
|
+
const images = () => { const files = Array.from(imagePicker.files ?? []); imagePicker.value = ''; options.onImages?.(files); };
|
|
130
|
+
element.addEventListener('click', click);
|
|
131
|
+
thinking.addEventListener('change', chooseThinking);
|
|
132
|
+
imagePicker.addEventListener('change', images);
|
|
98
133
|
input.addEventListener('input', onInput);
|
|
99
134
|
input.addEventListener('keydown', keydown);
|
|
100
135
|
element.addEventListener('submit', submit);
|
|
101
136
|
action.addEventListener('click', stop);
|
|
102
137
|
return { element, input, update, getValue: () => input.value,
|
|
103
|
-
reset(value) {
|
|
104
|
-
|
|
138
|
+
reset(value) { if (destroyed)
|
|
139
|
+
return; generation.invalidate(); pending = false; error.hidden = true; error.textContent = ''; input.value = value; update(last); resize(); }, focus: () => { if (!destroyed)
|
|
140
|
+
input.focus(); }, resize,
|
|
141
|
+
pickImages() { if (!destroyed)
|
|
142
|
+
imagePicker.click(); },
|
|
143
|
+
destroy() { if (destroyed)
|
|
144
|
+
return; destroyed = true; generation.destroy(); parts.destroy(); input.removeEventListener('input', onInput); input.removeEventListener('keydown', keydown); element.removeEventListener('submit', submit); action.removeEventListener('click', stop); element.removeEventListener('click', click); thinking.removeEventListener('change', chooseThinking); imagePicker.removeEventListener('change', images); element.remove(); } };
|
|
105
145
|
}
|
|
106
146
|
export function createWorkspaceShell(options) {
|
|
107
147
|
const element = document.createElement('div');
|
|
@@ -168,16 +208,81 @@ export function createWorkspaceShell(options) {
|
|
|
168
208
|
`;
|
|
169
209
|
element.querySelector('[data-brand-slot]').replaceWith(options.brand);
|
|
170
210
|
const prefix = options.prefix ?? 'pui-workspace-' + ++sequence + '-';
|
|
171
|
-
const composer = createComposerView({ prefix: '' });
|
|
211
|
+
const composer = createComposerView({ ...options.composer, prefix: '' });
|
|
172
212
|
element.querySelector('[data-composer-slot]').replaceWith(composer.element);
|
|
173
213
|
identify(element, prefix);
|
|
174
214
|
const part = (name) => element.querySelector('[id="' + prefix + name + '"]');
|
|
215
|
+
let destroyed = false;
|
|
216
|
+
const parts = adoptProductParts(element);
|
|
217
|
+
const dialogs = new Map(Array.from(element.querySelectorAll('dialog'), dialog => {
|
|
218
|
+
const name = dialog.id.slice(prefix.length).replace(/-dialog$/, '');
|
|
219
|
+
return [name, installDialogLifecycle(dialog, { onClose: () => options.onDialogClose?.(name) })];
|
|
220
|
+
}));
|
|
221
|
+
const setSidebarOpen = (open) => { if (destroyed)
|
|
222
|
+
return; part('sidebar').classList.toggle('pui-open', open); part('sidebar-scrim').classList.toggle('pui-visible', open); };
|
|
223
|
+
const sidebarClick = (event) => { const target = event.target; if (target === part('sidebar-scrim') || target.closest('[data-action="menu"]')) {
|
|
224
|
+
setSidebarOpen(target !== part('sidebar-scrim'));
|
|
225
|
+
event.stopPropagation();
|
|
226
|
+
} };
|
|
227
|
+
const search = part('history-search');
|
|
228
|
+
const onSearch = () => options.onSearch?.(search.value);
|
|
229
|
+
search.addEventListener('input', onSearch);
|
|
230
|
+
element.addEventListener('click', sidebarClick);
|
|
231
|
+
const busy = part('workspace-busy');
|
|
232
|
+
const onBusy = (event) => { if (event.target.closest('button') && busy.dataset.key) {
|
|
233
|
+
event.stopPropagation();
|
|
234
|
+
options.onBusyAction?.(busy.dataset.key);
|
|
235
|
+
} };
|
|
236
|
+
busy.addEventListener('click', onBusy);
|
|
175
237
|
return { element, composer, part, update(state) {
|
|
238
|
+
if (destroyed)
|
|
239
|
+
return;
|
|
176
240
|
if (state.workspace !== undefined)
|
|
177
241
|
part('workspace-label').textContent = state.workspace;
|
|
178
242
|
if (state.conversation !== undefined)
|
|
179
243
|
part('conversation-label').textContent = state.conversation;
|
|
180
244
|
part('connection-status').hidden = !state.reconnecting;
|
|
181
|
-
|
|
245
|
+
if (state.error) {
|
|
246
|
+
part('inline-error').textContent = state.error.message;
|
|
247
|
+
part('inline-error').hidden = !!state.error.hidden || !state.error.message;
|
|
248
|
+
}
|
|
249
|
+
if (state.busy !== undefined) {
|
|
250
|
+
busy.hidden = !state.busy;
|
|
251
|
+
if (state.busy) {
|
|
252
|
+
if (!busy.firstChild) {
|
|
253
|
+
busy.append(document.createElement('span'), document.createElement('button'));
|
|
254
|
+
const button = busy.lastElementChild;
|
|
255
|
+
button.type = 'button';
|
|
256
|
+
button.className = 'pui-text-button';
|
|
257
|
+
}
|
|
258
|
+
busy.dataset.key = state.busy.key;
|
|
259
|
+
if (busy.firstElementChild.textContent !== state.busy.message)
|
|
260
|
+
busy.firstElementChild.textContent = state.busy.message;
|
|
261
|
+
if (busy.lastElementChild.textContent !== state.busy.actionLabel)
|
|
262
|
+
busy.lastElementChild.textContent = state.busy.actionLabel;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
parts.update();
|
|
266
|
+
}, setSidebarOpen,
|
|
267
|
+
openDialog(name) { if (!destroyed) {
|
|
268
|
+
setSidebarOpen(false);
|
|
269
|
+
dialogs.get(name)?.open();
|
|
270
|
+
} },
|
|
271
|
+
closeDialog(name) { if (!destroyed)
|
|
272
|
+
dialogs.get(name)?.close(); },
|
|
273
|
+
isDialogOpen(name) { return !destroyed && !!dialogs.get(name)?.isOpen(); },
|
|
274
|
+
updateActionAvailability(unavailable, root = element) {
|
|
275
|
+
if (destroyed)
|
|
276
|
+
return;
|
|
277
|
+
for (const button of root.querySelectorAll('[data-idle-action], [data-global-idle], [data-mcp-edit], [data-action="new-mcp"]')) {
|
|
278
|
+
const scope = button.hasAttribute('data-global-idle') || button.hasAttribute('data-mcp-edit') || button.dataset.action === 'new-mcp' ? { kind: 'global' } : button.dataset.idleConversation ? { kind: 'conversation', id: button.dataset.idleConversation } : button.dataset.idleWorkspace ? { kind: 'workspace', id: button.dataset.idleWorkspace } : { kind: 'active' };
|
|
279
|
+
button.disabled = controlDisabled(button, unavailable(scope));
|
|
280
|
+
}
|
|
281
|
+
for (const link of root.querySelectorAll('a[data-download-conversation]'))
|
|
282
|
+
link.setAttribute('aria-disabled', String(unavailable({ kind: 'conversation', id: link.dataset.downloadConversation })));
|
|
283
|
+
},
|
|
284
|
+
destroy() { if (destroyed)
|
|
285
|
+
return; destroyed = true; for (const dialog of dialogs.values())
|
|
286
|
+
dialog.destroy(); parts.destroy(); search.removeEventListener('input', onSearch); element.removeEventListener('click', sidebarClick); busy.removeEventListener('click', onBusy); composer.destroy(); element.remove(); } };
|
|
182
287
|
}
|
|
183
288
|
//# sourceMappingURL=workspace.js.map
|
package/dist/workspace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmC,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,SAAS,QAAQ,CAAC,IAAiB,EAAE,MAAc;IACjD,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,C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AC,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC;YACzF,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS;gBAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC;YAClG,IAAI,CAAC,mBAAmB,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;QACzD,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import { Generation, type UIBlock, type ActionResult } from './core.js';\nimport { icon } from './dom.js';\n\nexport interface ComposerViewState { placeholder?: string; disabled?: boolean; readOnly?: boolean; action?: 'send' | 'queue' | 'stop'; actionDisabled?: boolean; }\nexport interface ComposerViewOptions { prefix?: string; onSubmit?: (text: string) => void | ActionResult | Promise<void | ActionResult>; onStop?: () => void | ActionResult | Promise<void | ActionResult>; onInput?: (text: string) => void; }\nlet sequence = 0;\nfunction identify(root: HTMLElement, prefix: string): void {\n if (!prefix) return;\n const attributes = ['id', 'for', 'aria-labelledby', 'aria-describedby', 'aria-controls', 'data-close'];\n for (const node of [root, ...root.querySelectorAll<HTMLElement>('*')]) for (const attribute of attributes) {\n const value = node.getAttribute(attribute); if (value) node.setAttribute(attribute, value.split(' ').map(part => prefix + part).join(' '));\n }\n}\nexport function createComposerView(options: ComposerViewOptions = {}) {\n const holder = document.createElement('div'); holder.innerHTML = `<form id=\"composer-form\" class=\"pui-composer\">\n <div id=\"draft-images\" class=\"pui-draft-images\" aria-label=\"Image attachments\" hidden></div>\n <input id=\"image-picker\" type=\"file\" accept=\"image/png,image/jpeg,image/gif,image/webp\" multiple hidden />\n <textarea id=\"composer-input\" rows=\"1\" placeholder=\"Ask Pith to help with your work…\" aria-label=\"Message Pith\"></textarea>\n <div class=\"pui-composer-toolbar\">\n <div class=\"pui-composer-context\">\n <button id=\"attach-images\" type=\"button\" class=\"pui-quiet-icon pui-attach-images\" data-action=\"attach-images\" aria-label=\"Attach images\" title=\"Attach images\">${icon('image')}</button>\n <label class=\"pui-permission-control\" id=\"permission-control\">${icon('shield')}<span class=\"pui-sr-only\">Conversation permissions</span><select id=\"permission-mode\" aria-describedby=\"permission-description\"><option value=\"ask\">Ask before changes</option><option value=\"workspace-write\">Allow workspace changes</option><option value=\"full-access\">Full access</option></select>${icon('down')}</label>\n </div>\n <div class=\"pui-composer-actions\"><button id=\"composer-model\" type=\"button\" class=\"pui-composer-model\" data-action=\"model\" data-idle-action data-global-idle aria-label=\"Choose model\">Choose model</button><label class=\"pui-composer-thinking\"><span class=\"pui-sr-only\">Thinking effort</span><select id=\"composer-thinking\" aria-label=\"Thinking effort\"></select></label><button id=\"send-button\" class=\"pui-send-button\" type=\"submit\" aria-label=\"Send message\">${icon('arrow')}</button></div>\n </div>\n </form>`;\n const element = holder.firstElementChild as HTMLFormElement;\n const input = element.querySelector<HTMLTextAreaElement>('textarea')!;\n const action = element.querySelector<HTMLButtonElement>('[type=\"submit\"]')!;\n identify(element, options.prefix ?? 'pui-composer-' + ++sequence + '-');\n const generation = new Generation();\n let pending = false, last: ComposerViewState = {}, lastAction = 'send';\n const error = document.createElement('div'); error.className = 'pui-form-error'; error.setAttribute('role','alert'); error.hidden = true; element.insertBefore(error, element.firstChild);\n const resize = () => { input.style.height = 'auto'; input.style.height = Math.min(input.scrollHeight, 180) + 'px'; };\n const update = (state: ComposerViewState) => {\n last = state;\n if (state.placeholder !== undefined) input.placeholder = state.placeholder;\n input.disabled = !!state.disabled; input.readOnly = !!state.readOnly;\n if (state.action && state.action !== lastAction) { lastAction = state.action; action.type = state.action === 'stop' ? 'button' : 'submit'; action.innerHTML = icon(state.action === 'stop' ? 'stop' : 'arrow'); action.classList.toggle('pui-is-stop', state.action === 'stop'); action.setAttribute('aria-label', state.action === 'stop' ? 'Stop agent' : state.action === 'queue' ? 'Queue message' : 'Send message'); }\n action.disabled = !!(state.actionDisabled || state.disabled || pending);\n };\n const onInput = () => { resize(); options.onInput?.(input.value); };\n const run = async (callback: (() => void | ActionResult | Promise<void | ActionResult>) | undefined) => {\n if (!callback || pending || action.disabled || input.disabled || input.readOnly) return;\n const seq = generation.next(); pending = true; error.hidden = true; error.textContent = ''; update(last);\n try {\n const result = await callback();\n if (generation.current(seq) && result && !result.ok) { error.textContent = result.error; error.hidden = false; }\n } catch (reason) {\n if (generation.current(seq)) { error.textContent = reason instanceof Error ? reason.message : String(reason); error.hidden = false; }\n } finally { if (generation.current(seq)) { pending = false; update(last); } }\n };\n const submit = (event: SubmitEvent) => { if (options.onSubmit) { event.preventDefault(); const text = input.value; void run(() => options.onSubmit!(text)); } };\n const stop = () => { if (action.type === 'button') void run(options.onStop); };\n const keydown = (event: KeyboardEvent) => {\n if (options.onSubmit && event.key === 'Enter' && !event.shiftKey && !event.isComposing && action.type === 'submit') { event.preventDefault(); element.requestSubmit(); }\n };\n input.addEventListener('input', onInput); input.addEventListener('keydown', keydown); element.addEventListener('submit', submit); action.addEventListener('click', stop);\n return { element, input, update, getValue: () => input.value,\n reset(value: string) { generation.invalidate(); pending = false; error.hidden = true; error.textContent = ''; input.value = value; update(last); resize(); }, focus: () => input.focus(), resize,\n destroy() { generation.destroy(); input.removeEventListener('input', onInput); input.removeEventListener('keydown', keydown); element.removeEventListener('submit', submit); action.removeEventListener('click', stop); element.remove(); } };\n\n}\n\nexport interface WorkspaceShellOptions { brand: Node; prefix?: string; }\nexport interface WorkspaceShellState { workspace?: string; conversation?: string; reconnecting?: boolean; }\nexport function createWorkspaceShell(options: WorkspaceShellOptions): UIBlock<WorkspaceShellState> & { composer: ReturnType<typeof createComposerView>; part<T extends HTMLElement = HTMLElement>(name: string): T } {\n const element = document.createElement('div'); element.className = 'pui-app';\n element.innerHTML = `\n <aside class=\"pui-sidebar\" id=\"sidebar\">\n <div class=\"pui-brand\"><span data-brand-slot></span></div>\n <div class=\"pui-sidebar-section-label\">WORKSPACES <button class=\"pui-quiet-icon\" data-action=\"workspace\" aria-label=\"Manage workspaces\">${icon('plus')}</button></div>\n <label class=\"pui-history-search\">${icon('search')}<span class=\"pui-sr-only\">Search conversation titles</span><input id=\"history-search\" type=\"search\" placeholder=\"Search conversations\" autocomplete=\"off\" /></label>\n <nav id=\"history-list\" class=\"pui-history-list\" aria-label=\"Workspaces and conversations\"></nav>\n <div class=\"pui-sidebar-bottom\">\n <button class=\"pui-settings-button\" data-action=\"resources\">${icon('file')}<span>Workspace resources</span></button>\n <button class=\"pui-settings-button\" data-action=\"connections\">${icon('plug')}<span>Connections</span></button>\n <button class=\"pui-settings-button\" data-action=\"settings\">${icon('settings')}<span>Settings</span></button>\n <div id=\"connection-status\" class=\"pui-local-status\" role=\"status\" hidden><span class=\"pui-status-dot pui-reconnecting\" aria-hidden=\"true\"></span><span>Reconnecting…</span></div>\n </div>\n </aside>\n <div id=\"conversation-menu\" class=\"pui-sidebar-conversation-menu\" role=\"menu\" hidden></div>\n <div class=\"pui-sidebar-scrim\" id=\"sidebar-scrim\"></div>\n <main class=\"pui-main\">\n <header class=\"pui-topbar\">\n <button class=\"pui-quiet-icon pui-mobile-menu\" data-action=\"menu\" aria-label=\"Open sidebar\">${icon('menu')}</button>\n <div class=\"pui-breadcrumb\">${icon('folder')}<span id=\"workspace-label\">No workspace</span>${icon('chevron', 'pui-breadcrumb-chevron')}<span class=\"pui-breadcrumb-current\" id=\"conversation-label\">New conversation</span></div>\n <div class=\"pui-conversation-actions\"><button class=\"pui-quiet-icon pui-compact-action\" data-sdk=\"compact\" data-sdk-idle title=\"Compress context by summarizing older messages\" aria-label=\"Compress context\">${icon('compress')}<span>Compact</span></button><div id=\"artifacts-control\" class=\"pui-artifacts-control\" hidden><button id=\"artifacts-toggle\" type=\"button\" class=\"pui-quiet-icon pui-artifacts-toggle\" aria-label=\"Conversation files\" title=\"Conversation files\" aria-expanded=\"false\" aria-controls=\"artifacts\">${icon('file')}<span id=\"artifacts-count\" class=\"pui-artifacts-count\" aria-hidden=\"true\"></span></button><section id=\"artifacts\" class=\"pui-artifacts-panel\" aria-labelledby=\"artifacts-title\" tabindex=\"-1\" hidden></section></div></div>\n </header>\n <section id=\"conversation-find\" class=\"pui-conversation-find\" aria-label=\"Find in conversation\" hidden>\n <input type=\"search\" aria-label=\"Find in this conversation\" placeholder=\"Find in this conversation\" autocomplete=\"off\" />\n <span data-find-count role=\"status\" aria-live=\"polite\"></span>\n <button type=\"button\" class=\"pui-quiet-icon pui-find-previous\" data-find-previous aria-label=\"Previous match\" title=\"Previous match (Shift+Enter)\">${icon('down')}</button>\n <button type=\"button\" class=\"pui-quiet-icon\" data-find-next aria-label=\"Next match\" title=\"Next match (Enter)\">${icon('down')}</button>\n <button type=\"button\" class=\"pui-quiet-icon\" data-find-close aria-label=\"Close search\" title=\"Close (Esc)\">${icon('close')}</button>\n </section>\n <div class=\"pui-conversation-region\"><section id=\"chat-scroll\" class=\"pui-chat-scroll\" aria-label=\"Conversation\" tabindex=\"-1\">\n <div id=\"welcome\" class=\"pui-welcome\"></div>\n <div id=\"messages\" class=\"pui-messages\" aria-live=\"polite\" aria-relevant=\"additions text\"></div>\n </section><button id=\"back-to-latest\" type=\"button\" class=\"pui-secondary-button pui-back-to-latest\" hidden>${icon('down')}<span>Back to latest</span></button></div>\n <div class=\"pui-composer-region\">\n <div class=\"pui-composer-panels\">\n <div id=\"approval\" class=\"pui-approval-region\"></div>\n <div id=\"workspace-busy\" class=\"pui-workspace-busy\" hidden></div><div id=\"inline-error\" class=\"pui-inline-error\" role=\"alert\" hidden></div>\n <section id=\"task-failure\" class=\"pui-task-failure\" role=\"status\" hidden></section>\n <details id=\"run-status\" class=\"pui-run-status\" hidden><summary id=\"run-status-summary\"></summary><div id=\"run-status-details\"><div id=\"runtime-values\"></div><details id=\"cost-requests\" class=\"pui-cost-requests\" hidden><summary>Request breakdown</summary><div id=\"cost-ledger\"></div></details></div></details>\n <section id=\"queued-messages\" class=\"pui-queued-messages\" aria-label=\"Pending messages\" aria-live=\"polite\" hidden></section>\n </div>\n <div data-composer-slot></div>\n <p id=\"image-guidance\" class=\"pui-composer-note pui-image-guidance\" hidden></p>\n <p class=\"pui-composer-note\" id=\"permission-description\">Pith can read workspace files. Changes and commands require your approval.</p>\n </div>\n </main>\n <section id=\"completion-notices\" class=\"pui-completion-notices\" aria-label=\"Completed tasks\" aria-live=\"polite\"></section>\n <span id=\"copy-status\" class=\"pui-sr-only\" role=\"status\" aria-live=\"polite\"></span>\n <dialog id=\"model-dialog\" class=\"pui-modal pui-model-modal\" aria-labelledby=\"model-title\"><div id=\"model-content\"></div></dialog>\n <dialog id=\"settings-dialog\" class=\"pui-modal\" aria-labelledby=\"settings-title\"><div id=\"settings-content\"></div></dialog>\n <dialog id=\"workspace-dialog\" class=\"pui-modal\" aria-labelledby=\"workspace-title\"><div id=\"workspace-content\"></div></dialog>\n <dialog id=\"permissions-dialog\" class=\"pui-modal pui-permission-modal\" aria-labelledby=\"full-access-title\"><div id=\"permissions-content\"></div></dialog>\n <dialog id=\"delete-dialog\" class=\"pui-modal\" aria-labelledby=\"delete-title\"><div id=\"delete-content\"></div></dialog>\n <dialog id=\"rename-dialog\" class=\"pui-modal\" aria-labelledby=\"rename-title\"><div id=\"rename-content\"></div></dialog>\n <dialog id=\"queue-edit-dialog\" class=\"pui-modal\" aria-labelledby=\"queue-edit-title\"><div id=\"queue-edit-content\"></div></dialog>\n <dialog id=\"message-edit-dialog\" class=\"pui-modal\" aria-labelledby=\"message-edit-title\"><div id=\"message-edit-content\"></div></dialog>\n <dialog id=\"resources-dialog\" class=\"pui-modal pui-feature-modal\" aria-labelledby=\"resources-title\"><div id=\"resources-content\"></div></dialog>\n <dialog id=\"connections-dialog\" class=\"pui-modal pui-feature-modal\" aria-labelledby=\"connections-title\"><div id=\"connections-content\"></div></dialog>\n <dialog id=\"preview-dialog\" class=\"pui-modal pui-file-preview-modal\" aria-labelledby=\"preview-title\"><div id=\"preview-content\"></div></dialog>\n <dialog id=\"image-dialog\"></dialog>\n`;\n element.querySelector('[data-brand-slot]')!.replaceWith(options.brand);\n const prefix = options.prefix ?? 'pui-workspace-' + ++sequence + '-';\n const composer = createComposerView({ prefix: '' }); element.querySelector('[data-composer-slot]')!.replaceWith(composer.element);\n identify(element, prefix);\n const part = <T extends HTMLElement = HTMLElement>(name: string) => element.querySelector<T>('[id=\"' + prefix + name + '\"]')!;\n return { element, composer, part, update(state) {\n if (state.workspace !== undefined) part('workspace-label').textContent = state.workspace;\n if (state.conversation !== undefined) part('conversation-label').textContent = state.conversation;\n part('connection-status').hidden = !state.reconnecting;\n }, destroy() { composer.destroy(); element.remove(); } };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmC,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAkBtD,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,SAAS,QAAQ,CAAC,IAAiB,EAAE,MAAc;IACjD,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;IACvG,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAc,GAAG,CAAC,CAAC;QAAE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YAC1G,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAAC,IAAI,KAAK;gB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MAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,CAAoB,+BAA+B,CAAC;gBAAE,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,CAAC;QACzN,CAAC;QACD,OAAO,KAAK,IAAI,SAAS;YAAE,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE;YAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzT,CAAC","sourcesContent":["import { Generation, type UIBlock, type ActionResult } from './core.js';\nimport { icon } from './dom.js';\nimport { controlDisabled } from './core.js';\nimport { adoptProductParts, reconcileSelectOptions } from './foundations.js';\nimport { installDialogLifecycle } from './surface.js';\n\nexport interface ComposerViewState {\n placeholder?: string; disabled?: boolean; readOnly?: boolean;\n action?: 'send' | 'queue' | 'stop'; actionDisabled?: boolean;\n model?: { label: string; description: string; disabled?: boolean };\n thinking?: { options: readonly { value: string; label: string }[]; value: string; disabled?: boolean };\n}\nexport interface ComposerViewOptions {\n prefix?: string;\n onSubmit?: (text: string) => void | ActionResult | Promise<void | ActionResult>;\n onStop?: () => void | ActionResult | Promise<void | ActionResult>;\n onInput?: (text: string) => void;\n onModel?: () => void;\n onAttach?: () => void;\n onImages?: (files: File[]) => void;\n onThinkingChange?: (value: string) => void;\n}\nlet sequence = 0;\nfunction identify(root: HTMLElement, prefix: string): void {\n if (!prefix) return;\n const attributes = ['id', 'for', 'aria-labelledby', 'aria-describedby', 'aria-controls', 'data-close'];\n for (const node of [root, ...root.querySelectorAll<HTMLElement>('*')]) for (const attribute of attributes) {\n const value = node.getAttribute(attribute); if (value) node.setAttribute(attribute, value.split(' ').map(part => prefix + part).join(' '));\n }\n}\nexport function createComposerView(options: ComposerViewOptions = {}) {\n const holder = document.createElement('div'); holder.innerHTML = `<form id=\"composer-form\" class=\"pui-composer\">\n <div id=\"draft-images\" class=\"pui-draft-images\" aria-label=\"Image attachments\" hidden></div>\n <input id=\"image-picker\" type=\"file\" accept=\"image/png,image/jpeg,image/gif,image/webp\" multiple hidden />\n <textarea id=\"composer-input\" rows=\"1\" placeholder=\"Ask Pith to help with your work…\" aria-label=\"Message Pith\"></textarea>\n <div class=\"pui-composer-toolbar\">\n <div class=\"pui-composer-context\">\n <button id=\"attach-images\" type=\"button\" class=\"pui-quiet-icon pui-attach-images\" data-action=\"attach-images\" aria-label=\"Attach images\" title=\"Attach images\">${icon('image')}</button>\n <label class=\"pui-permission-control\" id=\"permission-control\">${icon('shield')}<span class=\"pui-sr-only\">Conversation permissions</span><select id=\"permission-mode\" aria-describedby=\"permission-description\"><option value=\"ask\">Ask before changes</option><option value=\"workspace-write\">Allow workspace changes</option><option value=\"full-access\">Full access</option></select>${icon('down')}</label>\n </div>\n <div class=\"pui-composer-actions\"><button id=\"composer-model\" type=\"button\" class=\"pui-composer-model\" data-action=\"model\" data-idle-action data-global-idle aria-label=\"Choose model\">Choose model</button><label class=\"pui-composer-thinking\"><span class=\"pui-sr-only\">Thinking effort</span><select id=\"composer-thinking\" aria-label=\"Thinking effort\"></select></label><button id=\"send-button\" class=\"pui-send-button\" type=\"submit\" aria-label=\"Send message\">${icon('arrow')}</button></div>\n </div>\n </form>`;\n const element = holder.firstElementChild as HTMLFormElement;\n const input = element.querySelector<HTMLTextAreaElement>('textarea')!;\n const action = element.querySelector<HTMLButtonElement>('[type=\"submit\"]')!;\n const model = element.querySelector<HTMLButtonElement>('[data-action=\"model\"]')!;\n const thinking = element.querySelector<HTMLSelectElement>('[aria-label=\"Thinking effort\"]')!;\n const imagePicker = element.querySelector<HTMLInputElement>('[type=\"file\"]')!;\n identify(element, options.prefix ?? 'pui-composer-' + ++sequence + '-');\n const generation = new Generation();\n const parts = adoptProductParts(element);\n let destroyed = false;\n let pending = false, last: ComposerViewState = {}, lastAction = 'send';\n const error = document.createElement('div'); error.className = 'pui-form-error'; error.setAttribute('role','alert'); error.hidden = true; element.insertBefore(error, element.firstChild);\n const resize = () => { input.style.height = 'auto'; input.style.height = Math.min(input.scrollHeight, 180) + 'px'; };\n const update = (state: ComposerViewState) => {\n if (destroyed) return;\n last = state;\n parts.control(input).update({ disabled: !!state.disabled, readOnly: !!state.readOnly, ...(state.placeholder !== undefined ? { placeholder: state.placeholder } : {}) });\n if (state.action && state.action !== lastAction) { lastAction = state.action; action.type = state.action === 'stop' ? 'button' : 'submit'; action.innerHTML = icon(state.action === 'stop' ? 'stop' : 'arrow'); action.classList.toggle('pui-is-stop', state.action === 'stop'); }\n const actionLabel = lastAction === 'stop' ? 'Stop agent' : lastAction === 'queue' ? 'Queue message' : 'Send message';\n action.setAttribute('aria-label', actionLabel); action.title = actionLabel;\n parts.action(action).update({ disabled: !!(state.actionDisabled || state.disabled), pending });\n if (state.model) {\n parts.action(model).update({ label: state.model.label, title: state.model.description, disabled: !!state.model.disabled });\n }\n if (state.thinking) {\n const { options: choices, value, disabled } = state.thinking;\n reconcileSelectOptions(thinking, choices, value);\n parts.control(thinking).update({ disabled: !!disabled }); thinking.parentElement!.hidden = choices.length < 2;\n }\n parts.update();\n };\n const onInput = () => { resize(); options.onInput?.(input.value); };\n const run = async (callback: (() => void | ActionResult | Promise<void | ActionResult>) | undefined, textSubmission = true) => {\n if (!callback || pending || action.disabled || (textSubmission && (input.disabled || input.readOnly))) return;\n const seq = generation.next(); pending = true; error.hidden = true; error.textContent = ''; update(last);\n try {\n const result = await callback();\n if (generation.current(seq) && result && !result.ok) { error.textContent = result.error; error.hidden = false; }\n } catch (reason) {\n if (generation.current(seq)) { error.textContent = reason instanceof Error ? reason.message : String(reason); error.hidden = false; }\n } finally { if (generation.current(seq)) { pending = false; update(last); } }\n };\n const submit = (event: SubmitEvent) => { if (options.onSubmit) { event.preventDefault(); const text = input.value; void run(() => options.onSubmit!(text)); } };\n const stop = () => { if (action.type === 'button') void run(options.onStop, false); };\n const keydown = (event: KeyboardEvent) => {\n if (options.onSubmit && event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n if (action.type === 'submit') element.requestSubmit();\n }\n };\n const click = (event: MouseEvent) => {\n const button = (event.target as Element).closest<HTMLButtonElement>('button');\n if (!button || button.disabled) return;\n const callback = button === model ? options.onModel : button.hasAttribute('data-action') && button.dataset.action === 'attach-images' ? options.onAttach : undefined;\n if (callback) { event.stopPropagation(); callback(); }\n };\n const chooseThinking = () => options.onThinkingChange?.(thinking.value);\n const images = () => { const files = Array.from(imagePicker.files ?? []); imagePicker.value = ''; options.onImages?.(files); };\n element.addEventListener('click', click); thinking.addEventListener('change', chooseThinking); imagePicker.addEventListener('change', images);\n input.addEventListener('input', onInput); input.addEventListener('keydown', keydown); element.addEventListener('submit', submit); action.addEventListener('click', stop);\n return { element, input, update, getValue: () => input.value,\n reset(value: string) { if (destroyed) return; generation.invalidate(); pending = false; error.hidden = true; error.textContent = ''; input.value = value; update(last); resize(); }, focus: () => { if (!destroyed) input.focus(); }, resize,\n pickImages() { if (!destroyed) imagePicker.click(); },\n destroy() { if (destroyed) return; destroyed = true; generation.destroy(); parts.destroy(); input.removeEventListener('input', onInput); input.removeEventListener('keydown', keydown); element.removeEventListener('submit', submit); action.removeEventListener('click', stop); element.removeEventListener('click', click); thinking.removeEventListener('change', chooseThinking); imagePicker.removeEventListener('change', images); element.remove(); } };\n\n}\n\nexport type WorkspaceDialogName = 'model' | 'settings' | 'workspace' | 'permissions' | 'delete' | 'rename' | 'queue-edit' | 'message-edit' | 'resources' | 'connections' | 'preview' | 'image';\nexport interface ActionScope { kind: 'global' | 'conversation' | 'workspace' | 'active'; id?: string; }\nexport interface WorkspaceShellOptions { brand: Node; prefix?: string; composer?: ComposerViewOptions; onDialogClose?: (name: WorkspaceDialogName) => void; onSearch?: (query: string) => void; onBusyAction?: (key: string) => void; }\nexport interface WorkspaceShellState { workspace?: string; conversation?: string; reconnecting?: boolean; error?: { message: string; hidden?: boolean }; busy?: { key: string; message: string; actionLabel: string } | null; }\nexport function createWorkspaceShell(options: WorkspaceShellOptions) {\n const element = document.createElement('div'); element.className = 'pui-app';\n element.innerHTML = `\n <aside class=\"pui-sidebar\" id=\"sidebar\">\n <div class=\"pui-brand\"><span data-brand-slot></span></div>\n <div class=\"pui-sidebar-section-label\">WORKSPACES <button class=\"pui-quiet-icon\" data-action=\"workspace\" aria-label=\"Manage workspaces\">${icon('plus')}</button></div>\n <label class=\"pui-history-search\">${icon('search')}<span class=\"pui-sr-only\">Search conversation titles</span><input id=\"history-search\" type=\"search\" placeholder=\"Search conversations\" autocomplete=\"off\" /></label>\n <nav id=\"history-list\" class=\"pui-history-list\" aria-label=\"Workspaces and conversations\"></nav>\n <div class=\"pui-sidebar-bottom\">\n <button class=\"pui-settings-button\" data-action=\"resources\">${icon('file')}<span>Workspace resources</span></button>\n <button class=\"pui-settings-button\" data-action=\"connections\">${icon('plug')}<span>Connections</span></button>\n <button class=\"pui-settings-button\" data-action=\"settings\">${icon('settings')}<span>Settings</span></button>\n <div id=\"connection-status\" class=\"pui-local-status\" role=\"status\" hidden><span class=\"pui-status-dot pui-reconnecting\" aria-hidden=\"true\"></span><span>Reconnecting…</span></div>\n </div>\n </aside>\n <div id=\"conversation-menu\" class=\"pui-sidebar-conversation-menu\" role=\"menu\" hidden></div>\n <div class=\"pui-sidebar-scrim\" id=\"sidebar-scrim\"></div>\n <main class=\"pui-main\">\n <header class=\"pui-topbar\">\n <button class=\"pui-quiet-icon pui-mobile-menu\" data-action=\"menu\" aria-label=\"Open sidebar\">${icon('menu')}</button>\n <div class=\"pui-breadcrumb\">${icon('folder')}<span id=\"workspace-label\">No workspace</span>${icon('chevron', 'pui-breadcrumb-chevron')}<span class=\"pui-breadcrumb-current\" id=\"conversation-label\">New conversation</span></div>\n <div class=\"pui-conversation-actions\"><button class=\"pui-quiet-icon pui-compact-action\" data-sdk=\"compact\" data-sdk-idle title=\"Compress context by summarizing older messages\" aria-label=\"Compress context\">${icon('compress')}<span>Compact</span></button><div id=\"artifacts-control\" class=\"pui-artifacts-control\" hidden><button id=\"artifacts-toggle\" type=\"button\" class=\"pui-quiet-icon pui-artifacts-toggle\" aria-label=\"Conversation files\" title=\"Conversation files\" aria-expanded=\"false\" aria-controls=\"artifacts\">${icon('file')}<span id=\"artifacts-count\" class=\"pui-artifacts-count\" aria-hidden=\"true\"></span></button><section id=\"artifacts\" class=\"pui-artifacts-panel\" aria-labelledby=\"artifacts-title\" tabindex=\"-1\" hidden></section></div></div>\n </header>\n <section id=\"conversation-find\" class=\"pui-conversation-find\" aria-label=\"Find in conversation\" hidden>\n <input type=\"search\" aria-label=\"Find in this conversation\" placeholder=\"Find in this conversation\" autocomplete=\"off\" />\n <span data-find-count role=\"status\" aria-live=\"polite\"></span>\n <button type=\"button\" class=\"pui-quiet-icon pui-find-previous\" data-find-previous aria-label=\"Previous match\" title=\"Previous match (Shift+Enter)\">${icon('down')}</button>\n <button type=\"button\" class=\"pui-quiet-icon\" data-find-next aria-label=\"Next match\" title=\"Next match (Enter)\">${icon('down')}</button>\n <button type=\"button\" class=\"pui-quiet-icon\" data-find-close aria-label=\"Close search\" title=\"Close (Esc)\">${icon('close')}</button>\n </section>\n <div class=\"pui-conversation-region\"><section id=\"chat-scroll\" class=\"pui-chat-scroll\" aria-label=\"Conversation\" tabindex=\"-1\">\n <div id=\"welcome\" class=\"pui-welcome\"></div>\n <div id=\"messages\" class=\"pui-messages\" aria-live=\"polite\" aria-relevant=\"additions text\"></div>\n </section><button id=\"back-to-latest\" type=\"button\" class=\"pui-secondary-button pui-back-to-latest\" hidden>${icon('down')}<span>Back to latest</span></button></div>\n <div class=\"pui-composer-region\">\n <div class=\"pui-composer-panels\">\n <div id=\"approval\" class=\"pui-approval-region\"></div>\n <div id=\"workspace-busy\" class=\"pui-workspace-busy\" hidden></div><div id=\"inline-error\" class=\"pui-inline-error\" role=\"alert\" hidden></div>\n <section id=\"task-failure\" class=\"pui-task-failure\" role=\"status\" hidden></section>\n <details id=\"run-status\" class=\"pui-run-status\" hidden><summary id=\"run-status-summary\"></summary><div id=\"run-status-details\"><div id=\"runtime-values\"></div><details id=\"cost-requests\" class=\"pui-cost-requests\" hidden><summary>Request breakdown</summary><div id=\"cost-ledger\"></div></details></div></details>\n <section id=\"queued-messages\" class=\"pui-queued-messages\" aria-label=\"Pending messages\" aria-live=\"polite\" hidden></section>\n </div>\n <div data-composer-slot></div>\n <p id=\"image-guidance\" class=\"pui-composer-note pui-image-guidance\" hidden></p>\n <p class=\"pui-composer-note\" id=\"permission-description\">Pith can read workspace files. Changes and commands require your approval.</p>\n </div>\n </main>\n <section id=\"completion-notices\" class=\"pui-completion-notices\" aria-label=\"Completed tasks\" aria-live=\"polite\"></section>\n <span id=\"copy-status\" class=\"pui-sr-only\" role=\"status\" aria-live=\"polite\"></span>\n <dialog id=\"model-dialog\" class=\"pui-modal pui-model-modal\" aria-labelledby=\"model-title\"><div id=\"model-content\"></div></dialog>\n <dialog id=\"settings-dialog\" class=\"pui-modal\" aria-labelledby=\"settings-title\"><div id=\"settings-content\"></div></dialog>\n <dialog id=\"workspace-dialog\" class=\"pui-modal\" aria-labelledby=\"workspace-title\"><div id=\"workspace-content\"></div></dialog>\n <dialog id=\"permissions-dialog\" class=\"pui-modal pui-permission-modal\" aria-labelledby=\"full-access-title\"><div id=\"permissions-content\"></div></dialog>\n <dialog id=\"delete-dialog\" class=\"pui-modal\" aria-labelledby=\"delete-title\"><div id=\"delete-content\"></div></dialog>\n <dialog id=\"rename-dialog\" class=\"pui-modal\" aria-labelledby=\"rename-title\"><div id=\"rename-content\"></div></dialog>\n <dialog id=\"queue-edit-dialog\" class=\"pui-modal\" aria-labelledby=\"queue-edit-title\"><div id=\"queue-edit-content\"></div></dialog>\n <dialog id=\"message-edit-dialog\" class=\"pui-modal\" aria-labelledby=\"message-edit-title\"><div id=\"message-edit-content\"></div></dialog>\n <dialog id=\"resources-dialog\" class=\"pui-modal pui-feature-modal\" aria-labelledby=\"resources-title\"><div id=\"resources-content\"></div></dialog>\n <dialog id=\"connections-dialog\" class=\"pui-modal pui-feature-modal\" aria-labelledby=\"connections-title\"><div id=\"connections-content\"></div></dialog>\n <dialog id=\"preview-dialog\" class=\"pui-modal pui-file-preview-modal\" aria-labelledby=\"preview-title\"><div id=\"preview-content\"></div></dialog>\n <dialog id=\"image-dialog\"></dialog>\n`;\n element.querySelector('[data-brand-slot]')!.replaceWith(options.brand);\n const prefix = options.prefix ?? 'pui-workspace-' + ++sequence + '-';\n const composer = createComposerView({ ...options.composer, prefix: '' }); element.querySelector('[data-composer-slot]')!.replaceWith(composer.element);\n identify(element, prefix);\n const part = <T extends HTMLElement = HTMLElement>(name: string) => element.querySelector<T>('[id=\"' + prefix + name + '\"]')!;\n let destroyed = false;\n const parts = adoptProductParts(element);\n const dialogs = new Map(Array.from(element.querySelectorAll<HTMLDialogElement>('dialog'), dialog => {\n const name = dialog.id.slice(prefix.length).replace(/-dialog$/, '') as WorkspaceDialogName;\n return [name, installDialogLifecycle(dialog, { onClose: () => options.onDialogClose?.(name) })] as const;\n }));\n const setSidebarOpen = (open: boolean) => { if (destroyed) return; part('sidebar').classList.toggle('pui-open', open); part('sidebar-scrim').classList.toggle('pui-visible', open); };\n const sidebarClick = (event: MouseEvent) => { const target = event.target as Element; if (target === part('sidebar-scrim') || target.closest('[data-action=\"menu\"]')) { setSidebarOpen(target !== part('sidebar-scrim')); event.stopPropagation(); } };\n const search = part<HTMLInputElement>('history-search'); const onSearch = () => options.onSearch?.(search.value);\n search.addEventListener('input', onSearch); element.addEventListener('click', sidebarClick);\n const busy = part('workspace-busy');\n const onBusy = (event: MouseEvent) => { if ((event.target as Element).closest('button') && busy.dataset.key) { event.stopPropagation(); options.onBusyAction?.(busy.dataset.key); } };\n busy.addEventListener('click', onBusy);\n return { element, composer, part, update(state: Readonly<WorkspaceShellState>) {\n if (destroyed) return;\n if (state.workspace !== undefined) part('workspace-label').textContent = state.workspace;\n if (state.conversation !== undefined) part('conversation-label').textContent = state.conversation;\n part('connection-status').hidden = !state.reconnecting;\n if (state.error) { part('inline-error').textContent = state.error.message; part('inline-error').hidden = !!state.error.hidden || !state.error.message; }\n if (state.busy !== undefined) {\n busy.hidden = !state.busy;\n if (state.busy) {\n if (!busy.firstChild) { busy.append(document.createElement('span'), document.createElement('button')); const button = busy.lastElementChild as HTMLButtonElement; button.type = 'button'; button.className = 'pui-text-button'; }\n busy.dataset.key = state.busy.key;\n if (busy.firstElementChild!.textContent !== state.busy.message) busy.firstElementChild!.textContent = state.busy.message;\n if (busy.lastElementChild!.textContent !== state.busy.actionLabel) busy.lastElementChild!.textContent = state.busy.actionLabel;\n }\n }\n parts.update();\n }, setSidebarOpen,\n openDialog(name: WorkspaceDialogName) { if (!destroyed) { setSidebarOpen(false); dialogs.get(name)?.open(); } },\n closeDialog(name: WorkspaceDialogName) { if (!destroyed) dialogs.get(name)?.close(); },\n isDialogOpen(name: WorkspaceDialogName) { return !destroyed && !!dialogs.get(name)?.isOpen(); },\n updateActionAvailability(unavailable: (scope: ActionScope) => boolean, root: ParentNode = element) {\n if (destroyed) return;\n for (const button of root.querySelectorAll<HTMLButtonElement>('[data-idle-action], [data-global-idle], [data-mcp-edit], [data-action=\"new-mcp\"]')) {\n const scope: ActionScope = button.hasAttribute('data-global-idle') || button.hasAttribute('data-mcp-edit') || button.dataset.action === 'new-mcp' ? { kind: 'global' } : button.dataset.idleConversation ? { kind: 'conversation', id: button.dataset.idleConversation } : button.dataset.idleWorkspace ? { kind: 'workspace', id: button.dataset.idleWorkspace } : { kind: 'active' };\n button.disabled = controlDisabled(button, unavailable(scope));\n }\n for (const link of root.querySelectorAll<HTMLAnchorElement>('a[data-download-conversation]')) link.setAttribute('aria-disabled', String(unavailable({ kind: 'conversation', id: link.dataset.downloadConversation })));\n },\n destroy() { if (destroyed) return; destroyed = true; for (const dialog of dialogs.values()) dialog.destroy(); parts.destroy(); search.removeEventListener('input', onSearch); element.removeEventListener('click', sidebarClick); busy.removeEventListener('click', onBusy); composer.destroy(); element.remove(); } };\n}\n"]}
|