pi-studio 0.11.0 → 0.11.2
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/client/studio-client.js +99 -27
- package/client/studio.css +27 -2
- package/index.ts +17 -67
- package/package.json +1 -1
- package/shared/repl-cursor-column.js +46 -0
- package/shared/repl-m-language.js +26 -17
- package/shared/studio-buffer-client.js +1 -1
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.2] — 2026-10-27
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- "Queue steering" is now **Steer**, Pi's own term. Its hover text says when the message arrives: when the agent's current step ends, before its next model call.
|
|
11
|
+
- In the new layout, the Prompt pane's **View** menu sits in its top row after **File**, as the response pane's View sits in its header. With the shorter label, the toolbar stays on one line while a prompt runs, with the default split, from about 1,100 px wide, down from about 1,315. A long file name shortens before the top row wraps.
|
|
12
|
+
- Saving a Document no longer briefly shows a notice above the panes, which made them jump, or a recovery warning in the footer, while Studio finishes the save. A save Studio can't finish itself still shows its notice and **Resolve saved backing…**. After a normal save the footer says "Saved NOTES.md.".
|
|
13
|
+
|
|
14
|
+
## [0.11.1] — 2026-10-22
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- While a prompt runs, the status beside **Stop** shows the elapsed time alone ("0:16"), and "Compacting context…" is now "Compacting…". The status keeps only the room "Starting…" and "Stopping…" need, so the toolbar's tools stay on the first row in narrower windows: with the default split, from about 1,315 px wide, down from about 1,390.
|
|
18
|
+
- The line above a response shows which one you're on at its right end ("9/9"), in the accent colour while an older response is showing. The rest of the line reads "Assistant response · 10:08:28 PM".
|
|
19
|
+
- The REPL pane uses pi-repl 0.10.5's shared helpers to end each send's output and to run Octave and MATLAB, in place of its own copies. Code runs as before.
|
|
20
|
+
|
|
7
21
|
## [0.11.0] — 2026-10-21
|
|
8
22
|
|
|
9
23
|
### Added
|
package/client/studio-client.js
CHANGED
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
let documentHostingReady = false, documentHostingPreparingFile = false, documentHostingRetired = false;
|
|
60
60
|
let documentHostingSaveResolution = null;
|
|
61
61
|
let documentHostingSaveResolutionBufferId = null, documentHostingFilePreparationBufferId = null;
|
|
62
|
+
let documentHostingSaveResolutionOperationId = null, documentHostingSaveResolutionStartedAt = 0;
|
|
62
63
|
let documentHostingResourceDir = null, documentHostingResourceEditGeneration = 0, documentHostingMetadataLocked = false;
|
|
63
64
|
const settledHostingSaveRequests = new Map();
|
|
64
65
|
const documentHostingOwnerFlights = new Map();
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
let scratchpadHostingProduction = null, reviewNotesHostingProduction = null;
|
|
67
68
|
const documentHostingWaiters = new Set();
|
|
68
69
|
let bufferRecoveryClient = null;
|
|
69
|
-
let bufferRecoveryIssue = "", bufferRecoveryKeptClosed = false;
|
|
70
|
+
let bufferRecoveryIssue = "", bufferRecoveryKeptClosed = false, bufferRecoveryIssueChannels = null;
|
|
70
71
|
let bufferRecoveryPanel = null;
|
|
71
72
|
let bufferRecoveryInitializing = false;
|
|
72
73
|
let bufferRecoveryNavigationConsent = null;
|
|
@@ -107,6 +108,7 @@
|
|
|
107
108
|
? responseActionsEl.closest(".response-wrap")
|
|
108
109
|
: null;
|
|
109
110
|
const referenceBadgeEl = document.getElementById("referenceBadge");
|
|
111
|
+
const referenceHistoryCountEl = document.getElementById("referenceHistoryCount");
|
|
110
112
|
const editorViewSelect = document.getElementById("editorViewSelect");
|
|
111
113
|
const editorViewSelectWrap = document.getElementById("editorViewSelectWrap");
|
|
112
114
|
const rightViewSelect = document.getElementById("rightViewSelect");
|
|
@@ -372,7 +374,8 @@
|
|
|
372
374
|
let studioOperationNotices = new Map();
|
|
373
375
|
let studioOperationNoticesEl = null;
|
|
374
376
|
let studioDocumentDestinationsSection = null;
|
|
375
|
-
let studioOperationNoticeFingerprint = "";
|
|
377
|
+
let studioOperationNoticeFingerprint = "", studioHeldSaveNoticeTimer = null;
|
|
378
|
+
const studioOwnSaveAttemptsEnded = new Set();
|
|
376
379
|
let statusLevel = "";
|
|
377
380
|
let reconnectTimer = null;
|
|
378
381
|
let reconnectAttempt = 0;
|
|
@@ -950,15 +953,16 @@
|
|
|
950
953
|
const run = studioRuntimeActivity?.run;
|
|
951
954
|
if (wsState === "Disconnected" || wsState === "Connecting") return run ? "Run status unknown · reconnecting…" : "Reconnecting…";
|
|
952
955
|
const stopping = run && (run.stopping || studioStopRequestedRunId === run.id);
|
|
953
|
-
if (stopping) return "Stopping…" + (studioRuntimeActivity.compaction ? " · Compacting
|
|
954
|
-
if (studioRuntimeActivity?.compaction) return "Compacting
|
|
956
|
+
if (stopping) return "Stopping…" + (studioRuntimeActivity.compaction ? " · Compacting…" : "");
|
|
957
|
+
if (studioRuntimeActivity?.compaction) return "Compacting…";
|
|
955
958
|
if (run) {
|
|
956
959
|
if (run.origin === "outside") return "Pi is busy · started outside Studio";
|
|
957
960
|
if (run.origin === "unknown") return "Pi is busy · run origin unknown";
|
|
958
961
|
const seconds = Math.max(0, Math.floor((Date.now() - run.startedAt) / 1000));
|
|
959
|
-
|
|
962
|
+
// Oliver, 22 Oct: the clock alone, beside Stop, so the running row fits narrower windows.
|
|
963
|
+
return Math.floor(seconds / 60) + ":" + String(seconds % 60).padStart(2, "0");
|
|
960
964
|
}
|
|
961
|
-
// Oliver, 14 Oct: a Run waiting for Pi to start says so briefly here, so
|
|
965
|
+
// Oliver, 14 Oct: a Run waiting for Pi to start says so briefly here, so Steer fits
|
|
962
966
|
// beside it and the toolbar doesn't wrap and jump back. The footer keeps the detail.
|
|
963
967
|
if (uiBusy && pendingKind === "direct") return "Starting…";
|
|
964
968
|
return uiBusy ? getStudioBusyStatus(pendingKind) : "";
|
|
@@ -4065,13 +4069,14 @@
|
|
|
4065
4069
|
(isEditorOnlyMode || isWatchedFilePreview || followMenu) ? null : activityTrackingSelect,
|
|
4066
4070
|
(bufferSwitchingEnabled && !followMenu) ? documentPreviewFollowSelect : null]);
|
|
4067
4071
|
appendStudioUiRefreshMenuSection(viewMenu.menu, "Annotations", [annotationModeSelect, insertHeaderBtn, stripAnnotationsBtn, saveAnnotatedBtn]);
|
|
4072
|
+
// View sits after File in row 1, as the right pane's View sits in its header, so row 2 fits narrower panes (Oliver, 27 Oct).
|
|
4073
|
+
headerToolsEl.appendChild(viewMenu.anchor);
|
|
4068
4074
|
// Row 2 mirrors row 1: the main action on the left, the tools on the right (Oliver, 10 Oct).
|
|
4069
4075
|
const toolsEl = makeStudioUiRefreshElement("span", "studio-refresh-tools");
|
|
4070
4076
|
if (reviewNotesBtn) toolsEl.appendChild(reviewNotesBtn);
|
|
4071
4077
|
if (scratchpadBtn) toolsEl.appendChild(scratchpadBtn);
|
|
4072
4078
|
if (isEditorOnlyMode && askAsideBtn) toolsEl.appendChild(askAsideBtn);
|
|
4073
4079
|
if (reviewMenu) toolsEl.appendChild(reviewMenu.anchor);
|
|
4074
|
-
toolsEl.appendChild(viewMenu.anchor);
|
|
4075
4080
|
actionLineOneEl.appendChild(toolsEl);
|
|
4076
4081
|
|
|
4077
4082
|
toolbarMainEl.appendChild(actionsEl);
|
|
@@ -5001,12 +5006,57 @@
|
|
|
5001
5006
|
} else if (opening?.error) add({ id: "open:invalid", kind: "open", bufferId: null,
|
|
5002
5007
|
message: "Opening backup could not be verified. Keep it for recovery; current work was kept.",
|
|
5003
5008
|
actions: [{ controlId: "studioDownloadOpenBtn", label: "Export backup" }] });
|
|
5004
|
-
for (const save of bufferRecoveryClient?.pendingHostingSaves() || [])
|
|
5005
|
-
|
|
5006
|
-
|
|
5009
|
+
for (const save of bufferRecoveryClient?.pendingHostingSaves() || []) {
|
|
5010
|
+
if (holdStudioSaveNotice(save.operationId)) continue;
|
|
5011
|
+
add({ id: "save:" + save.operationId, kind: "save", bufferId: save.bufferId,
|
|
5012
|
+
message: "Disk save recorded; attaching its backing is unresolved. Current text kept.",
|
|
5013
|
+
actions: [{ controlId: "studioResolveSaveBtn", label: "Resolve saved backing…", selectedBufferOnly: true }] });
|
|
5014
|
+
}
|
|
5007
5015
|
return notices;
|
|
5008
5016
|
}
|
|
5009
5017
|
|
|
5018
|
+
// Oliver, 27 Oct: every Document save showed its own pending record for about 40 ms, above the panes (so they
|
|
5019
|
+
// jumped) and as a recovery warning in the footer. While this tab is still finishing that save itself, there's
|
|
5020
|
+
// nothing to decide yet; if it's still pending after that, or after 10 s, it shows as before.
|
|
5021
|
+
const STUDIO_OWN_SAVE_HOLD_MS = 10000;
|
|
5022
|
+
// When this tab's hold on a pending save ends, or 0 if it isn't held.
|
|
5023
|
+
function studioSaveHoldEndsAt(operationId) {
|
|
5024
|
+
// Once Studio's own attempt to finish it has ended, a save still pending is a decision to make.
|
|
5025
|
+
if (!operationId || studioOwnSaveAttemptsEnded.has(operationId)) return 0;
|
|
5026
|
+
let endsAt = 0;
|
|
5027
|
+
for (const operation of pendingSaveOperations.values()) {
|
|
5028
|
+
if (operation.hosting?.operationId === operationId) endsAt = Math.max(endsAt, (operation.startedAt || 0) + STUDIO_OWN_SAVE_HOLD_MS);
|
|
5029
|
+
}
|
|
5030
|
+
if (documentHostingSaveResolution && documentHostingSaveResolutionOperationId === operationId) {
|
|
5031
|
+
endsAt = Math.max(endsAt, documentHostingSaveResolutionStartedAt + STUDIO_OWN_SAVE_HOLD_MS);
|
|
5032
|
+
}
|
|
5033
|
+
return endsAt > Date.now() ? endsAt : 0;
|
|
5034
|
+
}
|
|
5035
|
+
function studioSaveIsFinishingItself(operationId) {
|
|
5036
|
+
return studioSaveHoldEndsAt(operationId) > 0;
|
|
5037
|
+
}
|
|
5038
|
+
function holdStudioSaveNotice(operationId) {
|
|
5039
|
+
const endsAt = studioSaveHoldEndsAt(operationId);
|
|
5040
|
+
if (!endsAt) return false;
|
|
5041
|
+
// Look again when the earliest hold ends, in case nothing else does: at its own end, not 10 s from now (Sol, Astra).
|
|
5042
|
+
if (!studioHeldSaveNoticeTimer || studioHeldSaveNoticeTimer.at > endsAt) {
|
|
5043
|
+
if (studioHeldSaveNoticeTimer) clearTimeout(studioHeldSaveNoticeTimer.id);
|
|
5044
|
+
studioHeldSaveNoticeTimer = { at: endsAt, id: setTimeout(() => {
|
|
5045
|
+
studioHeldSaveNoticeTimer = null; syncStudioOperationNotices(); renderStatus();
|
|
5046
|
+
}, Math.max(0, endsAt - Date.now()) + 50) };
|
|
5047
|
+
}
|
|
5048
|
+
return true;
|
|
5049
|
+
}
|
|
5050
|
+
function studioPendingSavesAreFinishing() {
|
|
5051
|
+
const saves = bufferRecoveryClient?.pendingHostingSaves() || [];
|
|
5052
|
+
return saves.length > 0 && saves.every(save => holdStudioSaveNotice(save.operationId));
|
|
5053
|
+
}
|
|
5054
|
+
function getStudioShownRecoveryIssue() {
|
|
5055
|
+
const channels = bufferRecoveryIssueChannels;
|
|
5056
|
+
if (!channels?.["file-save"] || Object.values(channels).join(" ") !== bufferRecoveryIssue || !studioPendingSavesAreFinishing()) return bufferRecoveryIssue;
|
|
5057
|
+
return Object.entries(channels).filter(([channel]) => channel !== "file-save").map(([, message]) => message).join(" ");
|
|
5058
|
+
}
|
|
5059
|
+
|
|
5010
5060
|
function getStudioPriorityOperationNotice() {
|
|
5011
5061
|
return [...studioOperationNotices.values()].find(notice => notice.unresolved && notice.severity === "warning") || null;
|
|
5012
5062
|
}
|
|
@@ -5078,11 +5128,12 @@
|
|
|
5078
5128
|
// the footer quiet rather than duplicating it or competing with a short
|
|
5079
5129
|
// confirmation; retain a fallback if notice rendering is unavailable.
|
|
5080
5130
|
const operationInNotice = operation && studioOperationNoticesEl?.isConnected && !studioOperationNoticesEl.hidden;
|
|
5081
|
-
|
|
5082
|
-
|
|
5131
|
+
const recoveryIssue = getStudioShownRecoveryIssue();
|
|
5132
|
+
statusEl.textContent = recoveryIssue
|
|
5133
|
+
? "Recovery: " + recoveryIssue + (bufferRecoveryKeptClosed ? "" : " Save or copy your text before reloading. " + (operationInNotice ? "" : (operation?.message || statusMessage)))
|
|
5083
5134
|
: operationInNotice ? "" : operation?.message || statusMessage;
|
|
5084
|
-
statusEl.className =
|
|
5085
|
-
statusEl.title =
|
|
5135
|
+
statusEl.className = recoveryIssue ? "warning" : operationInNotice ? "" : operation?.severity || (statusLevel || "");
|
|
5136
|
+
statusEl.title = recoveryIssue || (!operationInNotice && operation?.message) || "";
|
|
5086
5137
|
if (typeof syncStudioPromptAddUndo === "function") syncStudioPromptAddUndo();
|
|
5087
5138
|
|
|
5088
5139
|
const spinnerActive = shouldAnimateFooterSpinner();
|
|
@@ -7384,6 +7435,7 @@
|
|
|
7384
7435
|
|
|
7385
7436
|
function updateReferenceBadge() {
|
|
7386
7437
|
if (!referenceBadgeEl) return;
|
|
7438
|
+
if (referenceHistoryCountEl) referenceHistoryCountEl.hidden = true;
|
|
7387
7439
|
const referenceMetaEl = referenceBadgeEl.closest(".reference-meta");
|
|
7388
7440
|
if (rightView === "repl" || (studioUiRefreshUi && rightView === "editor-preview") || (bufferSwitchingEnabled && studioUiRefreshUi && rightView === "files")) {
|
|
7389
7441
|
if (referenceMetaEl instanceof HTMLElement) referenceMetaEl.hidden = true;
|
|
@@ -7490,10 +7542,20 @@
|
|
|
7490
7542
|
const selected = total > 0 && responseHistoryIndex >= 0 && responseHistoryIndex < total
|
|
7491
7543
|
? responseHistoryIndex + 1
|
|
7492
7544
|
: 0;
|
|
7493
|
-
|
|
7545
|
+
// Oliver, 22 Oct: the new layout shows the count on its own at the right, as agent-markdown-preview
|
|
7546
|
+
// does, so it's quick to find, and in the accent colour while an older response is showing.
|
|
7547
|
+
const countAtRight = Boolean(studioUiRefreshUi && referenceHistoryCountEl && total > 0);
|
|
7548
|
+
if (countAtRight) {
|
|
7549
|
+
referenceHistoryCountEl.textContent = selected + "/" + total;
|
|
7550
|
+
referenceHistoryCountEl.title = "Response " + selected + " of " + total + " in this branch's history";
|
|
7551
|
+
referenceHistoryCountEl.classList.toggle("is-older", selected > 0 && selected < total);
|
|
7552
|
+
referenceHistoryCountEl.hidden = false;
|
|
7553
|
+
}
|
|
7554
|
+
const historyPrefix = total > 0 && !countAtRight ? "Branch history " + selected + "/" + total + " · " : "";
|
|
7555
|
+
const label = countAtRight ? responseLabel.charAt(0).toUpperCase() + responseLabel.slice(1) : responseLabel;
|
|
7494
7556
|
referenceBadgeEl.textContent = time
|
|
7495
|
-
? historyPrefix +
|
|
7496
|
-
: historyPrefix +
|
|
7557
|
+
? historyPrefix + label + " · " + time
|
|
7558
|
+
: historyPrefix + label;
|
|
7497
7559
|
}
|
|
7498
7560
|
|
|
7499
7561
|
function normalizeForCompare(text) {
|
|
@@ -17416,6 +17478,7 @@
|
|
|
17416
17478
|
const current = () => !bufferPageClosed && client === bufferRecoveryClient && generation > 0 && generation === documentHostingGeneration
|
|
17417
17479
|
&& bufferId === client.snapshot().selectedBufferId && facts() === before && !studioModalBlocksDraftAction(decision);
|
|
17418
17480
|
documentHostingSaveResolutionBufferId = bufferId;
|
|
17481
|
+
documentHostingSaveResolutionOperationId = options.automaticOperationId || null; documentHostingSaveResolutionStartedAt = Date.now();
|
|
17419
17482
|
syncDocumentHostingReadiness();
|
|
17420
17483
|
documentHostingSaveResolution = (async () => {
|
|
17421
17484
|
try {
|
|
@@ -17493,10 +17556,19 @@
|
|
|
17493
17556
|
if (client.pendingHostingSaves().some(save => save.operationId === record.operationId) || !client.hostingAuthority(bufferId).ok) {
|
|
17494
17557
|
throw new Error("The saved baseline is kept locally, but recovery is not acknowledged. Keep this tab and recheck copies before closing.");
|
|
17495
17558
|
}
|
|
17496
|
-
|
|
17559
|
+
// A save Studio finished by itself is just a save (Oliver, 27 Oct); the longer wording stays for a resolved one.
|
|
17560
|
+
setStatus(options.automaticOperationId ? "Saved " + (basenameForStudioPath(record.path) || record.label || "the file") + "."
|
|
17561
|
+
: "Attached the saved baseline without replacing later typing. The disk file was not rewritten.", "success");
|
|
17497
17562
|
}
|
|
17498
17563
|
} catch (error) { setStatus(error.message || "The save outcome could not be resolved. Keep current work and recheck.", "warning"); }
|
|
17499
|
-
})().finally(() => {
|
|
17564
|
+
})().finally(() => {
|
|
17565
|
+
if (options.automaticOperationId) {
|
|
17566
|
+
studioOwnSaveAttemptsEnded.add(options.automaticOperationId);
|
|
17567
|
+
while (studioOwnSaveAttemptsEnded.size > 128) studioOwnSaveAttemptsEnded.delete(studioOwnSaveAttemptsEnded.values().next().value);
|
|
17568
|
+
}
|
|
17569
|
+
documentHostingSaveResolution = null; documentHostingSaveResolutionBufferId = null; documentHostingSaveResolutionOperationId = null;
|
|
17570
|
+
syncDocumentHostingReadiness(); renderStatus();
|
|
17571
|
+
});
|
|
17500
17572
|
return documentHostingSaveResolution;
|
|
17501
17573
|
}
|
|
17502
17574
|
function documentHostingMetadataIsIdle(bufferId) {
|
|
@@ -28068,7 +28140,7 @@
|
|
|
28068
28140
|
queueSteerBtn.disabled = true;
|
|
28069
28141
|
queueSteerBtn.classList.remove("request-stop-active");
|
|
28070
28142
|
queueSteerBtn.hidden = true;
|
|
28071
|
-
queueSteerBtn.title = "
|
|
28143
|
+
queueSteerBtn.title = "Steer is unavailable in editor-only mode.";
|
|
28072
28144
|
}
|
|
28073
28145
|
if (sendReplBtn) {
|
|
28074
28146
|
sendReplBtn.hidden = !showReplSend;
|
|
@@ -28138,9 +28210,9 @@
|
|
|
28138
28210
|
queueSteerBtn.classList.remove("request-stop-active");
|
|
28139
28211
|
queueSteerBtn.title = canQueueSteering
|
|
28140
28212
|
? (annotationsEnabled
|
|
28141
|
-
? "
|
|
28142
|
-
: "
|
|
28143
|
-
: "
|
|
28213
|
+
? "Steer the active run with the editor text. Pi adds it when the agent's current step ends, before its next model call. Shortcut: Cmd/Ctrl+Enter."
|
|
28214
|
+
: "Steer the active run with the editor text, without its [an: ...] markers. Pi adds it when the agent's current step ends, before its next model call. Shortcut: Cmd/Ctrl+Enter.")
|
|
28215
|
+
: "Steer is available while a Studio run is active.";
|
|
28144
28216
|
}
|
|
28145
28217
|
|
|
28146
28218
|
if (sendReplBtn) {
|
|
@@ -31317,7 +31389,7 @@
|
|
|
31317
31389
|
const requestId = beginUiAction("save_as");
|
|
31318
31390
|
if (!requestId) return false;
|
|
31319
31391
|
const operation = {
|
|
31320
|
-
kind: "save_as", ...(hosting ? { hosting } : {}),
|
|
31392
|
+
kind: "save_as", ...(hosting ? { hosting } : {}), startedAt: Date.now(),
|
|
31321
31393
|
sourceKey: getEditorDraftSourceKey(),
|
|
31322
31394
|
path: cleanPath,
|
|
31323
31395
|
content: String(content ?? ""),
|
|
@@ -31392,7 +31464,7 @@
|
|
|
31392
31464
|
const requestId = beginUiAction("save_over");
|
|
31393
31465
|
if (!requestId) return false;
|
|
31394
31466
|
const operation = {
|
|
31395
|
-
kind: "save_over", ...(settings.hosting ? { hosting: settings.hosting } : {}),
|
|
31467
|
+
kind: "save_over", ...(settings.hosting ? { hosting: settings.hosting } : {}), startedAt: Date.now(),
|
|
31396
31468
|
sourceKey: getEditorDraftSourceKey(),
|
|
31397
31469
|
path,
|
|
31398
31470
|
content: Object.prototype.hasOwnProperty.call(settings, "content")
|
|
@@ -31763,7 +31835,7 @@
|
|
|
31763
31835
|
return;
|
|
31764
31836
|
}
|
|
31765
31837
|
if (!studioRunChainActive) {
|
|
31766
|
-
setStatus("
|
|
31838
|
+
setStatus("Steer is only available while a Studio run is active.", "warning");
|
|
31767
31839
|
return;
|
|
31768
31840
|
}
|
|
31769
31841
|
|
|
@@ -32585,7 +32657,7 @@
|
|
|
32585
32657
|
return legacy.status === "unavailable" ? { ok: false, reason: "unavailable", message: "Legacy server recovery could not be checked." } : { ok: true, state: legacy.state };
|
|
32586
32658
|
},
|
|
32587
32659
|
// A tab Studio moved away from no longer owns the workspace; its issues don't apply.
|
|
32588
|
-
onIssue: (message) => { if (studioMovedAway) return; bufferRecoveryIssue = message; renderStatus(); },
|
|
32660
|
+
onIssue: (message, channels) => { if (studioMovedAway) return; bufferRecoveryIssue = message; bufferRecoveryIssueChannels = channels || null; renderStatus(); },
|
|
32589
32661
|
});
|
|
32590
32662
|
let client = createRecoveryClient();
|
|
32591
32663
|
try { promptRunIndicatorFresh = !recoveryStorage?.getItem("piStudio.bufferWorkspace.v2:" + studioTabStateId) && document.body.dataset.hostingResume !== "1"; } catch { promptRunIndicatorFresh = false; }
|
package/client/studio.css
CHANGED
|
@@ -7548,8 +7548,12 @@
|
|
|
7548
7548
|
/* Honor existing handler eligibility after controls are regrouped. */
|
|
7549
7549
|
body.studio-ui-refresh [hidden] { display: none !important; }
|
|
7550
7550
|
/* Dogfood workspace: two logical rows, with normal wrapping in small panes. */
|
|
7551
|
-
/* Room for "
|
|
7552
|
-
|
|
7551
|
+
/* Room for "Starting…" and "Stopping…", so nothing moves when a run starts, its clock ticks or it's stopped
|
|
7552
|
+
(Oliver, 14 Oct). Hidden copies in the page's own font set the width. The clock itself, "0:16", is narrower,
|
|
7553
|
+
and the old 13ch reserve for "Running 00:00" pushed the tools onto a second row (Oliver, 22 Oct). */
|
|
7554
|
+
.studio-run-status { color: var(--muted); font-size: 12px; min-width: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
7555
|
+
.studio-run-status::before { content: "Starting…"; display: block; height: 0; overflow: hidden; visibility: hidden; }
|
|
7556
|
+
.studio-run-status::after { content: "Stopping…"; display: block; height: 0; overflow: hidden; visibility: hidden; }
|
|
7553
7557
|
body.studio-ui-refresh #rightSectionHeader .studio-follow-button {
|
|
7554
7558
|
color: var(--muted); border: 0; border-radius: 0; background: transparent;
|
|
7555
7559
|
}
|
|
@@ -7576,6 +7580,20 @@
|
|
|
7576
7580
|
/* Natural widths with a small gap (Oliver, trial48): the unselected label may shift a little on switching. */
|
|
7577
7581
|
body.studio-workspace-layout .studio-workspace-file-controls { min-width: 0; margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
|
|
7578
7582
|
body.studio-workspace-layout .studio-workspace-filename { min-width: 0; max-width: min(180px, 35cqi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
|
|
7583
|
+
/* With View beside File, the name shortens before anything wraps (Oliver, 27 Oct). Its column can narrow to 4em, so
|
|
7584
|
+
row 1 wraps only when even that won't fit. Otherwise the controls take the rest of the row, and the name what's left
|
|
7585
|
+
of that, up to its cap. In a very narrow pane the controls wrap among themselves, as before. */
|
|
7586
|
+
body.studio-workspace-layout #leftSectionHeader .studio-workspace-file-controls {
|
|
7587
|
+
display: grid; grid-auto-flow: column; grid-template-columns: minmax(4em, max-content); grid-auto-columns: max-content;
|
|
7588
|
+
justify-content: end; justify-items: stretch; align-items: center; column-gap: 8px; flex: 1 1 0%; min-width: min-content;
|
|
7589
|
+
}
|
|
7590
|
+
body.studio-workspace-layout #leftSectionHeader .studio-workspace-file-controls > :has(> .studio-workspace-filename) { min-width: 0; max-width: min(180px, 35cqi); }
|
|
7591
|
+
body.studio-workspace-layout #leftSectionHeader .studio-workspace-file-controls > * > .studio-workspace-filename { max-width: 100%; }
|
|
7592
|
+
/* Its own line below the tabs, as before; it must also give up the row-filling size, or it stays beside the tabs
|
|
7593
|
+
and the name overlaps them (candidate 97, seen in a replay screenshot). */
|
|
7594
|
+
@container (max-width: 300px) {
|
|
7595
|
+
body.studio-workspace-layout #leftSectionHeader .studio-workspace-file-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; flex: 0 1 auto; min-width: 0; margin-left: auto; }
|
|
7596
|
+
}
|
|
7579
7597
|
body.studio-workspace-layout .studio-refresh-toolbar-main { display: block; }
|
|
7580
7598
|
body.studio-workspace-layout .studio-refresh-toolbar-actions { gap: 0; min-width: 0; width: 100%; }
|
|
7581
7599
|
body.studio-workspace-layout .studio-refresh-toolbar-actions > .studio-refresh-action-line { min-width: 0; width: 100%; }
|
|
@@ -7585,6 +7603,13 @@
|
|
|
7585
7603
|
body.studio-workspace-layout .response-option-select-wrap:not(:has(select)) { display: none; }
|
|
7586
7604
|
body.studio-workspace-layout .reference-meta .source-badge,
|
|
7587
7605
|
body.studio-workspace-layout #historyIndexBadge { border: 0; border-radius: 0; background: transparent; }
|
|
7606
|
+
/* The response count sits at the right of the line, in the text colour, and in the accent colour while an
|
|
7607
|
+
older response is showing (Oliver, 22 Oct). */
|
|
7608
|
+
body.studio-workspace-layout .reference-meta:not([hidden]) { display: flex; align-items: center; gap: 8px; }
|
|
7609
|
+
/* As a row its labels' vertical padding would count, making the line 7 px taller than before (Astra). */
|
|
7610
|
+
body.studio-workspace-layout .reference-meta .source-badge { padding-top: 0; padding-bottom: 0; }
|
|
7611
|
+
body.studio-workspace-layout #rightPane #referenceHistoryCount { margin-left: auto; flex: none; color: var(--text); font-variant-numeric: tabular-nums; }
|
|
7612
|
+
body.studio-workspace-layout #rightPane #referenceHistoryCount.is-older { color: var(--accent); }
|
|
7588
7613
|
body.studio-workspace-layout .studio-refresh-action-line { flex-wrap: wrap; gap: 6px 10px; }
|
|
7589
7614
|
body.studio-workspace-layout .studio-refresh-menu > button { display: block; width: 100%; text-align: left; white-space: normal; }
|
|
7590
7615
|
body.studio-workspace-layout .response-result-row { flex-wrap: wrap; }
|
package/index.ts
CHANGED
|
@@ -88,7 +88,8 @@ import {
|
|
|
88
88
|
cleanupPrivateReplControlFiles,
|
|
89
89
|
createPrivateReplControlFiles,
|
|
90
90
|
} from "./shared/repl-control-files.js";
|
|
91
|
-
import {
|
|
91
|
+
import { CURSOR_COLUMN_QUERY, CURSOR_COLUMN_SUPERVISOR } from "./shared/repl-cursor-column.js";
|
|
92
|
+
import { buildMLanguageControlSource, buildMLanguageDriverSource, mStringLiteral } from "./shared/repl-m-language.js";
|
|
92
93
|
import { buildGnuplotDriverSource, buildGnuplotGuardSource, buildGnuplotSubmissionLine } from "./shared/repl-gnuplot.js";
|
|
93
94
|
import { GNUPLOT_OWNER_ENV, GNUPLOT_OWNER_OPTION } from "./shared/repl-gnuplot-processes.js";
|
|
94
95
|
import { buildCppDriverSource, buildCppRequest, cppInclude, createCppControlCleanup, prepareCppSubmission, readCppCompletion } from "./shared/repl-cpp.js";
|
|
@@ -11671,17 +11672,17 @@ function buildStudioClojureDisplayStatements(display: ReplSubmissionDisplay, ind
|
|
|
11671
11672
|
return display.prefixLines.map((line) => `${indent}(clojure.core/println ${JSON.stringify(line)})`);
|
|
11672
11673
|
}
|
|
11673
11674
|
|
|
11674
|
-
//
|
|
11675
|
-
// 500 ms. A wrapper runs it with Node and ends a line before its
|
|
11676
|
-
// 0. Only the wrapper reads its output, so it never reaches the
|
|
11677
|
-
// outlives its wait can't print after the done file (Sol, Astra,
|
|
11675
|
+
// CURSOR_COLUMN_QUERY (shared with pi-repl) prints the pane's cursor column, or exits
|
|
11676
|
+
// non-zero; tmux gets 500 ms. A wrapper runs it with Node and ends a line before its
|
|
11677
|
+
// footer unless it prints 0. Only the wrapper reads its output, so it never reaches the
|
|
11678
|
+
// pane: a query that outlives its wait can't print after the done file (Sol, Astra,
|
|
11679
|
+
// candidate80).
|
|
11678
11680
|
// process.exit ends Node even if a startup hook in NODE_OPTIONS would keep it running,
|
|
11679
11681
|
// and each wrapper also limits the whole helper to 5 s.
|
|
11680
11682
|
// With the display Off, the footers still end a line that output left open, and add
|
|
11681
11683
|
// nothing else. Otherwise the runtime's prompt follows the output on the same row,
|
|
11682
11684
|
// which the record mistook for a prompt row, and line editors such as gnuplot's then
|
|
11683
11685
|
// redraw the next pasted line wrongly (Astra, candidate90).
|
|
11684
|
-
const STUDIO_CURSOR_COLUMN_QUERY = 'let code = 1; try { require("node:fs").writeSync(1, require("node:child_process").execFileSync("tmux", ["-N", "display-message", "-p", "-t", process.env.TMUX_PANE, "#{cursor_x}"], { encoding: "utf8", timeout: 500, killSignal: "SIGKILL", maxBuffer: 128, stdio: ["ignore", "pipe", "ignore"] }).trim()); code = 0; } catch {} process.exit(code);';
|
|
11685
11686
|
|
|
11686
11687
|
function buildStudioPythonFooter(display: ReplSubmissionDisplay): string[] {
|
|
11687
11688
|
return [
|
|
@@ -11691,7 +11692,7 @@ function buildStudioPythonFooter(display: ReplSubmissionDisplay): string[] {
|
|
|
11691
11692
|
" try:",
|
|
11692
11693
|
" __pi_studio_sys.stdout.flush()",
|
|
11693
11694
|
" __pi_studio_sys.stderr.flush()",
|
|
11694
|
-
` __pi_studio_query = __pi_studio_subprocess.run([${JSON.stringify(process.execPath)}, '-e', ${JSON.stringify(
|
|
11695
|
+
` __pi_studio_query = __pi_studio_subprocess.run([${JSON.stringify(process.execPath)}, '-e', ${JSON.stringify(CURSOR_COLUMN_QUERY)}], stdin=__pi_studio_subprocess.DEVNULL, stdout=__pi_studio_subprocess.PIPE, stderr=__pi_studio_subprocess.DEVNULL, timeout=5)`,
|
|
11695
11696
|
" if __pi_studio_query.returncode == 0:",
|
|
11696
11697
|
" __pi_studio_column = __pi_studio_query.stdout.decode('utf-8', 'replace').strip()",
|
|
11697
11698
|
// run() kills the query on any exception. Ctrl-C here must not skip the done file.
|
|
@@ -11750,7 +11751,7 @@ function buildStudioPythonControlSource(runtime: "python" | "ipython", code: str
|
|
|
11750
11751
|
}
|
|
11751
11752
|
|
|
11752
11753
|
function buildStudioJuliaFooter(display: ReplSubmissionDisplay): string[] {
|
|
11753
|
-
const query = `Cmd([${juliaStringLiteral(process.execPath)}, "-e", ${juliaStringLiteral(
|
|
11754
|
+
const query = `Cmd([${juliaStringLiteral(process.execPath)}, "-e", ${juliaStringLiteral(CURSOR_COLUMN_QUERY)}])`;
|
|
11754
11755
|
return [
|
|
11755
11756
|
' local __pi_studio_column = ""',
|
|
11756
11757
|
" local __pi_studio_query = nothing",
|
|
@@ -11809,7 +11810,7 @@ function buildStudioRFooter(display: ReplSubmissionDisplay): string[] {
|
|
|
11809
11810
|
// system2 quotes the command but not its arguments, and kills it after
|
|
11810
11811
|
// 5 s. A failed query sets a status; an error or Ctrl-C here gives
|
|
11811
11812
|
// NULL, not a lost done file.
|
|
11812
|
-
` .__pi_studio_column <- tryCatch(suppressWarnings(system2(${JSON.stringify(process.execPath)}, c("-e", ${JSON.stringify(shellQuote(
|
|
11813
|
+
` .__pi_studio_column <- tryCatch(suppressWarnings(system2(${JSON.stringify(process.execPath)}, c("-e", ${JSON.stringify(shellQuote(CURSOR_COLUMN_QUERY))}), stdout = TRUE, stderr = FALSE, timeout = 5)), error = function(e) NULL, interrupt = function(e) NULL)`,
|
|
11813
11814
|
' if (!is.null(attr(.__pi_studio_column, "status")) || !identical(trimws(paste(.__pi_studio_column, collapse = "")), "0")) base::cat("\\n")',
|
|
11814
11815
|
...display.suffixLines.map((line) => ` base::cat(${JSON.stringify(`${line}\n`)})`),
|
|
11815
11816
|
];
|
|
@@ -11863,7 +11864,7 @@ function buildStudioGhciControlSource(code: string, doneFile: string, display: R
|
|
|
11863
11864
|
// bounded, and Ctrl+C stops only the query. Empty if the query fails. ${NODE_OPTIONS-}
|
|
11864
11865
|
// because the Shell runtime's footer runs in the user's shell, which may have set -u (Astra).
|
|
11865
11866
|
function buildStudioShellCursorColumn(): string {
|
|
11866
|
-
return `__pi_studio_column=$(NODE_OPTIONS= ${shellQuote(process.execPath)} -e ${shellQuote(
|
|
11867
|
+
return `__pi_studio_column=$(NODE_OPTIONS= ${shellQuote(process.execPath)} -e ${shellQuote(CURSOR_COLUMN_SUPERVISOR)} -- "\${NODE_OPTIONS-}" </dev/null 2>/dev/null) || __pi_studio_column=`;
|
|
11867
11868
|
}
|
|
11868
11869
|
|
|
11869
11870
|
function buildStudioGhciCompletionLine(doneFile: string, display: ReplSubmissionDisplay): string {
|
|
@@ -11875,7 +11876,7 @@ function buildStudioGhciCompletionLine(doneFile: string, display: ReplSubmission
|
|
|
11875
11876
|
}
|
|
11876
11877
|
|
|
11877
11878
|
function buildStudioClojureFooter(display: ReplSubmissionDisplay): string[] {
|
|
11878
|
-
const builder = `(java.lang.ProcessBuilder. ^java.util.List [${JSON.stringify(process.execPath)} "-e" ${JSON.stringify(
|
|
11879
|
+
const builder = `(java.lang.ProcessBuilder. ^java.util.List [${JSON.stringify(process.execPath)} "-e" ${JSON.stringify(CURSOR_COLUMN_QUERY)}])`;
|
|
11879
11880
|
return [
|
|
11880
11881
|
" (try (.flush *out*) (.flush *err*) (catch Throwable _))",
|
|
11881
11882
|
// An interrupt left pending by the code would end the wait at once, so
|
|
@@ -12066,58 +12067,6 @@ function buildStudioJavaDriverSource(sourceFile: string, doneFile: string, displ
|
|
|
12066
12067
|
].join("\n");
|
|
12067
12068
|
}
|
|
12068
12069
|
|
|
12069
|
-
// Octave and MATLAB: pi-repl's shared buildMLanguageDriverSource, with two changes Sol and
|
|
12070
|
-
// Astra held candidate88 on, until pi-repl takes them:
|
|
12071
|
-
// - The column query is STUDIO_CURSOR_COLUMN_QUERY, which exits once it has written, run by
|
|
12072
|
-
// STUDIO_CURSOR_COLUMN_SUPERVISOR, which kills it after 5 s: system() itself has no time
|
|
12073
|
-
// limit. It writes to a private file, not to system()'s pipe, so nothing it leaves running
|
|
12074
|
-
// can hold that pipe open, and the file goes even if the script is interrupted (as in
|
|
12075
|
-
// pi-repl 0.10.1). The script exits 0 or 1: given a status such as 137, MATLAB printed the
|
|
12076
|
-
// command and "Killed" (Astra).
|
|
12077
|
-
// - In Octave, Ctrl+C during a cleanup action ended it before the done file was written.
|
|
12078
|
-
// unwind_protect_cleanup writes it even then. MATLAB finishes a cleanup action despite
|
|
12079
|
-
// Ctrl+C, and has no unwind_protect.
|
|
12080
|
-
// Runs STUDIO_CURSOR_COLUMN_QUERY in a child Node, with the caller's NODE_OPTIONS (its
|
|
12081
|
-
// argument), and kills it after 5 s. The supervisor runs without NODE_OPTIONS, so no startup
|
|
12082
|
-
// hook can stall it, keep it running or catch its timer; SIGKILL can't be caught either. It
|
|
12083
|
-
// signals only its own child, which Node tracks, so never a process ID since reused (Sol). A
|
|
12084
|
-
// preload that catches SIGALRM made perl's alarm wait for its stall (Astra). It ignores Ctrl+C
|
|
12085
|
-
// and hangups, so the deadline holds then too; the query gets the default handling.
|
|
12086
|
-
const STUDIO_CURSOR_COLUMN_SUPERVISOR = `for (const signal of ["SIGINT", "SIGHUP", "SIGTERM"]) process.on(signal, () => {}); const child = require("node:child_process").spawn(process.execPath, ["-e", ${JSON.stringify(STUDIO_CURSOR_COLUMN_QUERY)}], { stdio: ["ignore", "inherit", "ignore"], env: { ...process.env, NODE_OPTIONS: process.argv[1] ?? "" } }); const timer = setTimeout(() => child.kill("SIGKILL"), 5000); child.on("error", () => process.exit(1)); child.on("exit", (code) => { clearTimeout(timer); process.exit(code === 0 ? 0 : 1); });`;
|
|
12087
|
-
|
|
12088
|
-
function buildStudioMLanguageDriverSource(runtime: "octave" | "matlab", sourceFile: string, doneFile: string, display: ReplSubmissionDisplay): string {
|
|
12089
|
-
const query = [
|
|
12090
|
-
// The shell's own messages would reach the pane through system().
|
|
12091
|
-
"exec 2>/dev/null",
|
|
12092
|
-
"f=$(mktemp) || exit 1",
|
|
12093
|
-
`trap 'rm -f "$f"' EXIT`,
|
|
12094
|
-
"trap 'exit 1' HUP INT TERM",
|
|
12095
|
-
// After --, Node takes "$NODE_OPTIONS" as the script's argument, not as its own option.
|
|
12096
|
-
`NODE_OPTIONS= ${shellQuote(process.execPath)} -e ${shellQuote(STUDIO_CURSOR_COLUMN_SUPERVISOR)} -- "$NODE_OPTIONS" >"$f" </dev/null; s=$?`,
|
|
12097
|
-
'cat "$f"',
|
|
12098
|
-
'[ "$s" = 0 ]',
|
|
12099
|
-
].join("; ");
|
|
12100
|
-
const footer = [
|
|
12101
|
-
...(runtime === "octave" ? ["fflush(1);"] : []),
|
|
12102
|
-
"try",
|
|
12103
|
-
// /bin/sh whatever the user's shell is: MATLAB runs system() with $SHELL.
|
|
12104
|
-
` [pi_repl_status,pi_repl_column]=system(${mStringLiteral(`/bin/sh -c ${shellQuote(query)}`)});`,
|
|
12105
|
-
"catch",
|
|
12106
|
-
" pi_repl_status=-1; pi_repl_column='';",
|
|
12107
|
-
"end",
|
|
12108
|
-
"if pi_repl_status~=0 || ~strcmp(strtrim(pi_repl_column),'0'); fprintf(1,'\\n'); end",
|
|
12109
|
-
...display.suffixLines.map((line) => `fprintf(1,'%s\\n',${mStringLiteral(line)});`),
|
|
12110
|
-
];
|
|
12111
|
-
const done = `fclose(fopen(${mStringLiteral(doneFile)},'w'));`;
|
|
12112
|
-
const finish = (runtime === "octave"
|
|
12113
|
-
? ["unwind_protect", ...footer, "unwind_protect_cleanup", done, "end_unwind_protect"]
|
|
12114
|
-
: [...footer, done]).join("\n");
|
|
12115
|
-
// As in pi-repl: parameters give eval its own slots, so no helper variables, ans, cwd or
|
|
12116
|
-
// path changes reach the base workspace, and even clear all can't remove the guard.
|
|
12117
|
-
const cleanup = `onCleanup(@() feval(@(pi_repl_status,pi_repl_column) eval(${mStringLiteral(finish)}),-1,''))`;
|
|
12118
|
-
return `feval(@(pi_repl_error,pi_repl_guard) eval(fileread(${mStringLiteral(sourceFile)})),[],${cleanup});\n`;
|
|
12119
|
-
}
|
|
12120
|
-
|
|
12121
12070
|
function buildStudioShellControlSource(code: string, display: ReplSubmissionDisplay): string {
|
|
12122
12071
|
return [
|
|
12123
12072
|
...display.prefixLines.map((line) => `command printf '%s\\n' ${shellQuote(line)}`),
|
|
@@ -12242,14 +12191,14 @@ function prepareStudioReplSubmission(
|
|
|
12242
12191
|
}
|
|
12243
12192
|
}
|
|
12244
12193
|
if (runtime === "octave" || runtime === "matlab") {
|
|
12245
|
-
// pi-repl's M driver
|
|
12194
|
+
// pi-repl's M driver: the code runs in the base workspace,
|
|
12246
12195
|
// and a function-local onCleanup writes the footer and done file, even after an
|
|
12247
12196
|
// error, return, interrupt or clear all.
|
|
12248
12197
|
try {
|
|
12249
12198
|
const driver = createPrivateReplControlFiles({
|
|
12250
12199
|
...controlOptions,
|
|
12251
12200
|
extension: "m",
|
|
12252
|
-
buildSource: () =>
|
|
12201
|
+
buildSource: () => buildMLanguageDriverSource(runtime, controlFiles.sourceFile, controlFiles.doneFile, display),
|
|
12253
12202
|
});
|
|
12254
12203
|
controlFiles.helpers = [driver];
|
|
12255
12204
|
loader = driver.sourceFile;
|
|
@@ -13298,7 +13247,7 @@ ${cssVarsBlock}
|
|
|
13298
13247
|
<div class="source-actions">
|
|
13299
13248
|
<div class="source-actions-row">
|
|
13300
13249
|
<button id="sendRunBtn" type="button" title="Run editor text. If Studio loaded or staged an unchanged Pi terminal draft, clear that draft after Pi accepts the run. While a direct run is active, this button becomes Stop. Cmd/Ctrl+Enter queues steering from the current editor text. Stop the active request with Esc.">Run editor text</button>
|
|
13301
|
-
<button id="queueSteerBtn" type="button" title="
|
|
13250
|
+
<button id="queueSteerBtn" type="button" title="Steer is available while a Studio run is active." disabled>Steer</button>
|
|
13302
13251
|
</div>
|
|
13303
13252
|
<div class="source-actions-row repl-action-line" hidden>
|
|
13304
13253
|
<button id="sendReplBtn" type="button" hidden title="Send the current selection, or the full editor text, to the active REPL session shown in the right pane.">Send to REPL</button>
|
|
@@ -13526,6 +13475,7 @@ ${cssVarsBlock}
|
|
|
13526
13475
|
</div>
|
|
13527
13476
|
<div class="reference-meta">
|
|
13528
13477
|
<span id="referenceBadge" class="source-badge">Latest response: none</span>
|
|
13478
|
+
<span id="referenceHistoryCount" class="source-badge" hidden></span>
|
|
13529
13479
|
</div>
|
|
13530
13480
|
<div id="critiqueView" class="panel-scroll rendered-markdown"><pre class="plain-markdown">No response yet.</pre></div>
|
|
13531
13481
|
<div class="response-wrap">
|
|
@@ -13641,7 +13591,7 @@ ${cssVarsBlock}
|
|
|
13641
13591
|
<div><dt>Cmd/Ctrl+S</dt><dd>Save editor when the disk revision still matches</dd></div>
|
|
13642
13592
|
<div><dt>Cmd/Ctrl+Shift+S</dt><dd>Save editor as a new file</dd></div>
|
|
13643
13593
|
<div><dt>Cmd/Ctrl+Shift+L</dt><dd>Load the current Pi terminal input draft without clearing it</dd></div>
|
|
13644
|
-
<div class="shortcuts-full-only"><dt>Cmd/Ctrl+Enter</dt><dd>Run editor text, or
|
|
13594
|
+
<div class="shortcuts-full-only"><dt>Cmd/Ctrl+Enter</dt><dd>Run editor text, or steer an active run</dd></div>
|
|
13645
13595
|
<div><dt>Option/Alt+Tab or Cmd/Ctrl+Shift+Space</dt><dd>Suggest a completion at the editor cursor</dd></div>
|
|
13646
13596
|
<div><dt>Tab</dt><dd>Insert a visible completion suggestion; otherwise indent selected editor text</dd></div>
|
|
13647
13597
|
<div><dt>Esc</dt><dd>Dismiss a visible completion suggestion, close overlays, exit pane focus, or stop an active request</dd></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-studio",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
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",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// The Node script a REPL wrapper runs to learn the pane's cursor column, so
|
|
2
|
+
// that it ends a line before its footer only when output stopped mid-line. It
|
|
3
|
+
// prints the column, or exits non-zero; tmux gets 500 ms. process.exit ends
|
|
4
|
+
// Node even if a startup hook in NODE_OPTIONS would keep it running. Only the
|
|
5
|
+
// wrapper reads its output, so it never reaches the pane.
|
|
6
|
+
export const CURSOR_COLUMN_QUERY = 'let code = 1; try { require("node:fs").writeSync(1, require("node:child_process").execFileSync("tmux", ["-N", "display-message", "-p", "-t", process.env.TMUX_PANE, "#{cursor_x}"], { encoding: "utf8", timeout: 500, killSignal: "SIGKILL", maxBuffer: 128, stdio: ["ignore", "pipe", "ignore"] }).trim()); code = 0; } catch {} process.exit(code);';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Runs CURSOR_COLUMN_QUERY in a child Node, with the caller's NODE_OPTIONS
|
|
10
|
+
* (its argument), and kills it after 5 s. The supervisor itself runs without
|
|
11
|
+
* NODE_OPTIONS, so no startup hook can stall it, keep it running or catch its
|
|
12
|
+
* timer, and SIGKILL can't be caught either; a hook that caught perl's SIGALRM
|
|
13
|
+
* held the helper as long as it liked. It signals only its own child, which
|
|
14
|
+
* Node tracks, so never a process ID since reused. It ignores Ctrl-C and
|
|
15
|
+
* hangups, so the deadline holds then too; the query gets the default
|
|
16
|
+
* handling. It exits 0 or 1. From pi-studio 0.11.0.
|
|
17
|
+
*/
|
|
18
|
+
export const CURSOR_COLUMN_SUPERVISOR = `for (const signal of ["SIGINT", "SIGHUP", "SIGTERM"]) process.on(signal, () => {}); const child = require("node:child_process").spawn(process.execPath, ["-e", ${JSON.stringify(CURSOR_COLUMN_QUERY)}], { stdio: ["ignore", "inherit", "ignore"], env: { ...process.env, NODE_OPTIONS: process.argv[1] ?? "" } }); const timer = setTimeout(() => child.kill("SIGKILL"), 5000); child.on("error", () => process.exit(1)); child.on("exit", (code) => { clearTimeout(timer); process.exit(code === 0 ? 0 : 1); });`;
|
|
19
|
+
|
|
20
|
+
const shellQuote = (value) => `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A command that runs the query under /bin/sh, whatever the caller's shell
|
|
24
|
+
* (MATLAB's system() uses $SHELL), for runtimes whose own process call can't
|
|
25
|
+
* be bounded (GHCi's :!, and Octave and MATLAB system()).
|
|
26
|
+
* CURSOR_COLUMN_SUPERVISOR stops it after 5 s. The column passes through a
|
|
27
|
+
* temporary file, so a child the helper leaves behind can't hold the caller's
|
|
28
|
+
* pipe open; the file is removed even when the script is interrupted. The
|
|
29
|
+
* shell's messages are discarded, and it exits only 0 or 1, so the caller
|
|
30
|
+
* never prints a signal status.
|
|
31
|
+
*/
|
|
32
|
+
export function boundedCursorColumnCommand(nodePath) {
|
|
33
|
+
const script = [
|
|
34
|
+
"exec 2>/dev/null",
|
|
35
|
+
"f=$(mktemp) || exit 1",
|
|
36
|
+
// Ctrl-C reaches this shell too; the file goes either way.
|
|
37
|
+
`trap 'rm -f "$f"' EXIT`,
|
|
38
|
+
"trap 'exit 1' HUP INT TERM",
|
|
39
|
+
// After --, Node takes the caller's NODE_OPTIONS as the script's argument, not as its own option.
|
|
40
|
+
`NODE_OPTIONS= ${shellQuote(nodePath)} -e ${shellQuote(CURSOR_COLUMN_SUPERVISOR)} -- "\${NODE_OPTIONS-}" >"$f" </dev/null`,
|
|
41
|
+
"s=$?",
|
|
42
|
+
'cat "$f"',
|
|
43
|
+
'[ "$s" = 0 ]',
|
|
44
|
+
].join("; ");
|
|
45
|
+
return `/bin/sh -c ${shellQuote(script)}`;
|
|
46
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// MATLAB and Octave share the base-workspace protocol, not a process/session.
|
|
2
|
-
|
|
2
|
+
import { boundedCursorColumnCommand } from "./repl-cursor-column.js";
|
|
3
3
|
|
|
4
4
|
export function mStringLiteral(value) {
|
|
5
5
|
// Single-quoted ASCII is compact in the loader. Encode everything else as
|
|
@@ -21,23 +21,32 @@ export function buildMLanguageControlSource(code, display) {
|
|
|
21
21
|
].join("\n");
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* What runs once a submission's code has finished: the footer, then the done
|
|
26
|
+
* file. In Off the footer still ends a line that output left open, and adds
|
|
27
|
+
* nothing else. Ctrl-C during Octave's footer interrupts this cleanup action
|
|
28
|
+
* and skips whatever follows, so for Octave the done file is written by
|
|
29
|
+
* unwind_protect. MATLAB finishes the action, and has no unwind_protect.
|
|
30
|
+
*/
|
|
31
|
+
export function buildMLanguageFinish(runtime, doneFile, display) {
|
|
32
|
+
const footer = [
|
|
33
|
+
...(runtime === "octave" ? ["fflush(1);"] : []),
|
|
34
|
+
"try",
|
|
35
|
+
` [pi_repl_status,pi_repl_column]=system(${mStringLiteral(boundedCursorColumnCommand(process.execPath))});`,
|
|
36
|
+
"catch",
|
|
37
|
+
" pi_repl_status=-1; pi_repl_column='';",
|
|
38
|
+
"end",
|
|
39
|
+
"if pi_repl_status~=0 || ~strcmp(strtrim(pi_repl_column),'0'); fprintf(1,'\\n'); end",
|
|
40
|
+
...display.suffixLines.map((line) => `fprintf(1,'%s\\n',${mStringLiteral(line)});`),
|
|
41
|
+
];
|
|
42
|
+
const done = `fclose(fopen(${mStringLiteral(doneFile)},'w'));`;
|
|
43
|
+
return (runtime === "octave"
|
|
44
|
+
? ["unwind_protect", ...footer, "unwind_protect_cleanup", done, "end_unwind_protect"]
|
|
45
|
+
: [...footer, done]).join("\n");
|
|
46
|
+
}
|
|
47
|
+
|
|
24
48
|
export function buildMLanguageDriverSource(runtime, sourceFile, doneFile, display) {
|
|
25
|
-
const
|
|
26
|
-
'try { process.stdout.write(require("node:child_process").execFileSync("tmux", ["-N", "display-message", "-p", "-t", process.env.TMUX_PANE, "#{cursor_x}"], { encoding: "utf8", timeout: 500, killSignal: "SIGKILL", maxBuffer: 128, stdio: ["ignore", "pipe", "ignore"] }).trim()); } catch { process.exitCode = 1; }',
|
|
27
|
-
].join(" ");
|
|
28
|
-
const finish = [
|
|
29
|
-
...(display.enabled ? [
|
|
30
|
-
...(runtime === "octave" ? ["fflush(1);"] : []),
|
|
31
|
-
"try",
|
|
32
|
-
` [pi_repl_status,pi_repl_column]=system(${mStringLiteral(`${shellQuote(process.execPath)} -e ${shellQuote(query)} 2>/dev/null`)});`,
|
|
33
|
-
"catch",
|
|
34
|
-
" pi_repl_status=-1; pi_repl_column='';",
|
|
35
|
-
"end",
|
|
36
|
-
"if pi_repl_status~=0 || ~strcmp(strtrim(pi_repl_column),'0'); fprintf(1,'\\n'); end",
|
|
37
|
-
...display.suffixLines.map((line) => `fprintf(1,'%s\\n',${mStringLiteral(line)});`),
|
|
38
|
-
] : []),
|
|
39
|
-
`fclose(fopen(${mStringLiteral(doneFile)},'w'));`,
|
|
40
|
-
].join("\n");
|
|
49
|
+
const finish = buildMLanguageFinish(runtime, doneFile, display);
|
|
41
50
|
// Parameters give eval its own slots in MATLAB's static anonymous-function
|
|
42
51
|
// workspace. No helper variables/ans, cwd or path changes enter the base
|
|
43
52
|
// workspace. onCleanup runs on normal completion, return and interruption;
|
|
@@ -64,7 +64,7 @@ export function createStudioBufferClient(options) {
|
|
|
64
64
|
const issues = new Map();
|
|
65
65
|
function issue(channel, result) {
|
|
66
66
|
if (result) issues.set(channel, result.message || "Recovery is unavailable."); else issues.delete(channel);
|
|
67
|
-
options.onIssue?.([...issues.values()].join(" "));
|
|
67
|
+
options.onIssue?.([...issues.values()].join(" "), Object.fromEntries(issues));
|
|
68
68
|
}
|
|
69
69
|
function ack() {
|
|
70
70
|
try {
|