pi-studio 0.10.4 → 0.11.0

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,32 @@ All notable changes to `pi-studio` are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.11.0] — 2026-10-21
8
+
9
+ ### Added
10
+ - The REPL pane runs **Ruby** (irb) and **Java** (JShell), as pi-repl does. Choose them under **Runtime**, or send to a pi-repl Ruby or Java session. In Java, print values with `System.out.println(…)`: code is loaded with `/open`, which doesn't show expression results. Stop waits for JShell's second JVM to exit too.
11
+ - The REPL pane runs **Octave** (`octave-cli`) and **MATLAB**, as pi-repl does, as separate runtimes. Code runs in the base workspace, with the usual `ans` and semicolon behaviour; errors and Ctrl+C still complete the send. MATLAB starts without its desktop in the working directory, and Studio waits up to two minutes for its prompt. Stopping Octave doesn't leave an `octave-workspace` file in the working directory, unless you start it with your own **Start cmd**.
12
+ - The REPL pane runs **gnuplot**, as pi-repl does. Code runs as written, so your terminal and settings stay as you set them, and errors and Ctrl+C still complete the send. Stop also closes its Qt plot windows.
13
+ - The REPL pane runs **C++** in Cling, as pi-repl does. Send complete prompt groups, with a function's opening brace on its declaration line. Errors, incomplete code and uncaught C++ exceptions still complete the send, and earlier groups keep their effect. Cling and its development headers need to be on your PATH.
14
+
15
+ ### Changed
16
+ - Pane echo defaults to **Summary**, as in pi-repl, so the tmux pane shows each sent submission above its output. Summary now shows up to 20 lines or 2,000 characters, up from 6 lines or 600. If you chose Full before, Studio keeps it; if you chose Off, choose it again.
17
+ - In dual mode, **Pane echo** is under the REPL pane's **More**, below **Send mode**. The toolbar had stopped showing it, so it couldn't be changed there. Choose **Off** for a quiet pane.
18
+ - With Pane echo **Off**, a send whose output doesn't end its line now ends it, as pi-repl does. The record keeps that output, and the runtime's next prompt starts on a line of its own.
19
+ - Pane echo looks the same as pi-repl's: `── pi-studio · input · 2 lines · id: … ──`, then the code without `│` bars, the output, `── done · id: … ──` and a blank line. A blank line also separates the code from the line that loads it. Studio's temporary files for a send start with the same id. The record still holds only the code and its output.
20
+
21
+ ### Fixed
22
+ - When a runtime exits or crashes during a send, the send ends within a couple of seconds with "… ended while running the code." It used to wait out its 20-second timeout and then report that Studio couldn't capture the session. If tmux keeps the dead pane, the record keeps what it shows.
23
+ - In a Julia pane narrower than the line that loads the code, sent code no longer leaves copies of that line in the output. Studio pastes it as one bracketed paste, as pi-repl 0.8.5 does.
24
+ - With Summary or Full, the done marker goes on a line of its own when the output doesn't end with a newline, as with `print("c", end="")`. It used to join the output's last line and end up in the record.
25
+
26
+ ## [0.10.5] — 2026-10-20
27
+
28
+ ### Fixed
29
+ - After a Quick send, the record shows the result while the cursor stays in the box. Since 0.10.3 it waited for the next change, such as your next send. If the pane is redrawn while you type, the text, the selection and where typing goes are kept.
30
+ - While a prompt runs, the Prompt toolbar's tools stay on one row on a 13-inch screen. **Queue steering** took more room than its label needed, which left a gap before it and pushed them onto a second row.
31
+ - With Muxy 2.2, `/studio` opens in Muxy's built-in browser. Muxy 2.2 marks its terminals differently, so Studio didn't recognise them and opened the system browser instead.
32
+
7
33
  ## [0.10.4] — 2026-10-19
8
34
 
9
35
  ### Fixed
