|
@@ -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 { Icon } from "@opencode-ai/ui/icon"
|
|
|
import {
|
|
import {
|
|
|
paasRecord,
|
|
paasRecord,
|
|
@@ -8,19 +8,10 @@ import {
|
|
|
paasText,
|
|
paasText,
|
|
|
type PaasPlatform,
|
|
type PaasPlatform,
|
|
|
} from "@/paas"
|
|
} from "@/paas"
|
|
|
|
|
+import { groupPaasFiles, type PaasGeneratedFile } from "./file-groups"
|
|
|
import type { PaasPreviewFile } from "./preview"
|
|
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()
|
|
const extension = file.name.split(".").pop()?.toLowerCase()
|
|
|
return extension ? extension.toUpperCase() : "文件"
|
|
return extension ? extension.toUpperCase() : "文件"
|
|
|
}
|
|
}
|
|
@@ -33,8 +24,9 @@ export function PaasGeneratedFiles(props: {
|
|
|
selected?: PaasPreviewFile
|
|
selected?: PaasPreviewFile
|
|
|
onPreview?: (file: PaasPreviewFile) => void
|
|
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
|
|
const current = props.selected
|
|
|
return (
|
|
return (
|
|
|
!!current &&
|
|
!!current &&
|
|
@@ -69,62 +61,68 @@ export function PaasGeneratedFiles(props: {
|
|
|
artifactID: paasText(file.artifact_id) || paasText(file.id),
|
|
artifactID: paasText(file.artifact_id) || paasText(file.id),
|
|
|
mime: paasText(file.mime_type),
|
|
mime: paasText(file.mime_type),
|
|
|
size: typeof file.size === "number" ? file.size : undefined,
|
|
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 workspace = (Array.isArray(paasRecord(work)?.files) ? paasRows(work, "files") : []).flatMap((value) => {
|
|
|
const file = paasRecord(value)
|
|
const file = paasRecord(value)
|
|
|
const name = paasText(file?.name) || paasText(file?.path)?.split("/").at(-1)
|
|
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 [
|
|
return [
|
|
|
{
|
|
{
|
|
|
name,
|
|
name,
|
|
|
path: paasText(file.path),
|
|
path: paasText(file.path),
|
|
|
mime: paasText(file.mime_type),
|
|
mime: paasText(file.mime_type),
|
|
|
size: typeof file.size === "number" ? file.size : undefined,
|
|
size: typeof file.size === "number" ? file.size : undefined,
|
|
|
- } satisfies GeneratedFile,
|
|
|
|
|
|
|
+ } satisfies PaasGeneratedFile,
|
|
|
]
|
|
]
|
|
|
})
|
|
})
|
|
|
setFiles([...artifacts, ...workspace])
|
|
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 (
|
|
return (
|
|
|
- <Show when={files().length}>
|
|
|
|
|
|
|
+ <Show when={groups().files.length}>
|
|
|
<section class="paas-file-cards" aria-label="生成文件">
|
|
<section class="paas-file-cards" aria-label="生成文件">
|
|
|
<header>
|
|
<header>
|
|
|
<strong>生成文件</strong>
|
|
<strong>生成文件</strong>
|
|
|
- <span>{files().length}</span>
|
|
|
|
|
|
|
+ <span>{groups().files.length}</span>
|
|
|
</header>
|
|
</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>
|
|
</section>
|
|
|
</Show>
|
|
</Show>
|
|
|
)
|
|
)
|