Fix dialog dismiss command parsing (#605)

This commit is contained in:
layla
2026-03-05 11:16:14 +09:00
committed by leeguooooo
parent dad7be8c77
commit d56442cf91
2 changed files with 13 additions and 1 deletions
+7
View File
@@ -939,6 +939,13 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
} }
Ok(cmd) Ok(cmd)
} }
Some("dismiss") => {
let mut cmd = json!({ "id": id, "action": "dialog", "response": "dismiss" });
if let Some(prompt_text) = rest.get(1) {
cmd["promptText"] = json!(prompt_text);
}
Ok(cmd)
}
Some(sub) => Err(ParseError::UnknownSubcommand { Some(sub) => Err(ParseError::UnknownSubcommand {
subcommand: sub.to_string(), subcommand: sub.to_string(),
valid_options: VALID, valid_options: VALID,
+6 -1
View File
@@ -2880,7 +2880,12 @@ async fn handle_permissions(cmd: &Value, state: &DaemonState) -> Result<Value, S
async fn handle_dialog(cmd: &Value, state: &DaemonState) -> Result<Value, String> { async fn handle_dialog(cmd: &Value, state: &DaemonState) -> Result<Value, String> {
let mgr = state.browser.as_ref().ok_or("Browser not launched")?; let mgr = state.browser.as_ref().ok_or("Browser not launched")?;
let accept = cmd.get("accept").and_then(|v| v.as_bool()).unwrap_or(true); let accept = cmd
.get("response")
.and_then(|v| v.as_str())
.map(|r| r == "accept")
.or_else(|| cmd.get("accept").and_then(|v| v.as_bool()))
.unwrap_or(true);
let prompt_text = cmd.get("promptText").and_then(|v| v.as_str()); let prompt_text = cmd.get("promptText").and_then(|v| v.as_str());
mgr.handle_dialog(accept, prompt_text).await?; mgr.handle_dialog(accept, prompt_text).await?;