pi-sdk-web 0.4.6 → 0.4.8

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.
@@ -786,7 +786,9 @@ class PiWebClient {
786
786
  body.className = 'special-body body-text';
787
787
  div.appendChild(labelEl);
788
788
  div.appendChild(body);
789
- div.addEventListener('click', () => this.toggleSpecial(div));
789
+ // Click to expand/collapse, but NOT when the pointer was dragged (see
790
+ // bindExpandToggle - same drag-vs-click logic as tool blocks).
791
+ this.bindExpandToggle(div, (d) => this.toggleSpecial(d));
790
792
  this.contentEl.appendChild(div);
791
793
  return div;
792
794
  }
@@ -1151,6 +1153,25 @@ class PiWebClient {
1151
1153
  }
1152
1154
  }
1153
1155
 
1156
+ /**
1157
+ * Add expand/collapse-on-click to a block, while preserving text selection.
1158
+ *
1159
+ * A drag that selects text ends with mouseup -> click; toggling then would
1160
+ * re-render the block and wipe the selection. Record the mousedown
1161
+ * position and skip the toggle when the pointer moved more than 3px
1162
+ * (anything beyond that is a drag, not a click - 3px tolerates hand tremor
1163
+ * on a plain click).
1164
+ */
1165
+ bindExpandToggle(div, toggleFn) {
1166
+ let downX = 0, downY = 0;
1167
+ div.addEventListener('mousedown', (e) => { downX = e.clientX; downY = e.clientY; });
1168
+ div.addEventListener('click', (e) => {
1169
+ const dx = e.clientX - downX, dy = e.clientY - downY;
1170
+ if (dx * dx + dy * dy > 9) return; // dragged: preserve selection
1171
+ toggleFn(div);
1172
+ });
1173
+ }
1174
+
1154
1175
  createToolBlock(toolName, args, toolCallId) {
1155
1176
  const div = document.createElement('div');
1156
1177
  div.className = 'tool-block pending';
@@ -1203,8 +1224,9 @@ class PiWebClient {
1203
1224
  div.appendChild(content);
1204
1225
  div.appendChild(bottom);
1205
1226
 
1206
- // Click to expand/collapse
1207
- div.addEventListener('click', () => this.toggleToolExpand(div));
1227
+ // Click to expand/collapse, but NOT when the pointer was dragged (see
1228
+ // bindExpandToggle - a drag that selected text must preserve selection).
1229
+ this.bindExpandToggle(div, (d) => this.toggleToolExpand(d));
1208
1230
 
1209
1231
  this.contentEl.appendChild(div);
1210
1232
  return div;
@@ -63,6 +63,8 @@ body.theme-light {
63
63
  box-sizing: border-box;
64
64
  margin: 0;
65
65
  padding: 0;
66
+ user-select: text;
67
+ -webkit-user-select: text;
66
68
  }
67
69
 
68
70
  html, body {
@@ -162,8 +164,7 @@ body {
162
164
  border: 1px solid var(--border);
163
165
  border-radius: 6px;
164
166
  padding: 6px 10px;
165
- cursor: pointer;
166
- user-select: none;
167
+ cursor: text;
167
168
  font-size: 12px;
168
169
  }
169
170
 
@@ -268,8 +269,20 @@ body {
268
269
  background: var(--tool-pending-bg);
269
270
  margin: 4px 0;
270
271
  font-size: 13px;
271
- cursor: pointer;
272
+ }
273
+
274
+ .tool-block .tool-title,
275
+ .tool-block .tool-meta {
272
276
  user-select: none;
277
+ cursor: pointer;
278
+ }
279
+
280
+ /* Tool args (the JSON parameter summary) and output are informative
281
+ content: selectable/copyable with a text cursor. */
282
+ .tool-block .tool-args,
283
+ .tool-block .tool-output {
284
+ user-select: text;
285
+ cursor: text;
273
286
  }
274
287
 
275
288
  .tool-block.success {
@@ -307,14 +320,29 @@ body {
307
320
  font-size: 12px;
308
321
  }
309
322
 
323
+ /* Label the args area so it is visually distinct from the output below
324
+ (both are JSON-ish monospace text; without this users cannot tell where
325
+ the parameters end and the result begins). */
326
+ .tool-block .tool-args::before {
327
+ content: 'Args: ';
328
+ color: var(--dim);
329
+ font-weight: 600;
330
+ }
331
+
310
332
  .tool-block .tool-output {
311
- color: var(--muted);
333
+ color: var(--text);
312
334
  margin-top: 4px;
313
335
  white-space: pre-wrap;
314
336
  font-family: monospace;
315
337
  font-size: 12px;
316
338
  }
317
339
 
340
+ .tool-block .tool-output::before {
341
+ content: 'Output: ';
342
+ color: var(--dim);
343
+ font-weight: 600;
344
+ }
345
+
318
346
  .tool-block .tool-meta {
319
347
  margin-top: 4px;
320
348
  color: var(--dim);
@@ -337,8 +365,6 @@ body {
337
365
  margin: 4px 0;
338
366
  padding: 6px 12px;
339
367
  border-radius: 6px;
340
- cursor: pointer;
341
- user-select: none;
342
368
  }
343
369
 
344
370
  .special-block .special-label {
@@ -346,11 +372,15 @@ body {
346
372
  font-weight: bold;
347
373
  font-size: 12px;
348
374
  margin-bottom: 4px;
375
+ user-select: none;
376
+ cursor: pointer;
349
377
  }
350
378
 
351
379
  .special-block .special-body {
352
380
  color: var(--text);
353
381
  font-size: 13px;
382
+ user-select: text;
383
+ cursor: text;
354
384
  }
355
385
 
356
386
  .special-block .special-body > *:first-child {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-sdk-web",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
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": {