feat: add workflow branches and history panel
这个提交存在于:
父节点
72caaa9390
当前提交
68d57b3fcc
共有 10 个文件被更改,包括 158 次插入 和 23 次删除
|
|
@ -12,6 +12,9 @@ export const endpoints = {
|
|||
workflowCancel: (workflowId: string) => `workflows/${workflowId}/cancel`,
|
||||
workflowArchive: (workflowId: string) => `workflows/${workflowId}/archive`,
|
||||
workflowNodes: (workflowId: string) => `workflows/${workflowId}/nodes`,
|
||||
workflowBranches: (workflowId: string) => `workflows/${workflowId}/branches`,
|
||||
workflowSwitchBranch: (workflowId: string) => `workflows/${workflowId}/switch-branch`,
|
||||
workflowHistory: (workflowId: string) => `workflows/${workflowId}/history`,
|
||||
nodeGenerate: (nodeId: string) => `nodes/${nodeId}/generate`,
|
||||
nodeSelectImage: (nodeId: string) => `nodes/${nodeId}/select-image`,
|
||||
nodeAdoptImage: (nodeId: string) => `nodes/${nodeId}/adopt-image`,
|
||||
|
|
|
|||
|
|
@ -37,3 +37,29 @@ export interface WorkflowDetail {
|
|||
workflow: ProfileWorkflow
|
||||
nodes: WorkflowNode[]
|
||||
}
|
||||
|
||||
export interface WorkflowBranch {
|
||||
branch_id: string
|
||||
workflow_id: string
|
||||
branch_name: string
|
||||
base_branch_name?: string | null
|
||||
base_node_id?: string | null
|
||||
status: string
|
||||
metadata: Record<string, unknown>
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface WorkflowHistoryEntry {
|
||||
history_id: string
|
||||
profile_id?: string | null
|
||||
workflow_id: string
|
||||
node_id?: string | null
|
||||
image_id?: string | null
|
||||
branch_name: string
|
||||
action: string
|
||||
title?: string | null
|
||||
prompt?: string | null
|
||||
metadata: Record<string, unknown>
|
||||
created_at: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import type {
|
|||
} from "../../shared/types/settings"
|
||||
import type { MediaSignResult, StorageStatus } from "../../shared/types/storage"
|
||||
import type { WardrobeItem, WardrobeMatchResult } from "../../shared/types/wardrobe"
|
||||
import type { ProfileWorkflow, WorkflowDetail } from "../../shared/types/workflow"
|
||||
import type { ProfileWorkflow, WorkflowBranch, WorkflowDetail, WorkflowHistoryEntry } from "../../shared/types/workflow"
|
||||
|
||||
type ViewKey =
|
||||
| "dashboard"
|
||||
|
|
@ -105,10 +105,16 @@ const text = {
|
|||
emptyWorkflows: "\u6682\u65e0\u5de5\u4f5c\u6d41",
|
||||
nodes: "\u8282\u70b9",
|
||||
images: "\u56fe\u7247",
|
||||
branches: "\u5206\u652f",
|
||||
branchName: "\u5206\u652f\u540d",
|
||||
switchBranch: "\u5207\u6362\u5206\u652f",
|
||||
history: "\u5386\u53f2",
|
||||
emptyImages: "\u6682\u65e0\u56fe\u7247",
|
||||
emptyHistory: "\u6682\u65e0\u5386\u53f2",
|
||||
modelRoute: "\u6a21\u578b\u8def\u7531",
|
||||
prompt: "\u63d0\u793a\u8bcd",
|
||||
generationQueued: "\u751f\u6210\u5df2\u5165\u961f",
|
||||
branchCreated: "\u5206\u652f\u5df2\u521b\u5efa",
|
||||
imageArchived: "\u56fe\u7247\u5df2\u5f52\u6863",
|
||||
imageDeleted: "\u56fe\u7247\u5df2\u5220\u9664",
|
||||
currentBranch: "\u5f53\u524d\u5206\u652f",
|
||||
|
|
@ -193,6 +199,8 @@ const dashboard = ref<DashboardSummary | null>(null)
|
|||
const profiles = ref<ProfileListResult | null>(null)
|
||||
const workflows = ref<ProfileWorkflow[]>([])
|
||||
const workflowDetail = ref<WorkflowDetail | null>(null)
|
||||
const workflowBranches = ref<WorkflowBranch[]>([])
|
||||
const workflowHistory = ref<WorkflowHistoryEntry[]>([])
|
||||
const selectedNodeId = ref("")
|
||||
const nodeImages = ref<GenerationImage[]>([])
|
||||
const nodeGenerateResult = ref<NodeGenerateResult | null>(null)
|
||||
|
|
@ -228,6 +236,9 @@ const workflowDraft = ref({
|
|||
display_name: "",
|
||||
workflow_type: "single_image",
|
||||
})
|
||||
const branchDraft = ref({
|
||||
branch_name: "",
|
||||
})
|
||||
const nodeGenerateDraft = ref({
|
||||
model_route: "",
|
||||
prompt: "",
|
||||
|
|
@ -394,6 +405,8 @@ async function loadWorkflows(profileId?: string) {
|
|||
if (!profileId) {
|
||||
workflows.value = []
|
||||
workflowDetail.value = null
|
||||
workflowBranches.value = []
|
||||
workflowHistory.value = []
|
||||
selectedNodeId.value = ""
|
||||
nodeImages.value = []
|
||||
return
|
||||
|
|
@ -423,6 +436,7 @@ async function loadWorkflowDetail(workflowId: string) {
|
|||
selectedNodeId.value = ""
|
||||
nodeImages.value = []
|
||||
}
|
||||
await loadWorkflowExtras(workflowId)
|
||||
}
|
||||
|
||||
async function loadNodeImages(nodeId: string) {
|
||||
|
|
@ -430,6 +444,15 @@ async function loadNodeImages(nodeId: string) {
|
|||
nodeImages.value = await getJson<GenerationImage[]>(endpoints.nodeImages(nodeId))
|
||||
}
|
||||
|
||||
async function loadWorkflowExtras(workflowId: string) {
|
||||
const [branches, history] = await Promise.all([
|
||||
getJson<WorkflowBranch[]>(endpoints.workflowBranches(workflowId)),
|
||||
getJson<WorkflowHistoryEntry[]>(endpoints.workflowHistory(workflowId)),
|
||||
])
|
||||
workflowBranches.value = branches
|
||||
workflowHistory.value = history
|
||||
}
|
||||
|
||||
async function refreshSelectedWorkflow() {
|
||||
const workflowId = workflowDetail.value?.workflow.workflow_id
|
||||
if (workflowId) {
|
||||
|
|
@ -573,6 +596,43 @@ function archiveWorkflow(workflowId: string) {
|
|||
return runOperation(text.archive, () => postJson<ProfileWorkflow>(endpoints.workflowArchive(workflowId)))
|
||||
}
|
||||
|
||||
function createWorkflowBranch() {
|
||||
const workflow = workflowDetail.value?.workflow
|
||||
if (!workflow || !branchDraft.value.branch_name) return Promise.resolve()
|
||||
return runOperation(
|
||||
text.branches,
|
||||
async () => {
|
||||
const branch = await postJson<WorkflowBranch>(endpoints.workflowBranches(workflow.workflow_id), {
|
||||
branch_name: branchDraft.value.branch_name,
|
||||
base_branch_name: workflow.current_branch,
|
||||
base_node_id: selectedNodeId.value || workflow.current_node_id,
|
||||
copy_nodes: true,
|
||||
})
|
||||
branchDraft.value.branch_name = ""
|
||||
await refreshSelectedWorkflow()
|
||||
lastOperation.value = text.branchCreated
|
||||
return branch
|
||||
},
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
function switchWorkflowBranch(branchName: string) {
|
||||
const workflowId = workflowDetail.value?.workflow.workflow_id
|
||||
if (!workflowId) return Promise.resolve()
|
||||
return runOperation(
|
||||
text.switchBranch,
|
||||
async () => {
|
||||
const workflow = await postJson<ProfileWorkflow>(endpoints.workflowSwitchBranch(workflowId), {
|
||||
branch_name: branchName,
|
||||
})
|
||||
await refreshSelectedWorkflow()
|
||||
return workflow
|
||||
},
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
function generateSelectedNode() {
|
||||
const nodeId = selectedNodeId.value
|
||||
if (!nodeId) return Promise.resolve()
|
||||
|
|
@ -1128,6 +1188,36 @@ function storageRootBytes(uriPrefix: string) {
|
|||
</li>
|
||||
<li v-if="!workflows.length" class="empty">{{ text.emptyWorkflows }}</li>
|
||||
</ul>
|
||||
<section v-if="workflowDetail" class="editor-panel">
|
||||
<header>
|
||||
<h2>{{ text.branches }}</h2>
|
||||
<span>{{ workflowBranches.length }}</span>
|
||||
</header>
|
||||
<div class="form-grid">
|
||||
<label>
|
||||
<span>{{ text.branchName }}</span>
|
||||
<input v-model="branchDraft.branch_name" type="text" placeholder="alt_pose" />
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="Boolean(busy) || !branchDraft.branch_name"
|
||||
@click="createWorkflowBranch"
|
||||
>
|
||||
{{ text.create }}
|
||||
</button>
|
||||
</div>
|
||||
<ul>
|
||||
<li v-for="branch in workflowBranches" :key="branch.branch_id">
|
||||
<div>
|
||||
<strong>{{ branch.branch_name }}</strong>
|
||||
<small>{{ branch.base_branch_name ?? "main" }} / {{ branch.status }}</small>
|
||||
</div>
|
||||
<button type="button" :disabled="Boolean(busy)" @click="switchWorkflowBranch(branch.branch_name)">
|
||||
{{ text.switchBranch }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
<div class="list-view">
|
||||
<header>
|
||||
|
|
@ -1211,6 +1301,22 @@ function storageRootBytes(uriPrefix: string) {
|
|||
<li v-if="!nodeImages.length" class="empty">{{ text.emptyImages }}</li>
|
||||
</ul>
|
||||
<pre v-if="nodeGenerateResult">{{ JSON.stringify(nodeGenerateResult, null, 2) }}</pre>
|
||||
<section class="editor-panel">
|
||||
<header>
|
||||
<h2>{{ text.history }}</h2>
|
||||
<span>{{ workflowHistory.length }}</span>
|
||||
</header>
|
||||
<ul>
|
||||
<li v-for="entry in workflowHistory" :key="entry.history_id">
|
||||
<div>
|
||||
<strong>{{ entry.action }}</strong>
|
||||
<small>{{ entry.title ?? entry.node_id ?? entry.workflow_id }}</small>
|
||||
</div>
|
||||
<span>{{ entry.branch_name }}</span>
|
||||
</li>
|
||||
<li v-if="!workflowHistory.length" class="empty">{{ text.emptyHistory }}</li>
|
||||
</ul>
|
||||
</section>
|
||||
<pre v-if="workflowDetail">{{ JSON.stringify(workflowDetail.workflow, null, 2) }}</pre>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
|||
文件差异因一行或多行过长而隐藏
|
|
@ -1,3 +1,3 @@
|
|||
<script type="module" crossorigin src="/assets/index-CcPvFarb.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DDpQ4roE.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-KxvCyOGk.css">
|
||||
<div id="app"></div>
|
||||
|
|
|
|||
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
17
web/assets/index-DzwSrmLH.js
普通文件
17
web/assets/index-DzwSrmLH.js
普通文件
文件差异因一行或多行过长而隐藏
|
|
@ -1,3 +1,3 @@
|
|||
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BTjymfnK.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BMrshMnb.css">
|
||||
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-DzwSrmLH.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BBg1Dw3d.css">
|
||||
<div id="app"></div>
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用