Explorar o código

feat(paas): make agents easier to scan

Replace identical agent icons with stable monogram identity colors,
filter the directory locally by name, description or id, and omit the
repeated missing-description placeholder.
241880436@seecoder.cn hai 5 días
pai
achega
f65a2c826b

+ 1 - 1
PAAS_FRONTEND_DESIGN_REVIEW.zh-CN.md

@@ -11,7 +11,7 @@
 
 推荐的视觉方向是 **“安静的研究控制台”**:中性底色、单一蓝色重点、克制的边框和阴影、清楚的阅读轴,以及少量有辨识度的身份色。它应该像一个长期使用的科研工作台,而不是一个演示型仪表盘。
 
-实施状态(2026-11-29):P0 已完成——历史侧栏只显示真正使用过的智能体、组可折叠、组标题降到 13 px/500;侧栏增加全局“+ 新会话”;待确认内容移出“任务控制与确认”折叠层并前置;任务页与顶栏的重复计数已去除;归档降为文字开关;输入区删除常驻快捷键脚注和“草稿已保留”,快捷键移入输入框提示,智能体选择器加宽到可完整显示常见名称;报告阅读、续研、资源检查和任务处理已各自收敛为一个重点动作。自动化 30/30 通过。P1/P2 尚未开始。
+实施状态(2026-11-29):P0 已完成——历史侧栏只显示真正使用过的智能体、组可折叠、组标题降到 13 px/500;侧栏增加全局“+ 新会话”;待确认内容移出“任务控制与确认”折叠层并前置;任务页与顶栏的重复计数已去除;归档降为文字开关;输入区删除常驻快捷键脚注和“草稿已保留”,快捷键移入输入框提示,智能体选择器加宽到可完整显示常见名称;报告阅读、续研、资源检查和任务处理已各自收敛为一个重点动作。P1 已启动:智能体使用首字头像与低饱和身份色、本地搜索、无描述占位收敛。自动化 31/31 通过。P1 剩余任务是任务页扫读、设置页两栏和输入区轻表面;P2 尚未开始。
 
 ## 1. 用户与体验目标
 

+ 3 - 1
PAAS_FRONTEND_REDESIGN_PLAN.zh-CN.md

@@ -35,6 +35,8 @@
 
 历史索引与待确认层级(2026-11-29):侧栏不再遍历全部智能体,只显示当前/有本地会话、草稿或远程历史的智能体;组支持展开/收起,当前组默认展开,组标题降为 13 px/500/次文字色,右侧显示会话数量。搜索只显示匹配组,未使用本机智能体不生成空组。侧栏增加全局“+ 新会话”,任务页隐藏顶栏重复计数,归档降为文字开关。待确认消息不再包在“任务控制与确认”折叠层内,改为直接显示的任务卡,并将审批内容排在进度之前;待确认时不再重复显示任务通知条。输入区删除常驻快捷键脚注和“草稿已保留”,快捷键移入输入框提示;智能体选择器改为可伸缩的 300 px 工具栏控件,长名称不再被 180 px 上限截断。报告区将“阅读与对比”设为重点、续研改为文字动作;资源页“直接开始研究”改为文字动作;待确认任务行的“处理确认”成为该页唯一实心动作。E2E 新增未使用智能体隐藏、组折叠、任意页面新会话、待确认前置和输入区精简断言,30/30 通过。截图见 `phase5-history-index-light-1280.png`、`phase5-pending-live-light-1280.png`、`phase5-tasks-light-1280.png`、`phase5-resources-light-1280.png`。P0 完成,后续进入 P1 扫读与视觉系统。
 
+智能体扫读(2026-11-29):智能体卡片用名称首字 + 由 id 稳定决定的一组低饱和身份色替代统一脑图标;无描述时不再显示“平台未提供能力说明”;目录新增本地搜索,按名称、能力说明和 id 过滤,并显示“显示 X / N 个智能体”;无匹配时给出明确空态。E2E 新增搜索与头像断言,31/31 通过。截图见 `phase3-single-nav-agents-light-1280.png`、`phase5-agents-search-light-1280.png`。P1 剩余:任务页扫读、设置页宽屏布局、输入区轻表面。
+
 ## 1. 已确认的现状
 
 已阅读工作台入口、会话、控制器、任务面板、智能体编辑、AgentPack 和样式代码,并操作真实组件的隔离预览。暗色观察覆盖 1280、900、600 px 宽度;本次亮色测量采用 1280×800 视口,并确认实际生效的主题为 light。
