pi-pocket 0.27.0-beta.3 → 0.27.0-beta.4

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/docs/features.md CHANGED
@@ -15,6 +15,7 @@ The full tour. For setup, see the [README](../README.md).
15
15
  - **Keyboard.** Alt+1…9 jumps to a session (hold Alt to see the numbers), Alt+↑/↓ goes to the previous or next one, Alt+N starts a new one (where Ctrl/⌘+1…9 starts it in a favorite folder), Alt+B opens or closes the browser, Alt+E the Files tile, Alt+T turns Show thinking on or off, Alt+V starts or stops dictation, and `?` lists every shortcut. On a computer, a session opens with the caret in its message box, ready to type; on a touch screen it waits for a tap, so the keyboard does not cover the conversation, and on a Mac a session opened with Alt+1…9 or Alt+↑/↓ leaves the box alone, so the next Alt shortcut still works (Option types characters in a box).
16
16
  - **The conversation.** A column of turns, made for phones. Your messages are cards with the sender's avatar (the accent for yours, the sender's color for someone else's), who sent each and when; Pi's replies are plain prose at Appearance's text size, streamed as they come (lists keep a quiet marker column; code, tables, and rich blocks are rounded cards). The **Message time** item under completed replies shows the time, with the date for earlier days, and can be hidden or moved in Appearance → Layout. What Pi does between its words, its thinking and tool calls, folds into one line that says what it did and for how long ("Thought, searched, read 2 files, ran 1 command · 18s"), and opens, as a card, into a timeline: a line per call with a circle for how it went (✓ done, × failed or denied, ! waiting for an approval, a spinner while it runs, ⑂ for a subagent, ✦ for a thought) and what it came to (lines added and removed, lines read, matches, tests passed, an exit code, "needs approval"), and tapped, its input and output, with the diff viewer's diffs for edits (line numbers, syntax colors, and the words that changed) and bash's live output. The newest turn's groups are open and earlier ones closed, unless Appearance's **Keep activity folded** (off by default) keeps them on their line until you open one; a thought alone still follows Show thinking. An approval is a card at the end of its turn (the command, the reason, Deny and Allow; once answered, the call's line says who allowed or denied it), and while Pi works one line, a pulsing dot with the state in the accent (the warning color while it waits for an approval), says what it does (thinking, working, waiting for an approval, retrying) and for how long. With **Show thinking** on in Appearance (or Alt+T, or the launcher), the current thought shows above that line as it streams, and the thoughts in the conversation show their words once written (a thought alone in its group opens, and one on a timeline opens its step). A chevron before the line's dot folds the live thought away, and again brings it back. Alt+T shows a short on/off notice, even while Pi is idle. During tool calls the latest thought stays; a new response clears it until the model shares new thinking. Models that share none say so, rather than showing an old thought as current. A fold holds in that session, also over a reload, until you open it again; the setting is off until you turn it on, in each browser, and while it is off or folded the live thought is neither selected nor drawn. The reading area follows new words until you scroll up in it, and follows again for each new thought. While Pi works, **Steer**, **Queue**, or **Interrupt** beside the model chip says whether a message steers the run, waits for it to end, or stops the run at once (the tool call too, as Stop does, which also withdraws what waits in the queue) and is sent after; Interrupt goes back to Steer after one use, or when Pi stops before it was used, while Steer and Queue stay as chosen; queued messages can be withdrawn, and your own, tapped open, can go back into the message box to change (**Edit**: its words above what you were typing, on a line of their own, with its files), move to Queue or Steer until Pi reads it, or go now as an Interrupt (a second tap confirms; `CONFIRM_INTERRUPT` in `web/composer.js` turns that off): that stops the run and sends only that message, while every other queued message, from everyone, stays queued in its order with its sender and mode (a restart in between loses or repeats none), and so do subagents' reports; with take turns on, moving one to Steer or Interrupt waits for your turn at the wheel, as sending does; Stop (or Esc twice) stops the run. A run stopped in the middle of a tool call ends with a "Stopped." line under its card.
