pi-pocket 0.29.0-beta.1 → 0.29.0-beta.2

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.
@@ -192,7 +192,7 @@ A full view for a tab of protocol 4 has the order of every entry in the active c
192
192
 
193
193
  A tab of protocol 5 gets those entries light at first (`lightEntry` in `projection.ts`, marked `partial`): without a thought's words, with a tool's input and output cut to their first 300 characters, and without large details. That is what shows only when a step is opened, and most of a session's weight: the first view of a long session goes from hundreds of kilobytes to tens. The server does not count a light entry as sent, so the update right after the first view (`Room.push`) brings it whole. A long poll answers the first time as soon as the first view is built, so the whole entries come in the next answer. Until then, a call's line may say nothing of its outcome (a result of 300 characters or fewer, with small details, is never made light: it comes whole, so its line can show it), and a thought does not open.
194
194
 
195
- A tab of protocol 6 keeps the sessions it leaves (`keptViews` in `web/store.js`: the newest 1,500 entries of each, as many sessions as fit in 32 million characters of JSON, about 50 MB once parsed, the one left longest ago dropped first), and shows the one it goes back to at once, before the server answers. It tells the server what it kept (`have=<from>.<count>.<key>.<build>`): the first `count` ids of the order, as a fingerprint (`key`, from `web/text-hash.js`), whose entries it has whole from `from` on, as a server of build `build` sent them. The build (`src/server/build.ts`) is a hash of the server's code and its package: an entry is as that code projects it, so what a tab kept is good across a restart with the same code, and not across new code. The server checks `have` against the session (`Room.push`): its own build, and an order that still starts with those ids (no compaction since). If it fits, the full view counts those entries as sent, and its order is only what comes after them, with `orderFrom` where it goes on: a session that did not change sends no entries and no order. If it does not, the tab gets the full view any tab gets. An update to a tab of protocol 6 likewise sends only the end of the order when entries were only added: a long session's order has thousands of ids, and each entry added sent them all again. A view whose `orderFrom` does not fit the order the tab has, which should not happen, makes the tab drop what it kept and connect again. The tab keeps only views a server of the running build sent whole. It forgets them all when the server runs other code, when the person's rights change or another person signs in, or when a session leaves the list; and a session's own when the server says it is missing. Each of these but the last also keeps the view on screen from being kept when the tab leaves it: after a reconnect the list can come first, and a tab that leaves at once never hears that the session is missing.
195
+ A tab of protocol 6 keeps the sessions it leaves (`keptViews` in `web/store.js`: the newest 1,500 entries of each, as many sessions as fit in 16 million characters of JSON, about 25 MB once parsed, the one left longest ago dropped first), and shows the one it goes back to at once, before the server answers. It tells the server what it kept (`have=<from>.<count>.<key>.<build>`): the first `count` ids of the order, as a fingerprint (`key`, from `web/text-hash.js`), whose entries it has whole from `from` on, as a server of build `build` sent them. The build (`src/server/build.ts`) is a hash of the server's code and its package: an entry is as that code projects it, so what a tab kept is good across a restart with the same code, and not across new code. The server checks `have` against the session (`Room.push`): its own build, and an order that still starts with those ids (no compaction since). If it fits, the full view counts those entries as sent, and its order is only what comes after them, with `orderFrom` where it goes on: a session that did not change sends no entries and no order. If it does not, the tab gets the full view any tab gets. An update to a tab of protocol 6 likewise sends only the end of the order when entries were only added: a long session's order has thousands of ids, and each entry added sent them all again. A view whose `orderFrom` does not fit the order the tab has, which should not happen, makes the tab drop what it kept and connect again. The tab keeps only views a server of the running build sent whole. It forgets them all when the server runs other code, when the person's rights change or another person signs in, or when a session leaves the list; and a session's own when the server says it is missing. Each of these but the last also keeps the view on screen from being kept when the tab leaves it: after a reconnect the list can come first, and a tab that leaves at once never hears that the session is missing.
196
196
 
