fix(runtime): handle mobile review edge cases
This commit is contained in:
+26
-8
@@ -625,6 +625,21 @@ fn resolve_serve_bind_host(mobile: bool, host: Option<String>) -> ServeBindHost
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_serve_mode_selection(mcp: bool, http: bool, mobile: bool, acp: bool) -> Result<bool> {
|
||||
if http && mobile {
|
||||
bail!("--http and --mobile are mutually exclusive; choose one");
|
||||
}
|
||||
let http_selected = http || mobile;
|
||||
let selected_modes = [mcp, http_selected, acp]
|
||||
.into_iter()
|
||||
.filter(|selected| *selected)
|
||||
.count();
|
||||
if selected_modes != 1 {
|
||||
bail!("Choose exactly one server mode: --mcp, --http/--mobile, or --acp");
|
||||
}
|
||||
Ok(http_selected)
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug, Clone)]
|
||||
enum McpCommand {
|
||||
/// List configured MCP servers
|
||||
@@ -952,14 +967,8 @@ async fn main() -> Result<()> {
|
||||
let workspace = cli.workspace.clone().unwrap_or_else(|| {
|
||||
std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
|
||||
});
|
||||
let http_selected = args.http || args.mobile;
|
||||
let selected_modes = [args.mcp, http_selected, args.acp]
|
||||
.into_iter()
|
||||
.filter(|selected| *selected)
|
||||
.count();
|
||||
if selected_modes != 1 {
|
||||
bail!("Choose exactly one server mode: --mcp, --http/--mobile, or --acp");
|
||||
}
|
||||
let http_selected =
|
||||
validate_serve_mode_selection(args.mcp, args.http, args.mobile, args.acp)?;
|
||||
if args.mcp {
|
||||
mcp_server::run_mcp_server(workspace)
|
||||
} else if http_selected {
|
||||
@@ -5641,6 +5650,15 @@ mod serve_bind_host_tests {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn http_and_mobile_are_mutually_exclusive() {
|
||||
let err = validate_serve_mode_selection(false, true, true, false).unwrap_err();
|
||||
assert!(
|
||||
err.to_string()
|
||||
.contains("--http and --mobile are mutually exclusive")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -275,7 +275,7 @@
|
||||
}
|
||||
|
||||
function token() {
|
||||
return $("token").value.trim();
|
||||
return $("token").value;
|
||||
}
|
||||
|
||||
function takeTokenFromUrl() {
|
||||
@@ -368,7 +368,8 @@
|
||||
method: "POST",
|
||||
body: JSON.stringify({ decision, remember })
|
||||
});
|
||||
container.innerHTML = "<span class='meta'>Decision sent: " + escapeHtml(result.decision) + "</span>";
|
||||
const decided = result?.decision ?? decision;
|
||||
container.innerHTML = "<span class='meta'>Decision sent: " + escapeHtml(decided) + "</span>";
|
||||
}
|
||||
|
||||
function appendEvent(name, data) {
|
||||
|
||||
Reference in New Issue
Block a user