fix(view): use relative API URLs for path-prefix reverse proxy
Notebook and debugger controls now call api/... and open debug?path=... relative to the page, so the same HTML works under a path prefix such as /marqdo-view/<token>/. This enables same-origin DSH preview without publishing another Docker port.
This commit is contained in:
1 parent
d99b275336
commit
476c2b607b
3 files changed
+25
-19
No files matched your search
@@ -13,6 +13,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- **view 反向代理兼容**:Notebook / Debug 的 API 与 Debug URL 改为相对路径,可在 `/marqdo-view/...` 路径前缀下工作,便于 Docker 内通过 DSH 同源预览。
|
||||
- **分支内共同局部变量**:if/else 各臂都赋值的局部变量不再被误提升为必选形参;修复 `# llm` 构造器无端要求 `key`,恢复 agent/llm/ext 全量测试。新增 `branch_else_common_local_is_not_a_param` 回归测试。
|
||||
- **外联临时脚本路径**:入口目录为相对路径时,脚本参数现在使用绝对路径,避免 `tests/lib/tests/lib/...` 双拼接。
|
||||
- **外联失败可观测**:解释器不存在时进入 `invoke` 记录,`run` 仍报错;view 显示 stderr / exit / ms。
|
||||
|
||||
@@ -849,7 +849,7 @@ fn debug_js() -> &'static str {
|
||||
}
|
||||
renderBps();
|
||||
if (session) {
|
||||
post("/api/debug/breakpoints", {
|
||||
post("api/debug/breakpoints", {
|
||||
session: session,
|
||||
breakpoints: bpList()
|
||||
}).catch(function () {});
|
||||
@@ -861,7 +861,7 @@ fn debug_js() -> &'static str {
|
||||
startBtn.disabled = true;
|
||||
setStatus("Starting…");
|
||||
clearCurrent();
|
||||
post("/api/debug/start", {
|
||||
post("api/debug/start", {
|
||||
path: path,
|
||||
breakpoints: bpList(),
|
||||
stdin: stdinText()
|
||||
@@ -875,7 +875,7 @@ fn debug_js() -> &'static str {
|
||||
if (!session) return;
|
||||
setStatus("Continue…");
|
||||
setPausedUi(false);
|
||||
post("/api/debug/continue", {
|
||||
post("api/debug/continue", {
|
||||
session: session,
|
||||
breakpoints: bpList()
|
||||
}).then(applySnap).catch(function (e) { setStatus(String(e)); });
|
||||
@@ -884,14 +884,14 @@ fn debug_js() -> &'static str {
|
||||
if (!session) return;
|
||||
setStatus("Step…");
|
||||
setPausedUi(false);
|
||||
post("/api/debug/step", {
|
||||
post("api/debug/step", {
|
||||
session: session,
|
||||
breakpoints: bpList()
|
||||
}).then(applySnap).catch(function (e) { setStatus(String(e)); });
|
||||
});
|
||||
stopBtn.addEventListener("click", function () {
|
||||
if (!session) return;
|
||||
post("/api/debug/stop", { session: session }).then(function () {
|
||||
post("api/debug/stop", { session: session }).then(function () {
|
||||
session = null;
|
||||
clearCurrent();
|
||||
setStatus("Stopped");
|
||||
@@ -947,7 +947,7 @@ fn debug_js() -> &'static str {
|
||||
out.hidden = false;
|
||||
out.classList.remove("err");
|
||||
out.textContent = "Running…";
|
||||
fetch("/api/foreign-run", {
|
||||
fetch("api/foreign-run", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
|
||||
+18
-13
@@ -1614,7 +1614,7 @@ pub fn layout(title: &str, nav: &str, main: &str) -> String {
|
||||
out.hidden = false;
|
||||
out.classList.remove("err");
|
||||
out.textContent = "Running…";
|
||||
fetch("/api/foreign-run", {{
|
||||
fetch("api/foreign-run", {{
|
||||
method: "POST",
|
||||
headers: {{ "Content-Type": "application/json" }},
|
||||
body: JSON.stringify({{
|
||||
@@ -2137,7 +2137,7 @@ pub fn layout(title: &str, nav: &str, main: &str) -> String {
|
||||
clearStream();
|
||||
pinned = true;
|
||||
var stdinEl = document.getElementById("stdin");
|
||||
fetch("/api/run", {{
|
||||
fetch("api/run", {{
|
||||
method: "POST",
|
||||
headers: {{
|
||||
"Content-Type": "application/json",
|
||||
@@ -2927,7 +2927,7 @@ fn notebook_ui() -> &'static str {
|
||||
var head = el.querySelector(".code-head");
|
||||
if (head) head.appendChild(sel);
|
||||
sel.addEventListener("change", function () {
|
||||
post("/api/session/kernel/assign", { cell: c.name, kernel: sel.value }).then(function (r) {
|
||||
post("api/session/kernel/assign", { cell: c.name, kernel: sel.value }).then(function (r) {
|
||||
status(r.ok ? "kernel: " + sel.value : (r.error || "assign failed"));
|
||||
});
|
||||
});
|
||||
@@ -2946,7 +2946,7 @@ fn notebook_ui() -> &'static str {
|
||||
function openSession() {
|
||||
var bar = document.getElementById("notebook-bar");
|
||||
if (bar) bar.hidden = false;
|
||||
post("/api/session/open", {}).then(function (r) {
|
||||
post("api/session/open", {}).then(function (r) {
|
||||
if (!r.ok) { status(r.error || "session open failed"); return; }
|
||||
state.open = true;
|
||||
renderSummary(r.session);
|
||||
@@ -2954,14 +2954,14 @@ fn notebook_ui() -> &'static str {
|
||||
});
|
||||
}
|
||||
function runOne(name) {
|
||||
return post("/api/session/cell/run", { cell: name }).then(function (r) {
|
||||
return post("api/session/cell/run", { cell: name }).then(function (r) {
|
||||
if (r.ok) { renderRecord(name, r.record); if (r.session) renderSummary(r.session); }
|
||||
else status(r.error || "run failed");
|
||||
});
|
||||
}
|
||||
function runAll(restart) {
|
||||
status(restart ? "restarting…" : "running all…");
|
||||
post("/api/session/run_all", { restart: !!restart }).then(function (r) {
|
||||
post("api/session/run_all", { restart: !!restart }).then(function (r) {
|
||||
if (!r.ok) { status(r.error || "run all failed"); return; }
|
||||
if (r.session) renderSummary(r.session);
|
||||
var recs = (r.summary && r.summary.records) || [];
|
||||
@@ -2974,7 +2974,7 @@ fn notebook_ui() -> &'static str {
|
||||
bind("nb-run-all", function () { runAll(false); });
|
||||
bind("nb-restart", function () { runAll(true); });
|
||||
bind("nb-step", function () {
|
||||
post("/api/session/cell/step", {}).then(function (r) {
|
||||
post("api/session/cell/step", {}).then(function (r) {
|
||||
if (!r.ok) { status(r.error || "step failed"); return; }
|
||||
if (r.record) {
|
||||
if (r.record.cell) renderRecord(r.record.cell, r.record);
|
||||
@@ -2985,7 +2985,7 @@ fn notebook_ui() -> &'static str {
|
||||
});
|
||||
});
|
||||
bind("nb-state", function () {
|
||||
post("/api/session/state/list", {}).then(function (r) {
|
||||
post("api/session/state/list", {}).then(function (r) {
|
||||
var pre = document.getElementById("nb-state-out");
|
||||
var actions = document.getElementById("nb-state-actions");
|
||||
var ki = document.getElementById("nb-kernel-input");
|
||||
@@ -3005,7 +3005,7 @@ fn notebook_ui() -> &'static str {
|
||||
if (raw.trim()) {
|
||||
try { value = JSON.parse(raw); } catch (e) { status("value must be JSON"); return; }
|
||||
}
|
||||
post("/api/session/state/push", { kernel: k, name: n, value: value }).then(function (r) {
|
||||
post("api/session/state/push", { kernel: k, name: n, value: value }).then(function (r) {
|
||||
status(r.ok ? "pushed " + n + " → " + k : (r.error || "push failed"));
|
||||
});
|
||||
});
|
||||
@@ -3014,13 +3014,13 @@ fn notebook_ui() -> &'static str {
|
||||
var n = (document.getElementById("nb-name-input") || {}).value || "";
|
||||
var out = document.getElementById("nb-pull-out");
|
||||
if (!k || !n) { status("kernel and name required"); return; }
|
||||
post("/api/session/state/pull", { kernel: k, name: n }).then(function (r) {
|
||||
post("api/session/state/pull", { kernel: k, name: n }).then(function (r) {
|
||||
if (out) out.textContent = r.ok ? (n + " = " + JSON.stringify(r.value)) : (r.error || "pull failed");
|
||||
status(r.ok ? "pulled " + n + " ← " + k : "pull failed");
|
||||
});
|
||||
});
|
||||
bind("nb-journal", function () {
|
||||
post("/api/session/journal", {}).then(function (r) {
|
||||
post("api/session/journal", {}).then(function (r) {
|
||||
var pre = document.getElementById("nb-state-out");
|
||||
if (!pre) return;
|
||||
pre.hidden = false;
|
||||
@@ -3028,10 +3028,10 @@ fn notebook_ui() -> &'static str {
|
||||
});
|
||||
});
|
||||
bind("nb-debug", function () {
|
||||
window.open("/debug?path=" + encodeURIComponent(path), "_blank");
|
||||
window.open("debug?path=" + encodeURIComponent(path), "_blank");
|
||||
});
|
||||
bind("nb-reload", function () {
|
||||
post("/api/session/reload", {}).then(function (r) {
|
||||
post("api/session/reload", {}).then(function (r) {
|
||||
if (!r.ok) { status(r.error || "reload failed"); return; }
|
||||
renderSummary(r.session);
|
||||
status("reloaded");
|
||||
@@ -3459,5 +3459,10 @@ mod tests {
|
||||
] {
|
||||
assert!(ui.contains(id), "notebook UI missing {id}");
|
||||
}
|
||||
assert!(
|
||||
!ui.contains("\"/api/session"),
|
||||
"notebook API URLs must stay relative for path-prefix proxy"
|
||||
);
|
||||
assert!(ui.contains("post(\"api/session/open\""));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user