design: 連接器頁整理——已加入的改成一張清單,設定展開才有欄位;全 App 表單欄位名稱一律在上

- 已加入的連接器:一列一個(名稱、色點+狀態、「設定」、開關),按「設定」才在那一列下面展開欄位;
  「移除」在左、「重新連線」在右,不再每個連接器常駐七個輸入框
- 欄位一種標法:kit 的 form_row 改成名稱在上、輸入框在下滿寬(以前有左欄標籤、行內標籤、
  只有提示字沒有標籤三種混在一起);新增 form_pair(兩個短欄位並排,如帳號/密碼)、
  status_row(有即時狀態的清單列)
- 截圖模式的「整合」示範兩個已加入的連接器,ANYBOT_SHOT_MCP_OPEN=n 展開第 n 個

已驗證: cargo test 523 全過(含排版檢查)、截圖目視(收起、展開)
This commit is contained in:
王性驊 2026-11-16 22:45:03 +08:00
parent 784df79a32
commit 8b8c477852
5 changed files with 169 additions and 95 deletions

View File

@ -7,7 +7,7 @@
- 本機伺服器:填指令(例如 `npx -y @modelcontextprotocol/server-filesystem ~/Documents`),可加環境變數。遠端伺服器:填網址(Streamable HTTP,回 JSON 或 SSE 都可以),可加標頭(例如 Authorization)。 - 本機伺服器:填指令(例如 `npx -y @modelcontextprotocol/server-filesystem ~/Documents`),可加環境變數。遠端伺服器:填網址(Streamable HTTP,回 JSON 或 SSE 都可以),可加標頭(例如 Authorization)。
- 帳號、密碼:給要用帳號密碼登入的伺服器。在指令、環境變數、網址或標頭寫「{username}」「{password}」,就填在那裡;都沒寫時,本機伺服器收到環境變數 `MCP_USERNAME`、`MCP_PASSWORD`,遠端伺服器收到 Basic 驗證。 - 帳號、密碼:給要用帳號密碼登入的伺服器。在指令、環境變數、網址或標頭寫「{username}」「{password}」,就填在那裡;都沒寫時,本機伺服器收到環境變數 `MCP_USERNAME`、`MCP_PASSWORD`,遠端伺服器收到 Basic 驗證。
- 「給 Bot 的使用說明」:寫進 Bot 的系統指示(例如「查詢客戶資料時先用 search_customers」)。 - 「給 Bot 的使用說明」:寫進 Bot 的系統指示(例如「查詢客戶資料時先用 search_customers」)。
- 每個連接器一張卡:狀態(「已連上,N 個工具」「連線中…」「未連線」「已關閉」或錯誤原因)、開關、「重新連線」、「移除」,下面列「可以用的工具」。 - 「已加入」是一張清單,每個連接器一列:名稱、色點和狀態(「已連上,N 個工具」「連線中…」「未連線」「已關閉」或紅字錯誤原因)、「設定」和開關。按「設定」在那一列下面展開它的欄位(名稱、指令或網址、環境變數、標頭、帳號和密碼並排、給 Bot 的使用說明——每個欄位名稱都在輸入框上面),最下面左邊「移除」、右邊「重新連線」;再按「收起」收回。下面列「可以用的工具」。「新增連接器」表單也是同樣的欄位(名稱在上、框在下)。
- 「連接器市集」:8 個常用的(files、memory、thinking、fetch、git、time、playwright、github),按「加入」就能用;要金鑰的(github)會把「新增連接器」表單填好,補上 Token 再按「新增」。 - 「連接器市集」:8 個常用的(files、memory、thinking、fetch、git、time、playwright、github),按「加入」就能用;要金鑰的(github)會把「新增連接器」表單填好,補上 Token 再按「新增」。
- 「公用市集(官方 MCP Registry)」:搜尋用網址連的連接器,按「加入」會填好表單;還有「{…}」沒換成你的值時,按不下「新增」。 - 「公用市集(官方 MCP Registry)」:搜尋用網址連的連接器,按「加入」會填好表單;還有「{…}」沒換成你的值時,按不下「新增」。
- 給 Bot 的方式:所有連接器加起來 20 個工具以內,每個工具直接給,名字是 `mcp__連接器__工具`;超過 20 個,只給 `find_connector_tool` 和 `use_connector_tool`。 - 給 Bot 的方式:所有連接器加起來 20 個工具以內,每個工具直接給,名字是 `mcp__連接器__工具`;超過 20 個,只給 `find_connector_tool` 和 `use_connector_tool`。

