pi-studio 0.11.6 → 0.11.7

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/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ All notable changes to `pi-studio` are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.11.7] — 2026-11-02
8
+
9
+ This release brings the REPL pane up to pi-repl 0.11.7.
10
+
11
+ ### Added
12
+ - The agent is told what's new in the REPL record: your sends and notes, other clients' sends, and output that arrived late. Studio adds the entries it hasn't been shown when a run starts and to `studio_repl_send` and `studio_repl_status` results, for the session in the REPL pane and the sessions the agent used. `studio_repl_status` also lists recent entries (`recent`) or one (`entryId`). `PI_REPL_RECORD_ACTIVITY=send` keeps this to results, and `off` stops it; unset, it follows `PI_REPL_PANE_ACTIVITY`. Under **Shared REPL Record** the page says when new entries go to the agent and its model provider, and in Pi's terminal each report is one line until expanded.
13
+ - Your REPL sends and notes are recorded under your name. Quick send shows **Sending as** with ✎ to change the name for this page. The default is `PI_REPL_USER_NAME`, then the name saved with pi-repl's `/repl name` or `agent-repl name`, then "User". The record, the page and the agent show who sent each entry and how, such as "Ana · via Pi Studio" or "Sam · via terminal", as pi-repl and agent-markdown-preview do.
14
+
15
+ ### Changed
16
+ - A send that outlasts its wait keeps the session until its code finishes, then records its output. Before, its entry stayed "timeout" with the output so far. The page's card shows "Running…", and the agent is told not to send it again.
17
+ - A send from the page is recorded or not sent. If the session's shared record can't be used, another client holds the session or the first entry can't be written, Studio says why and sends nothing. The agent's sends still run when the record's details can't be used, as in pi-repl.
18
+ - A session's shared record is used only from the record directory its key names, as in pi-repl 0.11.7. Studio sets the key when it starts a session or first writes to one, and refuses a record in another or replaced temporary directory, such as one an ssh login with a different `TMPDIR` made; the record panel says why. Studio no longer sets record details on every session it lists.
19
+ - Studio doesn't paste into, or send Ctrl+C to, a session where pi-repl takes code through its own helper, such as pi-repl's LFortran session. It says "This session takes code only through pi-repl."
20
+ - A record entry shows who sent it in place of its kind, origin and time, which are in its tooltip.
21
+ - In the new layout, the REPL pane's **Start cmd** field has a plain border while you type in it, like the other text fields, in place of the browser's blue ring.
22
+
23
+ ### Fixed
24
+ - **File → Open file…** is no longer sometimes refused with "Checkpoint the current editor before opening a file." just after a reload, while a background save of an unchanged checkpoint was still finishing.
25
+
7
26
  ## [0.11.6] — 2026-10-30
8
27
 
9
28
  ### Added
