ソースを参照

feat(paas): finalize research inbox

Harden the current-project inbox entry and panel after review: keep a
recreated panel closed, scope Escape to the panel, scroll long lists,
drop dead task-shortcut styles, cap the entry icon, and extend browser
acceptance to exact counts, conversation opening, outside clicks and
approval persistence.
241880436@seecoder.cn 4 日 前
親
コミット
cdedccfac7

+ 39 - 8
packages/app/e2e/paas/inbox.spec.ts

@@ -8,15 +8,21 @@ test("completed research appears in inbox until opened", async ({ page }) => {
     .getByRole("button", { name: /已有研究/ })
     .first()
     .click()
-  const inbox = page.getByRole("button", { name: /待处理/ })
-  await expect(inbox).toContainText("1")
+  const inbox = page.getByRole("button", { name: "待处理 1 项", exact: true })
+  await expect(inbox).toBeVisible()
+  await page.getByRole("button", { name: "平台任务", exact: true }).click()
+  await expect(page.getByRole("heading", { name: "平台任务", exact: true })).toBeVisible()
+  await expect(page.getByRole("heading", { name: "研究计划", exact: true })).not.toBeVisible()
   await inbox.click()
-  const panel = page.getByRole("dialog", { name: "待处理" })
-  await panel.getByRole("button", { name: /已有研究/ }).click()
+  await page
+    .getByRole("dialog", { name: "待处理" })
+    .getByRole("button", { name: /已有研究/ })
+    .click()
+  await expect(page.getByRole("heading", { name: "研究计划", exact: true })).toBeVisible()
   await expect(page.getByRole("button", { name: /待处理/ })).toHaveCount(0)
 })
 
