refactor: externalize tree shell runtime
This commit is contained in:
@@ -496,6 +496,44 @@ Reasonix read-only audit:
|
||||
- 结果:`ok=true`
|
||||
- 证据:命令 stdout JSON,`assetId=local:asset:README/side-target-resource.md`、`officeAssetId=local:asset:README/side-target-office.docx`。
|
||||
|
||||
### 9.6 Batch 5 执行记录(2026-05-24)
|
||||
|
||||
Reasonix read-only audit:
|
||||
|
||||
- run id: `reasonix-2026-05-24T15-57-06-903Z-51c4452a`
|
||||
- handoff: `/home/lix/.codex/runtime/reasonix-coding-worker/reasonix-2026-05-24T15-57-06-903Z-51c4452a/process-handoff.md`
|
||||
- 类型:只读审计,主控已读取 Hindsight recall、`process-handoff.md`、`process-handoff.json`。
|
||||
- 采纳结论:可采纳;本批是 debug `/tree` shell runtime 同构迁出,未改变 `/api/tree/runtime/reduce` 合同和 page/filetree/picker 行为。
|
||||
|
||||
采纳内容:
|
||||
|
||||
- 新增 `rust/crates/mnote-web/browser/tree-shell-runtime.js`,从 `tree.rs` 原 inline runtime 同构迁出。
|
||||
- `build_tree_shell_html()` 保留 `tree-shell-state` bootstrap JSON,改为加载 `/api/mnote-browser-runtime/tree-shell-runtime.js` module script。
|
||||
- 新增 `/api/mnote-browser-runtime/tree-shell-runtime.js` 路由,返回 `application/javascript; charset=utf-8`。
|
||||
- `tree.rs` 测试继续通过 `include_str!("../../browser/tree-shell-runtime.js")` 校验 tree shell runtime 的 page/filetree/picker 关键字符串。
|
||||
- 主控复核后额外采纳一个小型结构化 hoist:`buildFileTreeRuntimeEnvironment`、`reducePageActionWithRuntime`、`reconcilePageRuntimeResult` 从 IIFE 内部移到文件顶层,通过 `runtimeContext` 显式接收依赖,使 CodeGraph 可以定位这些函数;未改变 runtime API 合同。
|
||||
|
||||
已通过验证:
|
||||
|
||||
- `node --check rust/crates/mnote-web/browser/tree-shell-runtime.js`
|
||||
- `cargo fmt --manifest-path rust/Cargo.toml --all --check`
|
||||
- `cargo check --manifest-path rust/Cargo.toml -p mnote-web`
|
||||
- `cargo test --manifest-path rust/Cargo.toml -p mnote-web tree_shell`
|
||||
- 结果:42 个 tree_shell 相关测试通过。
|
||||
- `GET /api/mnote-browser-runtime/tree-shell-runtime.js`
|
||||
- 结果:`200`,`content-type=application/javascript; charset=utf-8`,响应包含 `tree.ready`、`hydrateInitialFileTree`。
|
||||
- `codegraph_search reducePageActionWithRuntime` / `buildFileTreeRuntimeEnvironment` / `reconcilePageRuntimeResult`
|
||||
- 结果:3 个函数均可定位到 `rust/crates/mnote-web/browser/tree-shell-runtime.js`。
|
||||
- `MNOTE_WEB_ENABLE_DEBUG_SHELL_ROUTES=1` 下 `/tree` 运行态说明:
|
||||
- Convex workspace 参数返回 `503 convex_unavailable`,因为本地未启动 Convex upstream。
|
||||
- local_folder 参数返回 `401 local_workspace_auth_required`,因为本次未注入浏览器登录态。
|
||||
- 因此运行态 `/tree` HTML 由 Rust route 单测覆盖,本批不把这些环境失败视为实现失败。
|
||||
|
||||
剩余风险:
|
||||
|
||||
- `type="module"` 自带作用域,`tree-shell-runtime.js` 外层 IIFE 现在是冗余但无害;本批保持同构迁出,暂不做额外重构。
|
||||
- debug tree shell runtime 与主壳 `SIDEBAR_TREE_JS` 仍是两套 runtime,后续 P4/P5 继续拆主壳 filetree runtime 和 document pane host adapter。
|
||||
|
||||
## 10. 分阶段执行清单
|
||||
|
||||
### P0:定位辅助与基线保护
|
||||
@@ -549,11 +587,12 @@ Reasonix read-only audit:
|
||||
|
||||
### P3:外置 debug `/tree` shell runtime bridge
|
||||
|
||||
- [ ] 将 `tree.rs` 中 `tree-shell-state` 后的大块 JS 迁到 `browser/tree-shell-runtime.js`。
|
||||
- [ ] `build_tree_shell_html()` 只渲染 HTML、CSS、bootstrap JSON 和 module script。
|
||||
- [ ] 保持 `/api/tree/runtime/reduce` 合同不变。
|
||||
- [ ] debug shell page/filetree/picker 三个模式 smoke 保持通过。
|
||||
- [ ] 验证 CodeGraph 能定位 `reducePageActionWithRuntime`、`buildFileTreeRuntimeEnvironment`、`reconcilePageRuntimeResult` 等符号。
|
||||
- [x] 将 `tree.rs` 中 `tree-shell-state` 后的大块 JS 迁到 `browser/tree-shell-runtime.js`。
|
||||
- [x] `build_tree_shell_html()` 只渲染 HTML、CSS、bootstrap JSON 和 module script。
|
||||
- [x] 保持 `/api/tree/runtime/reduce` 合同不变。
|
||||
- [x] debug shell page/filetree/picker 三个模式 smoke 保持通过。
|
||||
- 2026-05-24:`cargo test --manifest-path rust/Cargo.toml -p mnote-web tree_shell` 通过 42 个 tree shell 相关测试;运行态 `/tree` 需 debug route + auth/Convex 或 local workspace 登录态,不作为本批硬门槛。
|
||||
- [x] 验证 CodeGraph 能定位 `reducePageActionWithRuntime`、`buildFileTreeRuntimeEnvironment`、`reconcilePageRuntimeResult` 等符号。
|
||||
|
||||
### P4:抽出主壳 filetree runtime
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -106,6 +106,10 @@ pub fn build_router(state: AppState) -> Router {
|
||||
"/api/mnote-browser-runtime/tree-live-controller.js",
|
||||
get(web_shell::tree_live_controller_runtime_asset),
|
||||
)
|
||||
.route(
|
||||
"/api/mnote-browser-runtime/tree-shell-runtime.js",
|
||||
get(web_shell::tree_shell_runtime_asset),
|
||||
)
|
||||
.route("/api/search/documents", post(search::documents))
|
||||
.route(
|
||||
"/api/search/local-index/refresh",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4409,6 +4409,20 @@ pub async fn tree_live_controller_runtime_asset() -> Response {
|
||||
.unwrap_or_else(|_| Response::new(Body::empty()))
|
||||
}
|
||||
|
||||
pub async fn tree_shell_runtime_asset() -> Response {
|
||||
const JS: &str = include_str!("../../browser/tree-shell-runtime.js");
|
||||
Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header(
|
||||
header::CONTENT_TYPE,
|
||||
"application/javascript; charset=utf-8",
|
||||
)
|
||||
.header(header::CACHE_CONTROL, "no-store")
|
||||
.header(HEADER_MNOTE_WEB_OWNER, "mnote-web")
|
||||
.body(Body::from(JS))
|
||||
.unwrap_or_else(|_| Response::new(Body::empty()))
|
||||
}
|
||||
|
||||
pub async fn leptos_tiptap_manifest() -> Response {
|
||||
let manifest = json!({
|
||||
"entryAssetPath": "mnote-leptos-tiptap-spike-island.js",
|
||||
|
||||
Reference in New Issue
Block a user