diff --git a/FEATURES.md b/FEATURES.md index ed772d1..fd126be 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -2236,7 +2236,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開) - **AnyBot 帳號**: - 填帳號伺服器網址、帳號、密碼,可以順便建立新帳號(有邀請碼時要填)。 - - 登入後,這台電腦會拿到自己的金鑰,之後保持連線。顯示「已連線」或錯誤原因。 + - 登入後,這台電腦會拿到自己的金鑰,之後保持連線。帳號下面一行顯示「已連線」或錯誤原因(長的錯誤自動換行,不會把卡片撐寬、把「登出」擠出視窗)。 - 電腦不會保存你的密碼,只保存由密碼算出的備份金鑰。 - 可以設定這台電腦在手機上顯示的名字(欄位跟卡片一樣寬,長名字不會被切掉)。 - 備份下面隔一條線是「登出帳號」那一列,右邊「登出」按鈕(紅字):把這台從帳號移除;?說明會斷掉哪些。 diff --git a/src/app/layout_audit.rs b/src/app/layout_audit.rs index 647bd2f..777cadf 100644 --- a/src/app/layout_audit.rs +++ b/src/app/layout_audit.rs @@ -110,6 +110,32 @@ fn scenes() -> Vec<(&'static str, Open)> { ), ("設定 › 一般", tab(SettingsTab::General)), ("設定 › 手機與帳號", tab(SettingsTab::Remote)), + ( + // Signed in with the account server out of reach, as a screen of a brain it can't + // reach either: the long errors once pushed the cards wider than the window (登出 off + // its right edge). + "設定 › 手機與帳號(已登入、連不上)", + Box::new(|a: &mut App| { + a.show_settings = true; + a.settings_tab = SettingsTab::Remote; + let r = &mut a.state.remote; + // (Signed in, the page asks the account server for 團隊: a port here that refuses + // at once — no lookups, nothing leaves the computer.) + r.relay_url = "https://127.0.0.1:9/anybot-relay/customer-service-third-floor".into(); + r.relay_user = "someone".into(); + r.host_token = "audit".into(); + r.host_name = "客戶服務部三樓的 MacBook Pro (2)".into(); + r.last_backup = chrono::Utc::now().timestamp() - 3_600; + r.brain_id = "audit-brain".into(); + r.brain_name = "雲端大腦".into(); + a.rm.relay_status_shown = Some("連不上帳號伺服器:找不到伺服器:這台電腦可能沒連上網路,或伺服器網址打錯了".into()); + a.mir.dir = std::env::temp_dir().join("anybot-layout-audit-screen"); + a.mir.on = true; + a.mir.online = false; + *a.mir.status.lock().unwrap() = "連不到大腦:連不到帳號伺服器:網路連線出了問題(等太久沒有回應:網路很慢或斷斷續續)".into(); + *a.rm.peers.lock().unwrap() = vec![("audit-brain".into(), "雲端大腦".into(), false)]; + }), + ), ("設定 › 模型", tab(SettingsTab::Providers)), ("設定 › 整合 › 訊息管道", tab(SettingsTab::Channels)), ( diff --git a/src/app/remote_ui.rs b/src/app/remote_ui.rs index a5dc58b..b414d68 100644 --- a/src/app/remote_ui.rs +++ b/src/app/remote_ui.rs @@ -40,6 +40,9 @@ pub struct RemoteUi { new_member: String, new_admin: bool, started: bool, + /// The layout check's account connection state (a long error) instead of the live one. + #[cfg(test)] + pub(super) relay_status_shown: Option, } /// Approvals as the phone shows them. @@ -825,6 +828,15 @@ impl App { }); } + /// The account connection's state as the page shows it. + fn relay_status_now(&self) -> String { + #[cfg(test)] + if let Some(s) = &self.rm.relay_status_shown { + return s.clone(); + } + remote::hub().relay_status() + } + pub(super) fn remote_page(&mut self, ui: &mut egui::Ui, _ctx: &egui::Context) { let p = self.pal; let mut changed = false; @@ -836,16 +848,21 @@ impl App { // ── 帳號(薄後端) ── setting_card(ui, p, |ui| { setting_title(ui, "AnyBot 帳號", "帳號伺服器保管帳號、裝置清單和加密備份,手機從外面連進來也靠它轉送。", p); + let status = self.relay_status_now(); let s = &self.state.remote; if !s.host_token.is_empty() { - let status = remote::hub().relay_status(); ui.horizontal(|ui| { let ok = status == "已連線"; let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover()); ui.painter().circle_filled(r.center(), 4.0, if ok { p.up } else { p.text3 }); - ui.label(RichText::new(format!("{} · {}", s.relay_user, s.relay_url)).size(FONT_BASE)); - ui.label(RichText::new(if status.is_empty() { "—".to_string() } else { status }).size(FONT_XS).color(p.text3)); + ui.add(egui::Label::new(RichText::new(format!("{} · {}", s.relay_user, s.relay_url)).size(FONT_BASE)).truncate()); }); + // The connection's state on a line of its own, wrapped: beside the account on one + // line, an error (「連不上帳號伺服器:找不到伺服器:…」) pushed the card wider than + // the window, and 登出 off its right edge. + if !status.is_empty() { + ui.add(egui::Label::new(RichText::new(status).size(FONT_XS).color(p.text3)).wrap()); + } hint(ui, format!("手機打開 {} 用同一個帳號登入就能用。可以「加入主畫面」當成 App。", s.relay_url), p); // (A field as wide as the card: a long name like 「…的MacBook Pro (2)」 was cut off.) form_row(ui, "這台電腦在手機上叫", p, |ui| { @@ -962,12 +979,13 @@ impl App { ui.horizontal(|ui| { let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover()); ui.painter().circle_filled(r.center(), 4.0, if self.mir.online { p.up } else { p.text3 }); - ui.label(RichText::new(status).size(FONT_SM).color(p.text2)); + // (Wrapped inside the card: a long 「連不到大腦:…」 widened it, like the account's.) + ui.add(egui::Label::new(RichText::new(status).size(FONT_SM).color(p.text2)).wrap()); }); // Which leg: this computer ↔ the account server, the account server ↔ the // brain (as the account server last said), and the line's speed. let brain_on = self.rm.peers.lock().unwrap().iter().find(|(id, _, _)| *id == s.brain_id).map(|x| x.2); - let legs = remote_legs(&remote::hub().relay_status(), brain_on, &s.brain_name, *self.mir.last_sync.lock().unwrap()); + let legs = remote_legs(&self.relay_status_now(), brain_on, &s.brain_name, *self.mir.last_sync.lock().unwrap()); for line in legs { ui.add(egui::Label::new(RichText::new(line).size(FONT_XS).color(p.text3)).wrap()); }