pi-studio 0.11.8 → 0.11.10
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 +14 -0
- package/README.md +1 -1
- package/ROADMAP.md +12 -2
- package/client/studio-client.js +164 -21
- package/client/studio.css +147 -1
- package/index.ts +189 -36
- package/package.json +1 -1
- package/shared/studio-repl-activity.js +80 -0
- package/shared/studio-repl-files.js +273 -0
- package/shared/studio-repl-selection.js +10 -3
- package/shared/studio-repl-tmux.js +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to `pi-studio` are documented here.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.11.10] — 2026-11-03
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- With pi-repl 0.12.1 or later loaded in the same Pi, the agent is told of each REPL record entry once. pi-repl keeps track of what the agent has been told about its own `pi-repl-*` sessions, including the one Studio's REPL pane shows and those the agent used through Studio's REPL tools. Its reports come at the start of a run, as before, and now also in Studio's REPL tool results. Studio tells the agent about the rest. Before, both told it about the `pi-repl-*` sessions. Without pi-repl, or with pi-repl 0.12.0 or older, Studio tells it about every session, as before.
|
|
11
|
+
|
|
12
|
+
## [0.11.9] — 2026-11-03
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- The REPL pane shows the images and PDFs a record entry's code saved, such as a plot, as agent-markdown-preview's REPL page does. An image shows under the entry's output; click it to open Studio's image viewer. A PDF is a link that opens it in a new tab. A file shows when the entry's code or output names it (a path ending in `.png`, `.jpg`, `.gif`, `.webp`, `.svg` or `.pdf`, relative paths taken from the REPL's current directory) and it was written while the entry ran. A file saved again by a later entry shows under that entry instead. Up to six files show for each of a session's latest 12 entries. Studio serves only those files.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- The REPL pane's record has no description line under its heading.
|
|
19
|
+
- A PDF's header, on its card and in its enlarged view, shows **Auto-refresh** and **More**. More holds **Refresh now**, **Browser tab**, **System viewer**, **Show in folder** and **Copy path**, so the header fits on one line. The card's Enlarge is its icon alone, with Enlarge as its tooltip.
|
|
20
|
+
|
|
7
21
|
## [0.11.8] — 2026-11-03
|
|
8
22
|
|
|
9
23
|
### Changed
|
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. 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).
|
|
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). An image or PDF an entry's code saved while it ran, such as a plot, shows under it when the code or output names it. 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. With pi-repl 0.12.1 or later loaded too, pi-repl tells it about its own `pi-repl-*` sessions, also in Studio's tool results, and Studio about the rest, so nothing is told twice. 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
|
|
package/ROADMAP.md
CHANGED
|
@@ -2,9 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This is the current planning source of truth for Studio work. `NEXT-STAGE.md` is historical; `TODO.md` tracks smaller backlog items that are not yet assigned to a release.
|
|
4
4
|
|
|
5
|
-
## Current status (
|
|
5
|
+
## Current status (3 Nov 2026)
|
|
6
6
|
|
|
7
|
-
`0.10.0`
|
|
7
|
+
`0.11.10` is the current release. Studio is in a feature freeze from `0.11.9`, for use in normal work. Before the freeze, `0.11.9` added the images and PDFs a REPL entry's code saved, shown under the entry, and a PDF header that fits on one line. `0.11.10`, the one change approved in the freeze, works with pi-repl `0.12.1` so that, with both loaded, the agent is told each REPL record entry once. During the freeze, changes are limited to fixes for failures in normal use, lost data, effects on other people's processes or files, and security. [TODO.md](TODO.md) lists the known limits and what comes after the freeze.
|
|
8
|
+
|
|
9
|
+
`0.10.0` (14 Oct) made the buffer-first workspace the default, as **dual editor mode** (Prompt and Document), with **single editor mode** one switch away (footer button, `/studio --single`). It went through real course use as private alpha candidates 49–69. The `PI_STUDIO_*` flags described further down are development overrides only: when any is set it decides, and the mode switch is hidden.
|
|
10
|
+
|
|
11
|
+
The `0.11` releases brought the REPL pane up to pi-repl `0.11.7`: Ruby, Java, Octave, MATLAB, gnuplot and C++; sends and notes recorded under the sender's name; the record-directory key; and telling the agent what's new in the record. They also brought Working closer to agent-markdown-preview's. The [changelog](CHANGELOG.md) has each release. The sections below are the history up to `0.10.0`.
|
|
12
|
+
|
|
13
|
+
### Parity at the freeze
|
|
14
|
+
|
|
15
|
+
- **pi-repl `0.11.7` and agent-repl `0.5.0`.** Studio's copies of the shared record, names, protocol, control-file, display, C++, gnuplot and M-language helpers are byte-identical to pi-repl's, and agent-repl carries the same record, names and protocol files. Two helpers differ: pi-repl generalised `repl-session-stop.js` and `repl-gnuplot-processes.js` for LFortran. Studio doesn't run LFortran, and won't paste into pi-repl's LFortran session ("This session takes code only through pi-repl").
|
|
16
|
+
- **pi-repl `0.12.1`'s record-activity channel.** pi-repl `0.12.0` started telling its agent about other clients' record entries itself. With both loaded, Studio `0.11.10` leaves the `pi-repl-*` sessions to pi-repl over Pi's event bus (protocol 2), and puts pi-repl's report in its own REPL results. Studio still has its older copy of pi-repl's activity module and protocol document, which are re-vendored after the freeze.
|
|
17
|
+
- **pi-markdown-preview `0.26.2` and agent-markdown-preview `0.13.2`.** Their REPL page reads the same records with the same record-directory check. Both show the images and PDFs an entry's code saved, by the same rules: a file shows when the entry names it and it was written in that entry's turn. Studio has them from `0.11.9`; the preview packages' REPL page has its latest rules on an unreleased branch.
|
|
8
18
|
|
|
9
19
|
## Release approach
|
|
10
20
|
|
package/client/studio-client.js
CHANGED
|
@@ -688,8 +688,6 @@
|
|
|
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
691
|
// The name this page's sends and notes are recorded under: chosen here and kept in this
|
|
694
692
|
// browser, else the default from Studio's server (PI_REPL_USER_NAME, then pi-repl's saved
|
|
695
693
|
// name, then "User"). Read once, so another tab choosing a name later leaves this page alone.
|
|
@@ -807,10 +805,20 @@
|
|
|
807
805
|
beforeTranscript: "",
|
|
808
806
|
status: typeof entry.status === "string" ? entry.status : "sent",
|
|
809
807
|
skippedChunks: Math.max(0, Math.floor(Number(entry.skippedChunks) || 0)),
|
|
808
|
+
// Image and PDF files the entry names, as Studio found them when it sent it; not kept.
|
|
809
|
+
files: normalizeReplEntryFiles(entry.files),
|
|
810
810
|
};
|
|
811
811
|
return (normalized.code.trim() || normalized.prose.trim() || normalized.output.trim()) ? normalized : null;
|
|
812
812
|
}
|
|
813
813
|
|
|
814
|
+
function normalizeReplEntryFiles(files) {
|
|
815
|
+
if (!Array.isArray(files)) return [];
|
|
816
|
+
return files.filter((file) => file && typeof file === "object" && typeof file.id === "string" && /^[0-9a-f]{64}$/.test(file.id)
|
|
817
|
+
&& typeof file.written === "string" && file.written && typeof file.v === "string" && /^[0-9a-f]{16}$/.test(file.v))
|
|
818
|
+
.slice(0, 6)
|
|
819
|
+
.map((file) => ({ id: file.id, written: file.written.slice(0, 1024), image: file.image === true, v: file.v }));
|
|
820
|
+
}
|
|
821
|
+
|
|
814
822
|
function loadPersistedReplJournalEntries() {
|
|
815
823
|
try {
|
|
816
824
|
const raw = window.localStorage ? window.localStorage.getItem("piStudio.replStudioEntries.v1") : null;
|
|
@@ -896,6 +904,8 @@
|
|
|
896
904
|
let replJournalEntries = loadPersistedReplJournalEntries();
|
|
897
905
|
let activeReplJournalEntryId = "";
|
|
898
906
|
const replJournalImportPendingSessions = new Set();
|
|
907
|
+
// Whether the REPL view is kept at its bottom, as of its last draw or scroll, for thumbnails that load later.
|
|
908
|
+
let replViewStuckToBottom = false;
|
|
899
909
|
let replJournalCollapsed = (() => {
|
|
900
910
|
try {
|
|
901
911
|
const stored = window.localStorage ? window.localStorage.getItem("piStudio.replStudioCollapsed") : null;
|
|
@@ -9686,7 +9696,6 @@
|
|
|
9686
9696
|
event.preventDefault();
|
|
9687
9697
|
event.stopPropagation();
|
|
9688
9698
|
});
|
|
9689
|
-
actions.appendChild(openLink);
|
|
9690
9699
|
|
|
9691
9700
|
const systemViewerBtn = document.createElement("button");
|
|
9692
9701
|
systemViewerBtn.type = "button";
|
|
@@ -9696,7 +9705,6 @@
|
|
|
9696
9705
|
systemViewerBtn.addEventListener("click", () => {
|
|
9697
9706
|
void runStudioPdfLocalAction("system-viewer", studioPdfFocusResourceQuery, systemViewerBtn, { isCurrent: studioPdfFocusIsCurrent });
|
|
9698
9707
|
});
|
|
9699
|
-
actions.appendChild(systemViewerBtn);
|
|
9700
9708
|
|
|
9701
9709
|
const revealBtn = document.createElement("button");
|
|
9702
9710
|
revealBtn.type = "button";
|
|
@@ -9706,7 +9714,6 @@
|
|
|
9706
9714
|
revealBtn.addEventListener("click", () => {
|
|
9707
9715
|
void runStudioPdfLocalAction("reveal", studioPdfFocusResourceQuery, revealBtn, { isCurrent: studioPdfFocusIsCurrent });
|
|
9708
9716
|
});
|
|
9709
|
-
actions.appendChild(revealBtn);
|
|
9710
9717
|
|
|
9711
9718
|
const copyPathBtn = document.createElement("button");
|
|
9712
9719
|
copyPathBtn.type = "button";
|
|
@@ -9716,16 +9723,14 @@
|
|
|
9716
9723
|
copyPathBtn.addEventListener("click", () => {
|
|
9717
9724
|
void copyStudioPdfResourcePath(studioPdfFocusResourceQuery, copyPathBtn, { isCurrent: studioPdfFocusIsCurrent });
|
|
9718
9725
|
});
|
|
9719
|
-
actions.appendChild(copyPathBtn);
|
|
9720
9726
|
|
|
9721
9727
|
const refreshBtn = document.createElement("button");
|
|
9722
9728
|
refreshBtn.type = "button";
|
|
9723
9729
|
refreshBtn.className = "studio-pdf-focus-btn studio-pdf-focus-refresh";
|
|
9724
|
-
refreshBtn.textContent = "Refresh";
|
|
9730
|
+
refreshBtn.textContent = "Refresh now";
|
|
9725
9731
|
refreshBtn.title = "Reload this PDF preview from disk. Shortcut: Cmd/Ctrl+Option/Alt+Shift+R.";
|
|
9726
9732
|
refreshBtn.setAttribute("aria-label", "Refresh PDF preview from disk");
|
|
9727
9733
|
refreshBtn.addEventListener("click", () => refreshStudioPdfFocusViewer());
|
|
9728
|
-
actions.appendChild(refreshBtn);
|
|
9729
9734
|
|
|
9730
9735
|
const autoRefreshBtn = document.createElement("button");
|
|
9731
9736
|
autoRefreshBtn.type = "button";
|
|
@@ -9736,6 +9741,7 @@
|
|
|
9736
9741
|
autoRefreshBtn.setAttribute("aria-pressed", "false");
|
|
9737
9742
|
autoRefreshBtn.addEventListener("click", () => toggleStudioPdfFocusAutoRefresh());
|
|
9738
9743
|
actions.appendChild(autoRefreshBtn);
|
|
9744
|
+
actions.appendChild(createStudioPdfMoreMenu("focus", [refreshBtn, openLink, systemViewerBtn, revealBtn, copyPathBtn]));
|
|
9739
9745
|
|
|
9740
9746
|
const fullscreenBtn = document.createElement("button");
|
|
9741
9747
|
fullscreenBtn.type = "button";
|
|
@@ -9818,6 +9824,7 @@
|
|
|
9818
9824
|
if (studioPdfFocusOpenLinkEl) studioPdfFocusOpenLinkEl.href = src;
|
|
9819
9825
|
setStudioPdfFocusFrameSource(src, title, sourceFrame);
|
|
9820
9826
|
if (document.body) document.body.classList.add("studio-pdf-focus-open");
|
|
9827
|
+
closeStudioPdfFocusMoreMenus();
|
|
9821
9828
|
if (studioPdfFocusOverlayEl) studioPdfFocusOverlayEl.hidden = false;
|
|
9822
9829
|
syncStudioBufferOpenOperation();
|
|
9823
9830
|
syncStudioPdfFocusFullscreenButton();
|
|
@@ -9839,6 +9846,7 @@
|
|
|
9839
9846
|
if (exitResult && typeof exitResult.catch === "function") exitResult.catch(() => {});
|
|
9840
9847
|
} catch {}
|
|
9841
9848
|
}
|
|
9849
|
+
closeStudioPdfFocusMoreMenus();
|
|
9842
9850
|
if (studioPdfFocusOverlayEl) studioPdfFocusOverlayEl.hidden = true;
|
|
9843
9851
|
restoreStudioPdfFocusMovedFrame();
|
|
9844
9852
|
if (studioPdfFocusFrameEl) studioPdfFocusFrameEl.src = "about:blank";
|
|
@@ -9888,6 +9896,64 @@
|
|
|
9888
9896
|
return query;
|
|
9889
9897
|
}
|
|
9890
9898
|
|
|
9899
|
+
// A PDF's less frequent actions, under More as in the REPL pane: a manual refresh beside
|
|
9900
|
+
// Auto-refresh, and the one-off ways to take the PDF elsewhere (Oliver, candidate 117).
|
|
9901
|
+
function createStudioPdfMoreMenu(kind, items) {
|
|
9902
|
+
const details = document.createElement("details");
|
|
9903
|
+
details.className = "studio-pdf-more studio-pdf-" + kind + "-more";
|
|
9904
|
+
const summary = document.createElement("summary");
|
|
9905
|
+
summary.textContent = "More";
|
|
9906
|
+
summary.title = "More ways to refresh or open this PDF.";
|
|
9907
|
+
details.appendChild(summary);
|
|
9908
|
+
const menu = document.createElement("div");
|
|
9909
|
+
menu.className = "studio-pdf-more-menu";
|
|
9910
|
+
items.forEach((item) => {
|
|
9911
|
+
item.classList.add("studio-pdf-more-item");
|
|
9912
|
+
menu.appendChild(item);
|
|
9913
|
+
});
|
|
9914
|
+
// A chosen item closes the menu once its own click has run. The items stop their clicks
|
|
9915
|
+
// from bubbling, so this listens on the way down; the card's items are handled first, on
|
|
9916
|
+
// the document, by handleStudioPreviewMediaActivation, which closes their menu itself.
|
|
9917
|
+
menu.addEventListener("click", (event) => {
|
|
9918
|
+
if (event.target instanceof Element) dismissStudioPdfMoreMenuAfterChoice(event.target);
|
|
9919
|
+
}, true);
|
|
9920
|
+
// Keyboard focus leaving the menu, such as Tab past its last item, closes it, so an open
|
|
9921
|
+
// menu never sits behind a focused control whose Escape belongs to the view (Sol, c117).
|
|
9922
|
+
details.addEventListener("focusout", (event) => {
|
|
9923
|
+
if (details.open && event.relatedTarget instanceof Node && !details.contains(event.relatedTarget)) details.open = false;
|
|
9924
|
+
});
|
|
9925
|
+
// Escape closes the menu, not the view it's in.
|
|
9926
|
+
details.addEventListener("keydown", (event) => {
|
|
9927
|
+
if (event.key !== "Escape" || !details.open) return;
|
|
9928
|
+
event.preventDefault();
|
|
9929
|
+
event.stopPropagation();
|
|
9930
|
+
details.open = false;
|
|
9931
|
+
summary.focus();
|
|
9932
|
+
});
|
|
9933
|
+
details.appendChild(menu);
|
|
9934
|
+
return details;
|
|
9935
|
+
}
|
|
9936
|
+
|
|
9937
|
+
// A chosen item's menu closes once its click has been handled.
|
|
9938
|
+
function dismissStudioPdfMoreMenuAfterChoice(element) {
|
|
9939
|
+
const item = element && typeof element.closest === "function" ? element.closest(".studio-pdf-more-item") : null;
|
|
9940
|
+
const details = item ? item.closest("details.studio-pdf-more") : null;
|
|
9941
|
+
if (details) window.setTimeout(() => { details.open = false; }, 0);
|
|
9942
|
+
}
|
|
9943
|
+
|
|
9944
|
+
// The enlarged view starts and ends with its menu closed.
|
|
9945
|
+
function closeStudioPdfFocusMoreMenus() {
|
|
9946
|
+
if (!studioPdfFocusOverlayEl) return;
|
|
9947
|
+
studioPdfFocusOverlayEl.querySelectorAll("details.studio-pdf-more[open]").forEach((details) => { details.open = false; });
|
|
9948
|
+
}
|
|
9949
|
+
|
|
9950
|
+
// A press outside an open PDF menu closes it.
|
|
9951
|
+
document.addEventListener("pointerdown", (event) => {
|
|
9952
|
+
document.querySelectorAll("details.studio-pdf-more[open]").forEach((details) => {
|
|
9953
|
+
if (!(event.target instanceof Node) || !details.contains(event.target)) details.open = false;
|
|
9954
|
+
});
|
|
9955
|
+
}, true);
|
|
9956
|
+
|
|
9891
9957
|
function syncStudioPdfAutoRefreshButton(button, enabled, available) {
|
|
9892
9958
|
if (!button) return;
|
|
9893
9959
|
const active = Boolean(enabled && available);
|
|
@@ -10477,6 +10543,8 @@
|
|
|
10477
10543
|
const card = actionBtn.closest(".studio-pdf-card");
|
|
10478
10544
|
if (!card) return;
|
|
10479
10545
|
consumeStudioPreviewMediaEvent(event);
|
|
10546
|
+
// The card's More menu would never see this click, which ends here (Sol, Astra, c117).
|
|
10547
|
+
dismissStudioPdfMoreMenuAfterChoice(actionBtn);
|
|
10480
10548
|
if (!studioPreviewNodeOwnerIsCurrent(actionBtn)) return;
|
|
10481
10549
|
const interactionContext = buildStudioPreviewInteractionContext(actionBtn);
|
|
10482
10550
|
if (!studioPreviewInteractionIsCurrent(interactionContext)) return;
|
|
@@ -11036,14 +11104,13 @@
|
|
|
11036
11104
|
const focusBtn = document.createElement("button");
|
|
11037
11105
|
focusBtn.type = "button";
|
|
11038
11106
|
focusBtn.className = "studio-pdf-card-action studio-pdf-card-focus";
|
|
11039
|
-
focusBtn.title = "
|
|
11107
|
+
focusBtn.title = "Enlarge";
|
|
11040
11108
|
focusBtn.setAttribute("aria-label", "Enlarge PDF");
|
|
11041
11109
|
if (focusBtn.dataset) {
|
|
11042
11110
|
focusBtn.dataset.studioPdfViewerUrl = viewerUrl;
|
|
11043
11111
|
focusBtn.dataset.studioPdfTitle = title;
|
|
11044
11112
|
}
|
|
11045
11113
|
focusBtn.appendChild(makeStudioUiRefreshIcon("focus"));
|
|
11046
|
-
focusBtn.appendChild(document.createTextNode("Enlarge"));
|
|
11047
11114
|
focusBtn.addEventListener("click", handleStudioPdfFocusButtonClick);
|
|
11048
11115
|
titleGroup.appendChild(focusBtn);
|
|
11049
11116
|
}
|
|
@@ -11069,7 +11136,6 @@
|
|
|
11069
11136
|
event.preventDefault();
|
|
11070
11137
|
event.stopPropagation();
|
|
11071
11138
|
});
|
|
11072
|
-
actions.appendChild(openLink);
|
|
11073
11139
|
|
|
11074
11140
|
const systemViewerBtn = document.createElement("button");
|
|
11075
11141
|
systemViewerBtn.type = "button";
|
|
@@ -11081,7 +11147,6 @@
|
|
|
11081
11147
|
event.stopPropagation();
|
|
11082
11148
|
void runStudioPdfLocalAction("system-viewer", resourceQuery, systemViewerBtn, { isCurrent });
|
|
11083
11149
|
});
|
|
11084
|
-
actions.appendChild(systemViewerBtn);
|
|
11085
11150
|
|
|
11086
11151
|
const revealBtn = document.createElement("button");
|
|
11087
11152
|
revealBtn.type = "button";
|
|
@@ -11093,7 +11158,6 @@
|
|
|
11093
11158
|
event.stopPropagation();
|
|
11094
11159
|
void runStudioPdfLocalAction("reveal", resourceQuery, revealBtn, { isCurrent });
|
|
11095
11160
|
});
|
|
11096
|
-
actions.appendChild(revealBtn);
|
|
11097
11161
|
|
|
11098
11162
|
const copyPathBtn = document.createElement("button");
|
|
11099
11163
|
copyPathBtn.type = "button";
|
|
@@ -11105,12 +11169,11 @@
|
|
|
11105
11169
|
event.stopPropagation();
|
|
11106
11170
|
void copyStudioPdfResourcePath(resourceQuery, copyPathBtn, { isCurrent });
|
|
11107
11171
|
});
|
|
11108
|
-
actions.appendChild(copyPathBtn);
|
|
11109
11172
|
|
|
11110
11173
|
const refreshBtn = document.createElement("button");
|
|
11111
11174
|
refreshBtn.type = "button";
|
|
11112
11175
|
refreshBtn.className = "studio-pdf-card-action studio-pdf-card-refresh";
|
|
11113
|
-
refreshBtn.textContent = "Refresh";
|
|
11176
|
+
refreshBtn.textContent = "Refresh now";
|
|
11114
11177
|
refreshBtn.title = "Reload this PDF preview from disk. Shortcut: Cmd/Ctrl+Option/Alt+Shift+R.";
|
|
11115
11178
|
refreshBtn.addEventListener("click", (event) => {
|
|
11116
11179
|
event.preventDefault();
|
|
@@ -11118,7 +11181,6 @@
|
|
|
11118
11181
|
if (!isCurrent()) return;
|
|
11119
11182
|
if (!refreshStudioPdfCard(card)) setStatus("Could not refresh this PDF preview.", "warning");
|
|
11120
11183
|
});
|
|
11121
|
-
actions.appendChild(refreshBtn);
|
|
11122
11184
|
|
|
11123
11185
|
const autoRefreshBtn = document.createElement("button");
|
|
11124
11186
|
autoRefreshBtn.type = "button";
|
|
@@ -11139,6 +11201,7 @@
|
|
|
11139
11201
|
setStudioPdfCardAutoRefresh(card, !state.enabled);
|
|
11140
11202
|
});
|
|
11141
11203
|
actions.appendChild(autoRefreshBtn);
|
|
11204
|
+
actions.appendChild(createStudioPdfMoreMenu("card", [refreshBtn, openLink, systemViewerBtn, revealBtn, copyPathBtn]));
|
|
11142
11205
|
|
|
11143
11206
|
header.appendChild(actions);
|
|
11144
11207
|
}
|
|
@@ -12167,6 +12230,21 @@
|
|
|
12167
12230
|
if (!actionBtn) return;
|
|
12168
12231
|
event.preventDefault();
|
|
12169
12232
|
const action = actionBtn.getAttribute("data-repl-action") || "";
|
|
12233
|
+
// Looking at a file changes nothing, whichever session the pane was drawn for.
|
|
12234
|
+
if (action === "file-view" || action === "file-open") {
|
|
12235
|
+
const url = actionBtn.getAttribute("data-repl-file-url") || "";
|
|
12236
|
+
if (!/^\/repl-file\?/.test(url)) return;
|
|
12237
|
+
if (action === "file-view") {
|
|
12238
|
+
openStudioImageFocusViewer(url, actionBtn.getAttribute("data-repl-file-name") || "Image");
|
|
12239
|
+
return;
|
|
12240
|
+
}
|
|
12241
|
+
try {
|
|
12242
|
+
openStudioTabDirect(url);
|
|
12243
|
+
} catch (error) {
|
|
12244
|
+
setStatus(error instanceof Error ? error.message : String(error), "warning");
|
|
12245
|
+
}
|
|
12246
|
+
return;
|
|
12247
|
+
}
|
|
12170
12248
|
// The name isn't the session's, so a pane drawn for another session can still change it.
|
|
12171
12249
|
if (action === "sender-edit") {
|
|
12172
12250
|
replSenderEditing = true;
|
|
@@ -12478,6 +12556,8 @@
|
|
|
12478
12556
|
critiqueViewEl.addEventListener("toggle", handleReplMoreToggle, true);
|
|
12479
12557
|
critiqueViewEl.addEventListener("click", handleTracePaneClick);
|
|
12480
12558
|
critiqueViewEl.addEventListener("click", handleReplPaneClick);
|
|
12559
|
+
critiqueViewEl.addEventListener("load", handleReplFileImageLoad, true);
|
|
12560
|
+
critiqueViewEl.addEventListener("scroll", handleReplViewScroll, { passive: true });
|
|
12481
12561
|
critiqueViewEl.addEventListener("click", handleFilesPaneClick);
|
|
12482
12562
|
critiqueViewEl.addEventListener("click", handleGitChangesPaneClick);
|
|
12483
12563
|
critiqueViewEl.addEventListener("click", handleStudioQuartoPreviewClick);
|
|
@@ -14514,6 +14594,7 @@
|
|
|
14514
14594
|
+ prose
|
|
14515
14595
|
+ code
|
|
14516
14596
|
+ output
|
|
14597
|
+
+ buildReplEntryFilesHtml(entry)
|
|
14517
14598
|
+ pending
|
|
14518
14599
|
+ "</article>";
|
|
14519
14600
|
}).join("");
|
|
@@ -14526,9 +14607,6 @@
|
|
|
14526
14607
|
+ (hasEntries ? cards : (recordRefusal ? "" : "<div class='repl-studio-empty'>" + escapeHtml(emptyText) + "</div>"));
|
|
14527
14608
|
return "<section class='repl-journal'>"
|
|
14528
14609
|
+ "<div class='repl-journal-header'><h3>Shared REPL Record</h3>" + toggleActions + "</div>"
|
|
14529
|
-
+ "<p class='repl-journal-description'>What Studio and pi-repl have sent to this session."
|
|
14530
|
-
+ (replRecordActivity === "off" ? "" : " New entries here go to the agent and its model provider.")
|
|
14531
|
-
+ "</p>"
|
|
14532
14610
|
+ (recordRefusal ? "<p class='repl-journal-omitted'>" + escapeHtml("Not shown: " + recordRefusal) + "</p>" : "")
|
|
14533
14611
|
+ (!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>" : "")
|
|
14534
14612
|
+ (omitted ? "<div class='repl-journal-omitted'>Showing latest 12 entries for this session; " + escapeHtml(String(omitted)) + " older entries remain in export.</div>" : "")
|
|
@@ -14537,6 +14615,69 @@
|
|
|
14537
14615
|
+ "</section>";
|
|
14538
14616
|
}
|
|
14539
14617
|
|
|
14618
|
+
function getReplFileUrl(file) {
|
|
14619
|
+
return "/repl-file?" + new URLSearchParams({ token: getToken(), id: file.id, v: file.v }).toString();
|
|
14620
|
+
}
|
|
14621
|
+
|
|
14622
|
+
// Image and PDF files an entry names, such as a saved plot, as pi-markdown-preview's REPL
|
|
14623
|
+
// page shows them: one tile each, images first, named inside the tile, the path as written
|
|
14624
|
+
// in its tooltip. An image opens in Studio's image viewer, a PDF in a new tab.
|
|
14625
|
+
function buildReplEntryFilesHtml(entry) {
|
|
14626
|
+
const files = Array.isArray(entry.files) ? entry.files : [];
|
|
14627
|
+
if (!files.length) return "";
|
|
14628
|
+
const name = (written) => written.split(/[\\/]/).pop() || written;
|
|
14629
|
+
const tiles = [...files.filter((file) => file.image), ...files.filter((file) => !file.image)].map((file) => {
|
|
14630
|
+
const url = getReplFileUrl(file);
|
|
14631
|
+
const attrs = " data-repl-file-url='" + escapeHtml(url) + "' data-repl-file-name='" + escapeHtml(name(file.written)) + "' title='" + escapeHtml(file.written) + "'";
|
|
14632
|
+
if (file.image) {
|
|
14633
|
+
return "<button type='button' class='repl-studio-file' data-repl-action='file-view'" + attrs + ">"
|
|
14634
|
+
+ "<img class='repl-studio-file-img' src='" + escapeHtml(url) + "' alt='" + escapeHtml(file.written) + "' data-repl-file-key='" + escapeHtml(url) + "'>"
|
|
14635
|
+
+ "<span class='repl-studio-file-name'>" + escapeHtml(name(file.written)) + "</span></button>";
|
|
14636
|
+
}
|
|
14637
|
+
const format = (/\.([^.]+)$/.exec(name(file.written)) || ["", ""])[1].toUpperCase();
|
|
14638
|
+
return "<button type='button' class='repl-studio-file repl-studio-file-other' data-repl-action='file-open'" + attrs + ">"
|
|
14639
|
+
+ "<span class='repl-studio-file-format'>" + escapeHtml(format) + "</span>"
|
|
14640
|
+
+ "<span class='repl-studio-file-name'>" + escapeHtml(name(file.written)) + "</span></button>";
|
|
14641
|
+
}).join("");
|
|
14642
|
+
return "<div class='repl-studio-files'>" + tiles + "</div>";
|
|
14643
|
+
}
|
|
14644
|
+
|
|
14645
|
+
// A redraw keeps the images already loaded, so a thumbnail doesn't flicker or change
|
|
14646
|
+
// the pane's height each time the record is drawn again.
|
|
14647
|
+
function captureReplFileImages() {
|
|
14648
|
+
const loaded = new Map();
|
|
14649
|
+
if (!critiqueViewEl) return loaded;
|
|
14650
|
+
critiqueViewEl.querySelectorAll("img[data-repl-file-key]").forEach((img) => {
|
|
14651
|
+
const key = img.getAttribute("data-repl-file-key") || "";
|
|
14652
|
+
if (key && img.complete && img.naturalWidth > 0 && !loaded.has(key)) loaded.set(key, img);
|
|
14653
|
+
});
|
|
14654
|
+
return loaded;
|
|
14655
|
+
}
|
|
14656
|
+
|
|
14657
|
+
function restoreReplFileImages(loaded) {
|
|
14658
|
+
if (!critiqueViewEl || !loaded.size) return;
|
|
14659
|
+
critiqueViewEl.querySelectorAll("img[data-repl-file-key]").forEach((img) => {
|
|
14660
|
+
const key = img.getAttribute("data-repl-file-key") || "";
|
|
14661
|
+
const kept = loaded.get(key);
|
|
14662
|
+
if (!kept) return;
|
|
14663
|
+
loaded.delete(key);
|
|
14664
|
+
img.replaceWith(kept);
|
|
14665
|
+
});
|
|
14666
|
+
}
|
|
14667
|
+
|
|
14668
|
+
// A thumbnail that loads while the pane is kept at its bottom keeps it there. Scrolling
|
|
14669
|
+
// decides that as a redraw does, so a load after the person scrolled up leaves them be (Sol).
|
|
14670
|
+
function handleReplViewScroll() {
|
|
14671
|
+
if (rightView === "repl") replViewStuckToBottom = shouldAutoStickReplView();
|
|
14672
|
+
}
|
|
14673
|
+
|
|
14674
|
+
function handleReplFileImageLoad(event) {
|
|
14675
|
+
if (rightView !== "repl" || !replViewStuckToBottom || !critiqueViewEl) return;
|
|
14676
|
+
const target = event.target;
|
|
14677
|
+
if (!(target instanceof Element) || !target.matches("img[data-repl-file-key]")) return;
|
|
14678
|
+
critiqueViewEl.scrollTop = critiqueViewEl.scrollHeight;
|
|
14679
|
+
}
|
|
14680
|
+
|
|
14540
14681
|
function buildReplMirrorHtml(body, transcript) {
|
|
14541
14682
|
const hasTranscript = Boolean(String(transcript || "").trim());
|
|
14542
14683
|
const summary = hasTranscript
|
|
@@ -14965,10 +15106,13 @@
|
|
|
14965
15106
|
function renderReplView() {
|
|
14966
15107
|
if (!critiqueViewEl) return;
|
|
14967
15108
|
const shouldStick = shouldAutoStickReplView();
|
|
15109
|
+
replViewStuckToBottom = shouldStick;
|
|
14968
15110
|
const previousScrollTop = critiqueViewEl.scrollTop;
|
|
14969
15111
|
const senderCursor = captureReplSenderCursor();
|
|
15112
|
+
const loadedFiles = captureReplFileImages();
|
|
14970
15113
|
finishPreviewRender(critiqueViewEl);
|
|
14971
15114
|
critiqueViewEl.innerHTML = buildReplPanelHtml();
|
|
15115
|
+
restoreReplFileImages(loadedFiles);
|
|
14972
15116
|
restoreReplSenderCursor(senderCursor);
|
|
14973
15117
|
critiqueViewEl.classList.remove("response-scroll-resetting");
|
|
14974
15118
|
if (shouldStick) {
|
|
@@ -21143,7 +21287,7 @@
|
|
|
21143
21287
|
if (!raw || raw.charAt(0) === "#") return false;
|
|
21144
21288
|
if (/^\/\//.test(raw)) return false;
|
|
21145
21289
|
if (/^(?:https?|mailto|tel|data|blob|javascript|about):/i.test(raw)) return false;
|
|
21146
|
-
if (/^\/(?:pdf-resource|html-preview-resource|export-pdf|export-html|render-preview|render-math|import-file-copy|resource-grants|local-preview-link|reveal-local-resource|open-local-resource)(?:[?#/]|$)/i.test(raw)) return false;
|
|
21290
|
+
if (/^\/(?:repl-file|pdf-resource|html-preview-resource|export-pdf|export-html|render-preview|render-math|import-file-copy|resource-grants|local-preview-link|reveal-local-resource|open-local-resource)(?:[?#/]|$)/i.test(raw)) return false;
|
|
21147
21291
|
return true;
|
|
21148
21292
|
}
|
|
21149
21293
|
|
|
@@ -29491,7 +29635,6 @@
|
|
|
29491
29635
|
noteReplChoiceAnswer(message);
|
|
29492
29636
|
const present = !isReplChoicePending();
|
|
29493
29637
|
replTmuxAvailable = typeof message.tmuxAvailable === "boolean" ? message.tmuxAvailable : replTmuxAvailable;
|
|
29494
|
-
if (message.recordActivity === "on" || message.recordActivity === "send" || message.recordActivity === "off") replRecordActivity = message.recordActivity;
|
|
29495
29638
|
const defaultName = validateReplPersonName(message.personName);
|
|
29496
29639
|
if (!defaultName.error) replPersonNameDefault = defaultName.name;
|
|
29497
29640
|
if (message.personNameSource === "environment" || message.personNameSource === "setting" || message.personNameSource === "default") replPersonNameSource = message.personNameSource;
|
package/client/studio.css
CHANGED
|
@@ -2198,6 +2198,91 @@
|
|
|
2198
2198
|
height: 15px;
|
|
2199
2199
|
}
|
|
2200
2200
|
|
|
2201
|
+
/* A PDF's More menu, on its card and in its enlarged view, as the REPL pane's (candidate 117). */
|
|
2202
|
+
.studio-pdf-more {
|
|
2203
|
+
position: relative;
|
|
2204
|
+
flex: 0 0 auto;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
.studio-pdf-more > summary {
|
|
2208
|
+
display: inline-flex;
|
|
2209
|
+
align-items: center;
|
|
2210
|
+
cursor: pointer;
|
|
2211
|
+
user-select: none;
|
|
2212
|
+
list-style: none;
|
|
2213
|
+
padding: 3px 7px;
|
|
2214
|
+
border: 1px solid transparent;
|
|
2215
|
+
border-radius: 7px;
|
|
2216
|
+
color: var(--studio-info-text, var(--muted));
|
|
2217
|
+
font-size: 12px;
|
|
2218
|
+
font-weight: 600;
|
|
2219
|
+
line-height: 1.2;
|
|
2220
|
+
white-space: nowrap;
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
.studio-pdf-more > summary::-webkit-details-marker {
|
|
2224
|
+
display: none;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
.studio-pdf-more > summary::after {
|
|
2228
|
+
content: "⌄";
|
|
2229
|
+
margin-left: 4px;
|
|
2230
|
+
font-size: 11px;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
.studio-pdf-more > summary:hover,
|
|
2234
|
+
.studio-pdf-more > summary:focus-visible,
|
|
2235
|
+
.studio-pdf-more[open] > summary {
|
|
2236
|
+
background: var(--panel);
|
|
2237
|
+
border-color: var(--control-border);
|
|
2238
|
+
color: var(--text);
|
|
2239
|
+
outline: none;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
.studio-pdf-more-menu {
|
|
2243
|
+
position: absolute;
|
|
2244
|
+
top: calc(100% + 6px);
|
|
2245
|
+
right: 0;
|
|
2246
|
+
z-index: 30;
|
|
2247
|
+
display: flex;
|
|
2248
|
+
flex-direction: column;
|
|
2249
|
+
align-items: stretch;
|
|
2250
|
+
gap: 2px;
|
|
2251
|
+
width: max-content;
|
|
2252
|
+
min-width: 160px;
|
|
2253
|
+
padding: 6px;
|
|
2254
|
+
border: 1px solid var(--panel-border);
|
|
2255
|
+
border-radius: 10px;
|
|
2256
|
+
background: var(--panel);
|
|
2257
|
+
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
.studio-pdf-more .studio-pdf-more-menu > .studio-pdf-more-item {
|
|
2261
|
+
display: flex;
|
|
2262
|
+
width: 100%;
|
|
2263
|
+
min-height: 0;
|
|
2264
|
+
justify-content: flex-start;
|
|
2265
|
+
padding: 5px 8px;
|
|
2266
|
+
border: 1px solid transparent;
|
|
2267
|
+
border-radius: 6px;
|
|
2268
|
+
background: transparent;
|
|
2269
|
+
color: var(--text);
|
|
2270
|
+
font-size: 12px;
|
|
2271
|
+
font-weight: 500;
|
|
2272
|
+
line-height: 1.3;
|
|
2273
|
+
text-align: left;
|
|
2274
|
+
text-decoration: none;
|
|
2275
|
+
white-space: nowrap;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
.studio-pdf-more .studio-pdf-more-menu > .studio-pdf-more-item:not(:disabled):hover,
|
|
2279
|
+
.studio-pdf-more .studio-pdf-more-menu > .studio-pdf-more-item:not(:disabled):focus-visible {
|
|
2280
|
+
background: var(--studio-header-action-hover-bg, var(--panel-2));
|
|
2281
|
+
border-color: transparent;
|
|
2282
|
+
color: var(--text);
|
|
2283
|
+
text-decoration: none;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2201
2286
|
.rendered-markdown .studio-pdf-card-caption {
|
|
2202
2287
|
padding: 8px 10px 0;
|
|
2203
2288
|
color: var(--studio-info-text, var(--muted));
|
|
@@ -4950,7 +5035,6 @@
|
|
|
4950
5035
|
}
|
|
4951
5036
|
|
|
4952
5037
|
.repl-journal-header p,
|
|
4953
|
-
.repl-journal-description,
|
|
4954
5038
|
.repl-journal-omitted {
|
|
4955
5039
|
margin: 1px 0 0;
|
|
4956
5040
|
color: var(--muted);
|
|
@@ -5122,6 +5206,68 @@
|
|
|
5122
5206
|
font-style: italic;
|
|
5123
5207
|
}
|
|
5124
5208
|
|
|
5209
|
+
/* Image and PDF files an entry names, such as a saved plot, as pi-markdown-preview's REPL
|
|
5210
|
+
page shows them: one tile a row, up to 640 by 420 px, named inside the tile. */
|
|
5211
|
+
.repl-studio-files {
|
|
5212
|
+
display: flex;
|
|
5213
|
+
flex-direction: column;
|
|
5214
|
+
align-items: flex-start;
|
|
5215
|
+
gap: 8px;
|
|
5216
|
+
margin: 6px 0 2px calc(var(--repl-studio-prompt-width) + var(--repl-studio-column-gap));
|
|
5217
|
+
}
|
|
5218
|
+
|
|
5219
|
+
.repl-journal-list .repl-studio-file {
|
|
5220
|
+
display: flex;
|
|
5221
|
+
flex-direction: column;
|
|
5222
|
+
gap: 6px;
|
|
5223
|
+
max-width: min(100%, 640px);
|
|
5224
|
+
padding: 8px;
|
|
5225
|
+
border: 1px solid var(--panel-border);
|
|
5226
|
+
border-radius: 8px;
|
|
5227
|
+
background: var(--panel);
|
|
5228
|
+
color: inherit;
|
|
5229
|
+
font-size: 12px;
|
|
5230
|
+
text-align: left;
|
|
5231
|
+
}
|
|
5232
|
+
|
|
5233
|
+
.repl-journal-list .repl-studio-file:not(:disabled):hover {
|
|
5234
|
+
background: var(--panel-2);
|
|
5235
|
+
}
|
|
5236
|
+
|
|
5237
|
+
.repl-studio-file-img {
|
|
5238
|
+
display: block;
|
|
5239
|
+
max-width: 100%;
|
|
5240
|
+
max-height: 420px;
|
|
5241
|
+
object-fit: contain;
|
|
5242
|
+
border-radius: 4px;
|
|
5243
|
+
background: #fff;
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5246
|
+
.repl-studio-file-name {
|
|
5247
|
+
color: var(--muted);
|
|
5248
|
+
overflow-wrap: anywhere;
|
|
5249
|
+
}
|
|
5250
|
+
|
|
5251
|
+
.repl-journal-list .repl-studio-file-other {
|
|
5252
|
+
flex-direction: row;
|
|
5253
|
+
align-items: center;
|
|
5254
|
+
gap: 8px;
|
|
5255
|
+
padding: 8px 10px;
|
|
5256
|
+
}
|
|
5257
|
+
|
|
5258
|
+
.repl-studio-file-other .repl-studio-file-name {
|
|
5259
|
+
color: var(--accent);
|
|
5260
|
+
text-decoration: underline;
|
|
5261
|
+
}
|
|
5262
|
+
|
|
5263
|
+
.repl-studio-file-format {
|
|
5264
|
+
padding: 1px 5px;
|
|
5265
|
+
border: 1px solid var(--panel-border);
|
|
5266
|
+
border-radius: 4px;
|
|
5267
|
+
color: var(--muted);
|
|
5268
|
+
font: 600 11px/1.4 var(--font-ui);
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5125
5271
|
.repl-journal-card-header,
|
|
5126
5272
|
.repl-journal-section,
|
|
5127
5273
|
.repl-journal-label,
|