-test("inbox panel closes with Escape and restores focus", async ({ page }) => {
+test("inbox panel closes on Escape inside it and on an outside pointer click", async ({ page }) => {
   await page.goto("/e2e/paas/index.html?completed")
   await page.getByLabel("API Key", { exact: true }).fill("inbox-escape")
   await page.getByRole("button", { name: "连接平台", exact: true }).click()
@@ -24,10 +30,35 @@ test("inbox panel closes with Escape and restores focus", async ({ page }) => {
     .getByRole("button", { name: /已有研究/ })
     .first()
     .click()
-  const inbox = page.getByRole("button", { name: /待处理/ })
+  const inbox = page.getByRole("button", { name: "待处理 1 项", exact: true })
+  const panel = page.getByRole("dialog", { name: "待处理" })
   await inbox.click()
-  await expect(page.getByRole("dialog", { name: "待处理" })).toBeVisible()
+  await expect(panel).toBeVisible()
+  await page.getByRole("textbox", { name: "消息", exact: true }).focus()
   await page.keyboard.press("Escape")
-  await expect(page.getByRole("dialog", { name: "待处理" })).toHaveCount(0)
+  await expect(panel).toBeVisible()
+  await inbox.focus()
+  await page.keyboard.press("Escape")
+  await expect(panel).toHaveCount(0)
   await expect(inbox).toBeFocused()
+  await inbox.click()
+  await expect(panel).toBeVisible()
+  await page.locator(".paas-conversation").click({ position: { x: 8, y: 8 } })
+  await expect(panel).toHaveCount(0)
+})
+
+test("opening an approval keeps it listed in inbox", async ({ page }) => {
+  await page.goto("/e2e/paas/index.html")
+  await page.getByLabel("API Key", { exact: true }).fill("inbox-approval")
+  await page.getByRole("button", { name: "连接平台", exact: true }).click()
+  await page
+    .getByRole("button", { name: /已有研究/ })
+    .first()
+    .click()
+  await page.getByRole("button", { name: "待处理 1 项", exact: true }).click()
+  const panel = page.getByRole("dialog", { name: "待处理" })
+  await panel.getByRole("button", { name: /已有研究/ }).click()
+  await expect(page.getByRole("heading", { name: "研究计划", exact: true })).toBeVisible()
+  await expect(page.getByRole("dialog", { name: "待处理" })).toHaveCount(0)
+  await expect(page.getByRole("button", { name: "待处理 1 项", exact: true })).toBeVisible()
 })

+ 8 - 0
packages/app/src/pages/paas/README.md

@@ -25,6 +25,14 @@
 - 工作区助手必须绑定项目文件夹,执行时通过 `context.work_dir` 传递;未绑定时前端阻止发送并给出绑定提示。
 - 自动路由当前是确定性规则(显式指定、表格数据、工作区文件操作、论文评审、默认科研),不声称是模型级智能决策。
 
+## P0-B Research Inbox(2026-11-30)
+
+- 顶栏提供当前项目的统一待处理入口,聚合待确认、失败和完成未读。
+- Inbox 只展示真实可确认状态;待确认和失败不会因为已读而消失。
+- 完成未读的已读状态保存在本机,按平台作用域、窗口和项目隔离,不伪装成平台已读。
+- 任务索引只有在 `thread_id` 属于当前项目会话时才纳入 Inbox。
+- Inbox v1 只覆盖当前项目;跨项目全局 Inbox 留到后续计划。
+
 ---
 
 # AgentPaaS 工作台:第一阶段 GUI

+ 9 - 2
packages/app/src/pages/paas/inbox-panel.tsx

@@ -1,4 +1,4 @@
-import { For, Show, createSignal, onCleanup, onMount } from "solid-js"
+import { For, Show, createEffect, createSignal, onCleanup, onMount } from "solid-js"
 import { ResearchIcon } from "./research-icon"
 import type { InboxItem } from "./inbox"
 
@@ -8,12 +8,19 @@ export function InboxPanel(props: { items: InboxItem[]; onOpen: (item: InboxItem
   const [open, setOpen] = createSignal(false)
   let root: HTMLDetailsElement | undefined
 
+  createEffect(() => {
+    // A recreated panel must not mount open when the previous item list emptied out.
+    if (!props.items.length) setOpen(false)
+  })
+
   onMount(() => {
     const close = (event: KeyboardEvent) => {
       if (event.key !== "Escape" || !open()) return
+      // Only reclaim Escape while focus is inside the panel, so other menus keep their own handling.
+      if (!root || !(event.target instanceof Node) || !root.contains(event.target)) return
       event.preventDefault()
       setOpen(false)
-      root?.querySelector("summary")?.focus()
+      root.querySelector("summary")?.focus()
     }
     const outside = (event: PointerEvent) => {
       if (!open() || !root || (event.target instanceof Node && root.contains(event.target))) return

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

@@ -2011,10 +2011,6 @@
   margin: 6px auto;
   box-shadow: 0 2px 8px #0001;
 }
-.paas-task-shortcut {
-  margin-left: auto;
-  font-size: var(--paas-type-meta);
-}
 .paas-task-counts {
   padding: 12px 0;
 }
@@ -2051,10 +2047,6 @@
   .paas-composer footer select {
     max-width: 140px;
   }
-  .paas-task-shortcut {
-    font-size: var(--paas-type-meta);
-    padding: 3px;
-  }
 }
 
 .paas-chat-search {
@@ -2811,11 +2803,6 @@
 .paas-topbar-chat-actions:empty {
   display: none;
 }
-@media (max-width: 900px) {
-  .paas-workspace.paas-chat-mode .paas-task-shortcut {
-    display: none;
-  }
-}
 .paas-topbar-chat-actions .paas-chat-header-actions {
   position: relative;
 }

+ 11 - 1
packages/app/src/pages/paas/studio.css

@@ -822,8 +822,12 @@
 
 /* Research inbox: one quiet topbar entry so pending work is reachable from every page. */
 .paas-topbar-inbox {
+  display: flex;
+  align-items: center;
   flex-shrink: 0;
-  margin-left: auto;
+}
+.paas-topbar-inbox:empty {
+  display: none;
 }
 .paas-inbox {
   position: relative;
@@ -840,6 +844,10 @@
   cursor: pointer;
   list-style: none;
 }
+.paas-inbox > summary > .paas-research-icon {
+  width: 20px;
+  height: 20px;
+}
 .paas-inbox > summary::-webkit-details-marker {
   display: none;
 }
@@ -856,6 +864,8 @@
   display: grid;
   gap: 6px;
   width: min(360px, 82vw);
+  max-height: min(70vh, 420px);
+  overflow-y: auto;
   padding: 12px;
   border: 1px solid var(--border-weak-base);
   border-radius: 12px;