Przeglądaj źródła

fix(paas): align workbench states and group generated files

241880436@seecoder.cn 4 dni temu
rodzic
commit
14c35ae7b1

+ 19 - 3
packages/app/e2e/paas/fixture.tsx

@@ -8,15 +8,19 @@ import "../../src/index.css"
 
 // Synthetic transport, real workbench. No model or developer service is started.
 const calls: PaasRequest[] = []
+const query = new URLSearchParams(location.search)
+const filesMode = query.has("files")
+const completedMode = query.has("completed")
 const agent = { id: "research", name: "科研助手", description: "研究规划与验证", current_version: 1 }
 const unusedAgent = { id: "unused", name: "未使用智能体", description: "从未开始过会话", current_version: 1 }
-const agents = new URLSearchParams(location.search).has("groups") ? [agent, unusedAgent] : [agent]
+const agents = query.has("groups") ? [agent, unusedAgent] : [agent]
 const run: Record<string, unknown> = {
   run_id: "run_1",
   agent_id: agent.id,
   thread_id: "thread_1",
   created_at: "2026-11-29T09:00:00Z",
-  status: "waiting_human",
+  status: completedMode ? "completed" : "waiting_human",
+  ...(completedMode ? { completed_at: "2026-11-29T09:00:30Z" } : {}),
   output: [
     "## 研究计划",
     "已整理材料并生成以下步骤:",
@@ -38,7 +42,13 @@ const run: Record<string, unknown> = {
     "[查看平台任务](https://research.example/tasks/run_1)",
   ].join("\n"),
   pending_approval: { approval_id: "approval_1", prompt: "是否执行验证?" },
-  artifacts: [{ artifact_id: "artifact_1", name: "研究计划成果.pdf" }],
+  artifacts: filesMode
+    ? [
+        { artifact_id: "artifact_1", name: "研究计划成果.pdf" },
+        { artifact_id: "artifact_2", name: "manifest.json" },
+        { artifact_id: "artifact_3", name: "manifest.json" },
+      ]
+    : [{ artifact_id: "artifact_1", name: "研究计划成果.pdf" }],
   events: [
     { type: "tool_call", tool: "file_search", content: "查找材料目录" },
     { type: "tool_result", tool: "file_search", content: "找到 2 份材料" },
@@ -265,6 +275,12 @@ const api: PaasPlatform = {
         files: [
           { name: "研究计划.pdf", path: "final/研究计划.pdf" },
           { name: ux.previewName || "研究计划.md", path: "final/研究计划.md" },
+          ...(filesMode
+            ? [
+                { name: "config.yml", path: "work/config.yml" },
+                { name: "trace.json", path: "work/trace.json" },
+              ]
+            : []),
         ],
       }
     if (request.action === "preview-file") {

+ 81 - 0
packages/app/e2e/paas/qa-fixes.spec.ts

@@ -0,0 +1,81 @@
+import { expect, test, type Page } from "@playwright/test"
+
+async function connect(page: Page, query = "") {
+  await page.goto(`/e2e/paas/index.html${query}`)
+  await page.getByLabel("API Key", { exact: true }).fill("qa-fixes")
+  await page.getByRole("button", { name: "连接平台", exact: true }).click()
+  await expect(page.getByRole("textbox", { name: "消息", exact: true })).toBeEnabled()
+}
+
+test("all primary page bars share one height and right edge", async ({ page }) => {
+  await page.setViewportSize({ width: 1280, height: 800 })
+  await connect(page, "?os=windows")
+  const pages = ["会话", "智能体", "平台任务", "平台设置"]
+  const boxes = []
+  for (const name of pages) {
+    await page.getByRole("button", { name, exact: true }).click()
+    await expect(page.locator(".paas-topbar-page")).toHaveText(name)
+    boxes.push(
+      await page.locator(".paas-topbar").evaluate((element) => {
+        const box = element.getBoundingClientRect()
+        return { height: box.height, right: box.right }
+      }),
+    )
+  }
+  expect(new Set(boxes.map((box) => Math.round(box.height))).size).toBe(1)
+  expect(new Set(boxes.map((box) => Math.round(box.right))).size).toBe(1)
+})
+
+test("completed research does not display an elapsed-time label", async ({ page }) => {
+  await connect(page, "?completed")
+  await page
+    .getByRole("button", { name: /已有研究/ })
+    .first()
+    .click()
+  const summary = page.locator(".paas-task-summary").first()
+  await expect(summary).toContainText("已完成")
+  await expect(summary).not.toContainText("已用时")
+})
+
+test("generated files separate preview cards from collapsed technical files", async ({ page }) => {
+  await page.setViewportSize({ width: 1280, height: 800 })
+  await connect(page, "?files")
+  await page
+    .getByRole("button", { name: /已有研究/ })
+    .first()
+    .click()
+  const section = page.getByRole("region", { name: "生成文件" })
+  await expect(section.locator("header span")).toHaveText("6")
+  const card = section.getByRole("button", { name: "预览 研究计划.md", exact: true })
+  await expect(card).toBeVisible()
+  const alignment = await card.evaluate((element) => {
+    const label = element.querySelector("small")!.getBoundingClientRect()
+    const box = element.getBoundingClientRect()
+    return Math.abs(label.top + label.height / 2 - (box.top + box.height / 2))
+  })
+  expect(alignment).toBeLessThanOrEqual(1)
+  await expect(section.getByText("技术文件 · 3", { exact: true })).toBeVisible()
+  await expect(section.locator('button[aria-label="预览 manifest.json"]')).toHaveCount(1)
+  await expect(section.locator('button[aria-label="预览 trace.json"]')).toBeHidden()
+  await section.getByText("技术文件 · 3", { exact: true }).click()
+  await expect(section.getByRole("button", { name: "预览 trace.json", exact: true })).toBeVisible()
+  await expect(section.locator('button[aria-label="预览 manifest.json"]')).toHaveCount(1)
+})
+
+test("completed work files show a total and collapse technical files", async ({ page }) => {
+  await page.goto("/e2e/paas/index.html?panel")
+  await expect(page.getByRole("button", { name: "暂停", exact: true })).toBeVisible()
+  await page.evaluate(() => {
+    window.paasPanelTest.files = [
+      { name: "研究报告.md", path: "final/研究报告.md" },
+      { name: "config.json", path: "work/config.json" },
+    ]
+  })
+  await page.getByRole("button", { name: "查看工作文件", exact: true }).click()
+  await expect(page.getByRole("heading", { name: "工作文件 · 2", exact: true })).toBeVisible()
+  await expect(page.getByText("研究报告.md", { exact: true })).toBeVisible()
+  await expect(page.getByText("技术文件 · 1", { exact: true })).toBeVisible()
+  await expect(page.getByText("config.json", { exact: true })).toBeHidden()
+  await page.getByText("技术文件 · 1", { exact: true }).click()
+  await expect(page.getByText("config.json", { exact: true })).toBeVisible()
+})

+ 1 - 1
packages/app/e2e/paas/workbench.spec.ts

@@ -166,7 +166,7 @@ test("wide layout keeps messages and composer on one reading axis", async ({ pag
   await page.getByRole("textbox", { name: "消息", exact: true }).fill("分析材料并制定研究计划")
   await page.getByRole("button", { name: "发送消息", exact: true }).click()
   await page.getByRole("button", { name: "同意并继续", exact: true }).waitFor()
-  expect(await box(".paas-result-live")).toEqual(content)
+  expect(await box(".paas-result-live")).toEqual(await box(".paas-chat-messages > div"))
 })
 
 test("history hides unused agents, collapses groups and starts a new session from any page", async ({ page }) => {

+ 3 - 5
packages/app/src/pages/paas/chat.tsx

@@ -4,6 +4,7 @@ import { Portal } from "solid-js/web"
 import { ResearchReport } from "./report"
 import { ResearchIcon } from "./research-icon"
 import { PaasActivity, paasActivityItems } from "./activity"
+import { researchElapsed } from "./progress"
 import { externalToolPhase, researchToolLabel } from "./tool-label"
 import { useDialog } from "@opencode-ai/ui/context/dialog"
 import { ResearchIssue } from "./issue"
@@ -338,10 +339,7 @@ export function PaasChat(props: {
       void model.send()
     }
   }
-  const elapsed = (message: ResearchMessage) =>
-    message.started
-      ? `${Math.max(0, Math.floor(((working(message) ? ui.now : message.updated || ui.now) - message.started) / 1000))} 秒`
-      : ""
+  const elapsed = (message: ResearchMessage) => researchElapsed(message, ui.now)
   const phase = (message: ResearchMessage) => {
     if (message.status === "submitting") return "正在提交任务"
     if (message.status === "unknown") return "正在核对执行状态"
@@ -798,7 +796,7 @@ export function PaasChat(props: {
                       <Show when={message.role === "assistant"}>
                         <div class="paas-task-summary">
                           <strong>{phase(message)}</strong>
-                          <Show when={message.started}>
+                          <Show when={elapsed(message)}>
                             <span>已用时 {elapsed(message)}</span>
                           </Show>
                           <Show when={working(message) && message.updated}>

+ 29 - 0
packages/app/src/pages/paas/file-groups.ts

@@ -0,0 +1,29 @@
+import { paasPreviewKind } from "@/paas"
+
+export type PaasGeneratedFile = {
+  name: string
+  path?: string
+  artifactID?: string
+  mime?: string
+  size?: number
+}
+
+const technicalExtensions = new Set(["json", "jsonl", "yaml", "yml", "toml", "ini", "cfg", "log", "lock"])
+
+export function groupPaasFiles<T extends { name: string; mime?: string }>(files: T[]) {
+  const unique = Array.from(new Map(files.map((file) => [file.name.trim().toLocaleLowerCase(), file])).values())
+  const technical = unique.filter((file) => isTechnicalFile(file))
+  return {
+    files: unique,
+    previewable: unique.filter((file) => !isTechnicalFile(file)),
+    technical,
+  }
+}
+
+function isTechnicalFile(file: { name: string; mime?: string }) {
+  const extension = file.name.split(".").pop()?.toLocaleLowerCase()
+  return (
+    (!!extension && technicalExtensions.has(extension)) ||
+    paasPreviewKind(file.name, file.mime || "") === "unsupported"
+  )
+}

+ 46 - 48
packages/app/src/pages/paas/generated-files.tsx

@@ -1,4 +1,4 @@
-import { For, Show, createEffect, createSignal } from "solid-js"
+import { For, Show, createEffect, createMemo, createSignal } from "solid-js"
 import { Icon } from "@opencode-ai/ui/icon"
 import {
   paasRecord,
@@ -8,19 +8,10 @@ import {
   paasText,
   type PaasPlatform,
 } from "@/paas"
+import { groupPaasFiles, type PaasGeneratedFile } from "./file-groups"
 import type { PaasPreviewFile } from "./preview"
 
-type GeneratedFile = {
-  name: string
-  path?: string
-  artifactID?: string
-  mime?: string
-  size?: number
-}
-
-const internal = new Set(["input.json", "output.json", "trace.json", "cost.json", "config.yml", "config.yaml"])
-
-function typeLabel(file: GeneratedFile) {
+function typeLabel(file: PaasGeneratedFile) {
   const extension = file.name.split(".").pop()?.toLowerCase()
   return extension ? extension.toUpperCase() : "文件"
 }
@@ -33,8 +24,9 @@ export function PaasGeneratedFiles(props: {
   selected?: PaasPreviewFile
   onPreview?: (file: PaasPreviewFile) => void
 }) {
-  const [files, setFiles] = createSignal<GeneratedFile[]>([])
-  const isSelected = (file: GeneratedFile) => {
+  const [files, setFiles] = createSignal<PaasGeneratedFile[]>([])
+  const groups = createMemo(() => groupPaasFiles(files()))
+  const isSelected = (file: PaasGeneratedFile) => {
     const current = props.selected
     return (
       !!current &&
@@ -69,62 +61,68 @@ export function PaasGeneratedFiles(props: {
             artifactID: paasText(file.artifact_id) || paasText(file.id),
             mime: paasText(file.mime_type),
             size: typeof file.size === "number" ? file.size : undefined,
-          } satisfies GeneratedFile,
+          } satisfies PaasGeneratedFile,
         ]
       })
-      const artifactNames = new Set(artifacts.map((file) => file.name))
       const workspace = (Array.isArray(paasRecord(work)?.files) ? paasRows(work, "files") : []).flatMap((value) => {
         const file = paasRecord(value)
         const name = paasText(file?.name) || paasText(file?.path)?.split("/").at(-1)
-        if (!file || !name || internal.has(name.toLowerCase()) || artifactNames.has(name)) return []
+        if (!file || !name) return []
         return [
           {
             name,
             path: paasText(file.path),
             mime: paasText(file.mime_type),
             size: typeof file.size === "number" ? file.size : undefined,
-          } satisfies GeneratedFile,
+          } satisfies PaasGeneratedFile,
         ]
       })
       setFiles([...artifacts, ...workspace])
     })
   })
 
+  const card = (file: PaasGeneratedFile) => (
+    <button
+      type="button"
+      class="paas-file-card"
+      classList={{ "is-selected": isSelected(file) }}
+      aria-label={`预览 ${file.name}`}
+      onClick={() =>
+        props.onPreview?.({
+          agentID: props.agentID,
+          runID: props.runID!,
+          name: file.name,
+          path: file.path,
+          artifactID: file.artifactID,
+          mime: file.mime,
+          size: file.size,
+        })
+      }
+    >
+      <span class="paas-file-card-icon" aria-hidden="true">
+        <Icon name="open-file" size="small" />
+      </span>
+      <span class="paas-file-card-name">{file.name}</span>
+      <small>{typeLabel(file)}</small>
+      <Icon name={isSelected(file) ? "circle-check" : "layout-right"} size="small" />
+    </button>
+  )
+
   return (
-    <Show when={files().length}>
+    <Show when={groups().files.length}>
       <section class="paas-file-cards" aria-label="生成文件">
         <header>
           <strong>生成文件</strong>
-          <span>{files().length}</span>
+          <span>{groups().files.length}</span>
         </header>
-        <For each={files()}>
-          {(file) => (
-            <button
-              type="button"
-              class="paas-file-card"
-              classList={{ "is-selected": isSelected(file) }}
-              aria-label={`预览 ${file.name}`}
-              onClick={() =>
-                props.onPreview?.({
-                  agentID: props.agentID,
-                  runID: props.runID!,
-                  name: file.name,
-                  path: file.path,
-                  artifactID: file.artifactID,
-                  mime: file.mime,
-                  size: file.size,
-                })
-              }
-            >
-              <span class="paas-file-card-icon" aria-hidden="true">
-                <Icon name="open-file" size="small" />
-              </span>
-              <span class="paas-file-card-name">{file.name}</span>
-              <small>{typeLabel(file)}</small>
-              <Icon name={isSelected(file) ? "circle-check" : "layout-right"} size="small" />
-            </button>
-          )}
-        </For>
+        <For each={groups().previewable}>{card}</For>
+        <Show when={groups().technical.length}>
+          <details class="paas-file-technical">
+            <summary>技术文件 · {groups().technical.length}</summary>
+            <p class="paas-muted">JSON、YAML、日志与中间产物;展开后仍可预览或保存。</p>
+            <For each={groups().technical}>{card}</For>
+          </details>
+        </Show>
       </section>
     </Show>
   )

+ 6 - 0
packages/app/src/pages/paas/issue.tsx

@@ -17,6 +17,12 @@ export function researchIssue(message: string) {
     }
   if (/401|凭证|API.?Key/i.test(message))
     return { title: "需要更新平台连接", help: "核对平台地址与访问凭证,重新连接后可同步原任务。", action: "connection" }
+  if (/HTTP 404|ARTIFACT_NOT_FOUND|RESOURCE_NOT_FOUND|不存在或已失效|not found/i.test(message))
+    return {
+      title: "文件或资源不存在",
+      help: "文件可能已被清理,或平台记录与当前版本不一致。刷新文件列表或核对原任务后再试。",
+      action: "tasks",
+    }
   if (/403|权限|ACTIVE_PROBE_FORBIDDEN/i.test(message))
     return { title: "当前账号无此操作权限", help: "其他可用功能不受影响;请联系管理员开通所需权限。", action: "" }
   if (/429|频繁|rate.limit/i.test(message))

+ 48 - 1
packages/app/src/pages/paas/paas.css

@@ -2679,9 +2679,27 @@
 }
 
 /* Keep all four primary pages on the same topbar baseline. */
+.paas-workspace .paas-main {
+  display: flex;
+  flex-direction: column;
+  min-height: 0;
+  overflow: hidden;
+}
+.paas-workspace .paas-content {
+  flex: 1 1 auto;
+  min-height: 0;
+  margin: 0 auto;
+  overflow: auto;
+}
+.paas-workspace.paas-chat-mode .paas-content {
+  overflow: hidden;
+}
 .paas-workspace .paas-topbar {
+  flex: 0 0 62px;
   align-items: center;
+  height: 62px;
   min-height: 62px;
+  padding-block: 0;
 }
 
 /* P2 touch and keyboard targets. */
@@ -2825,7 +2843,9 @@
 
 /* Windows overlay titlebar: put the toolbar row below the native caption buttons. */
 .paas-workspace[data-os="windows"] .paas-topbar {
-  min-height: 0;
+  flex-basis: 91px;
+  height: 91px;
+  min-height: 91px;
   padding-top: 46px;
   padding-bottom: 8px;
   -webkit-app-region: drag;
@@ -3373,6 +3393,31 @@
   color: var(--text-base);
   font-size: var(--paas-type-caption);
 }
+.paas-file-cards > details,
+.paas-run-technical {
+  margin-top: 2px;
+}
+.paas-file-technical > summary,
+.paas-run-technical > summary {
+  width: fit-content;
+  padding: 6px 2px;
+  color: var(--text-weak);
+  font-size: var(--paas-type-meta);
+}
+.paas-file-technical[open] > summary,
+.paas-run-technical[open] > summary {
+  margin-bottom: 4px;
+}
+.paas-file-technical > p,
+.paas-run-technical > p {
+  margin: 0 0 6px;
+  font-size: var(--paas-type-meta);
+}
+.paas-run-files-heading {
+  margin: 18px 0 4px;
+  font-size: var(--paas-type-body);
+  font-weight: 600;
+}
 .paas-file-card {
   display: flex;
   align-items: center;
@@ -3410,8 +3455,10 @@
 }
 .paas-file-card small {
   flex-shrink: 0;
+  margin: 0;
   color: var(--text-weak);
   font-size: var(--paas-type-meta);
+  line-height: 1;
 }
 .paas-file-card > [data-component="icon"]:last-child {
   flex-shrink: 0;

+ 16 - 1
packages/app/src/pages/paas/progress.test.ts

@@ -1,5 +1,5 @@
 import { expect, test } from "bun:test"
-import { researchProgress } from "./progress"
+import { researchElapsed, researchProgress } from "./progress"
 import { researchIssue } from "./issue"
 
 test("unknown usage is not presented as zero and server research outcomes remain distinct", () => {
@@ -19,12 +19,27 @@ test("unknown usage is not presented as zero and server research outcomes remain
   expect(researchProgress({ usage: { total_tokens: -1 } }).tokens).toBeUndefined()
 })
 
+test("completed messages never show elapsed time from a later refresh timestamp", () => {
+  expect(researchElapsed({ status: "running", started: 1_000 }, 6_000)).toBe("5 秒")
+  expect(researchElapsed({ status: "completed", started: 1_000 }, 6_000)).toBe("")
+  expect(researchElapsed({ status: "completed", started: 1_000, updated: 7_000 }, 9_000)).toBe("")
+  expect(researchElapsed({ status: "waiting_human", started: 1_000, updated: 2_000 }, 6_000)).toBe("5 秒")
+})
+
 test("account balance, research budget, network and permissions suggest different recovery paths", () => {
   expect(researchIssue("Insufficient Balance").title).toBe("模型账户额度不足")
   expect(researchIssue("model_budget_exhausted").action).toBe("settings")
   expect(researchIssue("HTTP 401").action).toBe("connection")
   expect(researchIssue("HTTP 403").action).toBe("")
   expect(researchIssue("连接中断").action).toBe("tasks")
+})
+
+test("missing artifacts are not reported as an account permission problem", () => {
+  const missing = researchIssue("AgentPaaS 返回 HTTP 404,请检查权限与平台版本。")
+  expect(missing.title).toBe("文件或资源不存在")
+  expect(missing.help).toContain("刷新")
+  expect(missing.action).toBe("tasks")
+  expect(researchIssue("HTTP 403").title).toBe("当前账号无此操作权限")
   expect(researchIssue("HTTP 503:平台执行服务尚未就绪")).toMatchObject({
     title: "平台执行服务尚未就绪",
     action: "connection",

+ 6 - 1
packages/app/src/pages/paas/progress.tsx

@@ -1,7 +1,12 @@
 import { For, Show } from "solid-js"
-import { paasRecord, paasText } from "@/paas"
+import { paasRecord, paasTerminalStatuses, paasText } from "@/paas"
 import { ResearchIssue } from "./issue"
 
+export function researchElapsed(message: { status?: string; started?: number; updated?: number }, now = Date.now()) {
+  if (!message.started || !message.status || paasTerminalStatuses.has(message.status)) return ""
+  return `${Math.max(0, Math.floor((now - message.started) / 1000))} 秒`
+}
+
 /** Only project server-owned observations; missing measurements are not zero progress. */
 export function researchProgress(run: Record<string, unknown>) {
   const science = paasRecord(paasRecord(run.research)?.science) || {}

+ 103 - 85
packages/app/src/pages/paas/run-panel.tsx

@@ -1,4 +1,4 @@
-import { For, Show, createEffect, on, onCleanup } from "solid-js"
+import { For, Show, createEffect, createMemo, on, onCleanup } from "solid-js"
 import { ResearchReport } from "./report"
 import { ResearchProgress } from "./progress"
 import { ResearchIssue } from "./issue"
@@ -15,6 +15,7 @@ import {
   type PaasPlatform,
   type PaasRequest,
 } from "@/paas"
+import { groupPaasFiles } from "./file-groups"
 import type { PaasPreviewFile } from "./preview"
 
 const active = new Set([
@@ -202,6 +203,86 @@ export function PaasRunPanel(props: {
       const name = paasText(file.name) || paasText(file.path)
       return name ? [{ name, path: paasText(file.path) }] : []
     })
+  const artifactGroups = createMemo(() => groupPaasFiles(artifacts()))
+  const workFileGroups = createMemo(() => groupPaasFiles(workFiles()))
+  const artifactRow = (file: ReturnType<typeof artifacts>[number]) => (
+    <div class="paas-actions">
+      <span>{file.name}</span>
+      <Show when={file.artifactID}>
+        <Show when={props.onPreviewFile}>
+          <button
+            type="button"
+            aria-label={`预览 ${file.name}`}
+            disabled={!!state.busy}
+            onClick={() =>
+              props.onPreviewFile?.({
+                agentID: props.agentID,
+                runID: props.runID,
+                artifactID: file.artifactID,
+                name: file.name,
+              })
+            }
+          >
+            预览
+          </button>
+        </Show>
+        <button
+          type="button"
+          disabled={!!state.busy}
+          onClick={() =>
+            void perform("下载", {
+              action: "download",
+              agentID: props.agentID,
+              runID: props.runID,
+              artifactID: file.artifactID,
+              name: file.name,
+            })
+          }
+        >
+          保存成果
+        </button>
+      </Show>
+    </div>
+  )
+  const workFileRow = (file: ReturnType<typeof workFiles>[number]) => (
+    <div class="paas-actions paas-run-file">
+      <span>{file.name}</span>
+      <Show when={file.path} fallback={<span class="paas-muted">平台未返回可下载路径。</span>}>
+        <Show when={props.onPreviewFile}>
+          <button
+            type="button"
+            aria-label={`预览 ${file.name}`}
+            disabled={!!state.busy}
+            onClick={() =>
+              props.onPreviewFile?.({
+                agentID: props.agentID,
+                runID: props.runID,
+                path: file.path,
+                name: file.name,
+              })
+            }
+          >
+            预览
+          </button>
+        </Show>
+        <button
+          type="button"
+          disabled={!!state.busy}
+          onClick={() =>
+            void perform("下载", {
+              action: "download",
+              agentID: props.agentID,
+              runID: props.runID,
+              path: file.path,
+              name: file.name,
+            })
+          }
+        >
+          保存文件
+        </button>
+      </Show>
+    </div>
+  )
 
   return (
     <section class="paas-panel" aria-label="任务进度与成果">
@@ -337,50 +418,17 @@ export function PaasRunPanel(props: {
           </div>
         </details>
       </Show>
-      <Show when={artifacts().length}>
+      <Show when={artifactGroups().files.length}>
         <section class="paas-run-results" aria-label="成果">
-          <h3>成果 · {artifacts().length}</h3>
-          <For each={artifacts()}>
-            {(file) => (
-              <div class="paas-actions">
-                <span>{file.name}</span>
-                <Show when={file.artifactID}>
-                  <Show when={props.onPreviewFile}>
-                    <button
-                      type="button"
-                      aria-label={`预览 ${file.name}`}
-                      disabled={!!state.busy}
-                      onClick={() =>
-                        props.onPreviewFile?.({
-                          agentID: props.agentID,
-                          runID: props.runID,
-                          artifactID: file.artifactID,
-                          name: file.name,
-                        })
-                      }
-                    >
-                      预览
-                    </button>
-                  </Show>
-                  <button
-                    type="button"
-                    disabled={!!state.busy}
-                    onClick={() =>
-                      void perform("下载", {
-                        action: "download",
-                        agentID: props.agentID,
-                        runID: props.runID,
-                        artifactID: file.artifactID,
-                        name: file.name,
-                      })
-                    }
-                  >
-                    保存成果
-                  </button>
-                </Show>
-              </div>
-            )}
-          </For>
+          <h3>成果 · {artifactGroups().files.length}</h3>
+          <For each={artifactGroups().previewable}>{artifactRow}</For>
+          <Show when={artifactGroups().technical.length}>
+            <details class="paas-run-technical">
+              <summary>技术文件 · {artifactGroups().technical.length}</summary>
+              <p class="paas-muted">JSON、YAML、日志与中间产物;展开后仍可预览或保存。</p>
+              <For each={artifactGroups().technical}>{artifactRow}</For>
+            </details>
+          </Show>
         </section>
       </Show>
       <div class="paas-actions paas-run-files">
@@ -406,47 +454,17 @@ export function PaasRunPanel(props: {
           </details>
         </div>
       </Show>
-      <For each={workFiles()}>
-        {(file) => (
-          <div class="paas-actions paas-run-file">
-            <span>{file.name}</span>
-            <Show when={file.path} fallback={<span class="paas-muted">平台未返回可下载路径。</span>}>
-              <Show when={props.onPreviewFile}>
-                <button
-                  type="button"
-                  aria-label={`预览 ${file.name}`}
-                  disabled={!!state.busy}
-                  onClick={() =>
-                    props.onPreviewFile?.({
-                      agentID: props.agentID,
-                      runID: props.runID,
-                      path: file.path,
-                      name: file.name,
-                    })
-                  }
-                >
-                  预览
-                </button>
-              </Show>
-              <button
-                type="button"
-                disabled={!!state.busy}
-                onClick={() =>
-                  void perform("下载", {
-                    action: "download",
-                    agentID: props.agentID,
-                    runID: props.runID,
-                    path: file.path,
-                    name: file.name,
-                  })
-                }
-              >
-                保存文件
-              </button>
-            </Show>
-          </div>
-        )}
-      </For>
+      <Show when={state.filesLoaded && !state.filesLoading && !state.filesError && workFileGroups().files.length}>
+        <h3 class="paas-run-files-heading">工作文件 · {workFileGroups().files.length}</h3>
+        <For each={workFileGroups().previewable}>{workFileRow}</For>
+        <Show when={workFileGroups().technical.length}>
+          <details class="paas-run-technical">
+            <summary>技术文件 · {workFileGroups().technical.length}</summary>
+            <p class="paas-muted">JSON、YAML、日志与中间产物;展开后仍可预览或保存。</p>
+            <For each={workFileGroups().technical}>{workFileRow}</For>
+          </details>
+        </Show>
+      </Show>
     </section>
   )
 }

+ 2 - 2
packages/app/src/pages/paas/studio.css

@@ -357,7 +357,7 @@
   padding: 24px 28px;
 }
 .paas-chat-messages {
-  padding-inline: max(0px, calc((100% - 800px) / 2));
+  padding-inline: max(0px, calc((100% - 830px) / 2));
 }
 .paas-conversation > .paas-composer {
   max-width: 800px;
@@ -392,7 +392,7 @@
   color: var(--paas-accent);
 }
 .paas-conversation-empty > :is(.paas-composer, .paas-suggestions) {
-  max-width: 760px;
+  max-width: 830px;
 }
 .paas-workspace .paas-chat-welcome h2 {
   font-size: clamp(26px, 2.5vw, 32px);

+ 9 - 1
packages/desktop/src/main/paas.ts

@@ -5,6 +5,7 @@ import { isAbsolute, join } from "node:path"
 import {
   paasPreviewKind,
   paasRecord,
+  paasText,
   type PaasProgress,
   type PaasRequest,
   type PaasUploadProgress,
@@ -143,7 +144,14 @@ export function createPaasConnections(fetcher: typeof fetch = fetch) {
       }
       if (method === "PUT" && [400, 422].includes(response.status))
         throw new Error("PaaS 未接受修改,请检查配置字段及其值。")
-      throw new Error(`AgentPaaS 返回 HTTP ${response.status},请检查权限与平台版本。`)
+      if (response.status === 404) {
+        const result = paasRecord(await response.json().catch(() => undefined))
+        const code = paasText(paasRecord(result?.detail)?.code)
+        throw new Error(
+          `AgentPaaS 返回 HTTP 404${code ? `:${code}` : ""}。请求的资源不存在或已失效,请刷新后重试。`,
+        )
+      }
+      throw new Error(`AgentPaaS 返回 HTTP ${response.status},请检查请求内容与平台版本。`)
     }
     if (raw) return response
     if (stream) return readPaasStream(response, stream.progress)