pi-pocket 0.28.0 → 0.28.2-beta.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.
Files changed (44) hide show
  1. package/docs/customizing.md +1 -1
  2. package/docs/features.md +3 -3
  3. package/docs/map.md +1 -1
  4. package/npm-shrinkwrap.json +69 -65
  5. package/package.json +8 -8
  6. package/src/server/alerts.ts +21 -8
  7. package/src/server/anthropic-shape.ts +4 -3
  8. package/src/server/app.ts +18 -3
  9. package/src/server/artifact-state.ts +1 -1
  10. package/src/server/background.ts +1 -1
  11. package/src/server/cache-keeper.ts +1 -0
  12. package/src/server/commands.ts +386 -77
  13. package/src/server/compaction.ts +56 -2
  14. package/src/server/design/bundle.ts +1 -1
  15. package/src/server/docs.ts +43 -1
  16. package/src/server/extension-points.ts +1 -1
  17. package/src/server/extension-request.ts +1 -1
  18. package/src/server/extensions/codemode.ts +1 -1
  19. package/src/server/extensions/schedules.ts +1 -1
  20. package/src/server/extensions/subagents.ts +1 -1
  21. package/src/server/goals.ts +1 -1
  22. package/src/server/hidden.ts +1 -1
  23. package/src/server/host.ts +1 -1
  24. package/src/server/http/conversation-routes.ts +22 -0
  25. package/src/server/linked-sessions.ts +1 -1
  26. package/src/server/memory.ts +1 -1
  27. package/src/server/pip-compact.ts +1 -1
  28. package/src/server/pip.ts +9 -1
  29. package/src/server/public-links.ts +1 -1
  30. package/src/server/repo-watches.ts +1 -1
  31. package/src/server/resend.ts +26 -9
  32. package/src/server/room.ts +17 -1
  33. package/src/server/running.ts +3 -0
  34. package/src/server/schedules.ts +112 -12
  35. package/src/server/shell.ts +1 -1
  36. package/src/server/spend.ts +1 -1
  37. package/src/server/watches.ts +1 -1
  38. package/types/pocket.d.ts +1 -1
  39. package/web/composer.js +101 -3
  40. package/web/running-board.js +1 -0
  41. package/web/sheets/schedules.js +6 -0
  42. package/web/store.js +7 -0
  43. package/web/style.css +37 -0
  44. package/web/transcript.js +15 -0
package/web/composer.js CHANGED
@@ -307,14 +307,14 @@ const SEND_MODES = [
307
307
  [
308
308
  "interrupt",
309
309
  "Interrupt",
310
- "Stops the run right now (also its tool call) and clears the queue, then sends it",
310
+ "Stops the run right now (also its tool call), then sends it. The queued messages stay queued",
311
311
  ],
312
312
  ];
313
313
 
314
314
  /** What a send mode does, for a queued message's buttons. */
315
315
  const modeHint = (mode) => SEND_MODES.find(([value]) => value === mode)[2];
316
316
 
317
- /** What Interrupt does to a message waiting in the queue: the others there stay, unlike the composer's Interrupt. */
317
+ /** What Interrupt does to a message waiting in the queue: the others there stay queued. */
318
318
  const QUEUED_INTERRUPT_HINT =
319
319
  "Stops the run right now (also its tool call), then sends this one. The other queued messages stay queued";
320
320
 
@@ -437,6 +437,87 @@ function DriverBar() {
437
437
  }
438
438
 
439
439
  /** Plan mode: Pi proposes and changes nothing until someone here approves its plan. */
440
+ /**
441
+ * What a Stop held out of the queue: it waits until someone sends it. Send sends them all, in their order; Show lists
442
+ * them, each with Edit (its sender's) and a × to withdraw it.
443
+ */
444
+ function HeldBar({ blocked, onEdit }) {
445
+ const { view, me, users } = store.state;
446
+ const held = view.held ?? [];
447
+ const [open, setOpen] = useState(false);
448
+
449
+ if (held.length === 0) {
450
+ return null;
451
+ }
452
+
453
+ const steer = canSteer();
454
+ const heldBy = (item) =>
455
+ item.by === undefined
456
+ ? ""
457
+ : item.by === me?.id
458
+ ? " · you"
459
+ : ` · ${users.find((user) => user.id === item.by)?.name ?? "someone"}`;
460
+
461
+ return html`<div class="held-bar" data-part="held">
462
+ <span class="grow">
463
+ <strong>${held.length === 1 ? "1 message held." : `${held.length} messages held.`}</strong> Stop kept ${held.length === 1 ? "it" : "them"} from Pi until sent.
464
+ </span>
465
+ <button class="link small" aria-expanded=${open} onClick=${() => setOpen(!open)}>
466
+ ${open ? "Hide" : "Show"}
467
+ </button>
468
+ ${
469
+ steer &&
470
+ !blocked &&
471
+ html`<button
472
+ class="button small primary"
473
+ title="Send them to Pi, in their order"
474
+ onClick=${() => attempt(actions.sendHeld)}
475
+ >
476
+ Send
477
+ </button>`
478
+ }
479
+ ${
480
+ open &&
481
+ html`<div class="held-list">
482
+ ${held.map(
483
+ (item) => html`<div class="queued" key=${item.key}>
484
+ <span class="queued-mode">
485
+ ${item.mode === "steer" ? "Steer" : "Queue"}
486
+ <span class="muted">${heldBy(item)}</span>
487
+ </span>
488
+ <span class="queued-text">${(item.text ?? "").replace(FROM, "")}</span>
489
+ ${
490
+ steer &&
491
+ !blocked &&
492
+ item.by !== undefined &&
493
+ item.by === me?.id &&
494
+ html`<button
495
+ class="link small"
496
+ title="Take it back into the message box to change it"
497
+ onClick=${() => onEdit(item)}
498
+ >
499
+ Edit
500
+ </button>`
501
+ }
502
+ ${
503
+ steer &&
504
+ (!blocked || item.by === me?.id) &&
505
+ html`<button
506
+ class="icon-button small queued-remove"
507
+ aria-label="Withdraw"
508
+ title="Withdraw: Pi will not get it"
509
+ onClick=${() => attempt(() => actions.dropHeld(item.key))}
510
+ >
511
+ <${Icon} name="close" size=${13} />
512
+ </button>`
513
+ }
514
+ </div>`,
515
+ )}
516
+ </div>`
517
+ }
518
+ </div>`;
519
+ }
520
+
440
521
  function PlanBar({ blocked }) {
441
522
  const { view } = store.state;
442
523
 
@@ -1090,6 +1171,22 @@ export function Composer() {
1090
1171
  }
1091
1172
  };
