diff --git a/src/app.rs b/src/app.rs index 1747b16..12c8f06 100644 --- a/src/app.rs +++ b/src/app.rs @@ -190,6 +190,8 @@ pub struct App { rm: remote_ui::RemoteUi, /// Running as `anybot --serve` (no window; the phone is the screen). headless: bool, + /// Running `anybot --ask` (one message from the command line, for testing tool use). + asking: bool, /// The computer the person last typed to a bot on: an account computer's id, "" for this /// one, None when not known (the phone isn't a computer). It is "我的電腦" to the bots. typed_on: Option, @@ -306,6 +308,7 @@ impl App { msg_index: 0, rm: Default::default(), headless: false, + asking: false, typed_on: None, panel: None, popped: HashMap::new(), @@ -917,8 +920,9 @@ impl App { v.push(t); }; // A brain on a server works on the bots' own computer and the person's computers, never on - // the server itself (the person asked for it to be off the list). - if !self.headless { + // the server itself (the person asked for it to be off the list). `anybot --ask` with + // ANYBOT_ASK_HERE=1 offers this computer too, for trying screen steps on it. + if !self.headless || (self.asking && std::env::var_os("ANYBOT_ASK_HERE").is_some()) { add(&mut v, tools::Target { name: self.state.this_computer_name(), place: tools::Place::Local { workdir: tools::expand_home(if b.workdir.trim().is_empty() { "~" } else { b.workdir.trim() }) } }); } for c in &self.state.remote_computers { @@ -3696,6 +3700,7 @@ impl App { pub fn ask_cli(ctx: &egui::Context, text: &str) -> ! { let mut app = App::new(ctx, None); app.headless = true; + app.asking = true; let id = app.state.primary_bot; let start = app.state.bot(id).map(|b| b.messages.len()).unwrap_or(0); app.drafts.insert(id, text.to_string()); diff --git a/src/tools.rs b/src/tools.rs index 91fcdff..0ed3b2f 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -732,7 +732,7 @@ pub fn sandbox_note(cmd: &str, out: &str) -> Option<&'static str> { }); } if (out.contains("Trace/BPT trap") || out.contains("指令因為收到訊號而終止")) && cmd.contains(".app/Contents/MacOS/") { - return Some("(這個 App 的指令列在 AnyBot 的沙盒裡會當掉,不是 App 壞了。用它的完整路徑單獨執行(不要接 ;、|、&& 或其他指令),App Store 版的 App 就會在沙盒外跑;不行就改用畫面操作。)"); + return Some("(這個 App 的指令列在 AnyBot 的沙盒裡會當掉,不是 App 壞了,也不是參數的問題。用它的完整路徑單獨執行:不要接 ;、|、&&,也不要用 >、< 把輸出存到檔案(要處理輸出就先單獨執行,再用下一條指令處理),App Store 版的 App 就會在沙盒外跑;不行就改用畫面操作。)"); } None }