diff --git a/frontend/shared/api/endpoints.ts b/frontend/shared/api/endpoints.ts index ddc9365..698b1ba 100644 --- a/frontend/shared/api/endpoints.ts +++ b/frontend/shared/api/endpoints.ts @@ -24,6 +24,8 @@ export const endpoints = { nodeMarkCompleted: (nodeId: string) => `nodes/${nodeId}/mark-completed`, nodeSelectImage: (nodeId: string) => `nodes/${nodeId}/select-image`, nodeAdoptImage: (nodeId: string) => `nodes/${nodeId}/adopt-image`, + reviewPolicy: "review/policy", + reviewPolicyValidate: "review/policy/validate", nodeReview: (nodeId: string) => `nodes/${nodeId}/review`, nodeImages: (nodeId: string) => `nodes/${nodeId}/images`, workflowReview: (workflowId: string) => `workflows/${workflowId}/review`, diff --git a/frontend/shared/types/review.ts b/frontend/shared/types/review.ts index 7098c3e..4df6ae9 100644 --- a/frontend/shared/types/review.ts +++ b/frontend/shared/types/review.ts @@ -13,3 +13,18 @@ export interface ReviewResult { summary: Record nodes?: ReviewResult[] } + +export interface ReviewPolicy { + version: string + warn_without_images: boolean + require_selected_image_for_statuses: string[] + fail_on_selected_image_not_found: boolean + fail_on_archived_selected_image: boolean + workflow_terminal_statuses: string[] +} + +export interface ReviewPolicyValidation { + valid: boolean + policy: ReviewPolicy + errors: ReviewMessage[] +} diff --git a/frontend/standalone-web/src/App.vue b/frontend/standalone-web/src/App.vue index b945233..7a06208 100644 --- a/frontend/standalone-web/src/App.vue +++ b/frontend/standalone-web/src/App.vue @@ -11,7 +11,7 @@ import type { GenerationJob, JobListResult } from "../../shared/types/job" import type { EventStreamResult, LogBundle } from "../../shared/types/logs" import type { Material, MaterialCategory, MaterialListResult } from "../../shared/types/material" import type { CharacterProfile, ProfileListResult, QuickProfileDraftResult } from "../../shared/types/profile" -import type { ReviewResult } from "../../shared/types/review" +import type { ReviewPolicy, ReviewPolicyValidation, ReviewResult } from "../../shared/types/review" import type { CurrentSettings, DiffSettingsResult, @@ -138,6 +138,10 @@ const text = { history: "\u5386\u53f2", review: "\u8bc4\u5ba1", reviewResult: "\u8bc4\u5ba1\u7ed3\u679c", + reviewPolicy: "\u8bc4\u5ba1\u7b56\u7565", + loadPolicy: "\u52a0\u8f7d\u7b56\u7565", + validatePolicy: "\u6821\u9a8c\u7b56\u7565", + policyDraftInvalid: "\u7b56\u7565 JSON \u683c\u5f0f\u65e0\u6548", emptyImages: "\u6682\u65e0\u56fe\u7247", emptyHistory: "\u6682\u65e0\u5386\u53f2", modelRoute: "\u6a21\u578b\u8def\u7531", @@ -260,6 +264,9 @@ const workflowDetail = ref(null) const workflowBranches = ref([]) const workflowHistory = ref([]) const reviewResult = ref(null) +const reviewPolicy = ref(null) +const reviewPolicyValidation = ref(null) +const reviewPolicyDraft = ref("") const selectedNodeId = ref("") const nodeImages = ref([]) const nodeGenerateResult = ref(null) @@ -474,6 +481,7 @@ async function load() { materialData, dialectData, capabilityData, + reviewPolicyData, ] = await Promise.all([ getJson(endpoints.uiBootstrap), getJson(endpoints.dashboardSummary), @@ -486,6 +494,7 @@ async function load() { getJson(endpoints.materials, { page: 1, page_size: 24 }), getJson(endpoints.apiDiscoveryDialects), getJson(endpoints.apiDiscoveryCapabilities), + getJson(endpoints.reviewPolicy), ]) bootstrap.value = bootstrapData dashboard.value = dashboardData @@ -499,6 +508,7 @@ async function load() { materials.value = materialData dialects.value = dialectData capabilities.value = capabilityData + setReviewPolicy(reviewPolicyData) await loadWardrobe(profileData.items[0]?.profile_id) await loadWorkflows(profileData.items[0]?.profile_id) await loadLogs() @@ -983,6 +993,41 @@ function reviewSelectedNode() { ) } +function setReviewPolicy(policy: ReviewPolicy) { + reviewPolicy.value = policy + reviewPolicyDraft.value = JSON.stringify(policy, null, 2) +} + +function loadReviewPolicy() { + return runOperation( + text.loadPolicy, + async () => { + const policy = await getJson(endpoints.reviewPolicy) + setReviewPolicy(policy) + return policy + }, + false, + ) +} + +function validateReviewPolicyDraft() { + let payload: unknown + try { + payload = JSON.parse(reviewPolicyDraft.value || "{}") + } catch { + lastOperation.value = text.policyDraftInvalid + return Promise.resolve() + } + return runOperation( + text.validatePolicy, + async () => { + reviewPolicyValidation.value = await postJson(endpoints.reviewPolicyValidate, payload) + return reviewPolicyValidation.value + }, + false, + ) +} + function generateSelectedNode() { const nodeId = selectedNodeId.value if (!nodeId) return Promise.resolve() @@ -2049,6 +2094,22 @@ function planStorageMigration() {
{{ JSON.stringify(reviewResult, null, 2) }}
+
+
+

{{ text.reviewPolicy }}

+
+ + +
+
+