mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-23 19:32:03 +00:00
普通用户建应用集成收尾:
- 问数据和个人应用的图放行绑定只读查询等合规工具的调用工具节点,只读和遮罩在这条路径上生效;被治理成写入的工具在只读运行里直接拒;知识库范围在工具层固定(图级默认值、参数名纠错、Agent 都改不了) - 个人应用的刷新和个人蓝图的试运行只有拥有者能读:运行、事件、证据、工件、文件、运行与审批列表、对比、可验证报告、质询、假设分析、提取工作流一并收紧;个人蓝图的试运行不论谁发起都按个人应用约束 - 共享蓝图只给拥有者、对应应用的管理者、管理员,看不到的一律 404;审核副本归审核人;管理员看别人的个人应用只有元数据、可以归档 - 记录表跨版本汇总(只读挂载旧版本、按当前列 UNION ALL、各版本各自固定高水位,缺的版本照实写进印章);停用前发起的运行可以继续写旧版本;更正沿用原提交人、更正人记审计 - 约定收口:待办种类 review、事件 file.extracted、表单错误 file、模板定义带示例与预置;前端类型一次补齐、去掉临时的局部类型;审核待办卡不再给打不开的链接;读附件事件有中文说法;检查脚本补断言
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
* 每 5 秒重取一次,生成完自动换上;引用的版本退役了照实提示,入口暂停发起。
|
||||
*
|
||||
* 另取一次应用详情:有 manage 的人点「编辑」在页面上直接改(地址上记 edit=1,见 PageEdit.tsx,normal-user-apps N6);
|
||||
* 个人应用(scope 为 personal)顶上写明是个人应用,给「刷新」和「提交审核」(personal.tsx,N7)。详情取不到不挡页面:
|
||||
* 照只能用的人画。
|
||||
* 个人应用(scope 为 personal)顶上写明是个人应用,给「刷新」和「提交审核」(personal.tsx,N7);开了登录的管理员打开别人的
|
||||
* 个人应用只拿到元数据,换成只写名称、拥有者、时间和「归档」的一页。详情取不到不挡页面:照只能用的人画。
|
||||
*/
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
import { LayoutGrid, PencilLine, RotateCw, Settings2 } from 'lucide-react'
|
||||
@@ -14,14 +14,14 @@ import { api } from '../../api/client'
|
||||
import { ViewRenderer } from '../../apps/ViewRenderer'
|
||||
import { parseViewParams } from '../../apps/components/input'
|
||||
import { Notice, PageHeader, Skeleton, Spinner, Tabs } from '../../components/ui'
|
||||
import { useAtLeast } from '../../store/auth'
|
||||
import { loginOn, useAtLeast, useAuth } from '../../store/auth'
|
||||
import { usePageTitle } from '../../lib/notify'
|
||||
import { APP_TEXT, PAGE_EDIT_TEXT, PERSONAL_TEXT } from '../../lib/termsApp'
|
||||
import type { AppDetail } from '../../typesApp'
|
||||
import { AppMeta, BackLink, LoadError, appPath, loadHome, useLoad, usePoll } from './shared'
|
||||
import { BackfillPanel } from './backfill'
|
||||
import { PageEditor } from './PageEdit'
|
||||
import { PersonalBar } from './personal'
|
||||
import { PersonalBar, PersonalStubPage, isPersonalStub } from './personal'
|
||||
|
||||
const POLL_MS = 5000
|
||||
|
||||
@@ -34,7 +34,9 @@ export function AppPage() {
|
||||
const [search, setSearch] = useSearchParams()
|
||||
const raw = search.get('params')
|
||||
const navigate = useNavigate()
|
||||
const { data: detail, reload: reloadDetail } = useLoad((signal) => api.apps.get(appId, { signal }), [appId])
|
||||
const { data: detail, error: detailError, reload: reloadDetail } = useLoad((signal) => api.apps.get(appId, { signal }), [appId])
|
||||
// 开了登录的管理员打开的可能是别人的个人应用(只有元数据):等详情回来再决定画哪一种,免得先去取一次看不到的页面
|
||||
const mayBeStub = useAuth((s) => loginOn(s.me) && s.me?.role === 'admin')
|
||||
const editing = editableOf(detail) && search.get('edit') === '1'
|
||||
const setEditing = (on: boolean) => setSearch((prev) => {
|
||||
const next = new URLSearchParams(prev)
|
||||
@@ -51,6 +53,9 @@ export function AppPage() {
|
||||
navigate(`${appPath(appId)}/p/${encodeURIComponent(id)}${tail ? `?${tail}` : ''}`)
|
||||
}
|
||||
|
||||
// 别人的个人应用(开了登录的管理员):服务端只给元数据,页面、运行都看不到,不去取
|
||||
if (detail && isPersonalStub(detail)) return <PersonalStubPage app={detail} onArchived={reloadDetail} />
|
||||
if (mayBeStub && !detail && !detailError) return <div className="p-4"><Skeleton rows={6} /></div>
|
||||
if (editing && detail) {
|
||||
return (
|
||||
<PageEditor key={appId} appId={appId} detail={detail} pageId={pageId} rawParams={raw} onNavigate={go}
|
||||
|
||||
@@ -21,6 +21,7 @@ import type { AppSummary, InstanceRow, Task } from '../../typesApp'
|
||||
import { LoadError, appPath, useLoad } from './shared'
|
||||
import { NEW_APP_TEXT } from '../../lib/termsBlueprint'
|
||||
import { CREATE_APP_PATH, useCreateScope } from '../blueprints/shared'
|
||||
import { PersonalStubCard, isPersonalStub } from './personal'
|
||||
|
||||
const TABS = ['inbox', 'apps', 'mine'] as const
|
||||
type Tab = (typeof TABS)[number]
|
||||
@@ -160,19 +161,23 @@ function AppsTab() {
|
||||
const { data, error, reload } = useLoad((signal) => api.apps.list({ signal }), [])
|
||||
if (error && !data) return <LoadError error={error} onRetry={reload} />
|
||||
if (!data) return <Skeleton rows={4} />
|
||||
// 个人应用(N7)单独一组「我的应用」放在前面:只有拥有者看得见,服务端只把自己的交来
|
||||
const mine = data.items.filter((a) => a.scope === 'personal')
|
||||
// 个人应用(N7)单独一组「我的应用」放在前面:只有拥有者看得见,服务端只把自己的交来。开了登录的管理员另看得到别人的
|
||||
// 个人应用在不在(服务端只给元数据,my_role 为空):单列一组「使用者的个人应用」放在最后,不链到页面,只给归档
|
||||
const others = data.items.filter(isPersonalStub)
|
||||
const mine = data.items.filter((a) => a.scope === 'personal' && !isPersonalStub(a))
|
||||
const shared = data.items.filter((a) => a.scope !== 'personal')
|
||||
if (mine.length) {
|
||||
if (mine.length || others.length) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<section aria-labelledby="apps-home-personal" data-app-group="personal">
|
||||
<h2 id="apps-home-personal" className="text-xs font-semibold">{PERSONAL_TEXT.group}</h2>
|
||||
<p className="mb-2 text-2xs text-faint">{PERSONAL_TEXT.groupHint}</p>
|
||||
<ul className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3" data-app-list-personal="">
|
||||
{mine.map((a) => <AppCard key={a.id} app={a} canEdit={false} />)}
|
||||
</ul>
|
||||
</section>
|
||||
{mine.length > 0 && (
|
||||
<section aria-labelledby="apps-home-personal" data-app-group="personal">
|
||||
<h2 id="apps-home-personal" className="text-xs font-semibold">{PERSONAL_TEXT.group}</h2>
|
||||
<p className="mb-2 text-2xs text-faint">{PERSONAL_TEXT.groupHint}</p>
|
||||
<ul className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3" data-app-list-personal="">
|
||||
{mine.map((a) => <AppCard key={a.id} app={a} canEdit={false} />)}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
{shared.length > 0 && (
|
||||
<section aria-labelledby="apps-home-shared" data-app-group="shared">
|
||||
<h2 id="apps-home-shared" className="mb-2 text-xs font-semibold">{PERSONAL_TEXT.sharedGroup}</h2>
|
||||
@@ -181,6 +186,15 @@ function AppsTab() {
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
{others.length > 0 && (
|
||||
<section aria-labelledby="apps-home-others" data-app-group="others">
|
||||
<h2 id="apps-home-others" className="text-xs font-semibold">{PERSONAL_TEXT.othersGroup}</h2>
|
||||
<p className="mb-2 text-2xs text-faint">{PERSONAL_TEXT.othersGroupHint}</p>
|
||||
<ul className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3" data-app-list-others="">
|
||||
{others.map((a) => <PersonalStubCard key={a.id} app={a} onArchived={reload} />)}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,13 +45,10 @@ import { AppMeta, BackLink, LoadError, appPath } from './shared'
|
||||
interface Box { top: number; left: number; width: number; height: number }
|
||||
|
||||
/**
|
||||
* 服务端给的「草稿和当前发布版是否一致」(AppDetail.draft_changed,见报告的接口约定请求)。没给的当不知道:
|
||||
* 只在这一次改过之后说「有未发布的改动」,不在浏览器里拿草稿和发布版逐项比(发布时服务端会规整 spec,比不准)
|
||||
* 服务端给的「草稿和当前发布版是否一致」(AppDetail.draft_changed)。没给的当不知道:只在这一次改过之后说「有未发布的
|
||||
* 改动」,不在浏览器里拿草稿和发布版逐项比(发布时服务端会规整 spec,比不准)
|
||||
*/
|
||||
const draftChangedOf = (d: AppDetail): boolean | null => {
|
||||
const v = (d as AppDetail & { draft_changed?: unknown }).draft_changed
|
||||
return typeof v === 'boolean' ? v : null
|
||||
}
|
||||
const draftChangedOf = (d: AppDetail): boolean | null => d.draft_changed ?? null
|
||||
|
||||
/** 组件在界面上叫什么:属性里写的名字、标题,再退到目录里的中文名 */
|
||||
function labelOf(comp: AppComponent | undefined, entry: CatalogComponent | undefined): string {
|
||||
|
||||
@@ -344,7 +344,8 @@ export function NotifySection() {
|
||||
const [channels, setChannels] = useState<NotifyChannelRow[] | null>(null)
|
||||
useEffect(() => { api.notify.channels().then(({ items }) => setChannels(items)).catch(() => setChannels([])) }, [])
|
||||
const set = (notify: typeof draft.notify) => setDraft((s) => ({ ...s, notify }))
|
||||
const events = Object.keys(NOTIFY_TEXT.eventLabel)
|
||||
// 「我提交审核的应用有结果」是发给提交人的,不归哪个应用:应用的通知里不列
|
||||
const events = Object.keys(NOTIFY_TEXT.eventLabel).filter((e) => e !== 'review.done')
|
||||
return (
|
||||
<div className="mx-auto max-w-3xl p-4" data-app-notify={draft.notify.length}>
|
||||
<SectionBar title={T.sections.notify} hint={T.notifyHint}>
|
||||
|
||||
@@ -3,47 +3,30 @@
|
||||
* 结果遮罩、探索运行未经发布审核),「刷新」写明今天还剩几次,「提交审核」交给一位搭建者或一个组。
|
||||
*
|
||||
* 印章上的「探索 · 未经发布审核」由服务端写,这里不另编(P1)。剩余次数以服务端为准:详情里给了(AppDetail.personal,
|
||||
* 服务端 blueprints/personal.personal_state 的形状,typesApp 还没有它、契约待补)就写,刷新的回包里也带;不知道的不猜,
|
||||
* 只说有上限。超了上限服务端回 429,照实说用完了。蓝图改过、还没重新存的(graph_changed),照实说刷新要先重新存。
|
||||
* 服务端 blueprints/personal.personal_state)就写,刷新的回包里也带;不知道的不猜,只说有上限。超了上限服务端回 429,
|
||||
* 照实说用完了。蓝图改过、还没重新存的(graph_changed),照实说刷新要先重新存。
|
||||
*
|
||||
* 审核状态同样以服务端为准:最近一条审核待办还在等(pending)写「审核中」;搭建者发布了(decision=published)写
|
||||
* 「已有正式版本:去看看」,链到发布的那个应用;退回了写退回和原因,可以再提交。详情没给时看蓝图的状态(in_review)。
|
||||
*
|
||||
* 别人的个人应用(开了登录的管理员看到的,my_role 为空):服务端只给名称、拥有者、状态、创建和更新时间(api/apps._personal_stub),
|
||||
* 这里照它写,给「归档」;页面、运行、蓝图的内容都看不到,也不去取(PersonalStubCard、PersonalStubPage)。
|
||||
*/
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { FileCheck2, Hourglass, RotateCw, Send, UserRound } from 'lucide-react'
|
||||
import { Archive, FileCheck2, Hourglass, LayoutGrid, RotateCw, Send, UserRound } from 'lucide-react'
|
||||
import { ApiError, api } from '../../api/client'
|
||||
import { PrincipalPicker, type Principal } from '../../components/PrincipalPicker'
|
||||
import { Modal, Notice, Spinner, toast } from '../../components/ui'
|
||||
import { PERSONAL_TEXT as T } from '../../lib/termsApp'
|
||||
import type { AppDetail } from '../../typesApp'
|
||||
import { Modal, Notice, PageHeader, Spinner, confirmDialog, toast } from '../../components/ui'
|
||||
import { formatDateTime } from '../../lib/format'
|
||||
import { APP_TEXT, PERSONAL_TEXT as T } from '../../lib/termsApp'
|
||||
import type { AppDetail, AppSummary, PersonalReview } from '../../typesApp'
|
||||
import { blueprintPath } from '../blueprints/shared'
|
||||
import { appPath } from './shared'
|
||||
|
||||
/** 最近一条审核待办(服务端 personal_state.review):status 是待办的状态,decision 是结论(published / reject) */
|
||||
export interface PersonalReview {
|
||||
task_id: string
|
||||
status: 'pending' | 'resolving' | 'resolved' | 'cancelled' | 'expired'
|
||||
decision?: 'published' | 'reject' | null
|
||||
note?: string
|
||||
/** 发布出来的正式应用(decision=published 时) */
|
||||
app_id?: string | null
|
||||
to?: { kind: 'user' | 'group'; name: string }[]
|
||||
resolved_at?: string | null
|
||||
}
|
||||
|
||||
/** 个人应用在详情里多给的(服务端 blueprints/personal.personal_state):今天还能刷新几次、蓝图改过没有、审核到哪了 */
|
||||
export interface PersonalInfo {
|
||||
remaining_today?: number | null
|
||||
daily_limit?: number | null
|
||||
blueprint_status?: string | null
|
||||
graph_changed?: boolean
|
||||
review?: PersonalReview | null
|
||||
}
|
||||
import { BackLink, appPath } from './shared'
|
||||
|
||||
/** 界面上的审核状态:在等、发布了、退回了;还没提交过(或审核取消、过期)为 null */
|
||||
type ReviewView =
|
||||
| { state: 'in_review'; to?: { kind: 'user' | 'group'; name: string }[] }
|
||||
| { state: 'in_review'; to?: PersonalReview['to'] }
|
||||
| { state: 'published'; appId?: string | null }
|
||||
| { state: 'rejected'; note?: string }
|
||||
|
||||
@@ -55,11 +38,11 @@ function reviewView(r: PersonalReview | null | undefined): ReviewView | null {
|
||||
return null
|
||||
}
|
||||
|
||||
export const personalOf = (d: AppDetail | undefined): PersonalInfo | null =>
|
||||
((d as (AppDetail & { personal?: PersonalInfo }) | undefined)?.personal) ?? null
|
||||
|
||||
export function PersonalBar({ detail, onRefreshed }: { detail: AppDetail; onRefreshed: () => void }) {
|
||||
const info = personalOf(detail)
|
||||
const info = detail.personal ?? null
|
||||
// 管理员关了开关:刷新、提交审核服务端都会拒,详情里照同一条规则给了 allowed(blueprints/personal.allowed),这里照它写明、
|
||||
// 按钮置灰。详情没给(老服务端)的不猜,按钮照常,由服务端拒并说清
|
||||
const allowed = info?.allowed !== false
|
||||
const [remaining, setRemaining] = useState<number | null>(info?.remaining_today ?? null)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [review, setReview] = useState<ReviewView | null>(reviewView(info?.review))
|
||||
@@ -102,6 +85,7 @@ export function PersonalBar({ detail, onRefreshed }: { detail: AppDetail; onRefr
|
||||
return (
|
||||
<div className="space-y-2" data-personal-bar={detail.id}>
|
||||
<Notice tone="info" attr={{ 'data-personal-banner': '' }}>{T.banner}</Notice>
|
||||
{!allowed && <Notice tone="warn" attr={{ 'data-personal-off': '' }}>{T.switchedOff}</Notice>}
|
||||
{info?.graph_changed && detail.blueprint_id && (
|
||||
<Notice tone="warn" attr={{ 'data-personal-graph-changed': '' }}>
|
||||
{T.graphChanged}{' '}
|
||||
@@ -109,8 +93,8 @@ export function PersonalBar({ detail, onRefreshed }: { detail: AppDetail; onRefr
|
||||
</Notice>
|
||||
)}
|
||||
<div className="flex flex-wrap items-center gap-2 text-xs">
|
||||
<button type="button" className="btn btn-sm" disabled={busy || usedUp} onClick={() => void refresh()}
|
||||
title={usedUp ? T.refreshUsedUp : T.refreshLimitHint} data-personal-refresh="">
|
||||
<button type="button" className="btn btn-sm" disabled={busy || usedUp || !allowed} onClick={() => void refresh()}
|
||||
title={!allowed ? T.switchedOff : usedUp ? T.refreshUsedUp : T.refreshLimitHint} data-personal-refresh="">
|
||||
{busy ? <Spinner size={11} /> : <RotateCw size={11} aria-hidden />} {busy ? T.refreshing : T.refresh}
|
||||
</button>
|
||||
<span className="text-2xs text-dim" data-personal-remaining={remaining ?? ''}>
|
||||
@@ -137,7 +121,8 @@ export function PersonalBar({ detail, onRefreshed }: { detail: AppDetail; onRefr
|
||||
{review.note ? T.rejectedNote(review.note) : T.rejected}
|
||||
</span>
|
||||
)}
|
||||
<button type="button" className="btn btn-sm" title={T.submitReviewHint} onClick={() => setAsking(true)}
|
||||
<button type="button" className="btn btn-sm" title={allowed ? T.submitReviewHint : T.switchedOff} disabled={!allowed}
|
||||
onClick={() => setAsking(true)}
|
||||
data-personal-submit-review="">
|
||||
<Send size={11} aria-hidden /> {T.submitReview}
|
||||
</button>
|
||||
@@ -198,3 +183,95 @@ function ReviewDialog({ appId, onClose, onSent }: {
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 别人的个人应用(管理员)
|
||||
|
||||
/** 别人的个人应用:开了登录的管理员看到的只有元数据(服务端 api/apps._personal_stub,my_role 为空) */
|
||||
export const isPersonalStub = (a: AppSummary): boolean => a.scope === 'personal' && a.my_role == null
|
||||
|
||||
/** 归档别人的个人应用:确认框写明后果;成功交回服务端的那一份(同样只有元数据),取消或失败为 null */
|
||||
async function archiveStub(app: AppSummary): Promise<AppSummary | null> {
|
||||
if (!(await confirmDialog({
|
||||
title: T.archiveTitle(app.name), consequences: T.archiveConsequences, confirmLabel: T.archiveConfirm, danger: true,
|
||||
}))) return null
|
||||
try {
|
||||
const next = await api.apps.archive(app.id)
|
||||
toast.ok(T.archiveDone(next.name))
|
||||
return next
|
||||
} catch (e) {
|
||||
toast.error(e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/** 拥有者、创建和更新时间:服务端只给这几样 */
|
||||
function StubMeta({ app }: { app: AppSummary }) {
|
||||
return (
|
||||
<div className="space-y-0.5 text-2xs leading-relaxed text-dim" data-app-stub-meta="">
|
||||
<p data-app-stub-owner={app.owner ?? ''}>{app.owner ? T.owner(app.owner) : T.ownerUnknown}</p>
|
||||
{app.created_at && <p data-app-stub-created="">{T.createdAt(formatDateTime(app.created_at))}</p>}
|
||||
<p data-app-stub-updated="">{T.updatedAt(formatDateTime(app.updated_at))}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ArchiveButton({ app, onArchived }: { app: AppSummary; onArchived: (next: AppSummary) => void }) {
|
||||
const [busy, setBusy] = useState(false)
|
||||
if (app.status === 'archived') return <span className="chip">{APP_TEXT.archived}</span>
|
||||
return (
|
||||
<button type="button" className="btn btn-xs" disabled={busy} data-app-stub-archive=""
|
||||
onClick={async () => {
|
||||
setBusy(true)
|
||||
const next = await archiveStub(app)
|
||||
setBusy(false)
|
||||
if (next) onArchived(next)
|
||||
}}>
|
||||
{busy ? <Spinner size={10} /> : <Archive size={11} aria-hidden />} {T.archive}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/** 应用首页「使用者的个人应用」一组里的一张卡:不链到应用页(看不到内容),只写元数据,给「归档」 */
|
||||
export function PersonalStubCard({ app, onArchived }: { app: AppSummary; onArchived: () => void }) {
|
||||
return (
|
||||
<li className="flex flex-col rounded-lg border bg-panel p-3" data-app-stub={app.id}>
|
||||
<div className="flex items-start gap-2">
|
||||
<span aria-hidden className="flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-elev text-dim">
|
||||
<LayoutGrid size={14} />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate text-sm font-semibold text-fg">{app.name}</div>
|
||||
<StubMeta app={app} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-2.5 flex flex-wrap items-center gap-1.5 text-2xs">
|
||||
<span className="chip" style={{ color: 'var(--accent)' }}>{T.badge}</span>
|
||||
<span className="flex-1" />
|
||||
<ArchiveButton app={app} onArchived={onArchived} />
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
/** 管理员打开别人的个人应用:写明看不到内容,只给元数据和「归档」,不去取页面 */
|
||||
export function PersonalStubPage({ app, onArchived }: { app: AppSummary; onArchived: () => void }) {
|
||||
const who = app.owner ?? T.ownerUnknown
|
||||
return (
|
||||
<div className="flex h-full flex-col" data-app-stub-page={app.id}>
|
||||
<PageHeader icon={<LayoutGrid size={14} />} title={app.name}
|
||||
actions={<span className="chip" title={T.badgeHint} data-app-personal="">{T.badge}</span>} />
|
||||
<div className="min-h-0 flex-1 overflow-y-auto">
|
||||
<div className="mx-auto max-w-5xl space-y-3 p-4">
|
||||
<div className="text-2xs"><BackLink to="/apps?tab=apps" label={APP_TEXT.backToApps} /></div>
|
||||
<Notice tone="info" attr={{ 'data-app-stub-notice': '' }}>
|
||||
<span className="font-medium">{T.stubTitle(who)}</span>:{T.stubBody}
|
||||
</Notice>
|
||||
<div className="flex flex-wrap items-start gap-3 rounded-lg border bg-panel p-3">
|
||||
<div className="min-w-0 flex-1"><StubMeta app={app} /></div>
|
||||
<ArchiveButton app={app} onArchived={onArchived} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -342,16 +342,18 @@ function AddButton({ ctx, label, prompt, path, make }: {
|
||||
)
|
||||
}
|
||||
|
||||
/** 「看哪些数」的一项:先写对到的数据(表、中文名、粒度、业务日期、为什么),再逐项列 */
|
||||
/**
|
||||
* 「看哪些数」的一项:先写对到的数据(表、粒度、业务日期、为什么),再逐项列。表只写「源.表」(服务端 BpDataItem.table 是
|
||||
* {source, table}):表的中文名不在蓝图里,要看去数据目录,这里不另取
|
||||
*/
|
||||
function DataBlock({ ctx, item, index }: { ctx: CardCtx; item: BpDataItem; index: number }) {
|
||||
const table = (item.table?.value ?? null) as { source?: string; table?: string; label?: string } | null
|
||||
const date = item.date?.value as { column?: string; rule?: string } | null
|
||||
const table = item.table?.value ?? null
|
||||
const date = item.date?.value ?? null
|
||||
const head = table?.table ? (
|
||||
<div className="mb-1.5 rounded border bg-bg px-2 py-1.5 text-2xs leading-relaxed" data-bp-match={`${table.source}.${table.table}`}>
|
||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-0.5">
|
||||
<span className="inline-flex items-center gap-1 text-fg"><Database size={11} aria-hidden className="text-faint" />
|
||||
{BLUEPRINT_TEXT.dataTable}:<span className="mono">{table.source}.{table.table}</span></span>
|
||||
{table.label && <span>{BLUEPRINT_TEXT.dataTableLabel}:<span className="text-fg">{table.label}</span></span>}
|
||||
{item.grain?.value != null && <span>{BLUEPRINT_TEXT.dataGrain}:<span className="text-fg">{String(item.grain.value)}</span></span>}
|
||||
{date?.column && <span>{BLUEPRINT_TEXT.dataDate}:<span className="text-fg">{valueText('date', date)}</span></span>}
|
||||
</div>
|
||||
@@ -448,9 +450,6 @@ function AccessCard({ ctx, note, issues }: { ctx: CardCtx; note?: string; issues
|
||||
|
||||
// ---------------------------------------------------------------- 关节
|
||||
|
||||
/** 关节的说明:服务端在关节状态上给了名字和种类时用它,没给写关节 id */
|
||||
type JointView = JointState & { label?: string | null; kind?: string | null }
|
||||
|
||||
/** 按卡片直接填好的确定性关节(表单、处理人、定时这些):不经模型,不逐个列 */
|
||||
const deterministic = (j: JointState) => j.status === 'filled' && j.by === 'template'
|
||||
|
||||
@@ -460,7 +459,7 @@ function Joints({ blueprintId }: { blueprintId: string }) {
|
||||
const bp = entry?.blueprint
|
||||
if (!bp) return null
|
||||
const fill = entry?.fill
|
||||
const all = Object.entries(bp.joints ?? {}) as [string, JointView][]
|
||||
const all = Object.entries(bp.joints ?? {})
|
||||
// 只列生成关节(取数的 SQL、指标的算法):确定性关节按卡片填,汇总成一句
|
||||
const joints = all.filter(([, j]) => !deterministic(j))
|
||||
const fixed = all.length - joints.length
|
||||
@@ -479,8 +478,9 @@ function Joints({ blueprintId }: { blueprintId: string }) {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
// 关节的说法:模板声明的名字,没有就写种类和 id(实例化之前存下的关节没有这两项)
|
||||
const nameOf = (id: string) => {
|
||||
const j = (bp.joints?.[id] ?? {}) as JointView
|
||||
const j: Partial<JointState> = bp.joints?.[id] ?? {}
|
||||
return j.label || (j.kind ? `${JOINT_KIND_LABEL[j.kind] ?? j.kind}(${id})` : id)
|
||||
}
|
||||
return (
|
||||
|
||||
@@ -16,10 +16,14 @@ import { decodeCopilot, type CopilotOp } from '../../run/decode'
|
||||
import { BLUEPRINT_TEXT } from '../../lib/terms'
|
||||
import { chatBusy, openAsk, useBlueprint, type BpTurn } from '../../store/blueprint'
|
||||
import type { ConversationTurn } from '../../types'
|
||||
import type { BlueprintTurnMeta } from '../../typesBlueprint'
|
||||
|
||||
/** 落过库的一轮 → 显示用的一轮。meta.asked 是服务端记的反问 {question, options};answer 是回答或这一轮的说明 */
|
||||
/**
|
||||
* 落过库的一轮 → 显示用的一轮。meta 的形状见 BlueprintTurnMeta(ConversationTurn.meta 是各种对话共用的宽类型,这里按蓝图
|
||||
* 对话的约定读,缺字段、类型不对的照样不崩);answer 是回答或这一轮的说明
|
||||
*/
|
||||
function pastTurn(t: ConversationTurn): StreamTurn {
|
||||
const meta = (t.meta ?? {}) as { looks?: CopilotOp[]; asked?: { question?: string; options?: string[] } | null }
|
||||
const meta: BlueprintTurnMeta = t.meta ?? {}
|
||||
const asked = meta.asked && typeof meta.asked === 'object' ? meta.asked : null
|
||||
const ops: CopilotOp[] = [...(Array.isArray(meta.looks) ? meta.looks.map((l) => ({ ...l, op: 'look' })) : [])]
|
||||
if (t.status !== 'error') ops.push({ op: 'done', explanation: t.explanation || '' })
|
||||
|
||||
@@ -29,8 +29,6 @@ import { blueprintPath, useCreateScope } from './shared'
|
||||
/** 起点:建蓝图的请求体里 source 那一段 */
|
||||
type Source = { kind: BlueprintSourceKind; id?: string; version?: number }
|
||||
|
||||
/** 模板说明:服务端给了会产出什么、要准备什么时用它的,没给时按模板 id 说(termsBlueprint.TEMPLATE_PRODUCES) */
|
||||
type TemplateCardInfo = TemplateInfo & { produces?: string | null; prepare?: string[] | null }
|
||||
|
||||
export function NewAppStart() {
|
||||
const scope = useCreateScope()
|
||||
@@ -155,7 +153,7 @@ function TemplateStart({ scope, busy, onPick }: {
|
||||
}) {
|
||||
const { data, error, reload } = useLoad(() => api.templates.list(), [])
|
||||
// 「自由形」是从已有的运行或工作流导入用的,不作为从零开始的场景
|
||||
const items = (data?.items ?? []).filter((t) => t.id !== 'freeform') as TemplateCardInfo[]
|
||||
const items = (data?.items ?? []).filter((t) => t.id !== 'freeform')
|
||||
return (
|
||||
<section className="space-y-2" data-new-app-start="template" aria-labelledby="new-app-template">
|
||||
<div>
|
||||
@@ -177,14 +175,15 @@ function TemplateStart({ scope, busy, onPick }: {
|
||||
}
|
||||
|
||||
function TemplateCard({ t, scope, busy, onPick }: {
|
||||
t: TemplateCardInfo; scope: BlueprintScope; busy: string | null; onPick: (t: TemplateInfo) => void
|
||||
t: TemplateInfo; scope: BlueprintScope; busy: string | null; onPick: (t: TemplateInfo) => void
|
||||
}) {
|
||||
// 个人应用只能用模板里只读的那部分;整个模板都用不了的(要派人审批、写外部系统)照实说,不给选
|
||||
const blocked = scope === 'personal' && !t.personal
|
||||
const produces = t.produces || TEMPLATE_PRODUCES[t.id]
|
||||
const prepare = t.prepare?.length ? t.prepare
|
||||
: t.cards.filter((c) => c.card !== 'purpose' && c.card !== 'template')
|
||||
.map((c) => (c.note ? `${CARD_LABEL[c.card] ?? c.card}:${c.note}` : CARD_LABEL[c.card] ?? c.card))
|
||||
// 会产出什么:按模板 id 说(termsBlueprint.TEMPLATE_PRODUCES,模板说明里没有这一项);要准备什么:用模板说明里各张卡片的
|
||||
// 说明拼(服务端 TemplateInfo.cards)
|
||||
const produces = TEMPLATE_PRODUCES[t.id]
|
||||
const prepare = t.cards.filter((c) => c.card !== 'purpose' && c.card !== 'template')
|
||||
.map((c) => (c.note ? `${CARD_LABEL[c.card] ?? c.card}:${c.note}` : CARD_LABEL[c.card] ?? c.card))
|
||||
const key = `template:${t.id}`
|
||||
return (
|
||||
<li className="flex flex-col rounded-lg border bg-panel p-3" data-template={t.id} aria-disabled={blocked || undefined}>
|
||||
|
||||
@@ -23,10 +23,10 @@ import { appPath, usePoll } from '../apps/shared'
|
||||
const WHO: ProblemWho[] = ['you', 'assistant', 'admin']
|
||||
|
||||
/**
|
||||
* 这条问题归谁:服务端在问题顶层给的 who(发布单按自动修复的种类、要管理员的编号算好的)为准,没有再看白话里登记的
|
||||
* 那一档。PlainIssue 还没有顶层的 who(契约待补),先按多一项读
|
||||
* 这条问题归谁:服务端在问题顶层给的 who(发布单按自动修复的种类、要管理员的编号算好的,没登记白话的也有)为准;
|
||||
* 没给的(老服务端)再看白话里登记的那一档
|
||||
*/
|
||||
const whoOf = (p: PlainIssue): ProblemWho => (p as PlainIssue & { who?: ProblemWho }).who ?? p.plain?.who ?? 'you'
|
||||
const whoOf = (p: PlainIssue): ProblemWho => p.who ?? p.plain?.who ?? 'you'
|
||||
const DISPOSITIONS: Disposition[] = ['recompute', 'dual', 'incomparable']
|
||||
const POLL_MS = 1000
|
||||
|
||||
@@ -97,7 +97,8 @@ export function PublishSummary({ blueprintId, open, onClose, onFix }: {
|
||||
}
|
||||
|
||||
const problems = plan?.problems ?? []
|
||||
const blocked = problems.some((p) => p.level === 'error')
|
||||
// 能不能确认以服务端为准(ok:没有 error 级问题、也没停下),界面不另算
|
||||
const blocked = !!plan && !plan.ok
|
||||
const started = !!plan && plan.status !== 'planned'
|
||||
const scheduled = !!plan?.steps.some((s) => s.kind === 'create_schedule' && s.status !== 'skipped')
|
||||
const when = scheduled ? cadenceWhen(bp?.spec.cadence?.value) : ''
|
||||
@@ -264,16 +265,7 @@ function ProblemColumn({ who, items, onFix, onDispose, busy }: {
|
||||
<div style={{ color: p.level === 'error' ? 'var(--st-failed)' : 'var(--st-waiting)' }}>{p.plain?.title ?? p.message}</div>
|
||||
{p.plain?.why && <div className="text-dim">{p.plain.why}</div>}
|
||||
{p.plain?.action && <div className="text-faint">{p.plain.action}</div>}
|
||||
{p.code === 'app.upgrade_policy' && typeof (p as { alias?: unknown }).alias === 'string' && (
|
||||
<div className="mt-1 flex flex-wrap gap-1" role="group" data-plan-disposition={(p as { alias?: string }).alias}>
|
||||
{DISPOSITIONS.map((d) => (
|
||||
<button key={d} type="button" className="btn btn-xs" disabled={busy} title={APP_EDITOR_TEXT.dispositionHint[d]}
|
||||
onClick={() => onDispose((p as { alias?: string }).alias!, d)}>
|
||||
{APP_EDITOR_TEXT.dispositions[d]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{p.code === 'app.upgrade_policy' && p.alias && <DispositionChoice alias={p.alias} busy={busy} onDispose={onDispose} />}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -286,3 +278,19 @@ function ProblemColumn({ who, items, onFix, onDispose, busy }: {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 钉住项升了版、要选处置的(app.upgrade_policy 带 alias):就地给三种处置,选了带着处置重出发布单 */
|
||||
function DispositionChoice({ alias, busy, onDispose }: {
|
||||
alias: string; busy: boolean; onDispose: (alias: string, d: Disposition) => void
|
||||
}) {
|
||||
return (
|
||||
<div className="mt-1 flex flex-wrap gap-1" role="group" data-plan-disposition={alias}>
|
||||
{DISPOSITIONS.map((d) => (
|
||||
<button key={d} type="button" className="btn btn-xs" disabled={busy} title={APP_EDITOR_TEXT.dispositionHint[d]}
|
||||
onClick={() => onDispose(alias, d)}>
|
||||
{APP_EDITOR_TEXT.dispositions[d]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import { cleanValues, validateForm, withDefaults } from '../../lib/schemaForm'
|
||||
import { TRIAL_TEXT } from '../../lib/terms'
|
||||
import { TaskCard } from '../../run/TaskCard'
|
||||
import { useBlueprint } from '../../store/blueprint'
|
||||
import type { AppSpec, FormError, FormSchema, ViewModel } from '../../typesApp'
|
||||
import type { FormError, FormSchema, ViewModel } from '../../typesApp'
|
||||
import { useLoad, usePoll } from '../apps/shared'
|
||||
import { blueprintPath } from './shared'
|
||||
|
||||
@@ -29,12 +29,11 @@ const POLL_MS = 4000
|
||||
/** 流程类模板:试运行里有人工步骤,右侧要列待办 */
|
||||
const PROCESS_TEMPLATES = new Set(['approval', 'exception_handling', 'reconcile_writeback'])
|
||||
|
||||
/** 应用骨架里第一个入口的表单(试运行的输入) */
|
||||
function entryForm(spec: AppSpec | null | undefined): FormSchema | null {
|
||||
const form = spec?.entries?.[0]?.form
|
||||
if (!form) return null
|
||||
return '$ref' in form ? spec?.forms?.[String((form as { $ref: string }).$ref)] ?? null : form as FormSchema
|
||||
}
|
||||
/**
|
||||
* 「换一期再试」填的表单:服务端随预览给(ViewModel.trial.form,blueprints/trial.retry_form,和试运行时认表单是同一条规则),
|
||||
* 这里照着画,不自己从骨架里挑。没有的只能原样再试一次
|
||||
*/
|
||||
const trialForm = (model: ViewModel | null | undefined): FormSchema | null => model?.trial?.form ?? null
|
||||
|
||||
/** 视图里报错的那一块:服务端在来源上写了为什么 */
|
||||
function failureOf(model: ViewModel | null | undefined): string | null {
|
||||
@@ -136,8 +135,7 @@ function TrialBanner({ blueprintId, runId, model, onRetried }: {
|
||||
}) {
|
||||
const entry = useBlueprint((s) => s.byId[blueprintId])
|
||||
const last = entry?.lastTrial?.run_id === runId ? entry.lastTrial : null
|
||||
// 输入表单:服务端随试运行给的,没给就用按卡片生成的应用骨架里的入口表单
|
||||
const form = last?.form ?? entryForm(entry?.instantiated?.app_spec)
|
||||
const form = trialForm(model)
|
||||
const [open, setOpen] = useState(false)
|
||||
const [values, setValues] = useState<Record<string, unknown>>({})
|
||||
const [errors, setErrors] = useState<FormError[]>([])
|
||||
|
||||
@@ -19,10 +19,10 @@ export const blueprintPath = (id: string, section?: 'trial', query?: Record<stri
|
||||
|
||||
/**
|
||||
* 管理员开没开「使用者建个人应用」(设置 apps.user_personal_apps,默认关)。使用者读不到设置,开关随认人接口
|
||||
* (GET /api/auth/me)一起给,同问数据的 user_can_chat。老服务端不给时按关。
|
||||
* (GET /api/auth/me 的 Principal.user_personal_apps)一起给,同问数据的 user_can_chat。老服务端不给时按关。
|
||||
*/
|
||||
export function personalAppsOn(me: Principal | null | undefined): boolean {
|
||||
return (me as (Principal & { user_personal_apps?: boolean }) | null | undefined)?.user_personal_apps === true
|
||||
return me?.user_personal_apps === true
|
||||
}
|
||||
|
||||
/** 这个人新建应用时建哪种蓝图;null = 没有入口 */
|
||||
|
||||
Reference in New Issue
Block a user