pi-sdk-web 0.3.2 → 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.
Files changed (2) hide show
  1. package/dist/static/app.js +14 -0
  2. package/package.json +1 -1
@@ -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
  // ------------------------------------------------------------------
@@ -1401,18 +1405,28 @@ class PiWebClient {
1401
1405
  renderStatusItem(req) {
1402
1406
  const el = document.getElementById('ext-status');
1403
1407
  if (!el) return;
1408
+ const wasAtBottom = this.wasAtBottom();
1404
1409
  if (req.statusText === undefined || req.statusText === null) {
1405
1410
  delete this.extStatus[req.statusKey];
1406
1411
  } else {
1407
1412
  this.extStatus[req.statusKey] = req.statusText;
1408
1413
  }
1409
1414
  this.updateExtStatusDisplay();
1415
+ if (wasAtBottom) this.scrollToBottom();
1410
1416
  }
1411
1417
 
1412
1418
  applyExtStatusSnapshot(snapshot) {
1413
1419
  if (!snapshot) return;
1420
+ const wasAtBottom = this.wasAtBottom();
1414
1421
  this.extStatus = Object.assign({}, snapshot);
1415
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;
1416
1430
  }
1417
1431
 
1418
1432
  updateExtStatusDisplay() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-sdk-web",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Browser Web access for Pi (AI coding agent) via the Pi SDK - standalone module, zero modification to Pi itself",
5
5
  "type": "module",
6
6
  "bin": {