17
17
  - **Getting around on a phone, with one hand.** Back (the swipe, Android's back button, the browser's) goes back to where you were: it closes what opened last (a sheet, the menu's next sheet back to the menu, a file back to the Files tree, back to Changes when the file was opened from there, the Files tile or the Browser panel, the drawer) before it leaves the session, and leaving goes to the session before or to the list, scrolled and searched as you left it. A session opened straight away (a link, a notification) has the list under it, so back does not leave the app. What you use most is a thumb's reach from the bottom edge: the button beside the message box (or a swipe up from it) opens the places, a short sheet of big tiles (Files, Changes, Browser, Artifacts, Chat, Find, Branch, Peeks) with the session menu below them. On the conversation, swipe left for Files and right to go back; in Files, swipe right to go back. Each swipe shows a mark that lights when letting go will act. The top bar leads back to the list (counting other sessions that wait for an approval) and keeps only the buttons with something to say. Every control is a thumb's size on a touch screen (small ones, such as a code block's Copy or a reply's Pin, keep their look and take a wider tap); a tap anywhere on the message box, off its one line of text, still goes to the text; a quick second tap does not land on whatever just slid in under it; tables in replies scroll sideways instead of crushing their columns; a diff's header keeps the file's name on a line of its own on a phone; and the command a peek tile asks about opens its session when tapped. The Files tile and the browser slide in as screens of their own and slide away on back, a file slides in over the tree, and the browser's tools sit on their own row under the address. Drag a sheet down, or the drawer left, to close it. In an iPhone home screen app, which has no back gesture of its own, swipe in from the left edge to go back.
18
+ - **Reply to a passage.** Select words in one of Pi's replies, on a phone or a desktop, and a **Reply** button appears by the selection (below it on a touch screen, where the system's menu sits above). It puts the passage in a quote strip above the message box (tap × to drop it); the next message goes to Pi with the passage first as a Markdown quote (up to 1,500 characters), and shows in the conversation as a quote block above your words.
18
19
  - **Forks.** Tap Pi's reply → More → **Fork from here**: a new session with everything up to that reply, which then goes its own way. Tap one of your messages to **edit it and send it again**, or send any message again, to the same model or another one (a retry). Each makes a new session that forks just before the message; the original stays as it is. A fork gets its own chat (with the pins of what it inherited), a link back to where it came from, and optionally a git worktree of its own.
19
20
  - **A new context.** Menu → **New context** (or `/reset [note]`): Pi starts fresh and no longer sees the messages so far, while everyone still does. An optional handoff note carries over what matters.
20
21
  - **Instructions for Pi.** Menu → **Instructions for Pi** (or `/instructions …`): ground rules Pi gets with every message in this session, such as "use pnpm, not npm". Everyone in the session can see them.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-pocket",
3
- "version": "0.27.0-beta.3",
3
+ "version": "0.27.0-beta.4",
4
4
  "description": "A durable, multiplayer, mobile-first web app for Pi agents, built on Pi Durable",
