agent-loft 0.2.49 → 0.2.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { api } from "../lib/api.js";
3
3
  import { desktop, remoteTabs, S, ui } from "../state.js";
4
4
  import { baseName } from "./topbar.js";
5
5
  import { newDraft, openConversation } from "./messages.js";
6
+ import { convExpert, expertIcon } from "./experts.js";
6
7
  import { leaveRemote } from "./remote.js";
7
8
  import { reportShellState } from "../lib/shell.js";
8
9
 
@@ -155,22 +156,60 @@ function forkForest(convs) {
155
156
  return roots.sort((a, b) => b.at - a.at);
156
157
  }
157
158
 
158
- /** 画一棵分叉树:主对话一行,分叉缩进挂在下面,用虚线连起来(样式见 .fork-node) */
159
- function renderForkNode(node, row, cls = "") {
160
- const self = row(node.c, !!node.c.forkOf && !node.parentShown);
161
- if (node.kids.length === 0) return self;
159
+ /** 整棵子树里所有分叉的 key(不含自己) */
160
+ function descendantKeys(node) {
161
+ return node.kids.flatMap((k) => [k.c.key, ...descendantKeys(k)]);
162
+ }
163
+
164
+ /** 标题后面的小三角:朝下是展开,朝右是折叠。onToggle 给了就自己响应点击(不触发整行的点击) */
165
+ function caret(folded, onToggle) {
166
+ return h("span", {
167
+ class: `caret${folded ? " folded" : ""}`,
168
+ html: ICON.caret,
169
+ role: onToggle ? "button" : null,
170
+ title: onToggle ? (folded ? "展开分叉" : "折叠分叉") : null,
171
+ onclick: onToggle
172
+ ? (e) => {
173
+ e.stopPropagation();
174
+ onToggle();
175
+ }
176
+ : null,
177
+ });
178
+ }
179
+
180
+ /**
181
+ * 画一棵分叉树:主对话一行(标题后面带三角),分叉缩进挂在下面,左边一条竖线,最后一条拐个圆角(样式见 .fork-node)。
182
+ * 折叠了就只留一行「N 个嵌套会话」。row(c, orphan, fold)
183
+ */
184
+ function renderForkNode(node, row) {
185
+ const orphan = !!node.c.forkOf && !node.parentShown;
186
+ if (node.kids.length === 0) return row(node.c, orphan);
187
+ const key = node.c.key;
188
+ const folded = sideState.forkFolded.includes(key);
189
+ const nested = descendantKeys(node);
190
+ const toggle = () => toggleSide("forkFolded", key);
162
191
  return h(
163
192
  "div",
164
193
  { class: "fork-group" },
165
- self,
194
+ row(node.c, orphan, { folded, keys: [key, ...nested], toggle }),
166
195
  h(
167
196
  "div",
168
- { class: `fork-children${cls}` },
169
- node.kids.map((k) => h("div", { class: "fork-node" }, renderForkNode({ ...k, parentShown: true }, row))),
197
+ { class: "fork-children" },
198
+ folded
199
+ ? h("div", { class: "fork-node" }, h("button", { class: "conv-item fork-more", onclick: toggle }, h("span", { class: "title" }, `${nested.length} 个嵌套会话`)))
200
+ : node.kids.map((k) => h("div", { class: "fork-node" }, renderForkNode({ ...k, parentShown: true }, row))),
170
201
  ),
171
202
  );
172
203
  }
173
204
 
205
+ /** 标题放不下的行加 .clip:尾巴淡出(代替省略号)。重绘、侧栏变宽窄时重新量 */
206
+ function markClipped() {
207
+ for (const el of ui.convList.querySelectorAll(".conv-item .title")) {
208
+ el.classList.toggle("clip", el.scrollWidth > el.clientWidth + 1);
209
+ }
210
+ }
211
+ let clipObserver = null;
212
+
174
213
  /** 分叉出来的对话:提示里写上从哪条来的 */
175
214
  function forkNote(c) {
176
215
  if (!c.forkOf) return "";
@@ -189,12 +228,19 @@ export function agentLabel(id) {
189
228
  return S.agents.find((a) => a.id === id)?.label ?? id;
190
229
  }
191
230
 
231
+ /** 会话名后面的专家图标,鼠标悬停在会话行上时显示 */
232
+ function convExpertMark(c) {
233
+ if (!c) return null;
234
+ const expert = convExpert(c);
235
+ return h("span", { class: "expert-mark", title: `专家:${expert.name}` }, expertIcon(expert, "expert-mark-icon"));
236
+ }
237
+
192
238
  function agentShort(id) {
193
239
  return id === "claude" ? "Claude" : id === "codex" ? "Codex" : id;
194
240
  }
195
241
 
196
- /** 侧栏里展开 / 收起的状态:哪些项目目录展开了、哪些分组折叠了、目录的顺序(more 是老版本的,不再用) */
197
- export const sideState = { open: [], more: [], folded: [], order: [], ...JSON.parse(localStorage.getItem("aim.side") || "{}") };
242
+ /** 侧栏里展开 / 收起的状态:哪些项目目录展开了、哪些分组折叠了、哪些主对话的分叉折叠了、目录的顺序(more 是老版本的,不再用) */
243
+ export const sideState = { open: [], more: [], folded: [], forkFolded: [], order: [], ...JSON.parse(localStorage.getItem("aim.side") || "{}") };
198
244
 
199
245
  /**
200
246
  * 「项目」目录的顺序固定按 sideState.order,新消息不会把目录顶到前面。
@@ -266,15 +312,6 @@ function setProjectOrder(order) {
266
312
  let dirDrag = null;
267
313
  let sidebarStale = false;
268
314
 
269
- /** 「最近」「项目」分组标题:点击折叠 / 展开,hover 时显示箭头 */
270
- function groupHead(label, id, folded) {
271
- return h(
272
- "button",
273
- { class: `conv-group${folded ? " collapsed" : ""}`, title: folded ? "展开" : "折叠", onclick: () => toggleSide("folded", id) },
274
- label,
275
- h("span", { class: "chev", html: ICON.down }),
276
- );
277
- }
278
315
  function toggleSide(list, id) {
279
316
  const set = new Set(sideState[list]);
280
317
  set.has(id) ? set.delete(id) : set.add(id);
@@ -426,8 +463,9 @@ export function renderSidebar() {
426
463
  // 在远程控制页上点进来之前那条对话:对话没动过,退出远程控制就露出来了
427
464
  else if (S.view === "remote") leaveRemote();
428
465
  };
429
- // 一行会话。orphan:是分叉出来的、但父对话不在这一组里(删了 / 在别的目录),没有连线可画,用图标标一下
430
- const convRow = (c, cls, detail, orphan) =>
466
+ // 一行会话。orphan:是分叉出来的、但父对话不在这一组里(删了 / 在别的目录),没有连线可画,用图标标一下。
467
+ // fold:有分叉的主对话,标题后面挂三角;折叠着时分叉的状态也显示在这一行
468
+ const convRow = (c, cls, detail, orphan, fold) =>
431
469
  h(
432
470
  "button",
433
471
  {
@@ -439,23 +477,20 @@ export function renderSidebar() {
439
477
  orphan ? h("span", { class: "brand-icon lead fork-mark", html: ICON.fork }) : null,
440
478
  // 定时任务的专用对话
441
479
  c.taskId ? h("span", { class: "brand-icon lead task-mark", title: "定时任务的对话", html: ICON.clock }) : null,
442
- // 自定义专家的对话:前面挂专家的 emoji
443
- c.expert?.icon && !c.expert.builtin ? h("span", { class: "brand-icon lead expert-mark", title: `专家:${c.expert.name}` }, c.expert.icon) : null,
444
480
  h("span", { class: "title" }, convTitle(c)),
445
- status([c.key]),
481
+ convExpertMark(c),
482
+ fold ? caret(fold.folded, fold.toggle) : null,
483
+ status(fold?.folded ? fold.keys : [c.key]),
446
484
  );
447
485
 
448
- // ---- 最近:Web 会话 + 每个飞书机器人一行(点开它最近活跃的聊天),按活跃时间混排 ----
449
- // 分叉出来的对话挂在主对话下面,整棵树按里面最近活跃的那条排
450
- const recent = [];
451
- for (const node of forkForest(visible.filter((c) => c.channel !== "feishu"))) {
452
- recent.push({ at: node.at, el: renderForkNode(node, (c, orphan) => convRow(c, "", `${agentLabel(c.agent)} · ${c.cwd}`, orphan)) });
453
- }
486
+ const nodes = [];
487
+ // 飞书机器人独立显示在文件夹后面,点击打开它最近活跃的聊天
488
+ const botRows = [];
454
489
  for (const bot of S.bots) {
455
490
  const convs = visible.filter((c) => c.channel === "feishu" && c.channelId === bot.id);
456
491
  if (bot.enabled === false && convs.length === 0) continue;
457
492
  const latest = convs[0];
458
- recent.push({
493
+ botRows.push({
459
494
  at: latest?.activeAt ?? 0,
460
495
  el: h(
461
496
  "button",
@@ -467,23 +502,13 @@ export function renderSidebar() {
467
502
  },
468
503
  h("span", { class: "brand-icon lead", title: "飞书", html: ICON.feishu }),
469
504
  h("span", { class: "title" }, bot.name),
505
+ convExpertMark(latest),
470
506
  status(convs.map((c) => c.key)),
471
507
  ),
472
508
  });
473
509
  }
474
- recent.sort((a, b) => b.at - a.at);
475
- const recentFolded = sideState.folded.includes("@recent");
476
- const nodes = [groupHead("最近", "@recent", recentFolded)];
477
- if (!recentFolded) {
478
- const rs = pages.recent;
479
- const shown = loadedPrefix(rs, recent);
480
- if (shown.length === 0 && !rs.loading) nodes.push(h("div", { class: "conv-empty" }, "还没有会话"));
481
- nodes.push(...shown.slice(0, rs.show).map((r) => r.el));
482
- const btn = moreButton(rs, shown.length, RECENT_LIMIT, (limit) => fetchPage(rs, { scope: "recent", limit: String(limit) }));
483
- if (btn) nodes.push(btn);
484
- }
485
510
 
486
- // ---- 项目:Web 会话按工作目录分组,目录按用户排的顺序(见 orderProjectDirs) ----
511
+ // ---- Web 会话直接按工作目录分组,目录按用户排的顺序(见 orderProjectDirs) ----
487
512
  const byDir = new Map();
488
513
  for (const c of visible.filter((c) => c.channel === "web")) {
489
514
  if (!byDir.has(c.cwd)) byDir.set(c.cwd, []);
@@ -500,11 +525,9 @@ export function renderSidebar() {
500
525
  // 目录行要全部显示:服务端给了每个目录最近的活跃时间,加上本地已有的(刚建的、刚变活跃的)
501
526
  const dirAt = new Map(pages.dirAt);
502
527
  for (const [dir, convs] of byDir) dirAt.set(dir, Math.max(dirAt.get(dir) ?? 0, convs[0].activeAt));
503
- const projFolded = sideState.folded.includes("@projects");
504
- if (dirAt.size) nodes.push(groupHead("项目", "@projects", projFolded));
505
528
  projDirsByActivity = [...dirAt.keys()].sort((a, b) => dirAt.get(b) - dirAt.get(a));
506
529
  projDirs = orderProjectDirs(projDirsByActivity);
507
- if (dirAt.size && !projFolded) {
530
+ if (dirAt.size) {
508
531
  const clearDrop = () => ui.convList.querySelectorAll(".drop-before, .drop-after").forEach((el) => el.classList.remove("drop-before", "drop-after"));
509
532
  const endDrag = () => {
510
533
  dirDrag = null;
@@ -564,8 +587,8 @@ export function renderSidebar() {
564
587
  h(
565
588
  "button",
566
589
  { class: "conv-item proj", title: `${dir}\n拖动可调整顺序,右键可置顶`, onclick: () => toggleSide("open", dir) },
567
- h("span", { class: "proj-icon", html: expanded ? ICON.folderOpen : ICON.folder }),
568
590
  h("span", { class: "title" }, baseName(dir)),
591
+ caret(!expanded),
569
592
  expanded ? null : status(convs.map((c) => c.key)),
570
593
  ),
571
594
  h(
@@ -575,11 +598,12 @@ export function renderSidebar() {
575
598
  title: `在 ${baseName(dir)} 中开新对话`,
576
599
  onclick: () => {
577
600
  S.draftCwd = dir === S.workspaceRoot ? null : dir;
601
+ S.draftCwdPicked = true;
578
602
  newDraft();
579
603
  closeSide();
580
604
  },
581
605
  },
582
- icon("edit"),
606
+ icon("plus"),
583
607
  ),
584
608
  ),
585
609
  );
@@ -591,22 +615,36 @@ export function renderSidebar() {
591
615
  // 「展开显示」按主对话算条数,分叉跟着主对话一起出现
592
616
  const forest = loadedPrefix(st, forkForest(convs));
593
617
  for (const node of forest.slice(0, st.show)) {
594
- nodes.push(renderForkNode(node, (c, orphan) => convRow(c, " sub", agentLabel(c.agent), orphan), " in-proj"));
618
+ nodes.push(renderForkNode(node, (c, orphan, fold) => convRow(c, " sub", agentLabel(c.agent), orphan, fold)));
595
619
  }
596
620
  const btn = moreButton(st, forest.length, PROJECT_LIMIT, load);
597
621
  if (btn) nodes.push(h("div", { class: "sub-more" }, btn));
598
622
  }
599
623
  }
624
+ nodes.push(...botRows.sort((a, b) => b.at - a.at).map((r) => r.el));
625
+ if (!nodes.length) nodes.push(h("div", { class: "conv-empty" }, "还没有会话"));
626
+ paintList(nodes, askKeys.size);
627
+ }
628
+
629
+ /** 把一组节点画进会话列表 */
630
+ function paintList(nodes, asks) {
600
631
  // 重绘会换掉 DOM:如果鼠标正停在某个标题上,重绘后接着滚
601
632
  const hovered = marquee.el ? marquee.el.textContent : null;
602
633
  stopMarquee();
603
634
  fill(ui.convList, ...nodes);
635
+ markClipped();
636
+ if (!clipObserver) {
637
+ clipObserver = new ResizeObserver(() => markClipped());
638
+ }
639
+ clipObserver.disconnect();
640
+ clipObserver.observe(ui.convList);
641
+ // hover 显示专家图标时,标题的可用宽度也会变化
642
+ for (const el of ui.convList.querySelectorAll(".conv-item .title")) clipObserver.observe(el);
604
643
  if (hovered) {
605
644
  requestAnimationFrame(() => {
606
645
  const el = ui.convList.querySelector(".conv-item:hover .title");
607
646
  if (el?.textContent === hovered) startMarquee(el);
608
647
  });
609
648
  }
610
- const asks = askKeys.size;
611
649
  document.title = asks ? `(${asks}) 待处理 · Agent Loft` : "Agent Loft";
612
650
  }
@@ -8,9 +8,10 @@ import { autosize, hideKeyboardForMenu, sendMessage, updateSendBtn } from "./com
8
8
  // ---------- 斜杠命令补全 ----------
9
9
  //
10
10
  // 输入框里只有「/xxx」(还没打空格)时弹出命令表,顺序就是设置 → 命令里排好的。
11
- // 列表按 agent + 会话目录缓存一分钟:Claude 的原生命令要起一次进程才问得到。
11
+ // 列表按 agent + 工作目录缓存:提前加载,过期后先用已有列表、后台刷新。
12
12
 
13
- export const slash = { open: false, shown: false, items: [], index: 0, cache: new Map(), token: 0 };
13
+ export const slash = { open: false, shown: false, items: [], index: 0, cache: new Map(), pending: new Map(), token: 0, contextKey: null };
14
+ let cacheEpoch = 0;
14
15
 
15
16
  export function commandUsage(c) {
16
17
  return `/${c.name}${c.args ? ` ${c.args}` : ""}`;
@@ -26,15 +27,62 @@ export function currentAgentId() {
26
27
  return c?.agent ?? S.draftAgent ?? usableAgents()[0]?.id ?? "claude";
27
28
  }
28
29
 
29
- async function loadCommands(agent) {
30
- const cacheKey = `${agent}|${S.current ?? ""}`;
31
- const hit = slash.cache.get(cacheKey);
32
- if (hit && Date.now() - hit.at < 60_000) return hit.list;
33
- const q = S.current ? `?key=${encodeURIComponent(S.current)}` : "";
34
- const data = await api(`/api/agents/${agent}/commands${q}`);
35
- const list = data.commands.filter((c) => !c.hidden);
36
- slash.cache.set(cacheKey, { at: Date.now(), list });
37
- return list;
30
+ function commandContext(agent = currentAgentId()) {
31
+ const conv = S.current ? S.convs.get(S.current) : null;
32
+ const cwd = conv?.cwd ?? S.draftCwd ?? S.workspaceRoot ?? "";
33
+ const query = new URLSearchParams({ channel: "web" });
34
+ if (conv) query.set("key", conv.key);
35
+ else if (cwd) query.set("cwd", cwd);
36
+ return { cacheKey: JSON.stringify([agent, cwd]), url: `/api/agents/${agent}/commands?${query}` };
37
+ }
38
+
39
+ function refreshCommands({ cacheKey, url }) {
40
+ const pending = slash.pending.get(cacheKey);
41
+ if (pending) return pending;
42
+ const epoch = cacheEpoch;
43
+ const request = api(url).then((data) => {
44
+ const list = data.commands.filter((c) => !c.hidden);
45
+ if (epoch === cacheEpoch) {
46
+ slash.cache.set(cacheKey, { at: Date.now(), list });
47
+ if (slash.open && ui.input?.isConnected && commandContext().cacheKey === cacheKey) void updateSlashMenu();
48
+ }
49
+ return list;
50
+ }).finally(() => {
51
+ if (slash.pending.get(cacheKey) === request) slash.pending.delete(cacheKey);
52
+ });
53
+ slash.pending.set(cacheKey, request);
54
+ return request;
55
+ }
56
+
57
+ function loadCommands(agent) {
58
+ const context = commandContext(agent);
59
+ const hit = slash.cache.get(context.cacheKey);
60
+ if (hit && Date.now() - hit.at < 60_000) return Promise.resolve(hit.list);
61
+ const request = refreshCommands(context);
62
+ if (hit) {
63
+ void request.catch(() => {});
64
+ return Promise.resolve(hit.list);
65
+ }
66
+ return request;
67
+ }
68
+
69
+ /** 后台预加载,不阻塞页面;输入 / 时复用同一份进行中的请求 */
70
+ export function preloadCommands() {
71
+ const agent = currentAgentId();
72
+ if (!usableAgents().some((a) => a.id === agent)) return;
73
+ void loadCommands(agent).catch(() => {});
74
+ if (slash.open && slash.contextKey !== commandContext(agent).cacheKey) {
75
+ closeSlashMenu();
76
+ void updateSlashMenu();
77
+ }
78
+ }
79
+
80
+ /** 换账号、修改命令设置时作废旧缓存和在途请求的结果 */
81
+ export function clearCommandCache() {
82
+ cacheEpoch++;
83
+ slash.cache.clear();
84
+ slash.pending.clear();
85
+ closeSlashMenu();
38
86
  }
39
87
 
40
88
  function slashQuery() {
@@ -60,6 +108,8 @@ export async function updateSlashMenu() {
60
108
  const q = slashQuery();
61
109
  if (q === null) return closeSlashMenu();
62
110
  const token = ++slash.token;
111
+ const contextKey = commandContext().cacheKey;
112
+ slash.contextKey = contextKey;
63
113
  if (!slash.open) renderSlashMenu(null);
64
114
  let list;
65
115
  try {
@@ -69,7 +119,7 @@ export async function updateSlashMenu() {
69
119
  return;
70
120
  }
71
121
  // 等待期间又打了字:以最新的那次为准
72
- if (token !== slash.token || slashQuery() === null) return;
122
+ if (token !== slash.token || slashQuery() === null || commandContext().cacheKey !== contextKey) return;
73
123
  const items = matchCommands(list, slashQuery());
74
124
  if (items.length === 0) return closeSlashMenu();
75
125
  slash.items = items;
@@ -133,6 +183,7 @@ export function closeSlashMenu() {
133
183
  slash.shown = false;
134
184
  slash.items = [];
135
185
  slash.index = 0;
186
+ slash.contextKey = null;
136
187
  slash.token++;
137
188
  if (ui.slashMenu) ui.slashMenu.hidden = true;
138
189
  }
@@ -25,8 +25,8 @@ export function renderTopbar() {
25
25
  ? h("span", { class: "conv-name" }, tasks ? "定时任务" : "远程控制")
26
26
  : c
27
27
  ? [
28
- // 自定义专家的对话:标题前面挂上专家的图标
29
- c.expert && !c.expert.builtin ? h("span", { class: "conv-expert-icon", title: `专家:${c.expert.name}` }, expertIcon(convExpert(c))) : null,
28
+ // 标题前面是专家的头像:点一下或鼠标停上去,看专家的信息和工作目录
29
+ expertAvatarButton(c),
30
30
  h("span", { class: "conv-name", title: convTitle(c) }, convTitle(c)),
31
31
  ]
32
32
  : null,
@@ -38,6 +38,107 @@ export function renderTopbar() {
38
38
  syncDesktopMenu();
39
39
  }
40
40
 
41
+ // ---------- 顶栏的专家头像和信息卡 ----------
42
+
43
+ const ACCESS_LABEL = { web: "只能联网", read: "能读文件", edit: "能改文件", exec: "能跑命令" };
44
+ const ENGINE_LABEL = { claude: "Claude", codex: "Codex" };
45
+ /** 鼠标停多久才弹、离开多久才收(从头像挪到卡片上的那一下不能收) */
46
+ const HOVER_OPEN_MS = 250;
47
+ const HOVER_CLOSE_MS = 200;
48
+ const hoverCard = { timer: 0, pinned: false };
49
+
50
+ function expertAvatarButton(c) {
51
+ const btn = h(
52
+ "button",
53
+ {
54
+ class: "conv-expert-icon",
55
+ "aria-label": `专家:${c.expert?.name ?? agentLabel(c.agent)}`,
56
+ onclick: () => {
57
+ clearTimeout(hoverCard.timer);
58
+ // 已经是悬停弹出来的:点一下就钉住,不随鼠标离开收起
59
+ if (ui.menu?.dataset.for === "expert-info" && !hoverCard.pinned) {
60
+ hoverCard.pinned = true;
61
+ return;
62
+ }
63
+ if (ui.menu?.dataset.for === "expert-info") return closeMenu();
64
+ openExpertCard(btn, c.key, true);
65
+ },
66
+ onpointerenter: (e) => {
67
+ if (e.pointerType !== "mouse") return;
68
+ clearTimeout(hoverCard.timer);
69
+ if (ui.menu?.dataset.for === "expert-info") return;
70
+ hoverCard.timer = setTimeout(() => openExpertCard(btn, c.key, false), HOVER_OPEN_MS);
71
+ },
72
+ onpointerleave: (e) => {
73
+ if (e.pointerType === "mouse") scheduleCardClose();
74
+ },
75
+ },
76
+ expertIcon(convExpert(c)),
77
+ );
78
+ return btn;
79
+ }
80
+
81
+ function scheduleCardClose() {
82
+ clearTimeout(hoverCard.timer);
83
+ hoverCard.timer = setTimeout(() => {
84
+ if (!hoverCard.pinned && ui.menu?.dataset.for === "expert-info") closeMenu();
85
+ }, HOVER_CLOSE_MS);
86
+ }
87
+
88
+ /** 专家信息卡:头像、名字、说明,引擎、模型、权限,当前工作目录(能读文件的才有) */
89
+ function openExpertCard(anchor, key, pinned) {
90
+ const c = S.convs.get(key);
91
+ if (!c || !anchor.isConnected) return;
92
+ const pop = showPopover(anchor, { place: "below", align: "left" });
93
+ pop.dataset.for = "expert-info";
94
+ pop.classList.add("expert-card");
95
+ hoverCard.pinned = pinned;
96
+ pop.onpointerenter = () => clearTimeout(hoverCard.timer);
97
+ pop.onpointerleave = (e) => {
98
+ if (e.pointerType === "mouse") scheduleCardClose();
99
+ };
100
+ const badge = convExpert(c);
101
+ // 自己的专家:说明、联网这些在 S.experts 里(别人的专家只有徽章上那点)
102
+ const mine = badge.builtin ? null : S.experts.find((e) => e.id === badge.id);
103
+ const access = badge.builtin ? null : (mine?.access ?? badge.access);
104
+ const abilities = badge.builtin
105
+ ? "原装的样子:所有工具"
106
+ : [
107
+ mine?.webSearch !== false ? "联网搜索" : null,
108
+ mine?.webFetch !== false && c.agent === "claude" ? "读网页" : null,
109
+ access && access !== "web" ? ACCESS_LABEL[access]?.replace(/^能/, "") : null,
110
+ ]
111
+ .filter(Boolean)
112
+ .join("、") || "只能聊天";
113
+ const model = modelName(c.agent, c.runtimeModel || c.model);
114
+ const effort = c.runtimeEffort || c.effort;
115
+ const row = (label, ...value) => h("div", { class: "ec-row" }, h("span", { class: "ec-label" }, label), h("span", { class: "ec-value" }, ...value));
116
+ fill(
117
+ pop,
118
+ h(
119
+ "div",
120
+ { class: "ec-head" },
121
+ expertIcon(badge, "ec-avatar"),
122
+ h(
123
+ "div",
124
+ { class: "ec-name" },
125
+ h("b", {}, badge.name),
126
+ h("span", { class: "ec-sub" }, badge.builtin ? "内置专家" : badge.missing ? "这个专家已经删除了" : `自定义专家 · ${ENGINE_LABEL[c.agent] ?? c.agent}`),
127
+ ),
128
+ ),
129
+ mine?.description ? h("div", { class: "ec-desc" }, mine.description) : null,
130
+ h(
131
+ "div",
132
+ { class: "ec-rows" },
133
+ row("引擎", agentLabel(c.agent)),
134
+ row("模型", [model ?? "默认", effort ? ` · ${effort}` : ""].join("")),
135
+ row("能力", abilities),
136
+ access === "web" ? null : row("工作目录", h("span", { class: "ec-cwd", title: c.cwd }, c.cwd)),
137
+ ),
138
+ );
139
+ placePopover(pop, anchor);
140
+ }
141
+
41
142
  /**
42
143
  * 右上角「更多」里的项。对话页(含新对话)有定时发送;设置哪个页面都有,
43
144
  * 桌面端自己的「更多」里已经有每台服务器的设置时不放
@@ -195,7 +296,7 @@ export function usableAgents() {
195
296
  return usable.length ? usable : enabled;
196
297
  }
197
298
 
198
- /** 新对话里选专家:内置的在前,再是自己的;最下面去设置里管理 */
299
+ /** 新对话里选专家:统一列表,简介在悬停时显示(新建、管理在「设置 → 专家」里) */
199
300
  function pickExpertMenu(anchor) {
200
301
  if (ui.menu?.dataset.for === "expert") return closeMenu();
201
302
  const pop = showPopover(anchor, { align: "left" });
@@ -207,18 +308,10 @@ function pickExpertMenu(anchor) {
207
308
  "button",
208
309
  { class: `pop-item${e.id === S.draftExpert ? " on" : ""}`, title: e.description || "", onclick: () => (closeMenu(), switchAgent(e.id)) },
209
310
  expertIcon(e),
210
- h("span", { class: "grow" }, h("span", { class: "t" }, e.name), e.description ? h("span", { class: "s" }, e.description) : null),
311
+ h("span", { class: "grow" }, h("span", { class: "t" }, e.name)),
211
312
  e.id === S.draftExpert ? h("span", { class: "check" }, "✓") : null,
212
313
  );
213
- const builtin = choices.filter((e) => e.builtin);
214
- const own = choices.filter((e) => !e.builtin);
215
- fill(
216
- pop,
217
- builtin.map(item),
218
- own.length ? [h("div", { class: "sep" }), h("div", { class: "pop-head" }, "我的专家"), own.map(item)] : null,
219
- h("div", { class: "sep" }),
220
- h("button", { class: "pop-item", onclick: () => (closeMenu(), openSettings("专家")) }, icon("gear"), h("span", { class: "grow" }, own.length ? "管理专家…" : "新建专家…")),
221
- );
314
+ fill(pop, choices.map(item));
222
315
  placePopover(pop, anchor);
223
316
  }
224
317