Skip to content

armgit / Wake

Public Imported from GitHub
0

All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.

Rust

feat(insights): brand colors for agents and a palette for models in the trend chart

Corey Chiudfff93e71ccd
diff --git a/DESIGN.md b/DESIGN.md
index 343893b..6110d17 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -214,7 +214,7 @@ emoji 不再承担界面或正文结构图标职责。
- 统计口径与主 UI 一致(archived 不计):"Prompts" 一律指主线用户消息。数据在打开与每次 Refresh 后后台重算,不阻塞浏览。
- 概览行:28px semibold 大数字 + Caption 标签,序为 Sessions / Tokens / Prompts / Agents / Projects / Active days(用户钉序,2026-08-27);Tokens 仅在有 agent 报过用量时出现。数字千分位。
- Last 7 days(概览下方):同序的四个度量(Sessions / Tokens / Prompts / Active days),值 Heading 16 semibold + Caption 标签 + Label 11 的相对变化行("+12% vs last week" / "Same as last week" / "New this week" / "No activity");上涨用 `primary`,持平与下降 `muted_foreground`,不引入第四种文字色。会话按创建日归属,prompts 按消息日,对比窗为滚动 7 天对前 7 天(不按自然周,免得周一早上全是零)。
-- Over time(热力图下方):近 53 周每周 prompts 的堆叠柱,列宽与步距与热力图完全一致(9px 柱 + 3px 缝,左侧留出热力图的 26px 星期标签列),两图的周列上下对齐,月份刻度同规则。按总量取前五个序列用 `primary` 100/72/50/34/22% 五档自下而上堆叠,其余合并为 "Other"(`muted_foreground` 35%);单色阶梯,不用品牌色。零周留 2px `muted` 基线;柱按窗口内峰值周归一。组头 ‹ Agents/Models › 二选一切换(无模型序列时不给切换钮),caption 点名本周领先者("Prompts per week by agent · Claude Code leads this week")。图例在刻度下方:9px 色块 + Label 11 名称,可换行。tooltip 给 "Week of Aug 3 · 120 prompts" 与前三层明细。
+- Over time(热力图下方):近 53 周每周 prompts 的堆叠柱,列宽与步距与热力图完全一致(9px 柱 + 3px 缝,左侧留出热力图的 26px 星期标签列),两图的周列上下对齐,月份刻度同规则。按总量取前五个序列各自着色自下而上堆叠:agent 用品牌色(theme.rs `agent_series_color`,彩色品牌取内嵌 PNG 主色、单色字形的六家给固定备选色,同一家在任何机器上不变),模型按排名取 `SERIES_PALETTE` 六色分类色板;其余合并为 "Other"(`muted_foreground` 35%)。曾试单色 `primary` 五档阶梯,用户否决(分不清)。零周留 2px `muted` 基线;柱按窗口内峰值周归一。组头 ‹ Agents/Models › 二选一切换(无模型序列时不给切换钮),caption 点名本周领先者("Prompts per week by agent · Claude Code leads this week")。图例在刻度下方:9px 色块 + Label 11 名称,可换行。tooltip 给 "Week of Aug 3 · 120 prompts" 与前三层明细。
- 活跃热力图:53 周 × 7 天(周一起始,最右列为本周),9px 方格 + 3px 缝,总宽 662px。热力格、分布柱和图例统一使用 `RADIUS_CELL` 2px 圆角;强度 = `muted` 空格 + `primary` 25/50/75/100% 四档(按窗口内峰值分位);未来日期留白。月份与 Mon/Wed/Fri 标签用 Label 11 muted;每格 tooltip 给 "N prompts · Aug 3, 2026"。底注左侧为 streak 与最忙一日(Label 11,` · ` 分隔),右侧 Less–More 固定满阶梯图例。
- 分布图:hour(24 柱)/ weekday(7 柱)/ month(12 柱)三个维度共用一张竖柱图,组头右侧 ‹ › ghost 按钮循环切换(纯视图状态,数据三份常驻不重查);峰值柱全饱和 `primary`、其余 55%,零值保留 2px `muted` 基线;柱数越少缝越大(4/8/6px)。hour 只标 6 小时锚点(靠左),weekday/month 每柱标签与柱居中;组头副行点出峰值("Most active around 2 PM" / "on Sundays" / "in August")。
- Agents / Projects / Models 三个榜单同构:24px 条形行 = 行首(品牌图 15px 原色 / folder 图标 / 无)+ 名称列定宽 truncate + 6px 圆头轨道条(`muted` 轨、`primary` 填充,按组内峰值归一)+ 右对齐 Label 计数。三个组头都挂 ‹ › 切换度量,循环序与概览行一致:Sessions / Tokens / Prompts;**当前档位名(首字母大写的裸名词)显示在两键中间**——64px 定宽居中,Caption muted,按钮位置不随文本跳动;榜单组头因此为单行(标题与按钮组居中对齐),分布图组头保留 caption 双行、按钮中间无标签(其标题本身就是档位名)。每个榜单各自记忆档位,行按当前度量降序重排后取 top-N(Agents 全量、Projects/Models 各 6;截断在排序之后,换度量不漏项);Tokens 档只列报过用量的组、值用 K/M 缩写,组内无人报 token 时该档不进循环。
diff --git a/crates/wake/src/theme.rs b/crates/wake/src/theme.rs
index 4507017..586063f 100644
--- a/crates/wake/src/theme.rs
+++ b/crates/wake/src/theme.rs
@@ -78,6 +78,36 @@ pub const MODEL_BADGE_BG: u32 = 0xD97757;
/// 收藏星选中色——macOS systemYellow(Finder/Mail 星标惯例),两模式通用
pub const STAR_YELLOW: u32 = 0xFFCC00;
+/// Insights 趋势图的 agent 序列色:有彩色品牌的家取品牌色(从内嵌 PNG 取主色,
+/// 与侧栏图标同调),单色字形的家(Copilot/Cursor/OpenCode/Pi/Grok/Kimi)
+/// 给固定备选色——同一家在任何机器上颜色都不变,相邻常见组合(Claude/Codex/
+/// Cursor/Copilot)互不撞色。两模式共用(用户 2026-09-03:单色阶梯分不清)
+pub fn agent_series_color(agent: wake_core::models::AgentId) -> u32 {
+ use wake_core::models::AgentId::*;
+ match agent {
+ ClaudeCode => 0xD97757,
+ Codex => 0x7A8DFF,
+ Grok => 0x8A7F73,
+ Dsh => 0x4D6BFE,
+ Cursor => 0x2DB6C8,
+ Opencode => 0xC98A2E,
+ Pi => 0x3AAE8C,
+ Omp => 0xB05CE6,
+ Kiro => 0x9148FF,
+ Kimi => 0xE4739E,
+ Gemini => 0x3B8BD9,
+ Copilot => 0x6E9C3F,
+ Antigravity => 0x648AB5,
+ Qoder => 0x2BB454,
+ Hermes => 0xE0B040,
+ Openclaw => 0xE04A4A,
+ }
+}
+
+/// 趋势图模型序列的分类色板(按排名取色);模型没有品牌可依,六色足够区分
+/// 前五 + Other
+pub const SERIES_PALETTE: [u32; 6] = [0x4C8DFF, 0xD97757, 0x2BB454, 0x9148FF, 0xE4739E, 0xE0B040];
+
/// 在 gpui-component 默认主题之上覆写 Wake 的 token。
/// 每次外观切换后都要重新调用(sync_system_appearance 会重置为默认)。
pub fn apply_wake_theme(cx: &mut App) {
diff --git a/crates/wake/src/workbench.rs b/crates/wake/src/workbench.rs
index 8c72387..79bb3d7 100644
--- a/crates/wake/src/workbench.rs
+++ b/crates/wake/src/workbench.rs
@@ -5953,7 +5953,6 @@ impl Workbench {
)
.into_any_element()
});
- let dark = cx.theme().mode.is_dark();
let name_of = move |raw: &str| -> SharedString {
match board {
TrendBoard::Agents => AgentId::from_str(raw)
@@ -5962,7 +5961,17 @@ impl Workbench {
TrendBoard::Models => raw.to_string().into(),
}
};
- let _ = dark;
+ // agent 用品牌色(库里冒出未知 agent_id 时退分类色板),模型按排名取色板
+ let color_of = move |raw: &str, rank: usize| -> Hsla {
+ let palette = crate::theme::SERIES_PALETTE[rank % crate::theme::SERIES_PALETTE.len()];
+ let hex = match board {
+ TrendBoard::Agents => AgentId::from_str(raw)
+ .map(crate::theme::agent_series_color)
+ .unwrap_or(palette),
+ TrendBoard::Models => palette,
+ };
+ rgb(hex).into()
+ };
v_flex()
.gap(SPACE_MD)
.child(switch_section_head(
@@ -5971,7 +5980,7 @@ impl Workbench {
arrows,
cx,
))
- .child(render_trend(d, series, name_of, cx))
+ .child(render_trend(d, series, name_of, color_of, cx))
.into_any_element()
}
@@ -7055,11 +7064,9 @@ fn render_distribution(range: InsightsRange, values: &[i64], peak: usize, cx: &A
.into_any_element()
}
-/// 趋势图堆叠层的着色阶梯:前五个序列按总量降序取 primary 五档不透明度,
-/// 其余合并为 "Other" 用 muted_foreground 淡层——与热力图同一单色语言,
-/// 不引入品牌色(十六家的品牌色叠在一起没法读)
-const TREND_STEPS: [f32; 5] = [1., 0.72, 0.5, 0.34, 0.22];
-const TREND_TOP: usize = TREND_STEPS.len();
+/// 趋势图堆叠的序列数上限:前五个按总量降序各自着色(agent 品牌色 / 模型
+/// 色板,见 theme.rs),其余合并为 "Other" 用 muted_foreground 淡层
+const TREND_TOP: usize = 5;
fn trend_caption(board: TrendBoard, series: &[TrendSeries]) -> String {
let unit = match board {
@@ -7183,6 +7190,7 @@ fn render_trend(
d: &InsightsData,
series: &[TrendSeries],
name_of: impl Fn(&str) -> SharedString,
+ color_of: impl Fn(&str, usize) -> Hsla,
cx: &App,
) -> AnyElement {
use chrono::Datelike as _;
@@ -7198,13 +7206,7 @@ fn render_trend(
.iter()
.take(TREND_TOP)
.enumerate()
- .map(|(i, s)| {
- (
- name_of(&s.name),
- theme.primary.opacity(TREND_STEPS[i]),
- s.weekly.clone(),
- )
- })
+ .map(|(i, s)| (name_of(&s.name), color_of(&s.name, i), s.weekly.clone()))
.collect();
if series.len() > TREND_TOP {
let mut other = vec![0i64; TREND_WEEKS];