197
197
  The browser also keeps those sessions on the device (`web/session-cache.js`, IndexedDB), for every tab of it: about 100 MB of JSON in all (`DEVICE_CHARS`), the session used longest ago dropped first. A session saved there shows at once after a reload, a tab the system closed in the background, or a restart of a server with the same build, and a tab opens a session its memory no longer holds from there in a moment. A tab that starts reads the ones used last back into its memory while it is idle, as many as its memory keeps, so that going to them after a reload is as quick as before it. A tab saves a session there as it leaves it, and the one it shows a few seconds after it last changed and as the page goes to the background. Each record names its build and whose it is (a fingerprint of the person's id, role, and shared sessions): a tab uses only one of its server's build and of the person signed in with the same rights, and the server checks `have` as for one from memory. The signed-in app page carries that identity and build, never a token, so the same check can show a device copy before `/api/me` answers; its answer checks the copy again and drops it if the identity, rights, build, or cache policy changed. What the device kept goes when the tab forgets what it kept (above), on sign-out, and, per session, when the server says it is missing. `PI_POCKET_SESSION_CACHE=off` keeps sessions off devices (`hello.server.deviceCache` false): tabs keep them in memory only, and drop what their browser kept on the device.
198
198
 
@@ -459,7 +459,7 @@ start(
459
459
  source: ConversationId,
460
460
  request: { title?: string; message: string; model?: string; thinking?: string; cwd?: string },
461
461
  key: string,
462
- ): Promise<{ session: ConversationId; address: string }>;
462
+ ): Promise<{ session: ConversationId; address: string; answers?: boolean }>;
463
463
  ```
464
464
 
465
465
  Since 0.14.0 · Experimental
@@ -479,12 +479,12 @@ send(
479
479
  source: ConversationId,
480
480
  request: { to: string; message: string; steer?: boolean },
481
481
  key: string,
482
- ): Promise<{ answers: boolean }>;
482
+ ): Promise<{ answers?: boolean }>;
483
483
  ```
484
484
 
485
485
  Since 0.14.0 · Experimental
486
486
 
487
- Sends `message` to the linked session at the address `to`. The session gets it at its next pause (since 0.28.0; before, only with `steer: true`). With `steer: false`, it waits for the session's run to end. `send` returns when the session takes the message, not when it answers, with `{ answers }` (since 0.28.0): whether the session's final answer comes back to the source by itself, which it does only when the source started it.
487
+ Sends `message` to the linked session at the address `to`. The session gets it at its next pause (since 0.28.0; before, only with `steer: true`). With `steer: false`, it waits for the session's run to end. `send` returns when the session takes the message, not when it answers, with `{ answers }` (since 0.28.0): whether the session's final answer comes back to the source by itself, which it does only when the source started it. An older Pi Pocket does not return it.
488
488
 
489
489
  The session that gets the message reads it between tags. Words before it say that the agent of another session wrote it, and that it is a request, not a person's order. They also give the address to write to, and say that its final answer goes back by itself when its run ends ([linked-sessions.md](../linked-sessions.md#a-sessions-final-answer-comes-back-by-itself)).
490
490
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-pocket",
3
- "version": "0.29.0-beta.1",
3
+ "version": "0.29.0-beta.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-pocket",
9
- "version": "0.29.0-beta.1",
9
+ "version": "0.29.0-beta.2",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@earendil-works/chord": "1.5.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-pocket",
3
- "version": "0.29.0-beta.1",
3
+ "version": "0.29.0-beta.2",
4
4
  "description": "A durable, multiplayer, mobile-first web app for Pi agents, built on Pi Durable",
5
5
  "keywords": [
6
6
  "pi",
@@ -197,7 +197,12 @@ function modelsOf(value: unknown): CustomModel[] {
197
197
  ...(window === undefined ? {} : { contextWindow: window }),
198
198
  ...(most === undefined ? {} : { maxTokens: most }),
199
199
  ...(images === undefined ? {} : { images }),
200
- ...(entry?.thinking === undefined ? {} : { thinking: tiersOf(id, entry.thinking) }),
200
+ // No levels at all is how a hand-made reasoning model with every level null reads back, and the form
201
+ // cannot make it: its save leaves the model's thinking as it is.
202
+ ...(entry?.thinking === undefined ||
203
+ (Array.isArray(entry.thinking) && entry.thinking.length === 0)
204
+ ? {}
205
+ : { thinking: tiersOf(id, entry.thinking) }),
201
206
  ...(entry?.cost === undefined ? {} : { cost: priceOf(id, entry.cost) }),
202
207
  });