View File

@ -103,7 +103,6 @@ const SETTINGS_HEIGHT: f32 = 600.0;
/// Bot 設定 dialog width. /// Bot 設定 dialog width.
const EDITOR_WIDTH: f32 = 540.0; const EDITOR_WIDTH: f32 = 540.0;
/// The label column in form rows ("預設電腦", "模型可讀長度"…). /// The label column in form rows ("預設電腦", "模型可讀長度"…).
const FORM_LABEL_WIDTH: f32 = 96.0;
/// Tool steps under a reply start a little in from the bubble's edge. /// Tool steps under a reply start a little in from the bubble's edge.
pub const SCREENSHOT_FRAMES: u32 = 120; pub const SCREENSHOT_FRAMES: u32 = 120;
@ -913,6 +912,20 @@ impl App {
app.shot_registry(&q); app.shot_registry(&q);
} }
app.state.channels.push(crate::channels::Channel { id: 1, kind: crate::channels::Kind::Slack, name: "客服群".into(), bot_id: 2, token: "xoxb-demo".into(), target: "C0123ABCD".into(), enabled: true, client_id: String::new(), tenant: String::new() }); app.state.channels.push(crate::channels::Channel { id: 1, kind: crate::channels::Kind::Slack, name: "客服群".into(), bot_id: 2, token: "xoxb-demo".into(), target: "C0123ABCD".into(), enabled: true, client_id: String::new(), tenant: String::new() });
// Two added connectors (連接器 page); ANYBOT_SHOT_MCP_OPEN=n unfolds the n-th's fields.
for (name, cmd) in [("github", "https://api.githubcopilot.com/mcp/"), ("files", "npx -y @modelcontextprotocol/server-filesystem ~/Documents")] {
let url = cmd.starts_with("https://");
let mut it = cmd.split_whitespace();
app.state.mcp_servers.push(crate::mcp::Server {
name: name.into(),
command: if url { String::new() } else { it.next().unwrap_or_default().into() },
args: if url { vec![] } else { it.map(String::from).collect() },
url: if url { cmd.into() } else { String::new() },
enabled: true,
..Default::default()
});
}
app.ch.mcp_open = std::env::var("ANYBOT_SHOT_MCP_OPEN").ok().and_then(|v| v.parse().ok());
} }
// 支線 (/btw): one done (its report below), one working, one waiting for the main line. // 支線 (/btw): one done (its report below), one working, one waiting for the main line.
Ok("btw") => { Ok("btw") => {

View File

@ -42,6 +42,8 @@ pub struct ChannelUi {
new_mcp_login: (String, String), new_mcp_login: (String, String),
/// The form was just filled from the market: scroll it into view. /// The form was just filled from the market: scroll it into view.
focus_form: bool, focus_form: bool,
/// 連接器: which added server's fields are unfolded (its place in the list).
pub(super) mcp_open: Option<usize>,
/// 公用市集 (the official MCP Registry): what is typed, a search on its way, what it found. /// 公用市集 (the official MCP Registry): what is typed, a search on its way, what it found.
reg_q: String, reg_q: String,
reg_busy: Arc<AtomicBool>, reg_busy: Arc<AtomicBool>,
@ -67,7 +69,7 @@ impl Default for ChannelUi {
fn default() -> Self { fn default() -> Self {
let (tx, rx) = channel(); let (tx, rx) = channel();
let (trig_tx, trig_rx) = channel(); let (trig_tx, trig_rx) = channel();
ChannelUi { tx, rx, replies: HashMap::new(), waiting: VecDeque::new(), new_kind: Kind::Telegram, new_name: String::new(), new_token: String::new(), new_target: String::new(), new_bot: 0, note: Default::default(), started: false, trig_tx, trig_rx, trig_sig: String::new(), new_client: String::new(), new_tenant: String::new(), ms_login: Default::default(), mcp_sig: String::new(), mcp_errors: Default::default(), mcp_busy: Default::default(), mcp_tried: None, new_mcp: Default::default(), sub: 0, adding: false, focus_market: false, skill_src: String::new(), skill_open: None, skill_confirm: None, skill_busy: Default::default(), skill_reload: Default::default(), skill_note: Default::default(), skill_note_list: false, new_mcp_hint: String::new(), new_mcp_login: Default::default(), focus_form: false, reg_q: String::new(), reg_busy: Default::default(), reg_found: Default::default() } ChannelUi { tx, rx, replies: HashMap::new(), waiting: VecDeque::new(), new_kind: Kind::Telegram, new_name: String::new(), new_token: String::new(), new_target: String::new(), new_bot: 0, note: Default::default(), started: false, trig_tx, trig_rx, trig_sig: String::new(), new_client: String::new(), new_tenant: String::new(), ms_login: Default::default(), mcp_sig: String::new(), mcp_errors: Default::default(), mcp_busy: Default::default(), mcp_tried: None, new_mcp: Default::default(), sub: 0, adding: false, focus_market: false, skill_src: String::new(), skill_open: None, skill_confirm: None, skill_busy: Default::default(), skill_reload: Default::default(), skill_note: Default::default(), skill_note_list: false, new_mcp_hint: String::new(), new_mcp_login: Default::default(), focus_form: false, mcp_open: None, reg_q: String::new(), reg_busy: Default::default(), reg_found: Default::default() }
} }
} }
@ -479,94 +481,111 @@ impl App {
let at = if self.mir.on { "在大腦上:" } else { "" }; let at = if self.mir.on { "在大腦上:" } else { "" };
let mut remove = None; let mut remove = None;
let mut reconnect = None; let mut reconnect = None;
for (i, s) in self.state.mcp_servers.iter_mut().enumerate() { // The servers as one list (a row each: name, its state, 設定, the switch); the one being
setting_card(ui, p, |ui| { // set up unfolds its fields under its row — every name above its box, all boxes alike.
let one = &st["servers"][s.name.as_str()]; let open_now = self.ch.mcp_open;
let (col, text) = match (s.enabled, one["tools"].as_u64(), one["error"].as_str()) { let mut open_next = open_now;
(false, _, _) => (p.text3, "已關閉".to_string()), if !self.state.mcp_servers.is_empty() {
(_, Some(n), _) => (p.up, format!("已連上,{n} 個工具")), section(ui, "已加入", p);
(_, _, Some(e)) => (p.danger, format!("{at}{e}")), rows_card(ui, p, |ui| {
_ if busy => (p.text3, "連線中…".to_string()), for (i, s) in self.state.mcp_servers.iter_mut().enumerate() {
_ => (p.text3, "未連線".to_string()), let one = &st["servers"][s.name.as_str()];
}; let (col, text) = match (s.enabled, one["tools"].as_u64(), one["error"].as_str()) {
let name = s.name.clone(); (false, _, _) => (p.text3, "已關閉".to_string()),
listing_row( (_, Some(n), _) => (p.up, format!("已連上,{n} 個工具")),
ui, (_, _, Some(e)) => (p.danger, format!("{at}{e}")),
|ui| { _ if busy => (p.text3, "連線中…".to_string()),
if ui.add(egui::Button::new(RichText::new(t("移除")).size(FONT_XS).color(p.danger)).frame(false)).clicked() { _ => (p.text3, "未連線".to_string()),
};
let open = open_now == Some(i);
let name = s.name.clone();
status_row(ui, p, &name, &text, col, |ui| {
ui.add(computers_ui::toggle(&mut s.enabled)).on_hover_text(t("開啟"));
if ui.add(secondary_button(if open { "收起" } else { "設定" })).clicked() {
open_next = if open { None } else { Some(i) };
}
});
if !open {
continue;
}
// 全部欄位都能改:改了就存(頁面尾端的簽名比對會標 dirty),mcp_poll 偵測到
// 簽名變動會自動重連。
let mut cmd_edit = if s.url.is_empty() { format!("{} {}", s.command, s.args.join(" ")).trim().to_string() } else { s.url.clone() };
let mut env_edit: String = s.env.iter().map(|(k, v)| format!("{k}={v}")).collect::<Vec<_>>().join(" ");
let mut hdr_edit: String = s.headers.iter().map(|(k, v)| format!("{k}: {v}")).collect::<Vec<_>>().join(" ");
let hide_hdr = !hdr_edit.contains('{') && !hdr_edit.is_empty();
let (mut cmd_changed, mut env_changed, mut hdr_changed) = (false, false, false);
form_row(ui, "名稱", p, |ui| {
ui.add(egui::TextEdit::singleline(&mut s.name).desired_width(ui.available_width()));
});
form_row(ui, "指令或網址", p, |ui| {
cmd_changed = ui.add(egui::TextEdit::singleline(&mut cmd_edit).font(egui::TextStyle::Monospace).hint_text(t("npx -y … 或 https://…/mcp")).desired_width(ui.available_width())).changed();
});
form_row(ui, "環境變數", p, |ui| {
env_changed = ui.add(egui::TextEdit::singleline(&mut env_edit).font(egui::TextStyle::Monospace).password(true).hint_text(t("K=V K2=V2(本機用,選填)")).desired_width(ui.available_width())).changed();
});
form_row(ui, "標頭", p, |ui| {
hdr_changed = ui.add(egui::TextEdit::singleline(&mut hdr_edit).font(egui::TextStyle::Monospace).password(hide_hdr).hint_text(t("Authorization: Bearer …(遠端用,選填)")).desired_width(ui.available_width())).changed();
});
if cmd_changed {
let c = cmd_edit.trim().to_string();
if c.starts_with("http://") || c.starts_with("https://") {
s.url = c;
s.command.clear();
s.args.clear();
} else {
let mut it = c.split_whitespace();
s.command = it.next().unwrap_or_default().to_string();
s.args = it.map(String::from).collect();
s.url.clear();
}
}
if env_changed {
s.env = env_edit.split_whitespace().filter_map(|kv| kv.split_once('=')).map(|(k, v)| (k.to_string(), v.to_string())).collect();
}
if hdr_changed {
s.headers = hdr_edit.split_once(':').map(|(k, v)| std::iter::once((k.trim().to_string(), v.trim().to_string())).collect()).unwrap_or_default();
}
if s.name != s.name.trim() {
s.name = s.name.trim().to_string();
}
// 帳號 / 密碼: changed here, the server is connected again with the new ones.
let (user, pass) = (&mut s.username, &mut s.password);
form_pair(
ui,
p,
"帳號",
|ui| {
ui.add(egui::TextEdit::singleline(user).hint_text(t("選填")).desired_width(ui.available_width()));
},
"密碼",
|ui| {
ui.add(egui::TextEdit::singleline(pass).password(true).hint_text(t("選填")).desired_width(ui.available_width()));
},
);
form_row(ui, "給 Bot 的使用說明(選填)", p, |ui| {
ui.add(egui::TextEdit::multiline(&mut s.instructions).desired_rows(1).desired_width(ui.available_width()).hint_text(t("例如:查詢客戶資料時先用 search_customers")));
});
// Its own actions, at the end of what they act on: 移除 on the left, away from the rest.
ui.add_space(crate::theme::sp::S3);
ui.horizontal(|ui| {
if ui.add(egui::Button::new(RichText::new(t("移除")).color(p.danger)).frame(false)).clicked() {
remove = Some(i); remove = Some(i);
} }
ui.add(computers_ui::toggle(&mut s.enabled)).on_hover_text(t("開啟")); ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if s.enabled && ui.add(egui::Button::new(RichText::new(t("重新連線")).size(FONT_SM).color(p.text2)).frame(false)).on_hover_text(t("再連一次,看連不連得上")).clicked() { if s.enabled && ui.add(secondary_button("重新連線")).on_hover_text(t("再連一次,看連不連得上")).clicked() {
reconnect = Some(name.clone()); reconnect = Some(s.name.clone());
} }
}, });
|ui| { });
// (長的伺服器名字在行尾的按鈕前截斷,不會壓到「重新連線」。) ui.add_space(crate::theme::sp::S3);
ui.add(egui::Label::new(RichText::new(&name).strong().family(crate::bold()).size(FONT_BASE)).truncate());
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
ui.painter().circle_filled(r.center(), 4.0, col);
ui.add(egui::Label::new(RichText::new(&text).size(FONT_XS).color(p.text3)).truncate()).on_hover_text(&text);
},
);
// 全部欄位都能改:改了就存(頁面尾端的簽名比對會標 dirty),
// mcp_poll 偵測到簽名變動會自動重連。名稱、指令/網址、環境變數、標頭都 editable。
let mut cmd_edit = if s.url.is_empty() {
format!("{} {}", s.command, s.args.join(" ")).trim().to_string()
} else {
s.url.clone()
};
let mut env_edit: String = s.env.iter().map(|(k, v)| format!("{k}={v}")).collect::<Vec<_>>().join(" ");
let mut hdr_edit: String = s.headers.iter().map(|(k, v)| format!("{k}: {v}")).collect::<Vec<_>>().join(" ");
ui.horizontal(|ui| {
ui.label(RichText::new(t("名稱")).size(FONT_XS).color(p.text3));
ui.add(egui::TextEdit::singleline(&mut s.name).desired_width((ui.available_width() - 44.0).max(120.0)));
});
let cmd_resp = ui.add(egui::TextEdit::singleline(&mut cmd_edit).font(egui::TextStyle::Monospace).hint_text(t("npx -y … 或 https://…/mcp")).desired_width(f32::INFINITY));
let env_resp = ui.add(egui::TextEdit::singleline(&mut env_edit).font(egui::TextStyle::Monospace).password(true).hint_text(t("環境變數:K=V K2=V2(本機用,選填)")).desired_width(f32::INFINITY));
let hide_hdr = !hdr_edit.contains('{') && !hdr_edit.is_empty();
let hdr_resp = ui.add(egui::TextEdit::singleline(&mut hdr_edit).font(egui::TextStyle::Monospace).password(hide_hdr).hint_text(t("標頭:Authorization: Bearer …(遠端用,選填)")).desired_width(f32::INFINITY));
if cmd_resp.changed() {
let c = cmd_edit.trim().to_string();
if c.starts_with("http://") || c.starts_with("https://") {
s.url = c;
s.command.clear();
s.args.clear();
} else {
let mut it = c.split_whitespace();
s.command = it.next().unwrap_or_default().to_string();
s.args = it.map(String::from).collect();
s.url.clear();
}
} }
if env_resp.changed() {
s.env = env_edit
.split_whitespace()
.filter_map(|kv| kv.split_once('='))
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect();
}
if hdr_resp.changed() {
s.headers = hdr_edit
.split_once(':')
.map(|(k, v)| std::iter::once((k.trim().to_string(), v.trim().to_string())).collect())
.unwrap_or_default();
}
if s.name != s.name.trim() {
s.name = s.name.trim().to_string();
}
// 帳號 / 密碼: changed here, the server is connected again with the new ones.
ui.horizontal(|ui| {
let w = ((ui.available_width() - 110.0) / 2.0).max(80.0);
ui.label(RichText::new(t("帳號")).size(FONT_XS).color(p.text3));
ui.add(egui::TextEdit::singleline(&mut s.username).hint_text(t("選填")).desired_width(w));
ui.label(RichText::new(t("密碼")).size(FONT_XS).color(p.text3));
ui.add(egui::TextEdit::singleline(&mut s.password).password(true).hint_text(t("選填")).desired_width(w));
});
field_label(ui, "給 Bot 的使用說明(選填)", p);
ui.add(egui::TextEdit::multiline(&mut s.instructions).desired_rows(1).desired_width(f32::INFINITY).hint_text(t("例如:查詢客戶資料時先用 search_customers")));
}); });
} }
if remove.is_some() {
open_next = None;
}
self.ch.mcp_open = open_next;
if let Some(i) = remove { if let Some(i) = remove {
self.state.mcp_servers.remove(i); self.state.mcp_servers.remove(i);
} }

View File

@ -9,7 +9,9 @@
//! 控制項先排、名稱拿剩下的寬度(太長就「…」)。高 52,有狀態 62。 //! 控制項先排、名稱拿剩下的寬度(太長就「…」)。高 52,有狀態 62。
//! - **卡片** `setting_card` + `setting_title`:給一整塊有標題、有欄位的內容(Bot 設定的幾段)。 //! - **卡片** `setting_card` + `setting_title`:給一整塊有標題、有欄位的內容(Bot 設定的幾段)。
//! 卡片裡放列、欄位、文字——**不再放卡片**(卡中卡是畫面亂的主因)。 //! 卡片裡放列、欄位、文字——**不再放卡片**(卡中卡是畫面亂的主因)。
//! - **欄位** `field_label`(13 灰小標)+輸入框;**表單列** `form_row`(固定寬的標籤欄)。 //! - **欄位** `form_row`:名稱在上(13 px 灰)、輸入框在下滿寬——整個 App 只有這一種標法;
//! 兩個短欄位並排用 `form_pair`(帳號/密碼)。`field_label` 是單獨的欄位名稱。
//! - **狀態列** `status_row`:清單裡有即時狀態的一列(連接器、訊息管道):名稱、色點+一行狀態、右邊控制項。
//! - **說明** `hint`:13 px 灰字,**一行**(長的結尾「…」,滑過看全文)。`help_mark` 是名稱旁的「?」, //! - **說明** `hint`:13 px 灰字,**一行**(長的結尾「…」,滑過看全文)。`help_mark` 是名稱旁的「?」,
//! 設定列上的只在滑鼠移到那一列時出現。 //! 設定列上的只在滑鼠移到那一列時出現。
//! - **按鈕** `primary_button`(實心,一個畫面一顆)、`secondary_button`(淡底)、`danger_button`; //! - **按鈕** `primary_button`(實心,一個畫面一顆)、`secondary_button`(淡底)、`danger_button`;
@ -182,14 +184,54 @@ pub(super) fn setting_card<R>(ui: &mut egui::Ui, p: Palette, body: impl FnOnce(&
} }
/// A label column so form rows line up. /// A label column so form rows line up.
/// A form field: its name above (13 px grey), the input below at full width. The app's one way
/// to label an input (a label column on the left, a label inline, or none at all made a form
/// whose boxes started at different places).
pub(super) fn form_row(ui: &mut egui::Ui, label: &str, p: Palette, body: impl FnOnce(&mut egui::Ui)) { pub(super) fn form_row(ui: &mut egui::Ui, label: &str, p: Palette, body: impl FnOnce(&mut egui::Ui)) {
ui.horizontal(|ui| { field_label(ui, label, p);
let (rect, _) = ui.allocate_exact_size(vec2(FORM_LABEL_WIDTH, 28.0), egui::Sense::hover()); ui.horizontal(|ui| body(ui));
// (English labels are longer than the column; painted un-truncated they run under the }
// control on the right. Cut them to the column width.)
let label = sidebar_ui::shorten_width(ui, &t(label), rect.width(), FONT_SM); /// Two short fields side by side (帳號 and 密碼), each with its name above it.
ui.painter().text(rect.left_center(), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(FONT_SM), p.text2); pub(super) fn form_pair(ui: &mut egui::Ui, p: Palette, left_label: &str, left: impl FnOnce(&mut egui::Ui), right_label: &str, right: impl FnOnce(&mut egui::Ui)) {
body(ui); let gap = sp::S3;
let w = ((ui.available_width() - gap) / 2.0).max(80.0);
ui.horizontal_top(|ui| {
ui.spacing_mut().item_spacing.x = gap;
ui.vertical(|ui| {
ui.set_width(w);
field_label(ui, left_label, p);
ui.horizontal(|ui| left(ui));
});
ui.vertical(|ui| {
ui.set_width(w);
field_label(ui, right_label, p);
ui.horizontal(|ui| right(ui));
});
});
}
/// A row of a list with a live state: the name, then a coloured dot and the state in one grey
/// line under it (an error in red), the controls on the right — a connector, a channel.
pub(super) fn status_row(ui: &mut egui::Ui, p: Palette, label: &str, status: &str, dot: Color32, control: impl FnOnce(&mut egui::Ui)) {
let top = ui.cursor().top();
if top > ui.max_rect().top() + 1.0 {
ui.painter().hline(ui.max_rect().x_range(), top, Stroke::new(1.0, p.border));
}
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), 62.0), egui::Sense::hover());
let mut right = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(Layout::right_to_left(Align::Center)));
right.spacing_mut().item_spacing.x = sp::S2;
control(&mut right);
let words = egui::Rect::from_min_max(rect.min, egui::pos2((right.min_rect().left() - 12.0).max(rect.left() + 80.0), rect.bottom()));
let mut left = ui.new_child(egui::UiBuilder::new().max_rect(words).layout(Layout::top_down(Align::Min)));
left.spacing_mut().item_spacing = vec2(6.0, 2.0);
left.add_space(10.0);
left.add(egui::Label::new(RichText::new(label).size(FONT_BASE).family(crate::bold()).color(p.text)).truncate());
left.horizontal(|ui| {
let (r, _) = ui.allocate_exact_size(vec2(8.0, 14.0), egui::Sense::hover());
ui.painter().circle_filled(r.center(), 3.5, dot);
let col = if dot == p.danger { p.danger } else { p.text2 };
ui.add(egui::Label::new(RichText::new(status).size(FONT_SM).color(col)).truncate());
}); });
} }

View File

@ -25,7 +25,7 @@ const DIRECT_TOOLS: usize = 20;
pub const FIND_TOOL: &str = "find_connector_tool"; pub const FIND_TOOL: &str = "find_connector_tool";
pub const USE_TOOL: &str = "use_connector_tool"; pub const USE_TOOL: &str = "use_connector_tool";
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] #[derive(Clone, Default, Serialize, Deserialize, Debug, PartialEq)]
pub struct Server { pub struct Server {
pub name: String, pub name: String,
/// stdio: the command; empty when `url` is used. /// stdio: the command; empty when `url` is used.