Open a cited script in the editor instead of a read-only viewer

This commit is contained in:
Gmer4Lfe
2026-08-10 21:15:45 -04:00
parent 9adf760c8e
commit 33affc5a59
2 changed files with 49 additions and 5 deletions
+14
View File
@@ -2444,6 +2444,7 @@ if (document.getElementById('vv-sched-ai-chat')) {
onOffer: (kind, yes) => { if (kind === 'fix') vvAiFixAnswer(yes); },
// Per-block Insert buttons render only where a page can receive them.
onInsertCode: vvAiInsertCode,
onOpenSource: vvAiOpenSource,
});
}
@@ -2510,6 +2511,19 @@ let vvAiFixAsk = null; // { scope, symptom } while the offer is open and awa
// It is an offer, never automatic: the editor usually holds work in progress, and a reply that
// silently rewrote it would be far worse than copy/paste.
// Clicking a retrieved source here opens it where it can be changed, not just read. The component
// falls back to its read-only viewer for anything this declines — which is everything that is not
// a script, since api/script.php serves scripts and the index also carries READMEs and manuals.
function vvAiOpenSource(path) {
if (!path) return;
if (/\.sh$/.test(path)) {
vvEditScript(path);
if (vvSchedChat) vvSchedChat.note('Opened ' + path + ' in the editor.');
return;
}
vvAiOpen(path);
}
// display:'' vs 'none' is how this panel switches views — see vvShowEditor and friends.
function vvAiEditorOpen() {
const ed = document.getElementById('vv-editor');