203
208
  }
@@ -327,7 +332,8 @@ export function tiersOf(id: string, value: unknown): ThinkingTier[] | null {
327
332
  /**
328
333
  * A model's thinking levels as Pi reads its entry: none without `reasoning`; else each level the map does not mark
329
334
  * null, sending what the map says. A level the map leaves out sends its own name, as Pi does, except xhigh and max,
330
- * which Pi then leaves out; and off, which sends nothing.
335
+ * which Pi then leaves out; and off, which sends nothing. A reasoning model whose map marks every level null has
336
+ * none: the form sends `[]` back, and a save leaves that model's thinking as it is.
331
337
  */
332
338
  export function tiersOfEntry(model: Json): ThinkingTier[] | null {
333
339
  if (model.reasoning !== true) {
@@ -72,7 +72,7 @@ export interface LinkedSessionsApi {
72
72
  cwd?: string;
73
73
  },
74
74
  key: string,
75
- ): Promise<{ session: ConversationId; address: string; answers: boolean }>;
75
+ ): Promise<{ session: ConversationId; address: string; answers?: boolean }>;
76
76
  /**
77
77
  * Send `message` to the linked session at address `to`: at its next pause, or with `steer: false` after its run.
78
78
  * `answers` says whether its final answer comes back to the source by itself (the source started it, and did not
@@ -82,7 +82,7 @@ export interface LinkedSessionsApi {
82
82
  source: ConversationId,
83
83
  request: { to: string; message: string; steer?: boolean },
84
84
  key: string,
85
- ): Promise<{ answers: boolean }>;
85
+ ): Promise<{ answers?: boolean }>;
86
86
  /**
87
87
  * Stop the run of the linked session at address `to`, and withdraw what waits in its queue. Idle is a no-op.
88
88
  * Returns whether it was working.
package/types/pocket.d.ts CHANGED
@@ -914,12 +914,12 @@ export interface LinkedSessions {
914
914
  cwd?: string;
915
915
  },
916
916
  key: string,
917
- ): Promise<{ session: ConversationId; address: string; answers: boolean }>;
917
+ ): Promise<{ session: ConversationId; address: string; answers?: boolean }>;
918
918
  /**
919
919
  * Sends `message` to the linked session at the address `to`: at its next pause (since 0.28.0; before, only with
920
920
  * `steer: true`), or with `steer: false` after its run. `answers` (since 0.28.0) says whether its final answer comes
921
921
  * back to the source by itself, which it does when the source started it; otherwise the message asks it to reply
922
- * when an answer is needed.
922
+ * when an answer is needed. An older Pi Pocket does not return it.
923
923
  * @since 0.14.0
924
924
  * @experimental
925
925
  */
@@ -927,7 +927,7 @@ export interface LinkedSessions {
927
927
  source: ConversationId,
928
928
  request: { to: string; message: string; steer?: boolean },
929
929
  key: string,
930
- ): Promise<{ answers: boolean }>;
930
+ ): Promise<{ answers?: boolean }>;
931
931
  /**
932
932
  * Stops the run of the linked session at the address `to`, and withdraws what waits in its queue. When it is idle,
933
933
  * it has no run to stop, and the call only withdraws the queue. `busy` says whether it was working.
package/web/pip.js CHANGED
@@ -1422,6 +1422,69 @@ function PipPanel({ leaving, scrim }) {
1422
1422
  }
1423
1423
 
1424
1424
  /** The mark in the corner: only while PiP works, or has something new. */