package/README.md CHANGED
@@ -136,7 +136,7 @@ Icons in exported PDFs need Mermaid CLI 11.12+ (`npm install -g @mermaid-js/merm
136
136
 
137
137
  ### REPL
138
138
 
139
- The REPL pane runs code in tmux sessions. It can start its own, and it shares a record of submissions and output with [pi-repl](https://github.com/omaclaren/pi-repl) when both use the same session. Pane echo sets how much submitted code goes into the raw tmux history, as in pi-repl: up to 20 lines with Summary, the default, up to 40 with Full, and none with Off. The record format is in [`shared/REPL_SESSION_RECORD_PROTOCOL.md`](./shared/REPL_SESSION_RECORD_PROTOCOL.md).
139
+ The REPL pane runs code in tmux sessions. It can start its own, and it shares a record of submissions and output with [pi-repl](https://github.com/omaclaren/pi-repl) when both use the same session. Pane echo sets how much submitted code goes into the raw tmux history, as in pi-repl: up to 20 lines with Summary, the default, up to 40 with Full, and none with Off. Your sends and notes are recorded under your name (**Sending as**, under Quick send). The agent is told of record entries it hasn't seen, such as your sends, other clients' sends and late output, when a run starts and with its REPL tools' results. The record format is in [`shared/REPL_SESSION_RECORD_PROTOCOL.md`](./shared/REPL_SESSION_RECORD_PROTOCOL.md).
140
140
 
141
141
  ### Side questions
142
142
 
@@ -157,6 +157,8 @@ For a container, `/studio --no-browser --listen-all --port 4321` listens on all
157
157
  | `BRAVE_API_KEY` | Enables web search in side questions |
158
158
  | `PI_STUDIO_FONT_MONO`, `PI_STUDIO_FONT_UI`, `PI_STUDIO_FONT_PROSE` | CSS font stacks for code, interface and previews |
159
159
  | `PI_STUDIO_REPL_ECHO_MODE` | Default pane echo for `studio_repl_send`: `summary` (the default), `off` or `full` |
160
+ | `PI_REPL_USER_NAME` | The name your REPL sends and notes are recorded under, ahead of the name saved with pi-repl |
161
+ | `PI_REPL_RECORD_ACTIVITY` | Whether the agent is told of new REPL record entries: `on` (the default: at a run's start and in REPL tool results), `send` (in results only) or `off`; unset, it follows `PI_REPL_PANE_ACTIVITY` |
160
162
  | `PI_STUDIO_PANDOC_TIMEOUT_MS`, `PI_STUDIO_LATEX_TIMEOUT_MS`, `PI_STUDIO_MERMAID_TIMEOUT_MS` | Export time limits |
161
163
 
162
164
  Installing pi-studio also adds `pi-studio-dark` and `pi-studio-light` to Pi's themes, without changing your current theme.
@@ -688,6 +688,20 @@
688
688
  error: "",
689
689
  };
690
690
  let replTmuxAvailable = null;
691
+ // Whether the agent is told of new record entries ("on", "send" or "off"), from Studio's server.
692
+ let replRecordActivity = "off";
693
+ // The name this page's sends and notes are recorded under: chosen here and kept in this
694
+ // browser, else the default from Studio's server (PI_REPL_USER_NAME, then pi-repl's saved
695
+ // name, then "User"). Read once, so another tab choosing a name later leaves this page alone.
696
+ const REPL_PERSON_NAME_STORAGE_KEY = "piStudio.replPersonName.v1";
697
+ let replPersonName = loadReplPersonName();
698
+ let replPersonNameDefault = "User";
699
+ let replPersonNameSource = "default";
700
+ let replSenderEditing = false;
701
+ // What's typed in the name field, kept as it's typed so a redraw by any route keeps it (Sol).
702
+ let replSenderDraft = "";
703
+ // After Enter or Esc in the name field, the cursor goes back to ✎.
704
+ let replSenderReturnFocus = false;
691
705
  let replSessions = [];
692
706
  let replActiveSessionName = "";
693
707
  // Studio's selection as this page last adopted it, with its `shown`, and this page's
@@ -1609,6 +1623,8 @@
1609
1623
  runtime: typeof session.runtime === "string" ? session.runtime : "unknown",
1610
1624
  label: typeof session.label === "string" && session.label.trim() ? session.label.trim() : sessionName,
1611
1625
  source: typeof session.source === "string" ? session.source : "tmux",
1626
+ // Why Studio won't use its shared record from here, such as another record directory (pi-repl's P0).
1627
+ recordRefusal: typeof session.recordRefusal === "string" ? session.recordRefusal.slice(0, 1000) : "",
1612
1628
  };
1613
1629
  }
1614
1630
 
@@ -1841,9 +1857,10 @@
1841
1857
 
1842
1858
  function reconcileReplQuickPending() {
1843
1859
  if (!replQuickPending) return false;
1844
- const entry = replJournalEntries.find((candidate) => candidate.requestId === replQuickPending.requestId);
1860
+ // By its entry: the record gives a page's send its own request ID (studio:send:).
1861
+ const entry = replJournalEntries.find((candidate) => candidate.id === replQuickPending.journalEntryId);
1845
1862
  if (!entry || entry.status === "sending") return false;
1846
- return settleReplQuickPending(entry.requestId, entry.status !== "error");
1863
+ return settleReplQuickPending(replQuickPending.requestId, entry.status !== "error");
1847
1864
  }
1848
1865
 
1849
1866
  function updateReplQuickComposerActions() {
@@ -1889,6 +1906,7 @@
1889
1906
  target: session.target,
1890
1907
  tmuxSessionId: session.tmuxSessionId,
1891
1908
  tmuxSessionCreatedAt: session.tmuxSessionCreatedAt,
1909
+ recordRefusal: session.recordRefusal,
1892
1910
  })));
1893
1911
  }
1894
1912
 
@@ -2134,7 +2152,8 @@
2134
2152
  // its frame runs: composing, typing, a drag or focus elsewhere can start in between
2135
2153
  // (Sol, Astra). Composing holds even a forced redraw.
2136
2154
  function replRedrawMustWait(force) {
2137
- return replQuickComposing || (!force && isReplControlFocused() && !canRedrawReplUnderFocus());
2155
+ // Not under the name field while it's open either, even when forced: it would close mid-edit.
2156
+ return replQuickComposing || (replSenderEditing && isReplSenderNameFocused()) || (!force && isReplControlFocused() && !canRedrawReplUnderFocus());
2138
2157
  }
2139
2158
 
2140
2159
  function deferReplRedraw(force) {
@@ -2287,6 +2306,7 @@
2287
2306
  restoreReplQuickComposerCursor(cursor);
2288
2307
  applyReplQuickRefocus();
2289
2308
  if (replQuickFocusRequested) focusReplQuickComposer();
2309
+ focusReplSenderNameIfEditing();
2290
2310
  });
2291
2311
  }
2292
2312
 
@@ -2568,6 +2588,94 @@
2568
2588
  return "… " + formatCompactNumber(value.length - REPL_JOURNAL_OUTPUT_MAX_CHARS) + " earlier chars omitted …\n" + value.slice(value.length - REPL_JOURNAL_OUTPUT_MAX_CHARS);
2569
2589
  }
2570
2590
 
2591
+ // pi-repl's rule for a person's name (shared/repl-person.js): trimmed, at most 80
2592
+ // characters, nothing that could break or disguise it where it's shown.
2593
+ function validateReplPersonName(value) {
2594
+ if (typeof value !== "string") return { error: "a name must be text" };
2595
+ const name = value.trim();
2596
+ if (!name) return { error: "the name is empty" };
2597
+ if ([...name].length > 80) return { error: "the name is longer than 80 characters" };
2598
+ if (/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/u.test(name)) return { error: "the name has control characters" };
2599
+ return { name };
2600
+ }
2601
+
2602
+ function loadReplPersonName() {
2603
+ try {
2604
+ const checked = validateReplPersonName(window.localStorage ? window.localStorage.getItem(REPL_PERSON_NAME_STORAGE_KEY) : null);
2605
+ return checked.error ? "" : checked.name;
2606
+ } catch {
2607
+ return "";
2608
+ }
2609
+ }
2610
+
2611
+ function getReplSenderName() {
2612
+ return replPersonName || replPersonNameDefault || "User";
2613
+ }
2614
+
2615
+ // What sends and notes are recorded under: the name on screen, since a redraw that would
2616
+ // show a new default can be waiting (Astra, Sol). Without the row on screen, the name now.
2617
+ function getShownReplSenderName() {
2618
+ const row = rightView === "repl" && critiqueViewEl ? critiqueViewEl.querySelector("[data-repl-sender-shown]") : null;
2619
+ const shown = row ? validateReplPersonName(row.getAttribute("data-repl-sender-shown")) : null;
2620
+ return shown && !shown.error ? shown.name : getReplSenderName();
2621
+ }
2622
+
2623
+ // A blank name goes back to the default.
2624
+ function chooseReplPersonName(value) {
2625
+ const trimmed = String(value || "").trim();
2626
+ const checked = trimmed ? validateReplPersonName(trimmed) : { name: "" };
2627
+ if (checked.error) return checked;
2628
+ replPersonName = checked.name;
2629
+ try {
2630
+ if (window.localStorage) {
2631
+ if (replPersonName) window.localStorage.setItem(REPL_PERSON_NAME_STORAGE_KEY, replPersonName);
2632
+ else window.localStorage.removeItem(REPL_PERSON_NAME_STORAGE_KEY);
2633
+ }
2634
+ } catch {
2635
+ // The name still applies to this page.
2636
+ }
2637
+ return { name: getReplSenderName() };
2638
+ }
2639
+
2640
+ // A version 4 UUID. getRandomValues, since randomUUID needs a secure context and Studio
2641
+ // can be opened over the network.
2642
+ function makeReplPersonUuid() {
2643
+ const bytes = window.crypto.getRandomValues(new Uint8Array(16));
2644
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
2645
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
2646
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
2647
+ return hex.slice(0, 8) + "-" + hex.slice(8, 12) + "-" + hex.slice(12, 16) + "-" + hex.slice(16, 20) + "-" + hex.slice(20);
2648
+ }
2649
+
2650
+ // A person's request ID under Studio's channel prefix (studio:send: or studio:note:).
2651
+ function makeReplPersonRequestId(kind) {
2652
+ return "studio:" + kind + ":" + makeReplPersonUuid();
2653
+ }
2654
+
2655
+ // This page's send, recorded under studio:send: and the send's request ID.
2656
+ function isReplEntryOfRequest(entry, requestId) {
2657
+ return Boolean(requestId) && (entry.requestId === requestId || entry.requestId === "studio:send:" + requestId);
2658
+ }
2659
+
2660
+ // Who sent an entry, as the shared protocol's readers show it and as Studio tells its
2661
+ // agent (describeReplEntrySender in shared/studio-repl-activity.js): an agent's label; a
2662
+ // name under a person's prefix on its matching origin; otherwise "User".
2663
+ function describeReplEntrySender(entry) {
2664
+ const oneLine = (value) => {
2665
+ const text = String(value == null ? "" : value).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]+/g, " ").replace(/\s+/g, " ").trim();
2666
+ return [...text].length > 80 ? [...text].slice(0, 79).join("") + "…" : text;
2667
+ };
2668
+ if (entry.mode === "agent") return oneLine(entry.label) || "Agent";
2669
+ const channels = [
2670
+ { prefix: /^pi:(?:send|env):/, origin: "pi-repl", channel: "Pi" },
2671
+ { prefix: /^cli:(?:send|env):/, origin: "pi-repl", channel: "terminal" },
2672
+ { prefix: /^studio:(?:send|note):/, origin: "pi-studio", channel: "Pi Studio" },
2673
+ ];
2674
+ const person = channels.find((candidate) => candidate.origin === entry.origin && candidate.prefix.test(entry.requestId || ""));
2675
+ if (person) return (oneLine(entry.label) || "User") + " · via " + person.channel;
2676
+ return entry.origin === "pi-studio" ? "User · via Pi Studio" : "User";
2677
+ }
2678
+
2571
2679
  function createReplJournalEntry(details) {
2572
2680
  const sharedSynced = details.sharedSynced === true;
2573
2681
  return {
@@ -2920,7 +3028,8 @@
2920
3028
  return;
2921
3029
  }
2922
3030
  const entry = addReplJournalEntry({
2923
- label: "note",
3031
+ requestId: makeReplPersonRequestId("note"),
3032
+ label: getShownReplSenderName(),
2924
3033
  prose: note,
2925
3034
  status: "note",
2926
3035
  mode: "literate",
@@ -2949,7 +3058,8 @@
2949
3058
  if (payload.noteOnly) {
2950
3059
  if (String(payload.prose || "").trim()) {
2951
3060
  const entry = addReplJournalEntry({
2952
- label: payload.label || "note",
3061
+ requestId: makeReplPersonRequestId("note"),
3062
+ label: getShownReplSenderName(),
2953
3063
  prose: payload.prose,
2954
3064
  status: "note",
2955
3065
  mode: payload.mode || "literate",
@@ -2970,12 +3080,14 @@
2970
3080
  setStatus("REPL submission is empty.", "warning");
2971
3081
  return null;
2972
3082
  }
2973
- const requestId = makeRequestId();
3083
+ // Recorded under the name shown, as studio:send: and this request's ID, here and by the
3084
+ // server, so the card shows the name while the send waits.
3085
+ const requestId = makeReplPersonUuid();
2974
3086
  const journalEntry = addReplJournalEntry({
2975
- requestId,
3087
+ requestId: "studio:send:" + requestId,
2976
3088
  sessionName: session.sessionName,
2977
3089
  runtime: getActiveReplRuntime(),
2978
- label: payload.label,
3090
+ label: getShownReplSenderName(),
2979
3091
  mode: payload.mode,
2980
3092
  prose: payload.prose,
2981
3093
  code: text,
@@ -2999,6 +3111,7 @@
2999
3111
  journalEntryId: journalEntry.id,
3000
3112
  createdAt: journalEntry.createdAt,
3001
3113
  label: journalEntry.label,
3114
+ personName: journalEntry.label,
3002
3115
  mode: journalEntry.mode,
3003
3116
  prose: journalEntry.prose,
3004
3117
  skippedChunks: journalEntry.skippedChunks,
@@ -3057,7 +3170,7 @@
3057
3170
  skippedChunks: 0,
3058
3171
  });
3059
3172
  if (!requestId) return false;
3060
- replQuickPending = { requestId, key, text };
3173
+ replQuickPending = { requestId, key, text, journalEntryId: activeReplJournalEntryId };
3061
3174
  const activeEl = document.activeElement;
3062
3175
  replQuickRefocus = activeEl instanceof Element && activeEl.closest(".repl-quick-composer") ? { requestId, settled: false } : null;
3063
3176
  renderReplViewIfActive({ force: true });
@@ -12029,6 +12142,13 @@
12029
12142
  if (!actionBtn) return;
12030
12143
  event.preventDefault();
12031
12144
  const action = actionBtn.getAttribute("data-repl-action") || "";
12145
+ // The name isn't the session's, so a pane drawn for another session can still change it.
12146
+ if (action === "sender-edit") {
12147
+ replSenderEditing = true;
12148
+ replSenderDraft = replPersonName || getReplSenderName();
12149
+ renderReplViewIfActive({ force: true });
12150
+ return;
12151
+ }
12032
12152
  if (isReplPaneStale(actionBtn)) {
12033
12153
  refuseStaleReplPaneAction(action === "quick-send" ? "The REPL session changed, so nothing was sent." : "The REPL session changed, so nothing was done.");
12034
12154
  return;
@@ -12175,7 +12295,13 @@
12175
12295
  }
12176
12296
 
12177
12297
  // A redraw that waited for a control runs once focus has left it.
12178
- function handleReplPaneFocusOut() {
12298
+ function handleReplPaneFocusOut(event) {
12299
+ const target = event && event.target;
12300
+ // Leaving the name field keeps what's in it; a redraw that removed it doesn't count.
12301
+ if (target instanceof HTMLInputElement && target.hasAttribute("data-repl-sender-name") && target.isConnected) {
12302
+ finishReplSenderEdit(true);
12303
+ return;
12304
+ }
12179
12305
  if (!replRedrawDeferred) return;
12180
12306
  window.setTimeout(replayDeferredReplRedraw, 0);
12181
12307
  }
@@ -12205,6 +12331,10 @@
12205
12331
  function handleReplPaneInput(event) {
12206
12332
  if (rightView !== "repl") return;
12207
12333
  const target = event && event.target;
12334
+ if (target instanceof HTMLInputElement && target.hasAttribute("data-repl-sender-name")) {
12335
+ replSenderDraft = target.value;
12336
+ return;
12337
+ }
12208
12338
  if (!(target instanceof HTMLTextAreaElement) || !target.hasAttribute("data-repl-quick-draft")) return;
12209
12339
  replQuickLastInputAt = Date.now();
12210
12340
  // The text belongs to the session the box was drawn for, even if another is selected
@@ -12219,6 +12349,15 @@
12219
12349
  function handleReplPaneKeydown(event) {
12220
12350
  if (rightView !== "repl" || !event || event.isComposing) return;
12221
12351
  const target = event.target;
12352
+ if (target instanceof HTMLInputElement && target.hasAttribute("data-repl-sender-name")) {
12353
+ if (event.key !== "Enter" && event.key !== "Escape") return;
12354
+ event.preventDefault();
12355
+ event.stopPropagation();
12356
+ replSenderReturnFocus = true;
12357
+ finishReplSenderEdit(event.key === "Enter");
12358
+ if (replSenderEditing) replSenderReturnFocus = false;
12359
+ return;
12360
+ }
12222
12361
  if (!(target instanceof HTMLTextAreaElement) || !target.hasAttribute("data-repl-quick-draft")) return;
12223
12362
  const submitShortcut = event.key === "Enter"
12224
12363
  && (event.metaKey || event.ctrlKey)
@@ -14206,8 +14345,9 @@
14206
14345
  function buildReplStudioMeta(entry) {
14207
14346
  const parts = [];
14208
14347
  const kind = getReplStudioEntryKind(entry);
14209
- if (kind !== "Raw") parts.push(kind);
14210
- if (entry.origin) parts.push(entry.origin);
14348
+ // An agent's entry is named by who sent it.
14349
+ if (kind !== "Raw" && kind !== "Pi") parts.push(kind);
14350
+ parts.push(describeReplEntrySender(entry));
14211
14351
  const time = formatReferenceTime(entry.createdAt);
14212
14352
  if (time) parts.push(time);
14213
14353
  if (entry.skippedChunks) parts.push("skipped " + String(entry.skippedChunks));
@@ -14259,10 +14399,12 @@
14259
14399
  }
14260
14400
 
14261
14401
  function buildReplJournalHtml(transcript) {
14262
- const visibleEntries = getVisibleReplJournalEntries();
14402
+ const sessionName = getActiveReplJournalSessionName();
14403
+ // A record Studio won't use from here says why, and entries kept from before aren't shown as its record (P0).
14404
+ const recordRefusal = (replSessions.find((session) => session.sessionName === sessionName) || {}).recordRefusal || "";
14405
+ const visibleEntries = recordRefusal ? [] : getVisibleReplJournalEntries();
14263
14406
  const hasEntries = visibleEntries.length > 0;
14264
14407
  const entryCount = visibleEntries.length;
14265
- const sessionName = getActiveReplJournalSessionName();
14266
14408
  const collapsedClass = replJournalCollapsed ? " is-collapsed" : "";
14267
14409
  const toggleButton = "<button type='button' data-repl-action='journal-toggle' aria-expanded='" + (replJournalCollapsed ? "false" : "true") + "'>" + (replJournalCollapsed ? "Show record" : "Hide record") + "</button>";
14268
14410
  const toggleActions = "<div class='repl-journal-actions'>" + toggleButton + "</div>";
@@ -14300,8 +14442,9 @@
14300
14442
  const pending = !output && entry.status === "sending"
14301
14443
  ? "<div class='repl-studio-pending'>Running…</div>"
14302
14444
  : "";
14445
+ // Who sent it shows; the rest, such as the time, is in its tooltip.
14303
14446
  return "<article class='repl-journal-card repl-studio-entry'>"
14304
- + (meta ? "<div class='repl-studio-entry-meta'>" + escapeHtml(meta) + "</div>" : "")
14447
+ + (meta ? "<div class='repl-studio-entry-meta' title='" + escapeHtml(meta) + "'>" + escapeHtml(describeReplEntrySender(entry)) + "</div>" : "")
14305
14448
  + prose
14306
14449
  + code
14307
14450
  + output
@@ -14314,10 +14457,13 @@
14314
14457
  : "No compatible-client record entries yet. Send code from pi-repl or Studio, or use More → Add note (Literate send) to record prose.")
14315
14458
  : "No compatible-client record entries yet. Send code from pi-repl or Studio, or use More → Add note (Literate send) to record prose.";
14316
14459
  const terminalContent = banner
14317
- + (hasEntries ? cards : "<div class='repl-studio-empty'>" + escapeHtml(emptyText) + "</div>");
14460
+ + (hasEntries ? cards : (recordRefusal ? "" : "<div class='repl-studio-empty'>" + escapeHtml(emptyText) + "</div>"));
14318
14461
  return "<section class='repl-journal'>"
14319
14462
  + "<div class='repl-journal-header'><h3>Shared REPL Record</h3>" + toggleActions + "</div>"
14320
- + "<p class='repl-journal-description'>What Studio and pi-repl have sent to this session.</p>"
14463
+ + "<p class='repl-journal-description'>What Studio and pi-repl have sent to this session."
14464
+ + (replRecordActivity === "off" ? "" : " New entries here go to the agent and its model provider.")
14465
+ + "</p>"
14466
+ + (recordRefusal ? "<p class='repl-journal-omitted'>" + escapeHtml("Not shown: " + recordRefusal) + "</p>" : "")
14321
14467
  + (omitted ? "<div class='repl-journal-omitted'>Showing latest 12 entries for this session; " + escapeHtml(String(omitted)) + " older entries remain in export.</div>" : "")
14322
14468
  // The prompt column fits the longest prompt, such as gnuplot>, in the prompt's own font.
14323
14469
  + "<div class='repl-journal-list' style='--repl-studio-prompt-chars: " + Math.max(0, ...visibleEntries.map((entry) => getReplStudioPrompt(entry.runtime).length)) + "'>" + terminalContent + "</div>"
@@ -14352,6 +14498,77 @@
14352
14498
  return "tmux attach -t " + String(session.sessionName || "");
14353
14499
  }
14354
14500
 
14501
+ // "Sending as …": the name this page's sends and notes are recorded under, and its editor.
14502
+ function buildReplSenderHtml() {
14503
+ const name = getReplSenderName();
14504
+ if (replSenderEditing) {
14505
+ return "<span class='repl-quick-sender'><label>Sending as <input data-repl-sender-name type='text' value='" + escapeHtml(replSenderDraft) + "' placeholder='" + escapeHtml(replPersonNameDefault || "User") + "' aria-label='Name your sends and notes are recorded under' title='Enter to keep, Esc to cancel. Leave it empty for " + escapeHtml(replPersonNameDefault || "User") + ".'></label></span>";
14506
+ }
14507
+ const from = replPersonName
14508
+ ? "Chosen in this browser."
14509
+ : (replPersonNameSource === "environment"
14510
+ ? "From PI_REPL_USER_NAME."
14511
+ : (replPersonNameSource === "setting" ? "The name saved with /repl name or agent-repl name." : "No name is set."));
14512
+ return "<span class='repl-quick-sender' data-repl-sender-shown='" + escapeHtml(name) + "' title='Your sends and notes are recorded under this name. " + escapeHtml(from) + "'>Sending as <strong>" + escapeHtml(name) + "</strong>"
14513
+ + "<button type='button' class='repl-quick-sender-edit' data-repl-action='sender-edit' aria-label='Change the name your sends and notes are recorded under' title='Change name'>✎</button></span>";
14514
+ }
14515
+
14516
+ function isReplSenderNameFocused() {
14517
+ const activeEl = document.activeElement;
14518
+ return activeEl instanceof HTMLInputElement && activeEl.hasAttribute("data-repl-sender-name");
14519
+ }
14520
+
14521
+ function focusReplSenderNameIfEditing() {
14522
+ if (!critiqueViewEl) return;
14523
+ if (!replSenderEditing) {
14524
+ const button = replSenderReturnFocus ? critiqueViewEl.querySelector("[data-repl-action='sender-edit']") : null;
14525
+ replSenderReturnFocus = false;
14526
+ if (button instanceof HTMLElement) button.focus({ preventScroll: true });
14527
+ return;
14528
+ }
14529
+ if (isReplSenderNameFocused()) return;
14530
+ const input = critiqueViewEl.querySelector("[data-repl-sender-name]");
14531
+ if (!(input instanceof HTMLInputElement)) return;
14532
+ input.focus({ preventScroll: true });
14533
+ input.select();
14534
+ }
14535
+
14536
+ // Where the cursor is in the name field, so a redraw by any route puts it back: a response
14537
+ // can redraw the pane without waiting for the field (Sol).
14538
+ function captureReplSenderCursor() {
14539
+ if (!replSenderEditing || !isReplSenderNameFocused()) return null;
14540
+ const input = document.activeElement;
14541
+ return { start: input.selectionStart, end: input.selectionEnd, direction: input.selectionDirection };
14542
+ }
14543
+
14544
+ function restoreReplSenderCursor(cursor) {
14545
+ if (!cursor || !replSenderEditing || !critiqueViewEl) return;
14546
+ const input = critiqueViewEl.querySelector("[data-repl-sender-name]");
14547
+ if (!(input instanceof HTMLInputElement)) return;
14548
+ input.focus({ preventScroll: true });
14549
+ try {
14550
+ input.setSelectionRange(cursor.start, cursor.end, cursor.direction || "none");
14551
+ } catch {}
14552
+ }
14553
+
14554
+ // Enter or leaving the field keeps the name; Esc doesn't.
14555
+ function finishReplSenderEdit(keep) {
14556
+ if (!replSenderEditing) return;
14557
+ const input = critiqueViewEl ? critiqueViewEl.querySelector("[data-repl-sender-name]") : null;
14558
+ if (keep && input instanceof HTMLInputElement) {
14559
+ const before = getReplSenderName();
14560
+ const chosen = chooseReplPersonName(input.value);
14561
+ if (chosen.error) {
14562
+ setStatus("Name not changed: " + chosen.error + ".", "warning");
14563
+ if (document.activeElement === input) return;
14564
+ } else if (chosen.name !== before) {
14565
+ setStatus("Sending as " + chosen.name + ".", "success");
14566
+ }
14567
+ }
14568
+ replSenderEditing = false;
14569
+ renderReplViewIfActive({ force: true });
14570
+ }
14571
+
14355
14572
  function buildReplQuickComposerHtml(activeSession, canSendToActiveSession) {
14356
14573
  const key = getReplQuickDraftKey(activeSession);
14357
14574
  const draft = getReplQuickDraft(activeSession);
@@ -14368,7 +14585,7 @@
14368
14585
  + "<div class='repl-quick-header'><div><strong id='replQuickComposerTitle'>Quick send</strong><button type='button' class='repl-quick-target' data-repl-action='jump-controls' title='Target: " + escapeHtml(targetDetails) + ". Jump to REPL session controls.' aria-label='Target: " + escapeHtml(targetDetails) + ". Jump to REPL session controls.'><span class='repl-quick-target-label'>" + escapeHtml(visibleTargetLabel) + "</span><span class='repl-quick-target-arrow' aria-hidden='true'>↑</span></button></div>"
14369
14586
  + "<span class='repl-quick-hint'>Enter adds a line · Cmd/Ctrl+Enter sends</span></div>"
14370
14587
  + "<textarea data-repl-quick-draft data-repl-quick-lifetime='" + escapeHtml(encodeURIComponent(key)) + "'" + (replQuickBoxHeight ? " style='height: " + replQuickBoxHeight + "'" : "") + " rows='3' maxlength='" + REPL_QUICK_DRAFT_MAX_CHARS + "' aria-label='Quick code for " + escapeHtml(targetDetails) + "' aria-keyshortcuts='Meta+Enter Control+Enter' placeholder='" + (activeSession ? (key ? "Type a short command or snippet…" : "Exact tmux identity unavailable; refresh the session list") : "Start or select a REPL session first") + "'" + (inputDisabled ? " disabled" : "") + ">" + escapeHtml(draft) + "</textarea>"
14371
- + "<div class='repl-quick-actions'><span></span><div>"
14588
+ + "<div class='repl-quick-actions'>" + buildReplSenderHtml() + "<div>"
14372
14589
  + "<button type='button' data-repl-action='quick-clear'" + (pending || !draft ? " disabled" : "") + ">Clear</button>"
14373
14590
  + "<button class='repl-quick-send-btn' type='button' data-repl-action='quick-send'" + (sendDisabled ? " disabled" : "") + ">" + (pending ? "Sending…" : "Send") + "</button>"
14374
14591
  + "</div></div></section>";
@@ -14682,8 +14899,10 @@
14682
14899
  if (!critiqueViewEl) return;
14683
14900
  const shouldStick = shouldAutoStickReplView();
14684
14901
  const previousScrollTop = critiqueViewEl.scrollTop;
14902
+ const senderCursor = captureReplSenderCursor();
14685
14903
  finishPreviewRender(critiqueViewEl);
14686
14904
  critiqueViewEl.innerHTML = buildReplPanelHtml();
14905
+ restoreReplSenderCursor(senderCursor);
14687
14906
  critiqueViewEl.classList.remove("response-scroll-resetting");
14688
14907
  if (shouldStick) {
14689
14908
  critiqueViewEl.scrollTop = critiqueViewEl.scrollHeight;
@@ -17927,6 +18146,10 @@
17927
18146
  if (!current()) throw new Error("The editor changed. Current work was kept.");
17928
18147
  captureStudioBufferTransientState(); persistWorkspaceStateNow(); await bufferRecoveryClient.settled();
17929
18148
  const ready = await prepareDocumentHostingReplacement(bufferId, current);
18149
+ // The persistence timer can resend an unchanged checkpoint during that request; the open's gate refuses
18150
+ // while any save is in flight, so let it land first. A real change meanwhile still fails the check below
18151
+ // (c73's intermittent refusal after a reload, 30 Oct).
18152
+ await bufferRecoveryClient.settled();
17930
18153
  if (!ready()) throw new Error("The owning checkpoint changed before opening.");
17931
18154
  },
17932
18155
  capture: () => { captureStudioBufferTransientState(); persistWorkspaceStateNow(); },
@@ -29195,11 +29418,16 @@
29195
29418
  const settlesPendingRequest = Boolean(responseRequestId && responseRequestId === replPendingRequestId);
29196
29419
  const previousActiveLifetimeKey = getReplQuickDraftKey(getActiveReplSession());
29197
29420
  const previousRuntime = replRuntime;
29421
+ const previousSender = getReplSenderName() + "\u001e" + replPersonNameSource;
29198
29422
  // Every repl_state states Studio's selection; while this page's own choice is
29199
29423
  // unanswered, only that choice's reply changes what the page shows.
29200
29424
  noteReplChoiceAnswer(message);
29201
29425
  const present = !isReplChoicePending();
29202
29426
  replTmuxAvailable = typeof message.tmuxAvailable === "boolean" ? message.tmuxAvailable : replTmuxAvailable;
29427
+ if (message.recordActivity === "on" || message.recordActivity === "send" || message.recordActivity === "off") replRecordActivity = message.recordActivity;
29428
+ const defaultName = validateReplPersonName(message.personName);
29429
+ if (!defaultName.error) replPersonNameDefault = defaultName.name;
29430
+ if (message.personNameSource === "environment" || message.personNameSource === "setting" || message.personNameSource === "default") replPersonNameSource = message.personNameSource;
29203
29431
  const sessionsChanged = setReplSessions(message.sessions);
29204
29432
  if (present) adoptReplSelection(message);
29205
29433
  const journalChanged = mergeReplJournalEntries(message.journalEntries);
@@ -29225,6 +29453,7 @@
29225
29453
  || previousError !== replError
29226
29454
  || previousMessage !== replMessage
29227
29455
  || journalChanged
29456
+ || previousSender !== getReplSenderName() + "\u001e" + replPersonNameSource
29228
29457
  || (!previousCapturedAt && replCapturedAt);
29229
29458
  if (viewChanged) renderReplViewIfActive({ force: activeSessionIdentityChanged });
29230
29459
  updateReferenceBadge();
@@ -29351,7 +29580,7 @@
29351
29580
  if (responseRequestId) settleReplQuickPending(responseRequestId, true);
29352
29581
  mergeReplJournalEntries(message.journalEntries);
29353
29582
  if (typeof message.requestId === "string") {
29354
- replJournalEntries = replJournalEntries.map((entry) => entry.requestId === message.requestId ? { ...entry, status: "sent", updatedAt: Date.now() } : entry);
29583
+ replJournalEntries = replJournalEntries.map((entry) => isReplEntryOfRequest(entry, message.requestId) ? { ...entry, status: "sent", updatedAt: Date.now() } : entry);
29355
29584
  persistReplJournalEntries();
29356
29585
  }
29357
29586
  setStatus("Sent to REPL.", "success");
@@ -29930,7 +30159,7 @@
29930
30159
  replError = typeof message.message === "string" ? message.message : "REPL request failed.";
29931
30160
  settleReplQuickPending(failedReplRequestId, false);
29932
30161
  if (typeof message.requestId === "string") {
29933
- replJournalEntries = replJournalEntries.map((entry) => entry.requestId === message.requestId ? { ...entry, status: "error", output: replError, updatedAt: Date.now() } : entry);
30162
+ replJournalEntries = replJournalEntries.map((entry) => isReplEntryOfRequest(entry, message.requestId) ? { ...entry, status: "error", output: replError, updatedAt: Date.now() } : entry);
29934
30163
  persistReplJournalEntries();
29935
30164
  }
29936
30165
  renderReplViewIfActive({ force: true });
package/client/studio.css CHANGED
@@ -4828,6 +4828,57 @@
4828
4828
  line-height: 1.35;
4829
4829
  }
4830
4830
 
4831
+ .repl-quick-sender {
4832
+ display: inline-flex;
4833
+ align-items: center;
4834
+ gap: 2px;
4835
+ min-width: 0;
4836
+ white-space: nowrap;
4837
+ }
4838
+
4839
+ .repl-quick-sender strong {
4840
+ min-width: 0;
4841
+ max-width: 28ch;
4842
+ margin-left: 4px;
4843
+ overflow: hidden;
4844
+ color: var(--text);
4845
+ font-weight: 600;
4846
+ text-overflow: ellipsis;
4847
+ }
4848
+
4849
+ .repl-quick-sender-edit {
4850
+ min-height: 0;
4851
+ padding: 0 4px;
4852
+ border-color: transparent;
4853
+ border-radius: 5px;
4854
+ background: transparent;
4855
+ color: var(--muted);
4856
+ font-size: 12px;
4857
+ line-height: 1.35;
4858
+ }
4859
+
4860
+ .repl-quick-sender-edit:not(:disabled):hover,
4861
+ .repl-quick-sender-edit:focus-visible {
4862
+ border-color: transparent;
4863
+ background: var(--studio-header-action-hover-bg, var(--panel-2));
4864
+ color: var(--text);
4865
+ }
4866
+
4867
+ /* As the new layout's other text fields (Quick send's box, Files' path): a border, no ring. */
4868
+ .repl-quick-sender input {
4869
+ width: 18ch;
4870
+ min-height: 0;
4871
+ margin-left: 4px;
4872
+ padding: 2px 6px;
4873
+ border: 1px solid var(--control-border);
4874
+ border-radius: 6px;
4875
+ background: var(--panel);
4876
+ color: var(--text);
4877
+ font: inherit;
4878
+ font-weight: 600;
4879
+ outline: none;
4880
+ }
4881
+
4831
4882
  .repl-quick-send-btn {
4832
4883
  border-color: color-mix(in srgb, var(--accent) 58%, var(--control-border));
4833
4884
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
@@ -4952,7 +5003,8 @@
4952
5003
 
4953
5004
  .repl-studio-entry {
4954
5005
  position: relative;
4955
- padding: 2px 8.5em 6px 0;
5006
+ /* Room for who sent it, such as "Oliver · via Pi Studio" (the meta's 12em at 11px). */
5007
+ padding: 2px calc(12 * 11px + 10px) 6px 0;
4956
5008
  background: transparent;
4957
5009
  }
4958
5010
 
@@ -4968,7 +5020,7 @@
4968
5020
  position: absolute;
4969
5021
  top: 3px;
4970
5022
  right: 0;
4971
- max-width: 8.1em;
5023
+ max-width: 12em;
4972
5024
  overflow: hidden;
4973
5025
  text-overflow: ellipsis;
4974
5026
  white-space: nowrap;
@@ -7785,6 +7837,14 @@
7785
7837
  box-shadow: none;
7786
7838
  border-color: var(--control-border);
7787
7839
  }
7840
+ /* Start cmd stays plain like the selects beside it, and in use looks like the other text fields: a border, no ring. */
7841
+ body.studio-workspace-layout .repl-command-label input { border: 1px solid transparent; border-radius: 6px; font-family: inherit; font-weight: 400; }
7842
+ body.studio-workspace-layout .repl-command-label input:focus {
7843
+ outline: none;
7844
+ box-shadow: none;
7845
+ border-color: var(--control-border);
7846
+ background: var(--panel);
7847
+ }
7788
7848
 
7789
7849
  /* Oliver, 10 Oct: the side thread's model and Thinking sit beside its Ask button. */
7790
7850
  body.studio-workspace-layout .side-question-actions { align-items: center; }