fix(runtime): keep packaged Core and WebUI coherent across updates - #176
fix(runtime): keep packaged Core and WebUI coherent across updates#176JosephTian876 wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Sorry @JosephTian876, your pull request is larger than the review limit of 150,000 diff characters
zouyonghe
left a comment
There was a problem hiding this comment.
Review findings
P1: Chunked response can panic Desktop
src-tauri/src/backend/http_response.rs:99 uses chunk_size + 2 where chunk_size comes from the HTTP response. A chunk size near usize::MAX overflows in debug builds and can panic during slicing in release builds. This parser handles backend HTTP responses, so a malformed or hostile backend response can terminate the Desktop process.
Please use checked arithmetic for both the bounds check and the input[chunk_size..chunk_size + 2] slice, for example by computing let required_length = chunk_size.checked_add(2)?; and reusing it.
P2: debug/dev mode can fail with leftover packaged resources
src-tauri/build.rs:82 sets ASTRBOT_RUNTIME_MANIFEST_SHA256 to development-unbound for debug builds. However, src-tauri/src/launch_plan.rs:469-475 still validates packaged resources whenever a leftover resources/backend/runtime-manifest.json exists. After a packaged build, running pnpm dev can therefore fail with an invalid manifest identity instead of falling back to the dev launch plan.
This contradicts the documented behavior that debug/dev launch paths do not use the packaged identity gate. Please make debug builds skip packaged launch, or provide a real manifest hash in debug builds.
A merge-style Desktop update can leave old Dashboard files beside the new payload. An official Windows update from v4.27.0 to v4.27.5 reproduced this condition: all 244 expected new WebUI files were present with matching SHA-256 values, but 134 stale files and the old
assets/versionmarker survived. Desktop/Core/code were 4.27.5 while the public versions API still reported WebUI v4.27.0.This PR implements the Desktop side of a complete packaged-resource identity boundary. The companion Core change is AstrBotDevs/AstrBot#9898; complete cache-transition protection in a release requires compatible changes from both repositories.
Summary / 改动概述
runtime-manifest.jsonwith Desktop/Core/source identity plus SHA-256 attestations forindex.htmland its local JavaScript/CSS entries._up_/resourcesas complete candidates rather than mixing backend and WebUI leaves across roots./api/v1/stats/versions,/index.html, and every attested entry response before navigating to an already-running or newly started packaged backend.astrbot_bundle=v1-<manifest-sha256>identity so Core #9898 can bypass and clear the previous WebView cache without clearing cookies or local storage.Compatibility notes:
/api/v1/stats/versions.ASTRBOT_WEBUI_DIR; dev/custom launch plans and explicitly external backends remain unchanged.Verification / 验证方式
Local source gates:
The skipped Node case requires symlink creation on Windows.
The one Rust failure is the unchanged
backend::restart::tests::restart_strategy_delegates_to_strategy_moduleassertion: it expects the non-Windows strategy even though the correct Windows
strategy is
ManagedSkipGraceful. The same assertion exists onorigin/main,and the dedicated Windows strategy test passes.
A repository-wide Node run reported 141 passed, 26 failed, and 1 skipped. All
26 failures are in unchanged Windows-incompatible fixtures that assume POSIX
executables, command lookup, or path formatting. Every changed or directly
related Node suite passes.
Windows x64 NSIS/WebView2 upgrade test:
/P /UPDATE /NS).Cache-Control: no-storeandClear-Site-Data: "cache"._up_/resources, runtime rejected direct and successfully selected the staged bundle.E2E limitations:
Checklist / 检查清单
sha2dependency is recorded insrc-tauri/Cargo.lock. / 新增依赖已同步到锁文件。