1092
1173
 
1174
+ // Edit on a held message: the same, for one a Stop held.
1175
+ const editHeld = async (item) => {
1176
+ if (takingBack.has(item.key)) {
1177
+ return;
1178
+ }
1179
+
1180
+ takingBack.add(item.key);
1181
+ const back = await attempt(() => actions.editHeld(item.key, conversationId));
1182
+
1183
+ takingBack.delete(item.key);
1184
+
1185
+ if (back) {
1186
+ keepBack(conversationId, back);
1187
+ }
1188
+ };
1189
+
1093
1190
  /** Put a message sent before into the box, to send again or change. */
1094
1191
  const recall = (value, at = value.length) => {
1095
1192
  edit(value, at);
@@ -1429,6 +1526,7 @@ export function Composer() {
1429
1526
  return html`<footer class="composer-wrap" data-part="composer">
1430
1527
  <div class="dock" data-part="dock" ref=${dock}>
1431
1528
  <${TypingLine} where="pi" />
1529
+ <${HeldBar} blocked=${blocked} onEdit=${editHeld} />
1432
1530
  ${
1433
1531
  // How many wait: shown when the queue does not show them all (`dock.js`).
1434
1532
  inbox.length > 0 &&
@@ -1961,7 +2059,7 @@ function StopButton() {
1961
2059
  class="stop-button"
1962
2060
  data-part="composer-button stop-button"
1963
2061
  aria-label="Stop"
1964
- title="Stop (Esc twice)"
2062
+ title="Stop (Esc twice). Queued messages are held until someone sends them"
1965
2063
  onClick=${() => attempt(actions.abort)}
1966
2064
  >
1967
2065
  <span class="stop-square" aria-hidden="true"></span>
@@ -1142,6 +1142,7 @@ function Row({
1142
1142
  <span class="rb-sched-rel">
1143
1143
  ${relative(schedule.next, now)}
1144
1144
  ${schedule.every ? ` · ${schedule.runs}×` : ""}
1145
+ ${schedule.skipped > 0 ? ` · skipped ${schedule.skipped}×` : ""}
1145
1146
  </span>
1146
1147
  </button>`,
1147
1148
  )
@@ -56,6 +56,12 @@ export function SchedulesSheet() {
56
56
  <div class="muted small">
57
57
  ${schedule.repeat ? `${schedule.repeat} · next ${formatWhen(schedule.next)}` : formatWhen(schedule.next)} · set by ${setBy(schedule.by)}${archived ? " · session archived" : ""}
58
58
  </div>
59
+ ${
60
+ schedule.skipped > 0 &&
61
+ html`<div class="muted small" data-part="schedule-skipped">
62
+ Skipped ${schedule.skipped === 1 ? "once" : `${schedule.skipped} times`}, last ${formatWhen(schedule.skippedAt)}: its last message still waits in the queue
63
+ </div>`
64
+ }
59
65
  </div>
60
66
  ${
61
67
  steer &&
package/web/store.js CHANGED
@@ -105,6 +105,7 @@ const emptyView = () => ({
105
105
  watch: null,
106
106
  branch: null,
107
107
  subagentsHeld: null,
108
+ held: [],
108
109
  });
109
110
 
110
111
  // ─── Each session's panel ──────────────────────────────────────────────────────────
@@ -1682,6 +1683,8 @@ function mergeView(current, data) {
1682
1683
  decisions: data.decisions ?? base.decisions,
1683
1684
  plan: data.plan ?? base.plan,
1684
1685
  schedules: data.schedules ?? base.schedules,
1686
+ // What a Stop held out of the queue: it waits until someone sends it.
1687
+ held: data.held ?? base.held,
1685
1688
  // No goal is null, which the server sends too: only a missing field keeps the last value.
1686
1689
  goal: data.goal === undefined ? base.goal : data.goal,
1687
1690
  // The session's PR watch, or null: the same.
@@ -2707,6 +2710,10 @@ export const actions = {
2707
2710
  /** Move one's own queued message to "steer" or "followUp", or send it now with "interrupt". */
2708
2711
  move: (submissionId, mode) => api(`c/${current()}/move`, { submissionId, mode }),
2709
2712
  editQueued: (submissionId, id = current()) => api(`c/${id}/edit-queued`, { submissionId }),
2713
+ /** What a Stop held: send them all, or drop one or take it back into the box, by its key. */
2714
+ sendHeld: () => api(`c/${current()}/held`, { action: "send" }),
2715
+ dropHeld: (key) => api(`c/${current()}/held`, { action: "drop", key }),
2716
+ editHeld: (key, id = current()) => api(`c/${id}/held`, { action: "edit", key }),
2710
2717
  configure: (change) => api(`c/${current()}/configure`, change),
2711
2718
  /** The owner's model and thinking level for new sessions, `{ provider, modelId, thinkingLevel }`; null clears it. */
2712
2719
  setDefaultModel: (choice) => api("settings", { defaultModel: choice }),
package/web/style.css CHANGED
@@ -10095,6 +10095,7 @@ textarea.notes {
10095
10095
  trust) and for a watch that had to stop. */
10096
10096
  .driver-bar,
10097
10097
  .plan-bar,
10098
+ .held-bar,
10098
10099
  .goal-bar,
10099
10100
  .watch-bar,
10100
10101
  .trust-bar,
@@ -10115,6 +10116,7 @@ textarea.notes {
10115
10116
 
10116
10117
  .driver-bar::before,
10117
10118
  .plan-bar::before,
10119
+ .held-bar::before,
10118
10120
  .goal-bar::before,
10119
10121
  .watch-bar::before,
10120
10122
  .trust-bar::before,
@@ -10151,6 +10153,41 @@ textarea.notes {
10151
10153
  margin-left: auto;
10152
10154
  }
10153
10155
 
10156
+ /* Messages a Stop held: their words, then Show and Send; the list under them scrolls past a few rows. */
10157
+ .held-bar {
10158
+ --tone: var(--accent);
10159
+ }
10160
+
10161
+ .held-bar > .grow {
10162
+ flex: 1 1 14rem;
10163
+ }
10164
+
10165
+ .held-bar > .link {
10166
+ margin-left: auto;
10167
+ }
10168
+
10169
+ .held-list {
10170
+ flex-basis: 100%;
10171
+ display: flex;
10172
+ flex-direction: column;
10173
+ gap: 6px;
10174
+ max-height: min(24vh, 10rem);
10175
+ overflow-y: auto;
10176
+ overscroll-behavior: contain;
10177
+ /* Room for a ×'s larger touch area, which would make the list scroll for 4 px. */
10178
+ padding-block: 4px;
10179
+ margin-block: -4px;
10180
+ }
10181
+
10182
+ .held-list > .queued > .link {
10183
+ flex: none;
10184
+ }
10185
+
10186
+ /* Words, not a button as in the queue: on the row's middle line, as its label is. */
10187
+ .held-list .queued-text {
10188
+ align-self: center;
10189
+ }
10190
+
10154
10191
  /* Trust choices keep the three existing decisions, with a selected radio and soft accent card. */
10155
10192
  .trust-choice {
10156
10193
  justify-content: flex-start;
package/web/transcript.js CHANGED
@@ -4074,6 +4074,15 @@ export function Transcript() {
4074
4074
  const { sessions, sessionsLoaded } = store.state;
4075
4075
  const source =
4076
4076
  conversation.forkedFrom && sessions.find((each) => each.id === conversation.forkedFrom.id);
4077
+ // The last run failed with no answer that says so (its compaction failed, say): the line stays until a run starts.
4078
+ // A failed answer after the newest message says it under itself already.
4079
+ const said =
4080
+ entries.findLast((entry) => entry?.kind === "assistant" || entry?.kind === "user")
4081
+ ?.stopReason === "error";
4082
+ const failure =
4083
+ busy || said
4084
+ ? undefined
4085
+ : sessions.find((each) => each.id === conversation.id && each.failed === true)?.failure;
4077
4086
 
4078
4087
  return html`<main class="scroller" ref=${scroller} onScroll=${onScroll}>
4079
4088
  <div
@@ -4131,6 +4140,12 @@ export function Transcript() {
4131
4140
  ${approvals.map(
4132
4141
  (approval) => html`<${ApprovalCard} key=${approval.id} approval=${approval} />`,
4133
4142
  )}
4143
+ ${
4144
+ failure &&
4145
+ html`<div class="error-box run-failure" data-part="run-failure" role="alert">
4146
+ Run failed: ${failure}
4147
+ </div>`
4148
+ }
4134
4149
  ${
4135
4150
  (busy || compacting) &&
4136
4151
  html`<${LiveLine}