@@ -316,7 +318,7 @@ Enter 发送、Shift+Enter 换行和中文输入法组合行为保持明确。
 | 字体、色彩、阴影 | 已统一蓝色重点色与语义 token;关键文字/状态对比度 5.12–10.35;全屏和 1024 px 阅读轴已对齐;CSS 重复选择器仍在 | `paas.css`;`phase4-fullscreen-chat-light-1707.png`、`phase4-fullscreen-agents-light-1707.png` | 清理重复选择器,并补测焦点与触控细节 |
 | 单侧导航、600 px 侧栏 | 桌面 240 px 单栏导航+历史;一级入口四项;历史只显示使用过的智能体并可折叠;≤1100 px 整栏为可关闭抽屉 | `chat.tsx`、`index.tsx`、`paas.css`;`phase5-history-index-light-1280.png`、`phase3-single-nav-light-1280.png`、`phase4-settings-light-1280.png` | 补测触控关闭、键盘焦点顺序与更多输入法场景 |
 | 待确认与重复状态 | 待确认卡直接前置;待确认时隐藏重复通知;任务页隐藏顶栏重复计数;报告/资源/任务各保留一个重点动作 | `chat.tsx`、`run-panel.tsx`、`index.tsx`、`tasks.tsx`、`paas.css`;`phase5-pending-live-light-1280.png`、`phase5-tasks-light-1280.png`、`phase5-resources-light-1280.png` | P0 已完成,进入 P1 的智能体扫读与设置布局 |
-| 测试与真实环境 | 隔离构建、App/E2E 类型检查、PaaS 单测 13/13、E2E 30/30 通过;真实 Electron 最大化逐页检查主页面与消息阅读轴 | `packages/app/e2e/paas`;本机 Electron 开发模式 | 真实平台审批、下载与 Electron IPC 仍需单独验收;部分操作未执行以免产生真实任务 |
+| 测试与真实环境 | 隔离构建、App/E2E 类型检查、PaaS 单测 13/13、E2E 31/31 通过;真实 Electron 最大化逐页检查主页面与消息阅读轴 | `packages/app/e2e/paas`;本机 Electron 开发模式 | 真实平台审批、下载与 Electron IPC 仍需单独验收;部分操作未执行以免产生真实任务 |
 
 Markdown、工具活动、任务详情合并与成果入口四批改动已分别提交;其余未提交改动以 `git status --short` 为准。接手后先执行 `git status --short` 和 `git diff --check`,不要丢弃、覆盖或把这些改动误认为新任务带来的差异。`PAAS_OPTIMIZATION_PLAN.zh-CN.md` 与 `packages/app/src/pages/paas/README.md` 含平台沿革;其中“尚未实现”等历史段落可能已过时,当前行为以代码和实际运行结果为准。
 

BIN=BIN
artifacts/paas-ui-review/phase3-single-nav-agents-light-1280.png


BIN=BIN
artifacts/paas-ui-review/phase5-agents-search-light-1280.png


+ 16 - 0
packages/app/e2e/paas/workbench.spec.ts

@@ -180,3 +180,19 @@ test("history hides unused agents, collapses groups and starts a new session fro
   await expect(page.locator(".paas-topbar-leading span")).toHaveText("会话")
   await expect(page.locator(".paas-chat-header h1")).toHaveText("新会话")
 })
+
+test("agent directory filters locally and keeps distinct monograms", async ({ page }) => {
+  await page.goto("/e2e/paas/index.html?groups")
+  await page.getByLabel("平台地址", { exact: true }).fill("https://research.example")
+  await page.getByLabel("API Key", { exact: true }).fill("test-only")
+  await page.getByRole("button", { name: "连接平台", exact: true }).click()
+  await page.locator('.paas-sidebar nav button[aria-label="智能体"]').click()
+  const cards = page.locator(".paas-agent-card")
+  await expect(cards).toHaveCount(2)
+  await page.getByLabel("搜索智能体", { exact: true }).fill("未使用")
+  await expect(cards).toHaveCount(1)
+  await expect(cards.locator("h2")).toHaveText("未使用智能体")
+  await expect(cards.locator(".paas-agent-monogram")).toHaveText("未")
+  await page.getByLabel("搜索智能体", { exact: true }).fill("")
+  await expect(cards).toHaveCount(2)
+})

+ 72 - 10
packages/app/src/pages/paas/index.tsx

@@ -28,6 +28,29 @@ const pages = [
   { id: "connection", icon: "server", name: "平台设置" },
 ] as const
 
+const agentTones = [
+  ["#315fce", "#83a8ff"],
+  ["#7c3aed", "#c4b5fd"],
+  ["#0f766e", "#7dd8b5"],
+  ["#b45309", "#f3c77a"],
+  ["#be185d", "#f9a8d4"],
+  ["#0369a1", "#7dd3fc"],
+] as const
+
+function agentTone(agent: Record<string, unknown>) {
+  const key = paasText(agent.id) || paasText(agent.name)
+  let hash = 0
+  for (const char of key) hash = (hash * 31 + (char.codePointAt(0) ?? 0)) % 100000
+  const tone = agentTones[hash % agentTones.length]
+  return `light-dark(${tone[0]}, ${tone[1]})`
+}
+
+function agentInitial(agent: Record<string, unknown>) {
+  const chars = Array.from(paasText(agent.name) || paasText(agent.id))
+  const first = chars[0] || "?"
+  return /^[a-z]/i.test(first) ? chars.slice(0, 2).join("").toUpperCase() : first
+}
+
 export default function PaasWorkspace(props: { standalone?: boolean; onOpenDeveloper?: () => void } = {}) {
   const platform = usePlatform()
   const dialog = useDialog()
@@ -45,6 +68,7 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
     chatAgentID: "",
     openingWorkspace: false,
     navOpen: false,
+    agentSearch: "",
     editAgentID: "",
     editReturn: "agents",
   })