package/README.md CHANGED
@@ -27,7 +27,7 @@ Watch the [demo](https://github.com/omaclaren/pi-studio/releases/download/demo-p
27
27
  - **Files and Changes** — browse folders you've allowed, open or preview files, and see the current git diff.
28
28
  - **Comments and scratchpad** — comments anchored to lines or selections, and a scratchpad per document.
29
29
  - **Side questions and quizzes** — ask about the text, a folder or the repository in a separate thread that stays out of the main conversation, or quiz yourself on it.
30
- - **REPL** — send code to tmux-backed Shell, Python, IPython, Julia, R, GHCi or Clojure sessions, shared with [pi-repl](https://github.com/omaclaren/pi-repl).
30
+ - **REPL** — send code to tmux-backed Shell, Python, IPython, Julia, R, GHCi, Clojure, Ruby, Java, Octave, MATLAB, gnuplot or C++ (Cling) sessions, shared with [pi-repl](https://github.com/omaclaren/pi-repl).
31
31
  - **Export** — PDF (Pandoc and LaTeX) or standalone HTML, from the preview, a file or the last response.
32
32
 
33
33
  ## Requirements
@@ -36,6 +36,7 @@ Watch the [demo](https://github.com/omaclaren/pi-studio/releases/download/demo-p
36
36
  - [Pandoc](https://pandoc.org/installing.html) for full previews and exports (`brew install pandoc` on macOS), and LaTeX (TeX Live or MacTeX) for PDF export
37
37
  - Optional:
38
38
  - `tmux` for the REPL;
39
+ - a JDK with `jshell` for the Java REPL, and `matlab` for MATLAB, on the PATH Pi runs with, since Studio doesn't start them through a login shell (or give the full path in the REPL pane's **Start cmd**);
39
40
  - `quarto` for Quarto previews;
40
41
  - Mermaid CLI 11.12+ for diagrams in exported PDFs;
41
42
  - `pdftotext` so side questions can read PDFs;
@@ -135,7 +136,7 @@ Icons in exported PDFs need Mermaid CLI 11.12+ (`npm install -g @mermaid-js/merm
135
136
 
136
137
  ### REPL
137
138
 
138
- 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 (Off, Summary, Full) controls how much submitted code appears in the raw tmux history; Full writes your code into that history. 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. The record format is in [`shared/REPL_SESSION_RECORD_PROTOCOL.md`](./shared/REPL_SESSION_RECORD_PROTOCOL.md).
139
140
 
140
141
  ### Side questions
141
142
 
@@ -155,7 +156,7 @@ For a container, `/studio --no-browser --listen-all --port 4321` listens on all
155
156
  | `MERMAID_CLI_PATH` | Mermaid CLI for diagrams in PDFs |
156
157
  | `BRAVE_API_KEY` | Enables web search in side questions |
157
158
  | `PI_STUDIO_FONT_MONO`, `PI_STUDIO_FONT_UI`, `PI_STUDIO_FONT_PROSE` | CSS font stacks for code, interface and previews |
158
- | `PI_STUDIO_REPL_ECHO_MODE` | Default pane echo for `studio_repl_send`: `off`, `summary` or `full` |
159
+ | `PI_STUDIO_REPL_ECHO_MODE` | Default pane echo for `studio_repl_send`: `summary` (the default), `off` or `full` |
159
160
  | `PI_STUDIO_PANDOC_TIMEOUT_MS`, `PI_STUDIO_LATEX_TIMEOUT_MS`, `PI_STUDIO_MERMAID_TIMEOUT_MS` | Export time limits |
160
161
 
161
162
  Installing pi-studio also adds `pi-studio-dark` and `pi-studio-light` to Pi's themes, without changing your current theme.
@@ -716,6 +716,18 @@
716
716
  // After a Quick send from the box, the cursor goes back to it (Oliver, 19 Oct):
717
717
  // { requestId, settled }, cleared when restored or when anything else is chosen.
718
718
  let replQuickRefocus = null;
719
+ // A REPL pane redraw that waited (for focus to leave a control, or for a pause in the
720
+ // Quick send box), and what the box is in the middle of (Oliver, 19 Oct).
721
+ let replRedrawDeferred = false;
722
+ let replRedrawDeferredForce = false;
723
+ let replRedrawForced = false;
724
+ let replRedrawRetryTimer = null;
725
+ // A height the box was dragged to, kept across redraws.
726
+ let replQuickBoxHeight = "";
727
+ let replQuickComposing = false;
728
+ let replQuickPointerDown = false;
729
+ let replQuickLastInputAt = 0;
730
+ const REPL_QUICK_TYPING_PAUSE_MS = 800;
719
731
  let replSendMode = (() => {
720
732
  try {
721
733
  const stored = window.localStorage && window.localStorage.getItem("piStudio.replSendMode");
@@ -726,10 +738,13 @@
726
738
  })();
727
739
  let replEchoMode = (() => {
728
740
  try {
729
- const stored = String((window.localStorage && window.localStorage.getItem("piStudio.replEchoMode.v2")) || "").trim().toLowerCase();
730
- return stored === "summary" || stored === "full" ? stored : "off";
741
+ const stored = String((window.localStorage && window.localStorage.getItem("piStudio.replEchoMode.v3")) || "").trim().toLowerCase();
742
+ if (stored === "off" || stored === "summary" || stored === "full") return stored;
743
+ // v2 saved Off whether or not it was chosen; keep only a Full chosen there.
744
+ const earlier = String((window.localStorage && window.localStorage.getItem("piStudio.replEchoMode.v2")) || "").trim().toLowerCase();
745
+ return earlier === "full" ? "full" : "summary";
731
746
  } catch {
732
- return "off";
747
+ return "summary";
733
748
  }
734
749
  })();
735
750
  function normalizeReplJournalEntry(entry) {
@@ -1486,6 +1501,7 @@
1486
1501
  function getKnownReplRuntime(value) {
1487
1502
  const runtime = String(value || "").trim().toLowerCase();
1488
1503
  return runtime === "shell" || runtime === "python" || runtime === "ipython" || runtime === "julia" || runtime === "r" || runtime === "ghci" || runtime === "clojure"
1504
+ || runtime === "ruby" || runtime === "java" || runtime === "octave" || runtime === "matlab" || runtime === "gnuplot" || runtime === "cpp"
1489
1505
  ? runtime
1490
1506
  : "";
1491
1507
  }
@@ -1502,6 +1518,12 @@
1502
1518
  if (runtime === "julia") return "Julia";
1503
1519
  if (runtime === "r") return "R";
1504
1520
  if (runtime === "ghci") return "GHCi";
1521
+ if (runtime === "ruby") return "Ruby";
1522
+ if (runtime === "java") return "Java";
1523
+ if (runtime === "octave") return "Octave";
1524
+ if (runtime === "matlab") return "MATLAB";
1525
+ if (runtime === "gnuplot") return "gnuplot";
1526
+ if (runtime === "cpp") return "C++";
1505
1527
  return "Clojure";
1506
1528
  }
1507
1529
 
@@ -1578,7 +1600,7 @@
1578
1600
 
1579
1601
  function normalizeReplEchoMode(value) {
1580
1602
  const normalized = String(value || "").trim().toLowerCase();
1581
- return normalized === "summary" || normalized === "full" ? normalized : "off";
1603
+ return normalized === "off" || normalized === "full" ? normalized : "summary";
1582
1604
  }
1583
1605
 
1584
1606
  function isMacShortcutPlatform() {
@@ -1639,12 +1661,23 @@
1639
1661
  replEchoMode = normalizeReplEchoMode(mode);
1640
1662
  if (replEchoModeSelect) replEchoModeSelect.value = replEchoMode;
1641
1663
  try {
1642
- if (window.localStorage) window.localStorage.setItem("piStudio.replEchoMode.v2", replEchoMode);
1664
+ if (window.localStorage) window.localStorage.setItem("piStudio.replEchoMode.v3", replEchoMode);
1643
1665
  } catch {
1644
1666
  // Ignore storage failures.
1645
1667
  }
1646
1668
  }
1647
1669
 
1670
+ function chooseReplEchoMode(mode) {
1671
+ setReplEchoMode(mode);
1672
+ syncActionButtons();
1673
+ setStatus(replEchoMode === "full"
1674
+ ? "Full pane echo enabled. Bounded submitted source code will remain in raw terminal history."
1675
+ : (replEchoMode === "off"
1676
+ ? "Pane echo disabled; new sends will not add alignment anchors to raw terminal history."
1677
+ : "Summary pane echo enabled; short submissions will be shown with compact anchors and a plain output divider."),
1678
+ replEchoMode === "full" ? "warning" : "success");
1679
+ }
1680
+
1648
1681
  function syncReplEchoModeSelect(visible) {
1649
1682
  if (!replEchoModeSelect) return;
1650
1683
  replEchoModeSelect.hidden = !visible;
@@ -1654,7 +1687,7 @@
1654
1687
  ? "Do not add a submitted-code display or alignment anchors to the raw REPL pane."
1655
1688
  : (replEchoMode === "full"
1656
1689
  ? "Display up to 40 lines or 4,000 characters of submitted code; source remains in raw terminal history."
1657
- : "Display short submissions in full, truncating after 6 lines or 600 characters, with compact anchors and a plain output divider.");
1690
+ : "Display short submissions in full, truncating after 20 lines or 2,000 characters, with compact anchors and a plain output divider.");
1658
1691
  }
1659
1692
 
1660
1693
  function getReplQuickDraftKey(session) {
@@ -1669,7 +1702,10 @@
1669
1702
  }
1670
1703
 
1671
1704
  function setReplQuickDraft(session, value) {
1672
- const key = getReplQuickDraftKey(session);
1705
+ return setReplQuickDraftForKey(getReplQuickDraftKey(session), value);
1706
+ }
1707
+
1708
+ function setReplQuickDraftForKey(key, value) {
1673
1709
  if (!key) return "";
1674
1710
  const draft = String(value || "").slice(0, REPL_QUICK_DRAFT_MAX_CHARS);
1675
1711
  if (!draft) {
@@ -2006,6 +2042,113 @@
2006
2042
  return activeEl instanceof Element && Boolean(activeEl.closest(".repl-controls, .repl-quick-composer"));
2007
2043
  }
2008
2044
 
2045
+ // The pane can be redrawn under the Quick send box: its text is kept as a draft on
2046
+ // every keystroke, and its cursor, selection and scroll are put back. Otherwise a
2047
+ // result that arrived while the cursor stayed there wasn't shown (since 0.10.3).
2048
+ // Not mid-typing, mid-composition or mid-drag, though: the redraw waits for a pause.
2049
+ // Other REPL controls wait until focus leaves them.
2050
+ function canRedrawReplUnderFocus() {
2051
+ const activeEl = document.activeElement;
2052
+ return activeEl instanceof HTMLTextAreaElement && activeEl.hasAttribute("data-repl-quick-draft")
2053
+ && !replQuickComposing && !replQuickPointerDown && Date.now() - replQuickLastInputAt >= REPL_QUICK_TYPING_PAUSE_MS;
2054
+ }
2055
+
2056
+ function retryReplRedrawAfterPause() {
2057
+ if (replRedrawRetryTimer !== null) return;
2058
+ const wait = Math.max(0, replQuickLastInputAt + REPL_QUICK_TYPING_PAUSE_MS - Date.now()) + 20;
2059
+ replRedrawRetryTimer = window.setTimeout(() => {
2060
+ replRedrawRetryTimer = null;
2061
+ replayDeferredReplRedraw();
2062
+ }, wait);
2063
+ }
2064
+
2065
+ // Whether a REPL redraw has to wait. Asked when the redraw is requested and again when
2066
+ // its frame runs: composing, typing, a drag or focus elsewhere can start in between
2067
+ // (Sol, Astra). Composing holds even a forced redraw.
2068
+ function replRedrawMustWait(force) {
2069
+ return replQuickComposing || (!force && isReplControlFocused() && !canRedrawReplUnderFocus());
2070
+ }
2071
+
2072
+ function deferReplRedraw(force) {
2073
+ replRedrawDeferred = true;
2074
+ replRedrawDeferredForce = replRedrawDeferredForce || force;
2075
+ // Only typing needs a timer: composing and a drag end with their own events (Sol).
2076
+ const activeEl = document.activeElement;
2077
+ if (!replQuickComposing && !replQuickPointerDown && activeEl instanceof HTMLTextAreaElement && activeEl.hasAttribute("data-repl-quick-draft")) retryReplRedrawAfterPause();
2078
+ }
2079
+
2080
+ // The session lifetime a drawn Quick send box belongs to. While a redraw waits (for
2081
+ // composing, say), the selection can move on and leave the box showing another one.
2082
+ function getReplQuickBoxKey(box) {
2083
+ try {
2084
+ return box instanceof Element ? decodeURIComponent(box.getAttribute("data-repl-quick-lifetime") || "") : "";
2085
+ } catch {
2086
+ return "";
2087
+ }
2088
+ }
2089
+
2090
+ // What the REPL pane is drawn for: the runtime, and the selected session's name and lifetime.
2091
+ function getReplPaneTargetKey() {
2092
+ const session = getActiveReplSessionForCurrentRuntime();
2093
+ return [normalizeReplRuntime(replRuntime), session ? session.sessionName : "", session ? getReplQuickDraftKey(session) : ""].join("\u001e");
2094
+ }
2095
+
2096
+ // A pane left on screen for another session, or a replacement with the same name. Its
2097
+ // controls do nothing then, and the redraw shows the current one (Sol, Astra).
2098
+ function isReplPaneStale(el) {
2099
+ const pane = el instanceof Element ? el.closest("[data-repl-drawn-target]") : null;
2100
+ if (!pane) return false;
2101
+ try {
2102
+ return decodeURIComponent(pane.getAttribute("data-repl-drawn-target") || "") !== getReplPaneTargetKey();
2103
+ } catch {
2104
+ return true;
2105
+ }
2106
+ }
2107
+
2108
+ function refuseStaleReplPaneAction(message) {
2109
+ setStatus(message, "warning");
2110
+ renderReplViewIfActive({ force: true });
2111
+ }
2112
+
2113
+ function replayDeferredReplRedraw() {
2114
+ if (!replRedrawDeferred) return;
2115
+ renderReplViewIfActive({ force: replRedrawDeferredForce });
2116
+ }
2117
+
2118
+ // The cursor goes back only into the box for the same session lifetime: a redraw that
2119
+ // shows another session, or a replacement with the same name, leaves focus to the page.
2120
+ function captureReplQuickComposerCursor() {
2121
+ const activeEl = document.activeElement;
2122
+ if (!(activeEl instanceof HTMLTextAreaElement) || !activeEl.hasAttribute("data-repl-quick-draft")) return null;
2123
+ return {
2124
+ lifetime: activeEl.getAttribute("data-repl-quick-lifetime") || "",
2125
+ start: activeEl.selectionStart,
2126
+ end: activeEl.selectionEnd,
2127
+ direction: activeEl.selectionDirection,
2128
+ scrollTop: activeEl.scrollTop,
2129
+ };
2130
+ }
2131
+
2132
+ function restoreReplQuickComposerCursor(cursor) {
2133
+ if (!cursor || rightView !== "repl" || !critiqueViewEl) return;
2134
+ const composer = critiqueViewEl.querySelector("[data-repl-quick-draft]");
2135
+ if (!(composer instanceof HTMLTextAreaElement) || composer.disabled) return;
2136
+ if (!cursor.lifetime || composer.getAttribute("data-repl-quick-lifetime") !== cursor.lifetime) return;
2137
+ if (document.activeElement !== composer) {
2138
+ try {
2139
+ composer.focus({ preventScroll: true });
2140
+ } catch {
2141
+ try { composer.focus(); } catch {}
2142
+ }
2143
+ }
2144
+ if (document.activeElement !== composer) return;
2145
+ const length = composer.value.length;
2146
+ try {
2147
+ composer.setSelectionRange(Math.min(cursor.start, length), Math.min(cursor.end, length), cursor.direction || "none");
2148
+ } catch {}
2149
+ composer.scrollTop = cursor.scrollTop;
2150
+ }
2151
+
2009
2152
  function focusReplQuickComposer() {
2010
2153
  replQuickFocusRequested = true;
2011
2154
  window.setTimeout(() => {
@@ -2054,11 +2197,26 @@
2054
2197
 
2055
2198
  function renderReplViewIfActive(options) {
2056
2199
  if (rightView !== "repl") return;
2057
- if ((!options || options.force !== true) && isReplControlFocused()) return;
2200
+ const force = Boolean(options && options.force === true);
2201
+ if (replRedrawMustWait(force)) {
2202
+ deferReplRedraw(force);
2203
+ return;
2204
+ }
2205
+ replRedrawDeferred = false;
2206
+ replRedrawDeferredForce = false;
2207
+ replRedrawForced = replRedrawForced || force;
2058
2208
  if (traceRenderRaf !== null) return;
2059
2209
  traceRenderRaf = window.requestAnimationFrame(() => {
2060
2210
  traceRenderRaf = null;
2211
+ const forced = replRedrawForced;
2212
+ replRedrawForced = false;
2213
+ if (rightView === "repl" && replRedrawMustWait(forced)) {
2214
+ deferReplRedraw(forced);
2215
+ return;
2216
+ }
2217
+ const cursor = captureReplQuickComposerCursor();
2061
2218
  refreshResponseUi();
2219
+ restoreReplQuickComposerCursor(cursor);
2062
2220
  applyReplQuickRefocus();
2063
2221
  if (replQuickFocusRequested) focusReplQuickComposer();
2064
2222
  });
@@ -2119,6 +2277,8 @@
2119
2277
  if (first === "bash") return "shell";
2120
2278
  if (first === "hs" || first === "haskell") return "ghci";
2121
2279
  if (first === "clj" || first === "cljc") return "clojure";
2280
+ if (first === "rb") return "ruby";
2281
+ if (first === "c++" || first === "cxx" || first === "hpp") return "cpp";
2122
2282
  return first;
2123
2283
  }
2124
2284
 
@@ -2176,6 +2336,12 @@
2176
2336
  if (activeRuntime === "shell") return lang === "shell" || lang === "bash" || lang === "sh";
2177
2337
  if (activeRuntime === "ghci") return lang === "ghci" || lang === "haskell";
2178
2338
  if (activeRuntime === "clojure") return lang === "clojure";
2339
+ if (activeRuntime === "ruby") return lang === "ruby";
2340
+ if (activeRuntime === "java") return lang === "java";
2341
+ if (activeRuntime === "octave") return lang === "octave";
2342
+ if (activeRuntime === "matlab") return lang === "matlab";
2343
+ if (activeRuntime === "gnuplot") return lang === "gnuplot";
2344
+ if (activeRuntime === "cpp") return lang === "cpp";
2179
2345
  return true;
2180
2346
  }
2181
2347
 
@@ -2800,6 +2966,11 @@
2800
2966
  return false;
2801
2967
  }
2802
2968
  const key = getReplQuickDraftKey(session);
2969
+ const box = critiqueViewEl ? critiqueViewEl.querySelector("[data-repl-quick-draft]") : null;
2970
+ if (isReplPaneStale(box)) {
2971
+ refuseStaleReplPaneAction("The REPL session changed, so nothing was sent.");
2972
+ return false;
2973
+ }
2803
2974
  const text = getReplQuickDraft(session);
2804
2975
  if (!text.trim()) {
2805
2976
  setStatus("Quick send is empty.", "warning");
@@ -11693,6 +11864,10 @@
11693
11864
  if (!actionBtn) return;
11694
11865
  event.preventDefault();
11695
11866
  const action = actionBtn.getAttribute("data-repl-action") || "";
11867
+ if (isReplPaneStale(actionBtn)) {
11868
+ refuseStaleReplPaneAction(action === "quick-send" ? "The REPL session changed, so nothing was sent." : "The REPL session changed, so nothing was done.");
11869
+ return;
11870
+ }
11696
11871
  if (action === "quick-send") {
11697
11872
  submitReplQuickDraft();
11698
11873
  return;
@@ -11834,13 +12009,44 @@
11834
12009
  }
11835
12010
  }
11836
12011
 
12012
+ // A redraw that waited for a control runs once focus has left it.
12013
+ function handleReplPaneFocusOut() {
12014
+ if (!replRedrawDeferred) return;
12015
+ window.setTimeout(replayDeferredReplRedraw, 0);
12016
+ }
12017
+
12018
+ function handleReplPaneComposition(event) {
12019
+ const target = event && event.target;
12020
+ if (!(target instanceof HTMLTextAreaElement) || !target.hasAttribute("data-repl-quick-draft")) return;
12021
+ replQuickComposing = event.type === "compositionstart";
12022
+ if (!replQuickComposing) replayDeferredReplRedraw();
12023
+ }
12024
+
12025
+ // A drag that starts in the box ends wherever the button comes up.
12026
+ function handleReplQuickPointer(event) {
12027
+ if (event.type === "pointerdown") {
12028
+ const target = event.target;
12029
+ replQuickPointerDown = target instanceof Element && Boolean(target.closest("[data-repl-quick-draft]"));
12030
+ return;
12031
+ }
12032
+ if (!replQuickPointerDown) return;
12033
+ replQuickPointerDown = false;
12034
+ // Dragging the box's corner sets its height; keep it for the boxes drawn after it.
12035
+ const composer = critiqueViewEl ? critiqueViewEl.querySelector("[data-repl-quick-draft]") : null;
12036
+ if (composer instanceof HTMLTextAreaElement && /^\d+(?:\.\d+)?px$/.test(composer.style.height)) replQuickBoxHeight = composer.style.height;
12037
+ replayDeferredReplRedraw();
12038
+ }
12039
+
11837
12040
  function handleReplPaneInput(event) {
11838
12041
  if (rightView !== "repl") return;
11839
12042
  const target = event && event.target;
11840
12043
  if (!(target instanceof HTMLTextAreaElement) || !target.hasAttribute("data-repl-quick-draft")) return;
11841
- const session = getActiveReplSessionForCurrentRuntime();
11842
- if (!session) return;
11843
- const draft = setReplQuickDraft(session, target.value);
12044
+ replQuickLastInputAt = Date.now();
12045
+ // The text belongs to the session the box was drawn for, even if another is selected
12046
+ // now and the box hasn't been redrawn yet (Astra).
12047
+ const key = getReplQuickBoxKey(target);
12048
+ if (!key) return;
12049
+ const draft = setReplQuickDraftForKey(key, target.value);
11844
12050
  if (target.value !== draft) target.value = draft;
11845
12051
  updateReplQuickComposerActions();
11846
12052
  }
@@ -11887,9 +12093,16 @@
11887
12093
  renderReplViewIfActive({ force: true });
11888
12094
  return;
11889
12095
  }
12096
+ const echoModeSelect = target.closest("[data-repl-echo-mode]");
12097
+ if (echoModeSelect && "value" in echoModeSelect) {
12098
+ chooseReplEchoMode(echoModeSelect.value);
12099
+ renderReplViewIfActive({ force: true });
12100
+ return;
12101
+ }
11890
12102
  const commandInput = target.closest("[data-repl-command]");
11891
12103
  if (commandInput && "value" in commandInput) {
11892
- setReplCommandOverride(replRuntime, commandInput.value);
12104
+ // For the runtime it was drawn for, even if another was selected meanwhile.
12105
+ setReplCommandOverride(commandInput.getAttribute("data-repl-command") || replRuntime, commandInput.value);
11893
12106
  return;
11894
12107
  }
11895
12108
  const sessionSelect = target.closest("[data-repl-session]");
@@ -11914,6 +12127,12 @@
11914
12127
  critiqueViewEl.addEventListener("click", handleStudioQuartoPreviewClick);
11915
12128
  critiqueViewEl.addEventListener("click", (event) => { void handleSideQuestionClick(event); });
11916
12129
  critiqueViewEl.addEventListener("focusin", handleReplPaneFocusIn);
12130
+ critiqueViewEl.addEventListener("focusout", handleReplPaneFocusOut);
12131
+ critiqueViewEl.addEventListener("compositionstart", handleReplPaneComposition);
12132
+ critiqueViewEl.addEventListener("compositionend", handleReplPaneComposition);
12133
+ document.addEventListener("pointerdown", handleReplQuickPointer, true);
12134
+ document.addEventListener("pointerup", handleReplQuickPointer, true);
12135
+ document.addEventListener("pointercancel", handleReplQuickPointer, true);
11917
12136
  document.addEventListener("focusin", cancelReplQuickRefocusOutside, true);
11918
12137
  document.addEventListener("pointerdown", cancelReplQuickRefocusOutside, true);
11919
12138
  critiqueViewEl.addEventListener("input", handleSideQuestionInput);
@@ -13739,6 +13958,8 @@
13739
13958
  if (normalized === "shell") return "bash";
13740
13959
  if (normalized === "ipython") return "python";
13741
13960
  if (normalized === "python" || normalized === "julia" || normalized === "r") return normalized;
13961
+ if (normalized === "octave" || normalized === "matlab") return "matlab";
13962
+ if (normalized === "cpp") return "cpp";
13742
13963
  return "text";
13743
13964
  }
13744
13965
 
@@ -13785,6 +14006,12 @@
13785
14006
  if (normalized === "shell") return "$";
13786
14007
  if (normalized === "ghci") return "ghci>";
13787
14008
  if (normalized === "clojure") return "user=>";
14009
+ if (normalized === "ruby") return "irb>";
14010
+ if (normalized === "java") return "jshell>";
14011
+ if (normalized === "octave") return "octave>";
14012
+ if (normalized === "matlab") return ">>";
14013
+ if (normalized === "gnuplot") return "gnuplot>";
14014
+ if (normalized === "cpp") return "[cling]$";
13788
14015
  return ">>>";
13789
14016
  }
13790
14017
 
@@ -13815,6 +14042,12 @@
13815
14042
  if (normalized === "r") return /^\s*(?:>|\+)\s?/.test(source);
13816
14043
  if (normalized === "ghci") return /^\s*(?:ghci>|Prelude>|\*?[A-Za-z0-9_.:]+>)\s?/.test(source);
13817
14044
  if (normalized === "clojure") return /^\s*[A-Za-z0-9_.-]+=>\s?/.test(source);
14045
+ if (normalized === "ruby") return /^\s*irb\([^)]*\):\d+(?::\d+)?[>*]\s?/.test(source);
14046
+ if (normalized === "java") return /^\s*jshell>\s?/.test(source);
14047
+ if (normalized === "octave") return /^\s*octave:\d+>\s?/.test(source);
14048
+ if (normalized === "matlab") return /^\s*>>\s?/.test(source);
14049
+ if (normalized === "gnuplot") return /^\s*gnuplot>\s?/.test(source);
14050
+ if (normalized === "cpp") return /^\s*\[cling\]\$\s?/.test(source);
13818
14051
  return false;
13819
14052
  }
13820
14053
 
@@ -13830,7 +14063,7 @@
13830
14063
  if (bannerLines.length >= 16) break;
13831
14064
  }
13832
14065
  const banner = bannerLines.join("\n").trim();
13833
- if (!/^(?:Python\s|IPython\s|R version\s|GHCi,\s|Clojure\s|Julia\s|julia\s)/i.test(banner)) return "";
14066
+ if (!/^(?:Python\s|IPython\s|R version\s|GHCi,\s|Clojure\s|Julia\s|julia\s|\|\s+Welcome to JShell\b)/i.test(banner)) return "";
13834
14067
  return banner;
13835
14068
  }
13836
14069
 
@@ -13905,7 +14138,8 @@
13905
14138
  + "<div class='repl-journal-header'><h3>Shared REPL Record</h3>" + toggleActions + "</div>"
13906
14139
  + "<p class='repl-journal-description'>What Studio and pi-repl have sent to this session.</p>"
13907
14140
  + (omitted ? "<div class='repl-journal-omitted'>Showing latest 12 entries for this session; " + escapeHtml(String(omitted)) + " older entries remain in export.</div>" : "")
13908
- + "<div class='repl-journal-list'>" + terminalContent + "</div>"
14141
+ // The prompt column fits the longest prompt, such as gnuplot>, in the prompt's own font.
14142
+ + "<div class='repl-journal-list' style='--repl-studio-prompt-chars: " + Math.max(0, ...visibleEntries.map((entry) => getReplStudioPrompt(entry.runtime).length)) + "'>" + terminalContent + "</div>"
13909
14143
  + "</section>";
13910
14144
  }
13911
14145
 
@@ -13952,7 +14186,7 @@
13952
14186
  return "<section class='repl-quick-composer' aria-labelledby='replQuickComposerTitle'>"
13953
14187
  + "<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>"
13954
14188
  + "<span class='repl-quick-hint'>Enter adds a line · Cmd/Ctrl+Enter sends</span></div>"
13955
- + "<textarea data-repl-quick-draft 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>"
14189
+ + "<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>"
13956
14190
  + "<div class='repl-quick-actions'><span></span><div>"
13957
14191
  + "<button type='button' data-repl-action='quick-clear'" + (pending || !draft ? " disabled" : "") + ">Clear</button>"
13958
14192
  + "<button class='repl-quick-send-btn' type='button' data-repl-action='quick-send'" + (sendDisabled ? " disabled" : "") + ">" + (pending ? "Sending…" : "Send") + "</button>"
@@ -13968,6 +14202,12 @@
13968
14202
  ["r", "R"],
13969
14203
  ["ghci", "GHCi"],
13970
14204
  ["clojure", "Clojure"],
14205
+ ["ruby", "Ruby"],
14206
+ ["java", "Java"],
14207
+ ["octave", "Octave"],
14208
+ ["matlab", "MATLAB"],
14209
+ ["gnuplot", "gnuplot"],
14210
+ ["cpp", "C++"],
13971
14211
  ].map(([value, label]) => "<option value='" + escapeHtml(value) + "'" + (replRuntime === value ? " selected" : "") + ">" + escapeHtml(label) + "</option>").join("");
13972
14212
  const runtimeLabel = getReplRuntimeLabel(replRuntime);
13973
14213
  const visibleSessions = getReplSessionsForRuntime(replRuntime);
@@ -13985,11 +14225,11 @@
13985
14225
  : "<div class='repl-empty'>" + escapeHtml(emptyMessage) + "</div>";
13986
14226
  const canSendToActiveSession = Boolean(activeSession) && !replBusy && replTmuxAvailable !== false;
13987
14227
  const canStopActiveSession = Boolean(activeSession && activeSession.source === "studio" && !replBusy && replTmuxAvailable !== false);
13988
- return "<div class='repl-panel'>"
14228
+ return "<div class='repl-panel' data-repl-drawn-target='" + escapeHtml(encodeURIComponent(getReplPaneTargetKey())) + "'>"
13989
14229
  + "<div class='repl-toolbar'>"
13990
14230
  + "<div class='repl-controls'>"
13991
14231
  + "<label class='repl-control-label'>Runtime <select class='studio-flat-select' data-repl-runtime aria-label='REPL runtime'>" + runtimeOptions + "</select></label>"
13992
- + "<label class='repl-control-label repl-command-label'>Start cmd <input data-repl-command type='text' value='" + escapeHtml(replCommand) + "' placeholder='default' aria-label='REPL start command' title='Command used by Start for this runtime. Leave blank for the default; use this for envs, e.g. .venv/bin/python, uv run python, or conda run --no-capture-output -n env python.'></label>"
14232
+ + "<label class='repl-control-label repl-command-label'>Start cmd <input data-repl-command='" + escapeHtml(normalizeReplRuntime(replRuntime)) + "' type='text' value='" + escapeHtml(replCommand) + "' placeholder='default' aria-label='REPL start command' title='Command used by Start for this runtime. Leave blank for the default; use this for envs, e.g. .venv/bin/python, uv run python, or conda run --no-capture-output -n env python.'></label>"
13993
14233
  + "<button class='repl-start-btn' type='button' data-repl-action='start'" + (replBusy || replTmuxAvailable === false ? " disabled" : "") + " title='Start or switch to a " + escapeHtml(runtimeLabel) + " session using the selected runtime and start command.'>Start</button>"
13994
14234
  + "<label class='repl-control-label repl-session-label'>Session <select class='studio-flat-select' data-repl-session aria-label='REPL session'" + (visibleSessions.length ? "" : " disabled") + ">" + sessionOptions + "</select></label>"
13995
14235
  + "<details class='repl-more-controls'>"
@@ -13998,6 +14238,9 @@
13998
14238
  // New layout: how Send to REPL reads the editor lives here, not in the Prompt toolbar (Oliver, 10 Oct).
13999
14239
  + (bufferSwitchingEnabled && studioUiRefreshUi ? "<label class='repl-more-send-mode' title='Raw sends the selection or all the text. Literate sends the selection, the code chunk at the cursor, or all matching chunks.'>Send mode <select class='studio-flat-select' data-repl-send-mode aria-label='Send mode'" + (wsState === "Disconnected" || uiBusy || replBusy ? " disabled" : "") + ">"
14000
14240
  + [["raw", "Raw"], ["literate", "Literate"]].map(([value, label]) => "<option value='" + value + "'" + (replSendMode === value ? " selected" : "") + ">" + label + "</option>").join("") + "</select></label>" : "")
14241
+ // Pane echo sits with Send mode; the toolbar menu isn't shown in this layout (Oliver, 19 Oct).
14242
+ + (bufferSwitchingEnabled && studioUiRefreshUi ? "<label class='repl-more-echo-mode' title='How much of the sent code the tmux pane shows: Summary up to 20 lines, Full up to 40, Off none.'>Pane echo <select class='studio-flat-select' data-repl-echo-mode aria-label='Pane echo'" + (wsState === "Disconnected" || uiBusy || replBusy ? " disabled" : "") + ">"
14243
+ + [["off", "Off"], ["summary", "Summary"], ["full", "Full"]].map(([value, label]) => "<option value='" + value + "'" + (replEchoMode === value ? " selected" : "") + ">" + label + "</option>").join("") + "</select></label>" : "")
14001
14244
  + "<button type='button' data-repl-action='stop-session'" + (canStopActiveSession ? "" : " disabled") + " title='Stop the selected Studio-owned REPL session.'>Stop session</button>"
14002
14245
  + "<button type='button' data-repl-action='interrupt'" + (activeSession && !replBusy ? "" : " disabled") + " title='Send Ctrl+C to the active REPL session.'>Interrupt</button>"
14003
14246
  + "<button type='button' data-repl-action='copy-attach-command'" + (activeSession ? "" : " disabled") + " title='Copy command for attaching to this tmux session in a terminal.'>Copy attach command</button>"
@@ -31560,16 +31803,7 @@
31560
31803
  }
31561
31804
 
31562
31805
  if (replEchoModeSelect) {
31563
- replEchoModeSelect.addEventListener("change", () => {
31564
- setReplEchoMode(replEchoModeSelect.value);
31565
- syncActionButtons();
31566
- setStatus(replEchoMode === "full"
31567
- ? "Full pane echo enabled. Bounded submitted source code will remain in raw terminal history."
31568
- : (replEchoMode === "off"
31569
- ? "Pane echo disabled; new sends will not add alignment anchors to raw terminal history."
31570
- : "Summary pane echo enabled; short submissions will be shown with compact anchors and a plain output divider."),
31571
- replEchoMode === "full" ? "warning" : "success");
31572
- });
31806
+ replEchoModeSelect.addEventListener("change", () => chooseReplEchoMode(replEchoModeSelect.value));
31573
31807
  }
31574
31808
 
31575
31809
  copyDraftBtn.addEventListener("click", async () => {
package/client/studio.css CHANGED
@@ -4990,16 +4990,19 @@
4990
4990
  white-space: pre-wrap;
4991
4991
  }
4992
4992
 
4993
+ /* The prompt column widens for a longer prompt (jshell>, octave>, gnuplot>), measured
4994
+ in the prompt's own font: --repl-studio-prompt-chars is the record's longest prompt. */
4993
4995
  .repl-studio-code-row,
4994
4996
  .repl-studio-output-row {
4995
4997
  display: grid;
4996
- grid-template-columns: var(--repl-studio-prompt-width) minmax(0, 1fr);
4998
+ grid-template-columns: minmax(var(--repl-studio-prompt-width), max-content) minmax(0, 1fr);
4997
4999
  gap: var(--repl-studio-column-gap);
4998
5000
  align-items: start;
4999
5001
  }
5000
5002
 
5001
5003
  .repl-studio-prompt,
5002
5004
  .repl-studio-output-label {
5005
+ min-width: calc(var(--repl-studio-prompt-chars, 0) * 1ch);
5003
5006
  font-family: var(--font-mono);
5004
5007
  font-size: var(--studio-working-font-size);
5005
5008
  line-height: 1.45;
@@ -6819,6 +6822,12 @@
6819
6822
  background: var(--studio-header-action-hover-bg, var(--panel-2));
6820
6823
  }
6821
6824
 
6825
+ /* Plain text needs no button width. The old 10rem left a gap before it and, on a
6826
+ 13-inch screen, pushed the tools onto a second row while running (Oliver, 19 Oct). */
6827
+ body.studio-ui-refresh #queueSteerBtn {
6828
+ min-width: 0;
6829
+ }
6830
+
6822
6831
  body.studio-ui-refresh .studio-refresh-review-btn.request-stop-active {
6823
6832
  background: color-mix(in srgb, var(--error) 82%, var(--panel));
6824
6833
  border-color: color-mix(in srgb, var(--error) 88%, var(--panel));
@@ -7803,7 +7812,9 @@
7803
7812
  body.studio-workspace-layout .repl-more-menu button:not(:disabled):hover { border-color: transparent; background: var(--studio-header-action-hover-bg, var(--panel-2)); }
7804
7813
  body.studio-workspace-layout .repl-more-menu button:disabled { color: var(--muted); }
7805
7814
  body.studio-workspace-layout .repl-more-menu button:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 3px; }
7806
- body.studio-workspace-layout .repl-more-send-mode { display: flex; align-items: center; gap: 6px; padding: 3px 8px 6px; margin-bottom: 2px; border-bottom: 1px solid var(--panel-border); color: var(--muted); font-size: 12px; }
7815
+ body.studio-workspace-layout .repl-more-send-mode,
7816
+ body.studio-workspace-layout .repl-more-echo-mode { display: flex; align-items: center; gap: 6px; padding: 3px 8px 6px; margin-bottom: 2px; border-bottom: 1px solid var(--panel-border); color: var(--muted); font-size: 12px; }
7817
+ body.studio-workspace-layout .repl-more-send-mode:has(+ .repl-more-echo-mode) { padding-bottom: 3px; margin-bottom: 0; border-bottom: 0; }
7807
7818
  body.studio-workspace-layout .files-pick-path { flex: 1 1 180px; min-width: 0; padding: 4px 8px; border: 1px solid var(--control-border); border-radius: 6px;
7808
7819
  background: var(--panel); color: var(--text); font: 12px var(--font-mono); outline: none; }
7809
7820
  body.studio-workspace-layout .files-pick-strip button { border-color: transparent; background: transparent; }