feat(admin-web): surface generation error message and speed up active polling
Hoists hasActiveGenerationStatus into the shared display helper so all views agree on what counts as in-flight generation, shows the backend generation_error_message inline on the imitation list and detail drawer when status is failed, and drops the workspace/templates/imitation poll interval from 10s to 3s (with a 5s fallback when streaming is enabled) plus explicit query-cache invalidation so failed/completed states show up promptly.
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
getGenerateStatusMeta,
|
||||
getPublishStatusMeta,
|
||||
getSourceTypeLabel,
|
||||
hasActiveGenerationStatus,
|
||||
} from '@/lib/display'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -124,6 +125,7 @@ const displayMarkdown = computed(() => streamMarkdown.value || detail.value?.mar
|
||||
const generateMeta = computed(() =>
|
||||
getGenerateStatusMeta(streamStatus.value || detail.value?.generate_status),
|
||||
)
|
||||
const displayGenerateStatus = computed(() => streamStatus.value || detail.value?.generate_status)
|
||||
const sourceArticleTitle = computed(() => detail.value?.source_title?.trim() || '')
|
||||
const sourceArticleURL = computed(() => detail.value?.source_url?.trim() || '')
|
||||
|
||||
@@ -170,13 +172,13 @@ watch(
|
||||
watch(
|
||||
[() => props.open, () => props.articleId, () => detail.value?.generate_status],
|
||||
([open, articleId, generateStatus], _prev, onCleanup) => {
|
||||
if (!open || !articleId || streamFeatureEnabled || generateStatus !== 'generating') {
|
||||
if (!open || !articleId || !hasActiveGenerationStatus(generateStatus)) {
|
||||
return
|
||||
}
|
||||
|
||||
const timer = window.setInterval(() => {
|
||||
void refreshArticleData()
|
||||
}, 2000)
|
||||
}, streamFeatureEnabled ? 5000 : 2000)
|
||||
|
||||
onCleanup(() => {
|
||||
window.clearInterval(timer)
|
||||
@@ -326,6 +328,14 @@ async function copyPublishLink(record: PublishRecord): Promise<void> {
|
||||
</a-descriptions>
|
||||
</section>
|
||||
|
||||
<a-alert
|
||||
v-if="displayGenerateStatus === 'failed' && detail.generation_error_message"
|
||||
class="article-drawer__alert"
|
||||
type="error"
|
||||
show-icon
|
||||
:message="detail.generation_error_message"
|
||||
/>
|
||||
|
||||
<a-tabs v-model:activeKey="activeTab" class="article-drawer__tabs">
|
||||
<a-tab-pane key="content" :tab="t('article.preview')">
|
||||
<div v-if="displayMarkdown" class="article-drawer__content">
|
||||
|
||||
@@ -2,16 +2,14 @@
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
import { computed } from 'vue'
|
||||
|
||||
import { getGenerateStatusMeta } from '@/lib/display'
|
||||
import { getGenerateStatusMeta, hasActiveGenerationStatus } from '@/lib/display'
|
||||
|
||||
const props = defineProps<{
|
||||
status?: string | null
|
||||
}>()
|
||||
|
||||
const statusMeta = computed(() => getGenerateStatusMeta(props.status))
|
||||
const isLoading = computed(
|
||||
() => props.status === 'queued' || props.status === 'generating' || props.status === 'running',
|
||||
)
|
||||
const isLoading = computed(() => hasActiveGenerationStatus(props.status))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user