Просмотр исходного кода

feat(paas): open previews from run details

241880436@seecoder.cn 4 дней назад
Родитель
Сommit
5d5012f93b

+ 4 - 0
packages/app/src/pages/paas/chat.tsx

@@ -930,6 +930,7 @@ export function PaasChat(props: {
                             focused={!!message.runID && state.focusRun === message.runID}
                             latest={current()?.messages.at(-1)?.id === message.id}
                             onUpdate={(run) => model.update(chatID, message.id, run)}
+                            onPreviewFile={props.onPreviewFile}
                           />
                         </Show>
                       </Show>
@@ -1155,6 +1156,7 @@ function ResearchRunDetails(props: {
   latest: boolean
   focused: boolean
   onUpdate: (run: Record<string, unknown>) => void
+  onPreviewFile?: (file: PaasPreviewFile) => void
 }) {
   const [state, setState] = createStore({ open: working(props.message) || props.latest || props.focused })
   createEffect(
@@ -1191,6 +1193,7 @@ function ResearchRunDetails(props: {
               runID={props.message.runID!}
               hideOutput
               onUpdate={props.onUpdate}
+              onPreviewFile={props.onPreviewFile}
             />
           </Show>
         </details>
@@ -1203,6 +1206,7 @@ function ResearchRunDetails(props: {
           runID={props.message.runID!}
           hideOutput
           onUpdate={props.onUpdate}
+          onPreviewFile={props.onPreviewFile}
         />
       </section>
     </Show>

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

@@ -39,7 +39,7 @@ export function PaasGeneratedFiles(props: {
     const api = props.api
     const runID = props.runID
     const status = props.status || ""
-    const ready = paasTerminalStatuses.has(status) || status.startsWith("waiting")
+    const ready = paasTerminalStatuses.has(status) || status.startsWith("waiting") || status === "paused"
     const current = ++request
     if (!api || !runID || !ready) {
       setFiles([])

+ 36 - 0
packages/app/src/pages/paas/run-panel.tsx

@@ -15,6 +15,7 @@ import {
   type PaasPlatform,
   type PaasRequest,
 } from "@/paas"
+import type { PaasPreviewFile } from "./preview"
 
 const active = new Set([
   "running",
@@ -36,6 +37,7 @@ export function PaasRunPanel(props: {
   runID: string
   hideOutput?: boolean
   onUpdate?: (run: Record<string, unknown>) => void
+  onPreviewFile?: (file: PaasPreviewFile) => void
 }) {
   const platform = usePlatform()
   const [state, setState] = createStore({
@@ -343,6 +345,23 @@ export function PaasRunPanel(props: {
               <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}
@@ -392,6 +411,23 @@ export function PaasRunPanel(props: {
           <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}