All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.
Rust
refactor: apply the simplify review to today's changes
Corey Chiucb341271a151
diff --git a/crates/wake-core/src/adapters/mod.rs b/crates/wake-core/src/adapters/mod.rsindex a4d4b3f..0e9e527 100644--- a/crates/wake-core/src/adapters/mod.rs+++ b/crates/wake-core/src/adapters/mod.rs@@ -465,13 +465,13 @@ pub fn expand_tilde(p: &str) -> String {}}-/// 这次工具调用是不是 agent 在查 Wake:MCP 工具按四个契约名认,客户端会给名字加+/// 这次工具调用是不是 agent 在查 Wake:MCP 工具按 `mcp::tools::NAMES` 认(加第五家+/// 自动覆盖),客户端会给名字加/// 自己的前缀(Claude Code / Codex 是 `mcp__wake__wake_search`,别家形态不一),所以/// 只看结尾、并要求前一个字符不是字母数字(`awake_search` 不算);shell 工具(Bash 等)/// 看输入预览里是否以整个词的形态出现 wake-cli / wake-mcpfn is_wake_lookup(tool_name: &str, input_preview: &str) -> bool {- use crate::mcp::tools::{GET_SESSION, LIST_PROJECTS, LIST_SESSIONS, SEARCH};- [SEARCH, LIST_SESSIONS, GET_SESSION, LIST_PROJECTS]+ crate::mcp::tools::NAMES.iter().any(|t| ends_with_word(tool_name, t))|| ["wake-cli", "wake-mcp"]diff --git a/crates/wake-core/src/db.rs b/crates/wake-core/src/db.rsindex 77bfafd..ceabd2a 100644--- a/crates/wake-core/src/db.rs+++ b/crates/wake-core/src/db.rs@@ -1260,26 +1260,11 @@ impl Store {.ok().filter(|d| *d <= today)};- // 同一会话在多台 host 上各有一份镜像时(两个远程 host 指向同一台机器,- // 或本地与远程都有)只算一次:按 (agent, native_id, created_at) 认同一会话- // ——native_id 单独不够(Hermes 的 id 是小整数,两台机器的 1 号会话不是- // 同一个),created_at 出自文件内容,同 id 同起点即同一会话;没有 created_at- // 的不合并。取更新时间最新的那份(最完整),平局按 host 名(本地 '' 最小)。- // scanner 层有意保留全部副本(不变量 8⑦:各机续跑会分叉),只是统计口径- // 不能把一份对话数两遍(2026-09-14,0.4.0 遗留)- const CANONICAL_SESSIONS: &str = "(SELECT key FROM (- SELECT key, ROW_NUMBER() OVER (- PARTITION BY agent_id, native_id, created_at,- CASE WHEN created_at > 0 THEN '' ELSE key END- ORDER BY updated_at DESC, host) AS rn- FROM sessions WHERE archived = 0) WHERE rn = 1)";// "一条 prompt" 的行集(主线用户消息)——整页口径共用这一个片段,// 内联多份的话谓词一漂移,总数就会与分桶/榜单悄悄不一致- let prompt_rows = format!(- "FROM messages m JOIN sessions s ON s.key = m.session_key+ const PROMPT_ROWS: &str = "FROM messages m JOIN sessions s ON s.key = m.session_keyWHERE s.archived = 0 AND m.role = 'user' AND m.sidechain_id IS NULL- AND s.key IN {CANONICAL_SESSIONS}"- );+ AND s.key IN canonical_sessions";// 临时连接,不与 UI 的 read 连接抢锁:WAL 多读并发,几十毫秒的// 统计扫描不该让导航点击的列表查询排队(2026-08-27 Codex review)@@ -1288,6 +1273,24 @@ impl Store {} else {open_conn(&self.path)?};+ // 同一会话在多台 host 上各有一份镜像时(两个远程 host 指向同一台机器,+ // 或本地与远程都有)只算一次:按 (agent, native_id, created_at) 认同一会话+ // ——native_id 单独不够(Hermes 的 id 是小整数,两台机器的 1 号会话不是+ // 同一个),created_at 出自文件内容,同 id 同起点即同一会话;没有 created_at+ // 的不合并。取更新时间最新的那份(最完整),平局按 host 名(本地 '' 最小)。+ // scanner 层有意保留全部副本(不变量 8⑦:各机续跑会分叉),只是统计口径+ // 不能把一份对话数两遍(2026-09-14,0.4.0 遗留)。算一次放临时表——这条+ // 连接是本次调用私有的,只读连接也能建 temp 表;内联成子查询的话下面+ // 六条语句会各排一遍序+ conn.execute_batch(+ "CREATE TEMP TABLE canonical_sessions AS+ SELECT key FROM (+ SELECT key, ROW_NUMBER() OVER (+ PARTITION BY agent_id, native_id, created_at,+ CASE WHEN created_at > 0 THEN '' ELSE key END+ ORDER BY updated_at DESC, host) AS rn+ FROM sessions WHERE archived = 0) WHERE rn = 1",+ )?;let mut data = InsightsData {as_of: today,..Default::default()@@ -1299,12 +1302,10 @@ impl Store {data.first_ts,data.project_count,) = conn.query_row(- &format!(- "SELECT COUNT(*), COALESCE(SUM(tokens_used),0),- COALESCE(MIN(NULLIF(created_at,0)),0),- COUNT(DISTINCT NULLIF(project_path,''))- FROM sessions WHERE archived = 0 AND key IN {CANONICAL_SESSIONS}"- ),+ "SELECT COUNT(*), COALESCE(SUM(tokens_used),0),+ COALESCE(MIN(NULLIF(created_at,0)),0),+ COUNT(DISTINCT NULLIF(project_path,''))+ FROM sessions WHERE archived = 0 AND key IN canonical_sessions",[],|r| Ok((r.get(0)?, r.get(1)?, r.get(2)?, r.get(3)?)),)?;@@ -1316,7 +1317,7 @@ impl Store {"SELECT CASE WHEN m.ts > 0 THEN date(m.ts/1000,'unixepoch','localtime') END d,CASE WHEN m.ts > 0 THEN CAST(strftime('%H', m.ts/1000,'unixepoch','localtime') AS INTEGER) END h,COUNT(*)- {prompt_rows}+ {PROMPT_ROWS}GROUP BY d, h ORDER BY d"))?;let rows = stmt.query_map([], |r| {@@ -1357,7 +1358,7 @@ impl Store {"SELECT s.agent_id, s.project_path, COALESCE(s.model,''),CASE WHEN m.ts > 0 THEN date(m.ts/1000,'unixepoch','localtime') END d,COUNT(*)- {prompt_rows}+ {PROMPT_ROWS}GROUP BY 1, 2, 3, 4"))?;let rows = stmt.query_map([], |r| {@@ -1406,7 +1407,7 @@ impl Store {-> Result<Vec<UsageTally>> {let sql = format!("SELECT {display}, {group}, COUNT(*), COALESCE(SUM(s.tokens_used),0)- FROM sessions s WHERE s.archived = 0 AND s.key IN {CANONICAL_SESSIONS}{filter}+ FROM sessions s WHERE s.archived = 0 AND s.key IN canonical_sessions{filter}GROUP BY {group} ORDER BY COUNT(*) DESC, {display}");let mut stmt = conn.prepare_cached(&sql)?;@@ -1451,6 +1452,7 @@ impl Store {let mut stmt = conn.prepare_cached("SELECT date(created_at/1000,'unixepoch','localtime'), COUNT(*)FROM sessions WHERE archived = 0 AND created_at > 0+ AND key IN canonical_sessionsGROUP BY 1 ORDER BY 1",)?;let rows = stmt.query_map([], |r| {diff --git a/crates/wake-core/src/mcp/tools.rs b/crates/wake-core/src/mcp/tools.rsindex fc9e4dd..f9dbb2f 100644--- a/crates/wake-core/src/mcp/tools.rs+++ b/crates/wake-core/src/mcp/tools.rs@@ -76,6 +76,9 @@ pub const SEARCH: &str = "wake_search";pub const LIST_SESSIONS: &str = "wake_list_sessions";pub const GET_SESSION: &str = "wake_get_session";pub const LIST_PROJECTS: &str = "wake_list_projects";+/// 四个工具名的清单:自指回声过滤(`adapters::is_wake_lookup`)与 definitions 的+/// 稳定性测试都读它,加第五家改这里与 `definitions()` 两处即可+pub const NAMES: [&str; 4] = [SEARCH, LIST_SESSIONS, GET_SESSION, LIST_PROJECTS];const MAX_SEARCH_SESSIONS: i64 = 30;const MAX_LIST_SESSIONS: i64 = 100;@@ -226,6 +229,13 @@ fn str_arg<'a>(args: &'a Value, name: &str) -> Result<Option<&'a str>, ToolError}}+/// 去掉首尾空白、空串当没传的字符串参数(key / query / project / subagent 共用)+fn text_arg<'a>(args: &'a Value, name: &str) -> Result<Option<&'a str>, ToolError> {+ Ok(str_arg(args, name)?+ .map(str::trim)+ .filter(|s| !s.is_empty()))+}+fn int_arg(args: &Value, name: &str, default: i64, min: i64, max: i64) -> Result<i64, ToolError> {let v = match args.get(name) {None | Some(Value::Null) => return Ok(default),@@ -352,10 +362,7 @@ enum ProjectScope {}fn project_arg(ctx: &ToolContext, args: &Value) -> Result<ProjectScope, ToolError> {- let Some(arg) = str_arg(args, "project")?- .map(str::trim)- .filter(|s| !s.is_empty())- else {+ let Some(arg) = text_arg(args, "project")? else {return Ok(ProjectScope::All);};// 含归档:搜索覆盖归档会话,只剩归档会话的项目不能在这一步被挡掉@@ -502,9 +509,7 @@ fn session_ref(key: &str, seq: i64) -> String {// ---------------------------------------------------------------- 工具实现fn search(ctx: &ToolContext, args: &Value) -> ToolResult {- let query = str_arg(args, "query")?- .map(str::trim)- .filter(|q| !q.is_empty())+ let query = text_arg(args, "query")?.ok_or_else(|| ToolError::InvalidParams("`query` is required".into()))?;let agents = agents_arg(args)?;let since = since_arg(ctx, args)?;@@ -723,13 +728,7 @@ const MAX_SUBAGENTS_LISTED: usize = 30;/// `agent-a1b2 — Explore: find the watcher code`;没有边车信息时只有 idfn subagent_label(sc: &SidechainInfo) -> String {- let desc = [sc.agent_type.as_deref(), sc.description.as_deref()]- .into_iter()- .flatten()- .map(|s| one_line(s, 80))- .filter(|s| !s.is_empty())- .collect::<Vec<_>>()- .join(": ");+ let desc = one_line(&sc.label(), 80);if desc.is_empty() {sc.id.clone()} else {@@ -752,9 +751,7 @@ fn subagent_lines(sidechains: &[SidechainInfo]) -> String {}fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {- let raw_key = str_arg(args, "key")?- .map(str::trim)- .filter(|k| !k.is_empty())+ let raw_key = text_arg(args, "key")?.ok_or_else(|| ToolError::InvalidParams("`key` is required".into()))?;let (key, ref_seq) = parse_key_arg(raw_key);let from_seq = int_arg(args, "from_seq", ref_seq.unwrap_or(0), 0, i64::MAX)?;@@ -766,9 +763,7 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {include_tools: bool_arg(args, "include_tools", false)?,include_thinking: bool_arg(args, "include_thinking", false)?,};- let subagent = str_arg(args, "subagent")?- .map(str::trim)- .filter(|s| !s.is_empty());+ let subagent = text_arg(args, "subagent")?;let meta = match find_session(ctx.store, &key)? {Ok(m) => m,Err(text) => return Err(ToolError::Failed(text)),@@ -796,7 +791,6 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {.sidechains.iter().find(|sc| sc.id == id)- .cloned().ok_or_else(|| {ToolError::Failed(if transcript.sidechains.is_empty() {format!("`{}` has no subagent transcripts.", meta.key)@@ -825,6 +819,7 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {Some((info, messages))}};+ let sub_id = sidechain.as_ref().map(|(info, _)| info.id.as_str());let messages: &[TranscriptMessage] = match &sidechain {Some((_, messages)) => messages,None => &transcript.mainline,@@ -871,19 +866,14 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {facts.push(format!("via {src}"));}// 时间范围:主线用会话的起止,子代理用它自己消息的首末时间(没有就不写)- let (start, end) = match &sidechain {- Some((_, messages)) => messages.iter().filter_map(|m| m.timestamp).fold(- (None, None),- |(lo, hi): (Option<i64>, Option<i64>), t| {- (- Some(lo.map_or(t, |lo| lo.min(t))),- Some(hi.map_or(t, |hi| hi.max(t))),- )- },- ),- None => (Some(live.created_at), Some(live.updated_at)),+ let range = match &sidechain {+ Some((_, messages)) => {+ let ts = messages.iter().filter_map(|m| m.timestamp);+ ts.clone().min().zip(ts.max())+ }+ None => Some((live.created_at, live.updated_at)),};- if let (Some(start), Some(end)) = (start, end) {+ if let Some((start, end)) = range {facts.push(format!("{} – {}",fmt_time(Some(start)),@@ -911,9 +901,8 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {let (first, last) = page.seq_range.unwrap_or((from_seq, from_seq));let mut summary = format!("Showing seq {first}–{last}{}: {} message{}",- sidechain- .as_ref()- .map(|(info, _)| format!(" of subagent `{}`", info.id))+ sub_id+ .map(|id| format!(" of subagent `{id}`")).unwrap_or_default(),page.rendered,plural(page.rendered as i64)@@ -928,7 +917,7 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {out.push_str(&summary);out.push_str(".\n");// 主线页脚列出子代理转录:它们不并进主线(各有自己的 seq),按 id 单独读- if sidechain.is_none() && !transcript.sidechains.is_empty() {+ if sub_id.is_none() && !transcript.sidechains.is_empty() {out.push_str(&format!("{} subagent transcript{} (pass an id as `subagent` to read one):\n{}",transcript.sidechains.len(),@@ -936,16 +925,19 @@ fn get_session(ctx: &ToolContext, args: &Value) -> ToolResult {subagent_lines(&transcript.sidechains)));}- match (page.next_seq, &sidechain) {- (Some(next), Some((info, _))) => out.push_str(&format!(- "More follows — call {GET_SESSION} again with subagent=\"{}\" and from_seq={next}.\n",- info.id- )),- (Some(next), None) => out.push_str(&format!(- "More follows — call {GET_SESSION} again with from_seq={next}.\n"+ let with_sub = sub_id+ .map(|id| format!("subagent=\"{id}\" and "))+ .unwrap_or_default();+ let noun = if sub_id.is_some() {+ "subagent transcript"+ } else {+ "transcript"+ };+ match page.next_seq {+ Some(next) => out.push_str(&format!(+ "More follows — call {GET_SESSION} again with {with_sub}from_seq={next}.\n")),- (None, Some(_)) => out.push_str("End of subagent transcript.\n"),- (None, None) => out.push_str("End of transcript.\n"),+ None => out.push_str(&format!("End of {noun}.\n")),}Ok(out)}@@ -1005,7 +997,7 @@ mod tests {fn definitions_are_stable() {let defs = definitions();let names: Vec<&str> = defs.iter().map(|d| d["name"].as_str().unwrap()).collect();- assert_eq!(names, [SEARCH, LIST_SESSIONS, GET_SESSION, LIST_PROJECTS]);+ assert_eq!(names, NAMES);for d in &defs {assert_eq!(d["inputSchema"]["type"], "object");assert_eq!(d["annotations"]["readOnlyHint"], true);diff --git a/crates/wake-core/src/models.rs b/crates/wake-core/src/models.rsindex a2fb276..6c4b748 100644--- a/crates/wake-core/src/models.rs+++ b/crates/wake-core/src/models.rs@@ -319,6 +319,20 @@ pub struct SidechainInfo {pub tool_use_id: Option<String>,}+impl SidechainInfo {+ /// 边车给的"是谁、干什么":`Explore: find the watcher code`;两项都没有时为空串。+ /// 导出的 `## ⑂ Subagent:` 标题与 MCP 的 subagent 事实行共用,别各拼一份+ pub fn label(&self) -> String {+ [self.agent_type.as_deref(), self.description.as_deref()]+ .into_iter()+ .flatten()+ .map(str::trim)+ .filter(|s| !s.is_empty())+ .collect::<Vec<_>>()+ .join(": ")+ }+}+#[derive(Debug, Clone)]pub struct ParsedTranscript {pub meta: SessionMeta,diff --git a/crates/wake-core/src/remote.rs b/crates/wake-core/src/remote.rsindex 98017df..54815c7 100644--- a/crates/wake-core/src/remote.rs+++ b/crates/wake-core/src/remote.rs@@ -209,7 +209,7 @@ pub fn purge_orphan_caches(store: &Store) {.into_iter().map(|h| h.name).collect();- let Ok(entries) = std::fs::read_dir(db_dir.join("remotes")) else {+ let Ok(entries) = std::fs::read_dir(remotes_dir(&db_dir)) else {return;};for entry in entries.flatten() {@@ -220,16 +220,21 @@ pub fn purge_orphan_caches(store: &Store) {}}+/// 全部镜像的根:`<索引库目录>/remotes/`+fn remotes_dir(db_dir: &Path) -> PathBuf {+ db_dir.join("remotes")+}+/// 单 host 的缓存树(各 host 挂在 `<索引库目录>/remotes/<host>/` 下)。pub fn host_cache_dir(db_dir: &Path, host: &str) -> PathBuf {- db_dir.join("remotes").join(host)+ remotes_dir(db_dir).join(host)}/// 全部镜像(`<db 目录>/remotes/`)的磁盘占用。Settings → Data 的 Storage 行把它/// 并进索引库的大小——"Wake 在这台机器上占了多少盘"得含镜像(0.4.0 遗留)。/// 逐文件 stat,几千个文件也是毫秒级;调用方别放进每帧的 render,目录不存在即 0pub fn cache_bytes(db_dir: &Path) -> u64 {- walkdir::WalkDir::new(db_dir.join("remotes"))+ walkdir::WalkDir::new(remotes_dir(db_dir)).into_iter().filter_map(Result::ok).filter(|e| e.file_type().is_file())diff --git a/crates/wake-core/src/services/exporter.rs b/crates/wake-core/src/services/exporter.rsindex ab832bc..88aa523 100644--- a/crates/wake-core/src/services/exporter.rs+++ b/crates/wake-core/src/services/exporter.rs@@ -115,12 +115,7 @@ pub fn to_markdown(if msgs.is_empty() {continue;}- let label = [sc.agent_type.as_deref(), sc.description.as_deref()]- .iter()- .flatten()- .copied()- .collect::<Vec<_>>()- .join(":");+ let label = sc.label();out.push_str(&format!("---\n\n## ⑂ Subagent: {}\n\n",if label.is_empty() { &sc.id } else { &label }diff --git a/crates/wake/src/settings.rs b/crates/wake/src/settings.rsindex 5468a7d..6152d2d 100644--- a/crates/wake/src/settings.rs+++ b/crates/wake/src/settings.rs@@ -227,9 +227,6 @@ pub(crate) struct SettingsView {copied: Option<SharedString>,/// 连点时只有最后一次的定时器能清掉 copiedcopied_generation: u64,- /// remotes/ 镜像的占用:开窗时后台走一遍目录树算出来(不放进每帧都跑的- /// render),None = 还没算完,Data 页先只显示索引库的大小- remote_cache_bytes: Option<u64>,_workbench_observer: Option<Subscription>,}@@ -246,24 +243,6 @@ impl SettingsView {cx.on_next_frame(window, move |this, _, cx| {this._workbench_observer = Some(cx.observe(&observed, |_, _, cx| cx.notify()));});- let cache_dir = wake_core::db::default_db_path()- .parent()- .map(std::path::Path::to_path_buf);- let remote_bytes = cx.background_spawn(async move {- cache_dir- .as_deref()- .map(wake_core::remote::cache_bytes)- .unwrap_or(0)- });- cx.spawn(async move |this, cx| {- let bytes = remote_bytes.await;- this.update(cx, |this, cx| {- this.remote_cache_bytes = Some(bytes);- cx.notify();- })- .ok();- })- .detach();Self {focus_handle: cx.focus_handle(),workbench,@@ -273,7 +252,6 @@ impl SettingsView {connect_shown: Default::default(),copied: None,copied_generation: 0,- remote_cache_bytes: None,_workbench_observer: None,}}@@ -590,19 +568,18 @@ impl SettingsView {let theme = cx.theme();let snapshot = self.workbench.read(cx).data_settings_snapshot();// 会话计数的措辞单点在 workbench 的 session_tally(Locations 与- // Remote hosts 也用它);这里只补分隔符,不再复制一遍句子。占用 = 索引库- // 三件套 + remotes/ 镜像(后者开窗时后台算,算完前只显示库的大小)- let remote_bytes = self.remote_cache_bytes.unwrap_or(0);+ // Remote hosts 也用它);这里只补分隔符,不再复制一遍句子。占用已含+ // remotes/ 镜像(Workbench 后台算好放进快照),镜像非零时另注一句let mut summary = format!("{} · {}",crate::workbench::session_tally(snapshot.session_count),- format_storage_size(snapshot.size_bytes + remote_bytes)+ format_storage_size(snapshot.size_bytes));- if remote_bytes > 0 {+ if snapshot.remote_bytes > 0 {summary.push(' ');summary.push_str(&crate::tf!("({} in remote mirrors)",- format_storage_size(remote_bytes)+ format_storage_size(snapshot.remote_bytes)));}let summary: SharedString = summary.into();diff --git a/crates/wake/src/workbench.rs b/crates/wake/src/workbench.rsindex 1975e49..b259438 100644--- a/crates/wake/src/workbench.rs+++ b/crates/wake/src/workbench.rs@@ -133,10 +133,23 @@ fn spawn_remote_sync_thread(// 同步期间被 Remove 的 host:rsync 取消不了,收工后按配置表把孤儿// 缓存目录清掉(含它刚写回的),Remove 的"缓存已删"承诺自此闭合wake_core::remote::purge_orphan_caches(&store);+ report_remote_cache_size(&store, &bg_tx);let _ = bg_tx.unbounded_send(BgEvent::RemoteSyncDone);});}+/// 算 remotes/ 镜像的占用并经 bg_tx 报回(走目录树 stat,只在后台线程调)。+/// 镜像只在启动、同步收工、删 host 后会变,所以只在那三处算,不放 render+fn report_remote_cache_size(+ store: &Store,+ bg_tx: &futures::channel::mpsc::UnboundedSender<BgEvent>,+) {+ if let Some(db_dir) = store.db_dir() {+ let bytes = wake_core::remote::cache_bytes(&db_dir);+ let _ = bg_tx.unbounded_send(BgEvent::RemoteCacheBytes(bytes));+ }+}+// ---------------- 后台事件桥 ----------------enum BgEvent {@@ -146,6 +159,8 @@ enum BgEvent {RescanNeeded,/// 远程 rsync 线程收工(成败都发;状态在 remote_hosts 表里)RemoteSyncDone,+ /// remotes/ 镜像的磁盘占用算好了(启动、同步收工、删 host 后各算一次)+ RemoteCacheBytes(u64),}struct ChannelEvents(futures::channel::mpsc::UnboundedSender<BgEvent>);@@ -757,14 +772,7 @@ impl ListDelegate for SessionsDelegate {theme.muted_foreground,)).when(!s.host.is_empty(), |this| {- // 远程会话的 host 徽章:填充胶囊但用 primary 淡底 +- // primary 字,与紧邻的 muted 项目胶囊拉开(描边版、- // muted 填充版都试过,用户否决 2026-09-03)- this.child(badge(- format!("@{}", s.host),- theme.primary.opacity(0.14),- theme.primary,- ))+ this.child(host_badge(&s.host, &theme))}).when(show_chevron, |this| {this.child(@@ -1321,14 +1329,8 @@ impl ListDelegate for SearchDelegate {.child(h.session.title.clone()),).child(div().flex_1())- // 远程会话的 @host 徽章,与列表行同款(0.4.0 遗留:- // 两台机器的同名会话在 ⌘K 里分不出来).when(!h.session.host.is_empty(), |this| {- this.child(badge(- format!("@{}", h.session.host),- theme.primary.opacity(0.14),- theme.primary,- ))+ this.child(host_badge(&h.session.host, &theme))}).child(div()@@ -1964,6 +1966,9 @@ pub struct Workbench {sort_ascending: bool,agent_counts: Vec<(AgentId, i64)>,+ /// remotes/ 镜像的磁盘占用(Settings → Data 的 Storage 行并进索引库大小);+ /// 后台算、经 RemoteCacheBytes 送达,None = 还没算完+ remote_cache_bytes: Option<u64>,projects: Vec<ProjectInfo>,agents_collapsed: bool,projects_collapsed: bool,@@ -2187,7 +2192,10 @@ pub(crate) struct LocationSettingsSnapshot {pub(crate) struct DataSettingsSnapshot {pub(crate) display_path: SharedString,pub(crate) raw_path: SharedString,+ /// 索引库三件套 + remotes/ 镜像pub(crate) size_bytes: u64,+ /// 其中镜像的部分(算完前为 0)+ pub(crate) remote_bytes: u64,pub(crate) session_count: i64,}@@ -2269,6 +2277,10 @@ impl Workbench {spawn_scan(adapters.clone(), store.clone(), events.clone(), false);let syncing_hosts = store.enabled_remote_host_names();spawn_remote_sync_thread(&store, bg_tx.clone(), syncing_hosts.clone());+ {+ let (store, bg_tx) = (store.clone(), bg_tx.clone());+ std::thread::spawn(move || report_remote_cache_size(&store, &bg_tx));+ }let watcher = start_watcher(adapters.clone(), store.clone(), events.clone());let scan_events = events.clone();@@ -2310,6 +2322,7 @@ impl Workbench {sort_ascending: false,favorite_only: false,agent_counts: Vec::new(),+ remote_cache_bytes: None,projects: Vec::new(),agents_collapsed: false,projects_collapsed: false,@@ -2635,15 +2648,17 @@ impl Workbench {pub(crate) fn data_settings_snapshot(&self) -> DataSettingsSnapshot {let path = wake_core::db::default_db_path();let raw = path.to_string_lossy().to_string();- let size_bytes = ["", "-wal", "-shm"]+ let index_bytes: u64 = ["", "-wal", "-shm"].iter().filter_map(|suffix| std::fs::metadata(format!("{raw}{suffix}")).ok()).map(|metadata| metadata.len()).sum();+ let remote_bytes = self.remote_cache_bytes.unwrap_or(0);DataSettingsSnapshot {display_path: tilde_path(&raw).into(),raw_path: raw.into(),- size_bytes,+ size_bytes: index_bytes + remote_bytes,+ remote_bytes,session_count: self.session_total(),}}@@ -3706,8 +3721,10 @@ impl Workbench {self.rebuild_roster(cx);if let Some(db_dir) = self.store.db_dir() {let cache = wake_core::remote::host_cache_dir(&db_dir, name);+ let (store, bg_tx) = (self.store.clone(), self.bg_tx.clone());std::thread::spawn(move || {let _ = std::fs::remove_dir_all(cache);+ report_remote_cache_size(&store, &bg_tx);});}self.kick_incremental_scan(cx);@@ -3795,6 +3812,11 @@ impl Workbench {self.kick_incremental_scan(cx);None}+ BgEvent::RemoteCacheBytes(bytes) => {+ self.remote_cache_bytes = Some(bytes);+ cx.notify();+ None+ }BgEvent::RemoteSyncDone => {self.syncing_hosts.clear();// 同步期间被排队的 host(如 add host)接着跑;与下面的收编@@ -8414,6 +8436,17 @@ pub(crate) fn session_tally(n: i64) -> String {crate::tp!("{} session", "{} sessions", n)}+/// 远程会话的 @host 徽章:填充胶囊但用 primary 淡底 + primary 字,与紧邻的 muted+/// 项目胶囊拉开(描边版、muted 填充版都试过,用户否决 2026-09-03)。列表行与 ⌘K+/// 结果行共用;详情页的描边版是有意的第三种+fn host_badge(host: &str, theme: &gpui_component::Theme) -> impl IntoElement {+ badge(+ format!("@{host}"),+ theme.primary.opacity(0.14),+ theme.primary,+ )+}+fn badge(name: impl Into<SharedString>, bg: Hsla, fg: Hsla) -> impl IntoElement {div().min_w_0()