Reproduce and fix the launchd SIGTERMed shutdown race; wait for owned processes to exit and report timeouts. Describe local task workspaces without claiming OS isolation.
171 lines
6.3 KiB
TypeScript
171 lines
6.3 KiB
TypeScript
'use client';
|
|
import Link from 'next/link';
|
|
import { ArrowRight, CircleAlert, GitBranch, Laptop, Plus, Settings2 } from 'lucide-react';
|
|
import { formatNumber, useResource } from '@/lib/api';
|
|
import { resourceState } from '@/lib/readiness';
|
|
import type { Dashboard } from '@/lib/types';
|
|
import { ButtonLink, EmptyState, ErrorNotice, Loading, PageHeader, Panel } from '@/components/ui';
|
|
import { RunTable } from '@/components/run-table';
|
|
const journey = [
|
|
['许愿与澄清', '将想法转化为可执行的任务,与 Agent 一起澄清细节。'],
|
|
['独立工作区', '在独立任务分支实现代码,按环境配置完成构建与验证。'],
|
|
['证据验证', '收集执行结果与证据,确认符合预期。'],
|
|
['发布审批', '绑定确切的代码与制品,完成发布评审。'],
|
|
['部署与观察', '部署到目标环境,并持续观察运行状态。'],
|
|
];
|
|
export function DashboardView() {
|
|
const { data: cachedData, error, isLoading, isValidating, mutate } = useResource<Dashboard>('/dashboard', 10000);
|
|
const data = error && [401, 403].includes(error.status) ? undefined : cachedData;
|
|
const connectionState = resourceState(Boolean(data), Boolean(error), isValidating);
|
|
const connectionTitle = {
|
|
ready: '控制面已连接',
|
|
refreshing: '正在刷新控制面',
|
|
loading: '正在连接控制面',
|
|
stale: '控制面连接已中断',
|
|
unavailable: '控制面尚未连接',
|
|
}[connectionState];
|
|
const metrics = [
|
|
{
|
|
title: '进行中的运行',
|
|
value: data?.runs.filter(run => ['running', 'queued'].includes(run.status)).length,
|
|
note: '正在推进的愿望',
|
|
},
|
|
{
|
|
title: '待确认',
|
|
value: data
|
|
? data.runs.filter(run => run.status === 'waiting').length +
|
|
data.releases.filter(
|
|
release =>
|
|
release.approvalId && ['pending', 'pending_approval', 'awaiting_approval'].includes(release.status),
|
|
).length
|
|
: undefined,
|
|
note: '需要你的判断',
|
|
},
|
|
{
|
|
title: '配置可用的执行器',
|
|
value: data?.providers.filter(provider => provider.configured && provider.enabled).length,
|
|
note: '账号权限在任务启动时检查',
|
|
},
|
|
];
|
|
return (
|
|
<>
|
|
<PageHeader
|
|
title="工作概览"
|
|
description="从一句愿望,到有证据的交付。"
|
|
action={
|
|
<ButtonLink href="/runs/new">
|
|
<Plus size={19} />
|
|
提交愿望
|
|
</ButtonLink>
|
|
}
|
|
/>
|
|
{error ? (
|
|
<ErrorNotice error={error} retry={() => void mutate().catch(() => undefined)} retrying={isValidating} />
|
|
) : null}
|
|
<div className="metrics-strip">
|
|
{metrics.map(metric => (
|
|
<div className="metric" key={metric.title}>
|
|
<h2>{metric.title}</h2>
|
|
<strong>{formatNumber(metric.value)}</strong>
|
|
<p>{data ? (connectionState === 'ready' ? metric.note : '上次结果,当前状态待刷新') : '等待控制面数据'}</p>
|
|
</div>
|
|
))}
|
|
</div>
|
|
<div className="dashboard-columns">
|
|
<Panel
|
|
title="最近运行"
|
|
aside={
|
|
<Link className="text-link" href="/runs">
|
|
全部运行
|
|
<ArrowRight size={15} />
|
|
</Link>
|
|
}
|
|
className="recent-panel"
|
|
>
|
|
{isLoading ? (
|
|
<Loading />
|
|
) : data ? (
|
|
<RunTable runs={data.runs.slice(0, 5)} projects={data.projects} compact />
|
|
) : (
|
|
<EmptyState title="尚未加载运行记录" description="控制面恢复连接后,运行与证据会显示在这里。" />
|
|
)}
|
|
</Panel>
|
|
<Panel title="交付路径" className="journey-panel">
|
|
<ol className="journey">
|
|
{journey.map(([title, description], index) => (
|
|
<li key={title}>
|
|
<span className="journey-number">{index + 1}</span>
|
|
<div>
|
|
<h3>{title}</h3>
|
|
<p>{description}</p>
|
|
</div>
|
|
</li>
|
|
))}
|
|
</ol>
|
|
<div
|
|
className={`connection-note ${connectionState === 'ready' ? 'connected' : ''}`}
|
|
role="status"
|
|
aria-live="polite"
|
|
>
|
|
<CircleAlert size={17} />
|
|
<div>
|
|
<strong>{connectionTitle}</strong>
|
|
<p>
|
|
{connectionState === 'stale'
|
|
? '保留上次成功读取的记录;重新连接后更新。'
|
|
: connectionState === 'refreshing'
|
|
? '正在校验最新状态,暂显示上次结果。'
|
|
: data
|
|
? `${data.system.region} · ${data.system.authMode}`
|
|
: error
|
|
? '请查看上方错误提示,处理后重新连接。'
|
|
: '正在读取当前工作空间状态。'}
|
|
</p>
|
|
</div>
|
|
<Link href="/providers" aria-label="查看连接状态">
|
|
<ArrowRight size={17} />
|
|
</Link>
|
|
</div>
|
|
</Panel>
|
|
</div>
|
|
<Panel title="准备你的工作空间" className="onboarding-panel">
|
|
<div className="onboarding">
|
|
{[
|
|
{
|
|
number: '01',
|
|
Icon: GitBranch,
|
|
title: '连接代码仓库',
|
|
text: '关联代码仓库,让 WishForge 了解你的项目。',
|
|
href: '/projects/new',
|
|
},
|
|
{
|
|
number: '02',
|
|
Icon: Settings2,
|
|
title: '配置执行器',
|
|
text: '选择可用的执行器,连接你的模型凭据。',
|
|
href: '/providers',
|
|
},
|
|
{
|
|
number: '03',
|
|
Icon: Laptop,
|
|
title: '打开云 IDE',
|
|
text: '在云端开发环境中构建与协作。',
|
|
href: '/projects',
|
|
},
|
|
].map(({ number, Icon, title, text, href }) => (
|
|
<Link href={href} key={number}>
|
|
<span className="onboarding-number">{number}</span>
|
|
<Icon size={21} />
|
|
<div>
|
|
<h3>{title}</h3>
|
|
<p>{text}</p>
|
|
</div>
|
|
<ArrowRight size={15} className="onboarding-arrow" />
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</Panel>
|
|
</>
|
|
);
|
|
}
|