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
+1
-1
@@ -8,7 +8,7 @@
|
||||
- **`lib/foreign` F2**:JSON 进 / JSON 出 `call`;并行 `run_many` / `call_many`(有序、单项隔离、并发上限);`invoke` 的 `input` / `output` / `result` / `result_error`。
|
||||
- **`lib/foreign` F3/F3.5**:Python / Node 持久会话 `session_open` / `session_eval` / `session_close` / `session_list`;状态桥 `session_set` / `session_get` / `session_names`;会话超时即杀、崩溃隔离、drop 清理。
|
||||
- **Notebook D1/D2**:`内核表` / `会话表` 文档原生语法;`DocumentSession`(cell index / 命名内核 / journal / value store);view Notebook 工具栏(Run All / Restart & Run All / Step / State / Journal / Reload)、状态徽标、内核下拉、Push/Pull 状态表单;`POST /api/session/*`。
|
||||
- **Notebook D3(部分)**:`reload` 重新解析并保留内核,源码变更的 cell 标为 `dirty`;Journal/Reload 按钮;状态桥 Push/Pull。
|
||||
- **Notebook D3**:`reload` 重新解析并保留内核,源码变更的 cell 标为 `dirty`;Journal/Reload/Debug 按钮;Debug 打开同一 view 服务的语句级单步页(`/debug` + `/api/debug/*`);状态桥 Push/Pull。
|
||||
- **安全与健壮性**:所有外联入口检查 `exec` 能力;有界 stdout/stderr 读取与截断标记;stdin 写线程;Unix 进程组 / Windows `taskkill /T` 超时清理;shell-like argv 切分。
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
| view 工具栏 / 状态徽标 / 内核下拉 / 状态表单 | ✅ | `src/view/html.rs` |
|
||||
| `POST /api/session/*` | ✅(含 `reload`) | `src/view/notebook_api.rs` |
|
||||
| cell step | ✅ | 同上 |
|
||||
| Marqdo statement step | 复用 `marqdo debug`;view 集成待做 | `src/debug` |
|
||||
| Marqdo statement step | ✅(notebook 工具栏 Debug → 同一 view 服务的 `/debug`;`/api/debug/*`) | `src/debug` · `src/view/debug_api.rs` |
|
||||
| dirty/stale 自动检测 | 部分(reload → dirty;assign → dirty;stale 传播待做) | `src/notebook/mod.rs` |
|
||||
| writeback 集成 | 待做 | `writeback` |
|
||||
| replay / 持久化 | 待做 | — |
|
||||
@@ -417,7 +417,7 @@ Kernel: [分析 ▾] Status: ready [Restart] [Interrupt]
|
||||
| POST | `/api/session/state/list` | Marqdo / kernel 变量列表 |
|
||||
| POST | `/api/session/state/push` | Marqdo 值 → kernel |
|
||||
| POST | `/api/session/state/pull` | kernel 变量 → value store |
|
||||
| POST | `/api/session/statement/step` | Marqdo 语句单步(复用 debug) |
|
||||
| POST | `/api/debug/*` + `/debug` | Marqdo 语句单步(Debug 按钮,复用 debugger) |
|
||||
| POST | `/api/session/writeback` | 显式写回 cell 输出 |
|
||||
| POST | `/api/session/journal` | 执行日志 |
|
||||
| GET | `/api/session` | 当前会话摘要 |
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **D1–D2 已落地;D3–D5 待做** |
|
||||
| 状态 | **D1–D3 已落地(首版);D4–D5 待做** |
|
||||
| 日期 | 2026-10-17 |
|
||||
| 层 | Runtime + Document(view 服务端 / 前端) |
|
||||
| 相关 | [notebook-session.md](../design/notebook-session.md) · [notebook-syntax.md](../design/notebook-syntax.md) · [foreign-kernel.md](../design/foreign-kernel.md) · [foreign-v2.md](foreign-v2.md) · [foreign-notebook-decisions.md](../research/foreign-notebook-decisions.md) |
|
||||
|
||||
@@ -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