pi-studio 0.11.7 → 0.11.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to `pi-studio` are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.11.8] — 2026-11-03
8
+
9
+ ### Changed
10
+ - The REPL pane's record says when a session's record directory isn't verified, because the session has no record-directory key yet, so the record shown may not be the one other clients use. When the agent is told of entries from such a session, it's told this too.
11
+
12
+ ### Fixed
13
+ - In a Shell session under zsh, Ctrl+C while your code runs no longer leaves Studio waiting for that send. Before, the session took no further sends until it was closed. bash was already unaffected.
14
+ - When the REPL pane's controls wrap and **More** starts a row, its menu opens inside the pane, not off its left edge.
15
+ - For a session whose shared record Studio won't use from here, **Copy Markdown**, **Export .md** and **Load record into editor** say why, instead of using the page's earlier copy of its entries. With no session selected, the page leaves that session's entries out.
16
+ - **Clear** empties the page's copy of a session's record once Studio has cleared it. If Studio refuses, the page keeps its copy and says why. Before, the page emptied its copy and reported success first.
17
+ - A note's name is checked before Studio shortens a long label, so a name that isn't usable can't be cut into one that is.
18
+
7
19
  ## [0.11.7] — 2026-11-02
8
20
 
9
21
  This release brings the REPL pane up to pi-repl 0.11.7.
@@ -700,6 +700,8 @@
700
700
  let replSenderEditing = false;
701
701
  // What's typed in the name field, kept as it's typed so a redraw by any route keeps it (Sol).
702
702
  let replSenderDraft = "";
703
+ // This page's clears of sessions' records, by request ID, until Studio answers each.
704
+ const replJournalClearRequests = new Map();
703
705
  // After Enter or Esc in the name field, the cursor goes back to ✎.
704
706
  let replSenderReturnFocus = false;
705
707
  let replSessions = [];
@@ -1625,6 +1627,8 @@
1625
1627
  source: typeof session.source === "string" ? session.source : "tmux",
1626
1628
  // Why Studio won't use its shared record from here, such as another record directory (pi-repl's P0).
1627
1629
  recordRefusal: typeof session.recordRefusal === "string" ? session.recordRefusal.slice(0, 1000) : "",
1630
+ // It has no record-directory key yet, so its record here may not be the one other clients use.
1631
+ recordUnverified: session.recordUnverified === true,
1628
1632
  };
1629
1633
  }
1630
1634
 
@@ -1907,6 +1911,7 @@
1907
1911
  tmuxSessionId: session.tmuxSessionId,
1908
1912
  tmuxSessionCreatedAt: session.tmuxSessionCreatedAt,
1909
1913
  recordRefusal: session.recordRefusal,
1914
+ recordUnverified: session.recordUnverified,
1910
1915
  })));
1911
1916
  }
1912
1917
 
@@ -2957,6 +2962,11 @@
2957
2962
  }
2958
2963
 