1425
+ /**
1426
+ * How far the session's message box rises above the bottom of the window, as it grows (a held-messages bar, a queue,
1427
+ * a long draft) and as the window changes; null while there is none. The mark keeps above it.
1428
+ */
1429
+ function useComposerRise(on) {
1430
+ const [rise, setRise] = useState(null);
1431
+
1432
+ useEffect(() => {
1433
+ if (!on) {
1434
+ return undefined;
1435
+ }
1436
+
1437
+ let box = null;
1438
+ let frame = 0;
1439
+
1440
+ const measure = () => {
1441
+ frame = 0;
1442
+ const top = box?.getBoundingClientRect().top;
1443
+
1444
+ setRise(top === undefined ? null : Math.max(0, Math.round(window.innerHeight - top)));
1445
+ };
1446
+
1447
+ const later = () => {
1448
+ frame ||= requestAnimationFrame(measure);
1449
+ };
1450
+
1451
+ const resized = new ResizeObserver(later);
1452
+
1453
+ // The box comes and goes with the session in view: found again when the page changes.
1454
+ const find = () => {
1455
+ const found = document.querySelector('footer.composer-wrap[data-part="composer"]');
1456
+
1457
+ if (found !== box) {
1458
+ resized.disconnect();
1459
+ box = found;
1460
+
1461
+ if (box) {
1462
+ resized.observe(box);
1463
+ }
1464
+
1465
+ later();
1466
+ }
1467
+ };
1468
+
1469
+ const changes = new MutationObserver(find);
1470
+
1471
+ find();
1472
+ changes.observe(document.body, { childList: true, subtree: true });
1473
+ window.addEventListener("resize", later);
1474
+ window.visualViewport?.addEventListener("resize", later);
1475
+
1476
+ return () => {
1477
+ cancelAnimationFrame(frame);
1478
+ resized.disconnect();
1479
+ changes.disconnect();
1480
+ window.removeEventListener("resize", later);
1481
+ window.visualViewport?.removeEventListener("resize", later);
1482
+ };
1483
+ }, [on]);
1484
+
1485
+ return rise;
1486
+ }
1487
+
1425
1488
  function PipBubble() {
1426
1489
  const { pip } = store.state;
1427
1490
  const unread = pipUnread();
@@ -1430,6 +1493,7 @@ function PipBubble() {
1430
1493
  pip && !pipBoard() && (pip.busy || unread) ? (pip.busy ? "busy" : "news") : null,
1431
1494
  150,
1432
1495
  );
1496
+ const rise = useComposerRise(kept !== null);
1433
1497
 
1434
1498
  if (kept === null) {
1435
1499
  return null;
@@ -1437,6 +1501,7 @@ function PipBubble() {
1437
1501
 
1438
1502
  return html`<button
1439
1503
  class=${`pip-bubble ${kept} ${leaving ? "leaving" : ""}`}
1504
+ style=${rise === null ? undefined : `--composer-rise: ${rise}px`}
1440
1505
  aria-label=${kept === "busy" ? "PiP is working: open PiP" : "PiP has something new: open PiP"}
1441
1506
  title="PiP (Alt+A)"
1442
1507
  onClick=${() => openPip()}
package/web/style.css CHANGED
@@ -8900,6 +8900,25 @@ div.group-head {
8900
8900
  min-width: 0;
8901
8901
  }
8902
8902
 
8903
+ /* On a phone the value goes under the level: side by side, the value had no room left to show. */
8904
+ @media (max-width: 480px) {
8905
+ .model-tier {
8906
+ grid-template-columns: minmax(0, 1fr) auto;
8907
+ }
8908
+
8909
+ .model-tier select {
8910
+ grid-area: 1 / 1;
8911
+ }
8912
+
8913
+ .model-tier button {
8914
+ grid-area: 1 / 2;
8915
+ }
8916
+
8917
+ .model-tier input {
8918
+ grid-area: 2 / 1 / 3 / 3;
8919
+ }
8920
+ }
8921
+
8903
8922
  .model-tier-buttons {
8904
8923
  gap: 8px;
8905
8924
  }
@@ -18954,9 +18973,13 @@ textarea.notes {
18954
18973
  display: block;
18955
18974
  }
18956
18975
 
18957
- /* Above the message box and the jump to the newest message, both at the bottom right. */
18976
+ /* Above the message box and the jump to the newest message, both at the bottom right. The message box grows with
18977
+ * what it holds (a held-messages bar, a queue): its height is measured, and the mark keeps above it. */
18958
18978
  .pip-bubble {
18959
- bottom: calc(176px + env(safe-area-inset-bottom));
18979
+ bottom: max(
18980
+ calc(176px + env(safe-area-inset-bottom)),
18981
+ calc(var(--composer-rise, 0px) + 56px)
18982
+ );
18960
18983
  }
18961
18984
 
18962
18985
  .pip-scrim {