feat(runtime): restore mobile control page#1968
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a built-in mobile control page for the codewhale serve command, accessible via a new --mobile flag. This feature enables thread management and tool approval resolution from mobile devices on the same LAN. Key changes include a new single-page HTML/JS interface, CLI updates to handle network binding, and expanded SSE event support. Reviewers recommended URL-encoding the runtime token in the displayed URLs and refining the LAN IP detection logic to avoid dependencies on hardcoded external DNS servers like 8.8.8.8.
| token | ||
| .filter(|token| !token.trim().is_empty()) | ||
| .map(|token| format!("?token={token}")) | ||
| .unwrap_or_default() |
There was a problem hiding this comment.
The token is appended to the URL without percent-encoding. If a manually configured token contains characters like &, #, or +, it will corrupt the query string or lead to authentication failures, as the server-side token_from_query (and the mobile page's own JS) expects correctly formatted parameters. Consider URL-encoding the token here for robustness.
|
|
||
| fn detect_lan_ip() -> Option<String> { | ||
| let socket = UdpSocket::bind("0.0.0.0:0").ok()?; | ||
| socket.connect("8.8.8.8:80").ok()?; |
There was a problem hiding this comment.
Hardcoding 8.8.8.8 for LAN IP detection might not work for users in regions where Google services are blocked (e.g., China), which is a key demographic for this project. Consider using a more neutral target or a non-routable IP like 10.255.255.255:1 to determine the default interface's local address without sending actual packets.
Rebased replacement for #852 after the v0.8.41 CodeWhale rebrand.
What changed:
codewhale serve --mobileas a thin mobile/LAN entry point over the existing runtime HTTP/SSE API/mobilecontrol page from a separateruntime_mobile.htmlfile viainclude_str!/v1/approvals/{approval_id}bridge instead of restoring the old per-turn approval routesValidation:
cargo fmt --allgit diff --checkcargo check -p codewhale-tui --lockedcargo test -p codewhale-tui --bin codewhale-tui --locked runtime_api::tests::codewhale-tui serve --mobile --port 7879 --insecure,GET /mobilereturned HTTP 200 with titleCodeWhale MobileNote:
cargo test -p codewhale-tui --locked runtime_api::tests::also passed the runtime API module tests, but the full cargo invocation then tried to launch the filteredskill_installintegration binary on Windows and hit OS error 740 (requires elevation). The bin-scoped command above avoids that unrelated Windows integration-test launcher issue.