feat(notebook): link statement debugger from view
Expose /debug and /api/debug/* on the live view server; add a notebook Debug button so Marqdo statement stepping is reachable from the same page/session as cell stepping.
This commit is contained in:
1 parent
9873df7099
commit
0f2c12b636
5 files changed
+40
-4
No files matched your search
@@ -2844,6 +2844,7 @@ fn notebook_ui() -> &'static str {
|
||||
<button type="button" id="nb-state">State</button>
|
||||
<button type="button" id="nb-journal">Journal</button>
|
||||
<button type="button" id="nb-reload">Reload</button>
|
||||
<button type="button" id="nb-debug">Debug</button>
|
||||
<span id="nb-status">opening…</span>
|
||||
</div>
|
||||
<div class="notebook-bar" id="nb-state-actions" hidden>
|
||||
@@ -3026,6 +3027,9 @@ fn notebook_ui() -> &'static str {
|
||||
pre.textContent = JSON.stringify(r.journal || r, null, 2);
|
||||
});
|
||||
});
|
||||
bind("nb-debug", function () {
|
||||
window.open("/debug?path=" + encodeURIComponent(path), "_blank");
|
||||
});
|
||||
bind("nb-reload", function () {
|
||||
post("/api/session/reload", {}).then(function (r) {
|
||||
if (!r.ok) { status(r.error || "reload failed"); return; }
|
||||
@@ -3447,6 +3451,7 @@ mod tests {
|
||||
"nb-state",
|
||||
"nb-journal",
|
||||
"nb-reload",
|
||||
"nb-debug",
|
||||
"nb-kernel-input",
|
||||
"nb-push",
|
||||
"nb-pull",
|
||||
|
||||
@@ -234,6 +234,29 @@ fn handle(root: &ViewRoot, request: Request) -> Result<()> {
|
||||
notebook_api::api_journal(&root.root, body)
|
||||
})
|
||||
}
|
||||
"/api/debug/start" => {
|
||||
return api_debug_post(request, |body| {
|
||||
debug_api::api_debug_start(&root.root, body)
|
||||
})
|
||||
}
|
||||
"/api/debug/continue" => {
|
||||
return api_debug_post(request, |body| {
|
||||
debug_api::api_debug_action(body, crate::debug::DebugAction::Continue)
|
||||
})
|
||||
}
|
||||
"/api/debug/step" => {
|
||||
return api_debug_post(request, |body| {
|
||||
debug_api::api_debug_action(body, crate::debug::DebugAction::Step)
|
||||
})
|
||||
}
|
||||
"/api/debug/stop" => {
|
||||
return api_debug_post(request, |body| debug_api::api_debug_stop(body))
|
||||
}
|
||||
"/api/debug/breakpoints" => {
|
||||
return api_debug_post(request, |body| {
|
||||
debug_api::api_debug_set_breakpoints(body)
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
let resp =
|
||||
Response::from_string("method not allowed").with_status_code(StatusCode(405));
|
||||
@@ -272,6 +295,14 @@ fn handle(root: &ViewRoot, request: Request) -> Result<()> {
|
||||
let body = page_file(&root.files, &rel, &vm, &LinkMode::Live);
|
||||
respond_html(request, body)
|
||||
}
|
||||
"/debug" => {
|
||||
let rel = query_param(query, "path").unwrap_or_default();
|
||||
let resolved = resolve_rel(root, &rel)?;
|
||||
let source = std::fs::read_to_string(&resolved).unwrap_or_default();
|
||||
let vm = build_debug_model(&resolved, &rel, &source);
|
||||
let body = page_debug(&root.files, &rel, &vm);
|
||||
respond_html(request, body)
|
||||
}
|
||||
"/api/tree" => {
|
||||
let json = files_json(&root.files);
|
||||
respond_json(request, json)
|
||||
|
||||
Reference in new issue
Block a user