pi-sdk-web 0.3.1 → 0.3.3
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/dist/static/app.js +22 -1
- package/package.json +1 -1
package/dist/static/app.js
CHANGED
|
@@ -804,12 +804,14 @@ class PiWebClient {
|
|
|
804
804
|
const widgetsEl = document.getElementById('widgets');
|
|
805
805
|
if (!widgetsEl) return;
|
|
806
806
|
const key = req.widgetKey || 'widget';
|
|
807
|
+
const wasAtBottom = this.wasAtBottom();
|
|
807
808
|
|
|
808
809
|
if (req.widgetLines === undefined || req.widgetLines === null) {
|
|
809
810
|
// Clear this widget
|
|
810
811
|
const el = widgetsEl.querySelector(`[data-widget-key="${CSS.escape(key)}"]`);
|
|
811
812
|
if (el) el.remove();
|
|
812
813
|
if (widgetsEl.children.length === 0) widgetsEl.style.display = 'none';
|
|
814
|
+
if (wasAtBottom) this.scrollToBottom();
|
|
813
815
|
return;
|
|
814
816
|
}
|
|
815
817
|
|
|
@@ -829,6 +831,8 @@ class PiWebClient {
|
|
|
829
831
|
el.querySelector('.widget-title').textContent = key;
|
|
830
832
|
el.querySelector('.widget-body').textContent = (req.widgetLines || []).join('\n');
|
|
831
833
|
widgetsEl.style.display = 'block';
|
|
834
|
+
// Layout change: keep pinned to bottom if already there
|
|
835
|
+
if (wasAtBottom) this.scrollToBottom();
|
|
832
836
|
}
|
|
833
837
|
|
|
834
838
|
// ------------------------------------------------------------------
|
|
@@ -1205,7 +1209,14 @@ class PiWebClient {
|
|
|
1205
1209
|
} else if (builtin && builtin.unsupported) {
|
|
1206
1210
|
this.appendError(`/${name} is not supported in web mode`);
|
|
1207
1211
|
} else {
|
|
1208
|
-
|
|
1212
|
+
// Prompt templates (/cl etc.) are expanded by Pi's prompt layer -
|
|
1213
|
+
// send as prompt text, same as /skill: commands.
|
|
1214
|
+
const knownTemplate = (this.lastState?.commands || []).find((c) => c.name === name && c.source === 'prompt');
|
|
1215
|
+
if (knownTemplate) {
|
|
1216
|
+
this.send({ type: 'prompt', message: text });
|
|
1217
|
+
} else {
|
|
1218
|
+
this.send({ type: 'command', name: name, args: args });
|
|
1219
|
+
}
|
|
1209
1220
|
}
|
|
1210
1221
|
} else {
|
|
1211
1222
|
this.send({ type: 'prompt', message: text });
|
|
@@ -1394,18 +1405,28 @@ class PiWebClient {
|
|
|
1394
1405
|
renderStatusItem(req) {
|
|
1395
1406
|
const el = document.getElementById('ext-status');
|
|
1396
1407
|
if (!el) return;
|
|
1408
|
+
const wasAtBottom = this.wasAtBottom();
|
|
1397
1409
|
if (req.statusText === undefined || req.statusText === null) {
|
|
1398
1410
|
delete this.extStatus[req.statusKey];
|
|
1399
1411
|
} else {
|
|
1400
1412
|
this.extStatus[req.statusKey] = req.statusText;
|
|
1401
1413
|
}
|
|
1402
1414
|
this.updateExtStatusDisplay();
|
|
1415
|
+
if (wasAtBottom) this.scrollToBottom();
|
|
1403
1416
|
}
|
|
1404
1417
|
|
|
1405
1418
|
applyExtStatusSnapshot(snapshot) {
|
|
1406
1419
|
if (!snapshot) return;
|
|
1420
|
+
const wasAtBottom = this.wasAtBottom();
|
|
1407
1421
|
this.extStatus = Object.assign({}, snapshot);
|
|
1408
1422
|
this.updateExtStatusDisplay();
|
|
1423
|
+
if (wasAtBottom) this.scrollToBottom();
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
/** Whether the view is currently pinned to the bottom (before layout changes). */
|
|
1427
|
+
wasAtBottom() {
|
|
1428
|
+
const scroller = document.getElementById('scroll-view');
|
|
1429
|
+
return !!scroller && scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 2;
|
|
1409
1430
|
}
|
|
1410
1431
|
|
|
1411
1432
|
updateExtStatusDisplay() {
|