Files
aigc-home/calliope-web/src/lib/components/workbench/JobChip.svelte
T
施工员andmultica-agent e42212a16f feat(ui): fusion design tokens and shared component reskin (HEL-651 A batch)
- app.css: HEL-649 §一 tokens (bg/line/accent/status/text/type/space/radius/shadow/motion), legacy names aliased, reduced-motion via prefers-reduced-motion and data-reduce
- shared .a-btn/.status-chip/.a-panel/inputs reskinned; new .a-tag/.a-progress/.a-sprocket/.a-stage/.a-float
- tailwind colors/radii reference the same CSS variables
- ui primitives (StatusChip/ProgressBar/Modal/Button/ConfirmDialog/Skeleton/Switch/Card/Toast) on tokens
- running state -> --run, awaiting confirm -> --warn, --cloud purple removed, old palette literals -> tokens

Co-authored-by: multica-agent <github@multica.ai>
2026-09-30 08:29:37 +08:00

104 lines
2.1 KiB
Svelte

<script lang="ts">
import type { WorkbenchJobBrief } from '$lib/api';
import { progressFor } from '$lib/jobProgress';
import { t } from '$lib/i18n.svelte';
/**
* Inline workbench job state chip (spec §5 任务条目四态):
* 排队灰 / 进行中琥珀百分比 / 完成绿 / 失败红(附原因).
*/
interface Props {
job: WorkbenchJobBrief;
}
let { job }: Props = $props();
const live = $derived(progressFor(job.id));
const pct = $derived(live?.progress ?? null);
const state = $derived(
job.status === 'done'
? 'done'
: job.status === 'failed'
? 'failed'
: job.status === 'running'
? 'running'
: 'pending',
);
</script>
<span class="job-chip st-{state}" data-testid="wb-job-chip">
{#if state === 'running'}
<span class="breath" aria-hidden="true"></span>
{#if pct != null}{t('workbench.jobRunningPct', { n: Math.round(pct) })}{:else}{t('workbench.jobRunning')}{/if}
{:else if state === 'pending'}
{t('workbench.jobQueued')}
{:else if state === 'done'}
{t('workbench.jobDone')}
{:else}
{t('workbench.jobFailed')}
{/if}
</span>
{#if state === 'failed' && job.error}
<span class="job-error">{job.error}</span>
{/if}
<style>
.job-chip {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 1px 9px;
border-radius: 999px;
font-size: 10.5px;
font-weight: 600;
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.st-pending {
color: var(--text-2);
background: var(--surface-3);
}
.st-running {
color: var(--run);
background: var(--run-soft);
}
.st-done {
color: var(--success);
background: var(--success-dim);
}
.st-failed {
color: var(--error);
background: var(--error-dim);
}
.job-error {
display: block;
font-size: 11px;
color: var(--error);
line-height: 1.5;
margin-top: 2px;
}
.breath {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent);
animation: wb-chip-breath 2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
@keyframes wb-chip-breath {
0%,
100% {
opacity: 0.35;
}
50% {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.breath {
animation: none;
}
}
</style>