@@ -109,6 +133,16 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
 
   const localServer = () => server?.list.find(ServerConnection.builtin) ?? server?.list.find(ServerConnection.local)
   const settingsPage = () => state.page === "connection" || state.page === "resources"
+  const visibleAgents = () => {
+    const query = ui.agentSearch.trim().toLocaleLowerCase()
+    if (!query) return state.agents
+    return state.agents.filter((agent) =>
+      [paasText(agent.name), paasText(agent.description), paasText(agent.id)]
+        .join(" ")
+        .toLocaleLowerCase()
+        .includes(query),
+    )
+  }
   const pageLabel = () => {
     if (state.page === "edit-agent") return "编辑智能体"
     if (settingsPage()) return "平台设置"
@@ -471,10 +505,22 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
                 <div>
                   <h1>智能体</h1>
                   <Show when={state.connected}>
-                    <p class="paas-muted">共 {state.agents.length} 个智能体</p>
+                    <p class="paas-muted">
+                      {ui.agentSearch.trim()
+                        ? `显示 ${visibleAgents().length} / ${state.agents.length} 个智能体`
+                        : `共 ${state.agents.length} 个智能体`}
+                    </p>
                   </Show>
                 </div>
                 <div class="paas-directory-actions">
+                  <input
+                    class="paas-directory-search"
+                    type="search"
+                    aria-label="搜索智能体"
+                    placeholder="搜索名称或能力"
+                    value={ui.agentSearch}
+                    onInput={(event) => setUI("agentSearch", event.currentTarget.value)}
+                  />
                   <button type="button" disabled={disabled()} onClick={workspace.catalog}>
                     <Icon name="reset" size="small" />
                     刷新
@@ -506,16 +552,26 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
                 </p>
               </Show>
               <Show
-                when={state.agents.length}
+                when={visibleAgents().length}
                 fallback={
                   <Empty
-                    title={state.connected ? "暂未发现智能体" : "连接后查看智能体"}
-                    text="平台目录为空、发现未完成或尚未连接时,不会显示演示智能体。"
+                    title={
+                      !state.agents.length
+                        ? state.connected
+                          ? "暂未发现智能体"
+                          : "连接后查看智能体"
+                        : "没有匹配的智能体"
+                    }
+                    text={
+                      !state.agents.length
+                        ? "平台目录为空、发现未完成或尚未连接时,不会显示演示智能体。"
+                        : "换个关键词,或清空搜索查看全部智能体。"
+                    }
                   />
                 }
               >
                 <div class="paas-directory-grid">
-                  <For each={state.agents}>
+                  <For each={visibleAgents()}>
                     {(agent) => {
                       const id = () => paasText(agent.id)
                       const name = () => paasText(agent.name)
@@ -539,8 +595,12 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
                       return (
                         <article class="paas-agent-card">
                           <header>
-                            <span class="paas-agent-card-icon" aria-hidden="true">
-                              <Icon name="brain" size="large" />
+                            <span
+                              class="paas-agent-card-icon paas-agent-monogram"
+                              aria-hidden="true"
+                              style={{ "--agent-tone": agentTone(agent) }}
+                            >
+                              {agentInitial(agent)}
                             </span>
                             <div class="paas-agent-card-identity">
                               <h2 title={name()}>{name()}</h2>
@@ -564,9 +624,11 @@ export default function PaasWorkspace(props: { standalone?: boolean; onOpenDevel
                               </DropdownMenu.Portal>
                             </DropdownMenu>
                           </header>
-                          <p class="paas-agent-card-description" title={paasText(agent.description)}>
-                            {paasText(agent.description) || "平台未提供能力说明。"}
-                          </p>
+                          <Show when={paasText(agent.description)}>
+                            <p class="paas-agent-card-description" title={paasText(agent.description)}>
+                              {paasText(agent.description)}
+                            </p>
+                          </Show>
                           <footer>
                             <button
                               type="button"

+ 20 - 0
packages/app/src/pages/paas/paas.css

@@ -2657,3 +2657,23 @@
   border-color: transparent;
   background: color-mix(in srgb, var(--paas-accent) 6%, transparent);
 }
+
+/* Agent identity and local directory search. */
+.paas-agent-card-icon.paas-agent-monogram {
+  background: color-mix(in srgb, var(--agent-tone) 14%, var(--background-base));
+  color: var(--agent-tone);
+  font-size: 15px;
+  font-weight: 600;
+  letter-spacing: 0.2px;
+}
+.paas-workspace .paas-directory-search {
+  flex: 0 1 220px;
+  width: 220px;
+  padding-block: 8px;
+}
+@media (max-width: 720px) {
+  .paas-workspace .paas-directory-search {
+    flex-basis: 100%;
+    width: 100%;
+  }
+}