2959
2964
  async function copyReplJournalToClipboard() {
2965
+ const refusal = getActiveReplRecordState().refusal;
2966
+ if (refusal) {
2967
+ setStatus(refusal, "warning");
2968
+ return;
2969
+ }
2960
2970
  const entries = getVisibleReplJournalEntries();
2961
2971
  if (!entries.length) {
2962
2972
  setStatus("No shared REPL record entries to copy for this session yet.", "warning");
@@ -2970,6 +2980,11 @@
2970
2980
  }
2971
2981
 
2972
2982
  function exportReplJournalMarkdown() {
2983
+ const refusal = getActiveReplRecordState().refusal;
2984
+ if (refusal) {
2985
+ setStatus(refusal, "warning");
2986
+ return;
2987
+ }
2973
2988
  const entries = getVisibleReplJournalEntries();
2974
2989
  if (!entries.length) {
2975
2990
  setStatus("No shared REPL record entries to export for this session yet.", "warning");
@@ -2989,23 +3004,33 @@
2989
3004
  setStatus("Exported shared REPL record Markdown.", "success");
2990
3005
  }
2991
3006
 
3007
+ // A session's record is cleared here once Studio has cleared it: Studio can refuse, and then
3008
+ // this page keeps its copy too (pi-repl's P0).
2992
3009
  function clearReplJournal() {
2993
3010
  const sessionName = getActiveReplJournalSessionName();
2994
- if (sessionName) {
2995
- replJournalEntries = replJournalEntries.filter((entry) => entry.sessionName !== sessionName);
2996
- } else {
3011
+ if (!sessionName) {
2997
3012
  replJournalEntries = [];
3013
+ activeReplJournalEntryId = "";
3014
+ persistReplJournalEntries();
3015
+ setStatus("Cleared local REPL record cache.", "success");
3016
+ renderReplViewIfActive({ force: true });
3017
+ return;
2998
3018
  }
2999
- activeReplJournalEntryId = "";
3000
- persistReplJournalEntries();
3001
- if (sessionName) {
3002
- sendMessage({ type: "repl_journal_clear_request", requestId: makeRequestId(), sessionName });
3019
+ const requestId = makeRequestId();
3020
+ if (!sendMessage({ type: "repl_journal_clear_request", requestId, sessionName })) {
3021
+ setStatus("Nothing was cleared: Studio isn't connected.", "warning");
3022
+ return;
3003
3023
  }
3004
- setStatus(sessionName ? "Cleared shared REPL record for this session." : "Cleared local REPL record cache.", "success");
3005
- renderReplViewIfActive({ force: true });
3024
+ replJournalClearRequests.set(requestId, sessionName);
3025
+ setStatus("Clearing the shared REPL record…", "info");
3006
3026
  }
3007
3027
 
3008
3028
  function loadReplJournalIntoEditor() {
3029
+ const refusal = getActiveReplRecordState().refusal;
3030
+ if (refusal) {
3031
+ setStatus(refusal, "warning");
3032
+ return;
3033
+ }
3009
3034
  const entries = getVisibleReplJournalEntries();
3010
3035
  if (!entries.length) {
3011
3036
  setStatus("No shared REPL record entries to load for this session yet.", "warning");
@@ -12286,6 +12311,32 @@
12286
12311
  }
12287
12312
  }
12288
12313
 
12314
+ // The REPL pane's More menu opens right-aligned under More. Where the controls have wrapped
12315
+ // and More starts a row, that runs off the pane's left edge, so the menu is kept inside the
12316
+ // pane, narrower if the pane is.
12317
+ function placeReplMoreMenu(details) {
12318
+ const menu = details.querySelector(".repl-more-menu");
12319
+ const pane = details.closest("#leftPane, #rightPane");
12320
+ if (!(menu instanceof HTMLElement) || !pane) return;
12321
+ menu.style.left = "";
12322
+ menu.style.right = "";
12323
+ menu.style.minWidth = "";
12324
+ menu.style.maxWidth = "";
12325
+ const bounds = pane.getBoundingClientRect();
12326
+ const minLeft = bounds.left + 8;
12327
+ const available = Math.max(0, bounds.right - 8 - minLeft);
12328
+ // The stylesheet's minimum width would win over a smaller maximum (Sol, Astra).
12329
+ if (menu.getBoundingClientRect().width > available) menu.style.minWidth = menu.style.maxWidth = available + "px";
12330
+ if (menu.getBoundingClientRect().left >= minLeft) return;
12331
+ menu.style.right = "auto";
12332
+ menu.style.left = (minLeft - details.getBoundingClientRect().left) + "px";
12333
+ }
12334
+
12335
+ function handleReplMoreToggle(event) {
12336
+ const details = event && event.target;
12337
+ if (details instanceof HTMLDetailsElement && details.open && details.classList.contains("repl-more-controls")) placeReplMoreMenu(details);
12338
+ }
12339
+
12289
12340
  function handleReplPaneFocusIn(event) {
12290
12341
  if (!replQuickFocusRequested || rightView !== "repl") return;
12291
12342
  const target = event && event.target;
@@ -12424,6 +12475,7 @@
12424
12475
  if (!critiqueViewEl) return;
12425
12476
  critiqueViewEl.addEventListener("scroll", handleTracePaneScroll);
12426
12477
  critiqueViewEl.addEventListener("toggle", handleTraceDetailsToggle, true);
12478
+ critiqueViewEl.addEventListener("toggle", handleReplMoreToggle, true);
12427
12479
  critiqueViewEl.addEventListener("click", handleTracePaneClick);
12428
12480
  critiqueViewEl.addEventListener("click", handleReplPaneClick);
12429
12481
  critiqueViewEl.addEventListener("click", handleFilesPaneClick);
@@ -13948,9 +14000,22 @@
13948
14000
  return String(replActiveSessionName || "").trim();
13949
14001
  }
13950
14002
 
14003
+ // The active session's record as Studio's server reads it (pi-repl's P0): refused, with why, or not verified.
14004
+ function getActiveReplRecordState() {
14005
+ const sessionName = getActiveReplJournalSessionName();
14006
+ const session = sessionName ? replSessions.find((candidate) => candidate.sessionName === sessionName) : null;
14007
+ return { refusal: (session && session.recordRefusal) || "", unverified: Boolean(session && session.recordUnverified) };
14008
+ }
14009
+
13951
14010
  function getVisibleReplJournalEntries() {
13952
14011
  const sessionName = getActiveReplJournalSessionName();
13953
- if (!sessionName) return replJournalEntries;
14012
+ if (!sessionName) {
14013
+ // With no session selected, every session's entries, but not a refused record's (Sol, Astra).
14014
+ const refused = new Set(replSessions.filter((session) => session.recordRefusal).map((session) => session.sessionName));
14015
+ return refused.size ? replJournalEntries.filter((entry) => !refused.has(entry.sessionName)) : replJournalEntries;
14016
+ }
14017
+ // Entries kept from before aren't a refused record's, to show, copy, export or load.
14018
+ if (getActiveReplRecordState().refusal) return [];
13954
14019
  return replJournalEntries.filter((entry) => entry.sessionName === sessionName);
13955
14020
  }
13956
14021
 
@@ -14400,9 +14465,10 @@
14400
14465
 
14401
14466
  function buildReplJournalHtml(transcript) {
14402
14467
  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();
14468
+ // A record Studio won't use from here says why; one with no record-directory key yet says so (P0).
14469
+ const recordState = getActiveReplRecordState();
14470
+ const recordRefusal = recordState.refusal;
14471
+ const visibleEntries = getVisibleReplJournalEntries();
14406
14472
  const hasEntries = visibleEntries.length > 0;
14407
14473
  const entryCount = visibleEntries.length;
14408
14474
  const collapsedClass = replJournalCollapsed ? " is-collapsed" : "";
@@ -14464,6 +14530,7 @@
14464
14530
  + (replRecordActivity === "off" ? "" : " New entries here go to the agent and its model provider.")
14465
14531
  + "</p>"
14466
14532
  + (recordRefusal ? "<p class='repl-journal-omitted'>" + escapeHtml("Not shown: " + recordRefusal) + "</p>" : "")
14533
+ + (!recordRefusal && recordState.unverified ? "<p class='repl-journal-omitted'>Record directory not verified: this session has no record-directory key yet, so the record here may not be the one other clients use.</p>" : "")
14467
14534
  + (omitted ? "<div class='repl-journal-omitted'>Showing latest 12 entries for this session; " + escapeHtml(String(omitted)) + " older entries remain in export.</div>" : "")
14468
14535
  // The prompt column fits the longest prompt, such as gnuplot>, in the prompt's own font.
14469
14536
  + "<div class='repl-journal-list' style='--repl-studio-prompt-chars: " + Math.max(0, ...visibleEntries.map((entry) => getReplStudioPrompt(entry.runtime).length)) + "'>" + terminalContent + "</div>"
@@ -29564,6 +29631,11 @@
29564
29631
  if (message.cleared && sessionName) {
29565
29632
  replJournalEntries = replJournalEntries.filter((entry) => entry.sessionName !== sessionName);
29566
29633
  persistReplJournalEntries();
29634
+ if (replJournalClearRequests.delete(message.requestId)) {
29635
+ // The active entry was this session's only if this session is still the one shown.
29636
+ if (sessionName === getActiveReplJournalSessionName()) activeReplJournalEntryId = "";
29637
+ setStatus("Cleared shared REPL record for " + sessionName + ".", "success");
29638
+ }
29567
29639
  } else {
29568
29640
  mergeReplJournalEntries(message.journalEntries);
29569
29641
  }
@@ -30129,6 +30201,13 @@
30129
30201
  return;
30130
30202
  }
30131
30203
 
30204
+ // This page's clear, refused: only its status changes, and its copy stays.
30205
+ if (message.type === "error" && replJournalClearRequests.delete(message.requestId)) {
30206
+ setStatus(typeof message.message === "string" ? message.message : "Nothing was cleared.", "warning");
30207
+ renderReplViewIfActive({ force: true });
30208
+ return;
30209
+ }
30210
+
30132
30211
  if (message.type === "error") {
30133
30212
  let rejectedSubmission = false;
30134
30213
  clearPiEditorOperations(message.requestId);
package/index.ts CHANGED
@@ -10229,15 +10229,18 @@ function parseStudioReplJournalEntryInput(value: unknown): Partial<StudioReplJou
10229
10229
  const prose = typeof entry.prose === "string" ? entry.prose.slice(0, 80_000) : "";
10230
10230
  const output = typeof entry.output === "string" ? entry.output.slice(0, 200_000) : "";
10231
10231
  if (!code.trim() && !prose.trim() && !output.trim()) return null;
10232
+ // The request ID as it's kept, which decides whether the label is a person's name (Sol).
10233
+ const requestId = typeof entry.requestId === "string" ? entry.requestId.slice(0, 300) : undefined;
10232
10234
  return {
10233
10235
  id: typeof entry.id === "string" ? entry.id.slice(0, 240) : undefined,
10234
- requestId: typeof entry.requestId === "string" ? entry.requestId.slice(0, 300) : undefined,
10236
+ requestId,
10235
10237
  createdAt: typeof entry.createdAt === "number" && Number.isFinite(entry.createdAt) ? entry.createdAt : undefined,
10236
10238
  updatedAt: typeof entry.updatedAt === "number" && Number.isFinite(entry.updatedAt) ? entry.updatedAt : undefined,
10237
10239
  completedAt: typeof entry.completedAt === "number" && Number.isFinite(entry.completedAt) ? entry.completedAt : null,
10238
10240
  runtime: normalizeStudioReplRuntime(entry.runtime) || "unknown",
10239
10241
  origin: entry.origin === "pi-repl" ? "pi-repl" : "pi-studio",
10240
- label: typeof entry.label === "string" ? entry.label.slice(0, 240) : undefined,
10242
+ // A person's name is checked as sent (checkStudioReplPersonEntry), so cutting it can't make it usable (Sol, Astra).
10243
+ label: typeof entry.label === "string" ? (isStudioReplPersonRequestId(requestId) ? entry.label : entry.label.slice(0, 240)) : undefined,
10241
10244
  mode: normalizeStudioReplJournalMode(entry.mode),
10242
10245
  prose,
10243
10246
  code,
@@ -10247,12 +10250,16 @@ function parseStudioReplJournalEntryInput(value: unknown): Partial<StudioReplJou
10247
10250
  };
10248
10251
  }
10249
10252
 
10253
+ // Whether a request ID is under Studio's person prefix (studio:send:, studio:note:), read as the
10254
+ // shared record will keep it, without line breaks or NULs and trimmed (Sol).
10255
+ function isStudioReplPersonRequestId(requestId: unknown): boolean {
10256
+ return typeof requestId === "string" && requestId.replace(/[\r\n\0]+/g, "").trim().startsWith("studio:");
10257
+ }
10258
+
10250
10259
  // A note under Studio's person prefix (studio:note:) records a name as its label, checked
10251
- // as pi-repl checks names. An unusable one is an error, so it isn't shown as a name. The
10252
- // request ID is read as the shared record will keep it, without line breaks or NULs and
10253
- // trimmed (Sol).
10260
+ // as pi-repl checks names. An unusable one is an error, so it isn't shown as a name.
10254
10261
  function checkStudioReplPersonEntry(entry: Partial<StudioReplJournalEntry>): { entry: Partial<StudioReplJournalEntry>; error?: string } {
10255
- if (!String(entry.requestId || "").replace(/[\r\n\0]+/g, "").trim().startsWith("studio:")) return { entry };
10262
+ if (!isStudioReplPersonRequestId(entry.requestId)) return { entry };
10256
10263
  const person = validatePersonName(entry.label);
10257
10264
  return person.error ? { entry, error: person.error } : { entry: { ...entry, label: person.name } };
10258
10265
  }
@@ -12380,7 +12387,16 @@ function buildStudioReplSubmissionLine(runtime: StudioReplRuntime, sourceFile: s
12380
12387
  if (runtime === "octave" || runtime === "matlab") return `eval(fileread(${mStringLiteral(sourceFile)}));`;
12381
12388
  if (runtime === "gnuplot") return buildGnuplotSubmissionLine(sourceFile);
12382
12389
  if (runtime === "cpp") return cppInclude(sourceFile);
12383
- if (runtime === "shell") return `. ${shellQuote(sourceFile)}; touch ${shellQuote(doneFile)}`;
12390
+ // zsh ends the whole command line when Ctrl+C stops a command in the code, so there the done
12391
+ // file is written in an always block, which runs however the code ends; bash goes on to the
12392
+ // end of the file and to the touch. The shell that reads the line chooses, since a pane's
12393
+ // foreground command can be a child that won't read it (Sol). zsh's form is in eval, which
12394
+ // other shells don't parse, and keeps its separators for sh emulation (Sol).
12395
+ if (runtime === "shell") {
12396
+ return `__pi_studio_source=${shellQuote(sourceFile)}; __pi_studio_done=${shellQuote(doneFile)}; `
12397
+ + `case "\${ZSH_VERSION-}" in "") . "$__pi_studio_source"; touch "$__pi_studio_done";; `
12398
+ + `*) eval '{ . "$__pi_studio_source"; } always { touch "$__pi_studio_done"; }';; esac`;
12399
+ }
12384
12400
  return `exec(open(${quotedPath}, encoding="utf-8").read(), globals())`;
12385
12401
  }
12386
12402
 
@@ -12996,6 +13012,8 @@ type StudioReplActivityObservation =
12996
13012
  record: Awaited<ReturnType<typeof readReplRecordInert>> & {};
12997
13013
  runtime: string;
12998
13014
  runtimeLabel: string;
13015
+ // No record-directory key yet: this may not be the record other clients use (P0).
13016
+ unverified: boolean;
12999
13017
  }
13000
13018
  | { sessionName: string; ok: false; problem?: string };
13001
13019
 
@@ -13016,9 +13034,10 @@ async function observeStudioReplActivity(sessionNames: string[]): Promise<Studio
13016
13034
  if (!pane || pane.sessionName !== sessionName || !isValidReplSessionRecordId(pane.recordId)) return null;
13017
13035
  const identity = { recordId: pane.recordId, tmuxSessionId: pane.sessionId, tmuxSessionCreatedAt: Math.max(0, Math.floor(Number(pane.createdAt) || 0)) };
13018
13036
  let record: Awaited<ReturnType<typeof readReplRecordInert>>;
13037
+ let state: ReturnType<typeof classifyReplSessionRecordRoot>;
13019
13038
  try {
13020
13039
  // Only a record in the directory the session's key names, or one with no key yet (P0).
13021
- const state = classifyReplSessionRecordRoot(pane.rootKey || undefined);
13040
+ state = classifyReplSessionRecordRoot(pane.rootKey || undefined);
13022
13041
  if (state === "different" || state === "malformed") return { sessionName, ok: false, problem: studioReplRecordRootRefusal(state, sessionName) };
13023
13042
  record = await readReplRecordInert(getReplSessionRecordPath(pane.recordId), { ...identity, sessionName });
13024
13043
  } catch (error) {
@@ -13026,7 +13045,7 @@ async function observeStudioReplActivity(sessionNames: string[]): Promise<Studio
13026
13045
  }
13027
13046
  if (!record) return null;
13028
13047
  const runtime = normalizeStudioReplRuntime(pane.runtime) || inferStudioReplSessionRuntime(sessionName).runtime;
13029
- return { sessionName, ok: true, identity, record, runtime, runtimeLabel: runtime === "unknown" ? "unknown runtime" : STUDIO_REPL_RUNTIME_LABELS[runtime] };
13048
+ return { sessionName, ok: true, identity, record, runtime, runtimeLabel: runtime === "unknown" ? "unknown runtime" : STUDIO_REPL_RUNTIME_LABELS[runtime], unverified: state === "unverified" };
13030
13049
  };
13031
13050
  try {
13032
13051
  const observed = await Promise.all(sessionNames.map((sessionName) => Promise.race([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-studio",
3
- "version": "0.11.7",
3
+ "version": "0.11.8",
4
4
  "description": "Two-pane browser workspace for pi with prompt/response editing, annotations, critiques, active quiz, prompt/response history, live previews, and tmux-backed REPL/literate REPL workflows",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
2
  import { lstat, readFile } from "node:fs/promises";
3
- import { isValidReplSessionRecordId, normalizeReplSessionRecordEntry, REPL_SESSION_RECORD_MAX_BYTES, REPL_SESSION_RECORD_PROTOCOL, REPL_SESSION_RECORD_VERSION } from "./repl-session-record.js";
3
+ import { describeReplSessionRecordRoot, isValidReplSessionRecordId, normalizeReplSessionRecordEntry, REPL_SESSION_RECORD_MAX_BYTES, REPL_SESSION_RECORD_PROTOCOL, REPL_SESSION_RECORD_VERSION } from "./repl-session-record.js";
4
4
 
5
5
  /*
6
6
  * What Studio's agent is told of shared REPL record entries it hasn't been shown: at the start
@@ -261,6 +261,9 @@ function describeObservedSession(state, observed, exclude) {
261
261
  if (known?.considered === version) continue;
262
262
  session.candidates.push({ entry, version, session, updated: Boolean(known?.told) });
263
263
  }
264
+ // A record from a session with no record-directory key yet says so with its entries, not on
265
+ // its own: it would otherwise be told at every look (pi-repl's P0).
266
+ if (observed.unverified && session.candidates.length) notes.push(describeReplSessionRecordRoot("unverified", name));
264
267
  return session;
265
268
  }
266
269
 
@@ -269,7 +272,7 @@ const sessionBlock = (session) => [session.heading, ...session.notes].join("\n\n
269
272
  /**
270
273
  * The report for these observations, and what to mark once it reaches the model. Each
271
274
  * observation is a session that was checked: `{ sessionName, runtime, runtimeLabel, ok: true,
272
- * identity, record }`, or `{ sessionName, ok: false, problem? }` when it couldn't be checked in
275
+ * identity, record, unverified? }`, or `{ sessionName, ok: false, problem? }` when it couldn't be checked in
273
276
  * time, or its record couldn't be read. Entries in `exclude` (the agent's own send) aren't
274
277
  * reported; `own` marks them as told once the text of their own result reaches the model.
275
278
  *