5
5
  "keywords": [
6
6
  "pi",
package/web/app.js CHANGED
@@ -34,6 +34,7 @@ import { Drawer, RailNav, ResizeHandle, SessionList, toSessions } from "./sessio
34
34
  // Loaded for what it does: it gives replies' Markdown the component for pages, images, and diffs in code blocks.
35
35
  import "./rich.js";
36
36
  import { takeShare } from "./share.js";
37
+ import { QuoteReplyButton } from "./quote-reply.js";
37
38
  import { Sheets } from "./sheets.js";
38
39
  import { defineItem, slotItems } from "./slots.js";
39
40
  import { branchAvailable, headLabel } from "./sheets/branch.js";
@@ -584,6 +585,7 @@ function App() {
584
585
  <${Drawer} />
585
586
  <${PipHost} />
586
587
  <${Sheets} />
588
+ <${QuoteReplyButton} />
587
589
  <${LauncherHost} />
588
590
  <${Notices} />
589
591
  </div>`;
package/web/composer.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  planAvailable,
12
12
  suggestCommands,
13
13
  } from "./commands.js";
14
+ import { withQuote } from "./quote-text.js";
14
15
  import { loadFiles, mentionAt, mentionText, suggestFiles } from "./files.js";
15
16
  import { remember, searchHistory, sentHistory } from "./history.js";
16
17
  import {
@@ -695,7 +696,9 @@ export function Composer() {
695
696
  const canSend =
696
697
  !sending &&
697
698
  !uploading &&
698
- (text.trim() !== "" || files.some((file) => file.state === "done"));
699
+ (text.trim() !== "" ||
700
+ store.state.replyQuote ||
701
+ files.some((file) => file.state === "done"));
699
702
 
700
703
  /** What went out stays for ↑; its pastes are done with. */
701
704
  const sent = (full) => {
@@ -765,7 +768,7 @@ export function Composer() {
765
768
  .map((file) => file.attachment);
766
769
  const ok = await attempt(() =>
767
770
  actions.submit(
768
- full,
771
+ withQuote(store.state.replyQuote, full),
769
772
  attachments,
770
773
  busy ? sendMode : "followUp",
771
774
  inlineFiles && mentionsFiles,
@@ -781,6 +784,7 @@ export function Composer() {
781
784
  }
782
785
 
783
786
  sent(full);
787
+ store.set({ replyQuote: null });
784
788
  forget(files);
785
789
  setFiles([]);
786
790
 
@@ -1466,6 +1470,20 @@ export function Composer() {
1466
1470
  )}
1467
1471
  </div>`
1468
1472
  }
1473
+ ${
1474
+ store.state.replyQuote &&
1475
+ html`<div class="quote-strip" data-part="quote-strip">
1476
+ <${Icon} name="reply" size=${13} />
1477
+ <span class="quote-strip-text">${store.state.replyQuote}</span>
1478
+ <button
1479
+ class="icon-button small"
1480
+ aria-label="Remove the quote"
1481
+ onClick=${() => store.set({ replyQuote: null })}
1482
+ >
1483
+ <${Icon} name="close" size=${12} />
1484
+ </button>
1485
+ </div>`
1486
+ }
1469
1487
  <textarea
1470
1488
  ref=${setBox}
1471
1489
  rows="1"
@@ -0,0 +1,113 @@
1
+ // Select words in one of Pi's replies and reply to just those: a small Reply button appears by the selection (below it
2
+ // on a touch screen, where the system's own menu sits above), and the passage waits above the message box as a quote.
3
+ import { useEffect, useState } from "preact/hooks";
4
+ import { quoteReply } from "./store.js";
5
+ import { html, Icon } from "./ui.js";
6
+
7
+ const coarse = matchMedia("(pointer: coarse)").matches;
8
+ const WIDTH = 92;
9
+ const HEIGHT = 36;
10
+
11
+ /** The selected passage and where to put the button, when the selection lies within one reply of Pi's. */
12
+ function selected() {
13
+ const selection = getSelection();
14
+
15
+ if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
16
+ return null;
17
+ }
18
+
19
+ const range = selection.getRangeAt(0);
20
+ const within = (node) => (node.nodeType === 1 ? node : node.parentElement)?.closest(".reply");
21
+ // A triple-click can end the range at the start of the next block: that end does not count.
22
+ const end =
23
+ range.endOffset === 0 && range.endContainer !== range.startContainer
24
+ ? range.commonAncestorContainer
25
+ : range.endContainer;
26
+ const from = within(range.startContainer);
27
+ const to = within(end) ?? (within(range.commonAncestorContainer) ? from : null);
28
+ const text = selection.toString().trim();
29
+
30
+ // Whoever cannot write to Pi has no message box to put the quote in.
31
+ if (
32
+ !from ||
33
+ from !== to ||
34
+ text === "" ||
35
+ !document.querySelector('[data-part="composer"] textarea')
36
+ ) {
37
+ return null;
38
+ }
39
+
40
+ const rects = [...range.getClientRects()].filter((rect) => rect.width > 0);
41
+
42
+ if (rects.length === 0) {
43
+ return null;
44
+ }
45
+
46
+ const first = rects[0];
47
+ const last = rects[rects.length - 1];
48
+ const below = coarse || first.top < HEIGHT + 12;
49
+ const top = below ? last.bottom + 10 : first.top - HEIGHT - 8;
50
+ const anchor = below ? last.right : first.left;
51
+ const left = Math.max(8, Math.min(anchor - (below ? WIDTH : 0), innerWidth - WIDTH - 8));
52
+
53
+ // A button that would fall off the screen (the selection runs past it) is not shown.
54
+ if (top < 0 || top > (visualViewport?.height ?? innerHeight) - HEIGHT) {
55
+ return null;
56
+ }
57
+
58
+ return { text, top, left };
59
+ }
60
+
61
+ export function QuoteReplyButton() {
62
+ const [at, setAt] = useState(null);
63
+
64
+ useEffect(() => {
65
+ let timer = 0;
66
+
67
+ const look = () => {
68
+ clearTimeout(timer);
69
+ // Dragging a handle changes the selection all the time: show the button once it holds still.
70
+ timer = setTimeout(() => setAt(selected()), 160);
71
+ };
72
+
73
+ document.addEventListener("selectionchange", look);
74
+ addEventListener("scroll", look, true);
75
+ addEventListener("resize", look);
76
+
77
+ return () => {
78
+ clearTimeout(timer);
79
+ document.removeEventListener("selectionchange", look);
80
+ removeEventListener("scroll", look, true);
81
+ removeEventListener("resize", look);
82
+ };
83
+ }, []);
84
+
85
+ if (!at) {
86
+ return null;
87
+ }
88
+
89
+ const reply = () => {
90
+ quoteReply(at.text);
91
+ getSelection()?.removeAllRanges();
92
+ setAt(null);
93
+
94
+ if (!coarse) {
95
+ requestAnimationFrame(() =>
96
+ document.querySelector('[data-part="composer"] textarea')?.focus(),
97
+ );
98
+ }
99
+ };
100
+
101
+ // Pressing the button must not take the selection away before the click reads it.
102
+ return html`<button
103
+ class="quote-reply-button"
104
+ data-part="quote-reply-button"
105
+ style=${`top:${at.top}px;left:${at.left}px`}
106
+ onPointerDown=${(event) => event.preventDefault()}
107
+ onMouseDown=${(event) => event.preventDefault()}
108
+ onClick=${reply}
109
+ >
110
+ <${Icon} name="reply" size=${14} stroke=${2} />
111
+ <span>Reply</span>
112
+ </button>`;
113
+ }
@@ -0,0 +1,37 @@
1
+ // A reply to a passage: the passage goes first as a Markdown quote, then what the person wrote.
2
+
3
+ /** The most of a passage that goes into a message. */
4
+ export const QUOTE_MAX = 1500;
5
+
6
+ /** A passage as quote lines ("> …"), cut at QUOTE_MAX characters. */
7
+ export function quoteLines(passage) {
8
+ const text = passage.trim().replace(/\r\n?/g, "\n");
9
+ const cut = text.length > QUOTE_MAX ? `${text.slice(0, QUOTE_MAX).trimEnd()}…` : text;
10
+
11
+ return cut
12
+ .split("\n")
13
+ .map((line) => (line === "" ? ">" : `> ${line}`))
14
+ .join("\n");
15
+ }
16
+
17
+ /** The message to send: the quoted passage, a blank line, then the reply. */
18
+ export function withQuote(passage, reply) {
19
+ return passage ? `${quoteLines(passage)}\n\n${reply}`.trimEnd() : reply;
20
+ }
21
+
22
+ /** A message that starts with quote lines, split into the passage and the rest; null when it starts with none. */
23
+ export function splitQuote(text) {
24
+ const match = /^((?:>[^\n]*(?:\n|$))+)\n*([\s\S]*)$/.exec(text);
25
+
26
+ if (!match) {
27
+ return null;
28
+ }
29
+
30
+ const passage = match[1]
31
+ .replace(/\n$/, "")
32
+ .split("\n")
33
+ .map((line) => line.replace(/^> ?/, ""))
34
+ .join("\n");
35
+
36
+ return { passage, rest: match[2] };
37
+ }
package/web/store.js CHANGED
@@ -144,6 +144,8 @@ export const store = {
144
144
  auth: null,
145
145
  /** A transcript message the next chat message discusses: `{ entryId, text }`. */
146
146
  chatQuote: null,
147
+ /** A passage of Pi's reply the next message to Pi quotes. */
148
+ replyQuote: null,
147
149
  /** Text to put into the message box to Pi: `{ text, n }`, picked up by the composer. */
148
150
  composerInsert: null,
149
151
  /** Pi's prompt templates for a conversation's folder: `{ conversationId, at, list }`. */
@@ -275,6 +277,7 @@ function peopleFor(id, reads = store.state.chatReads) {
275
277
  presence: [],
276
278
  notes: null,
277
279
  chatQuote: null,
280
+ replyQuote: null,
278
281
  chatRead: id === null ? 0 : (reads[id] ?? 0),
279
282
  };
280
283
  }
@@ -1685,6 +1688,11 @@ export function insertIntoComposer(text, files = [], { inline = false } = {}) {
1685
1688
  }));
1686
1689
  }
1687
1690
 
1691
+ /** Quote a passage of Pi's reply: it waits above the message box, and the next message goes out with it. */
1692
+ export function quoteReply(text) {
1693
+ store.set({ replyQuote: text });
1694
+ }
1695
+
1688
1696
  /** Open the chat to discuss a transcript message: the next chat message quotes it. */
1689
1697
  export function discuss(entryId, text) {
1690
1698
  store.set((state) => ({
package/web/style.css CHANGED
@@ -17642,3 +17642,63 @@ pre.gallery-code {
17642
17642
  margin-left: 0;
17643
17643
  }
17644
17644
  }
17645
+
17646
+ /* Reply to a selected passage of Pi's answer: the button by the selection, the quote above the message box, and the
17647
+ quote atop the sent message. */
17648
+ .quote-reply-button {
17649
+ position: fixed;
17650
+ z-index: 70;
17651
+ display: inline-flex;
17652
+ align-items: center;
17653
+ justify-content: center;
17654
+ gap: 6px;
17655
+ min-width: 92px;
17656
+ height: 36px;
17657
+ padding: 0 12px;
17658
+ border: 1px solid var(--hair-2);
17659
+ border-radius: 999px;
17660
+ background: var(--card);
17661
+ color: var(--text);
17662
+ font: inherit;
17663
+ font-size: 13px;
17664
+ font-weight: 600;
17665
+ box-shadow: 0 4px 16px rgb(0 0 0 / 0.25);
17666
+ cursor: pointer;
17667
+ -webkit-user-select: none;
17668
+ user-select: none;
17669
+ }
17670
+
17671
+ .quote-strip {
17672
+ display: flex;
17673
+ align-items: center;
17674
+ gap: 8px;
17675
+ margin: 0 0 6px;
17676
+ padding: 6px 6px 6px 10px;
17677
+ border-left: 2px solid var(--accent);
17678
+ border-radius: var(--r-row);
17679
+ background: var(--card);
17680
+ color: var(--muted);
17681
+ font-size: 12px;
17682
+ }
17683
+
17684
+ .quote-strip-text {
17685
+ flex: 1;
17686
+ min-width: 0;
17687
+ display: -webkit-box;
17688
+ -webkit-line-clamp: 2;
17689
+ -webkit-box-orient: vertical;
17690
+ overflow: hidden;
17691
+ white-space: pre-line;
17692
+ }
17693
+
17694
+ .reply-quote {
17695
+ margin: 0 0 0.4rem;
17696
+ padding-left: 0.7rem;
17697
+ border-left: 2px solid var(--hair-2);
17698
+ color: var(--muted);
17699
+ white-space: pre-line;
17700
+ display: -webkit-box;
17701
+ -webkit-line-clamp: 4;
17702
+ -webkit-box-orient: vertical;
17703
+ overflow: hidden;
17704
+ }
package/web/transcript.js CHANGED
@@ -9,6 +9,7 @@ import { browserAvailable, setBrowserOpen } from "./browser.js";
9
9
  import { describeCall, describersRevision } from "./calls.js";
10
10
  import { DiffBlock } from "./diff.js";
11
11
  import { LinkedSessions } from "./linked-sessions.js";
12
+ import { splitQuote } from "./quote-text.js";
12
13
  import { fromServer } from "./seen.js";
13
14
  import { defineItem, slotItems, slotKey } from "./slots.js";
14
15
  import { Highlighted, InlineArtifact } from "./rich.js";
@@ -470,7 +471,7 @@ function UserEntry({ entry, view, users }) {
470
471
  ${
471
472
  via
472
473
  ? html`<${FencedText} text=${body} />`
473
- : html`<${MentionedText} text=${skill ? skill[3] : body} />`
474
+ : html`<${QuotedText} text=${skill ? skill[3] : body} />`
474
475
  }
475
476
  </div>`
476
477
  }
@@ -513,6 +514,18 @@ function UserEntry({ entry, view, users }) {
513
514
  </div>`;
514
515
  }
515
516
 
517
+ /** A message that opens with a quoted passage of Pi's reply: the passage in a quote block, then the words. */
518
+ function QuotedText({ text }) {
519
+ const quote = splitQuote(text);
520
+
521
+ if (!quote) {
522
+ return html`<${MentionedText} text=${text} />`;
523
+ }
524
+
525
+ return html`<blockquote class="reply-quote" data-part="reply-quote">${quote.passage}</blockquote>
526
+ ${quote.rest && html`<${MentionedText} text=${quote.rest} />`}`;
527
+ }
528
+
516
529
  function Collapsible({ text, limit = 600 }) {
517
530
  const [open, setOpen] = useState(false);
518
531
 
package/web/ui.js CHANGED
@@ -1022,6 +1022,7 @@ const ICONS = {
1022
1022
  pip: "M12 20a8 8 0 100-16 8 8 0 000 16zM8.5 11a3.5 3.5 0 013.5-3.5",
1023
1023
  more: "M5 12h.01M12 12h.01M19 12h.01",
1024
1024
  close: "M6 6l12 12M18 6L6 18",
1025
+ reply: "M9 14L4 9l5-5M4 9h10a6 6 0 016 6v4",
1025
1026
  send: "M12 19V5M5 12l7-7 7 7",
1026
1027
  stop: "M7 7h10v10H7z",
1027
1028
  mic: "M12 3a3 3 0 00-3 3v6a3 3 0 006 0V6a3 3 0 00-3-3zM19 11a7 7 0 01-14 0M12 18v3",