mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-20 18:12:02 +00:00
目录修改提案落在已驳回的项上时,改前写出被驳回的原值:plan_patch 交回的 before 带上驳回的值、before_status 写 rejected(只改给人看的信息,算改后、算状态照旧按没有这一项,保存时照旧换成人工确认的新值);助手流的提案卡片、表助手的提案卡片和待保存的修改写「已驳回:<原值>」,和导入预览「目标里这一项已经驳回」一致;check-catalog-loop、check-stream 补对应检查
This commit is contained in:
@@ -2610,6 +2610,8 @@ export const CATALOG_PATCH_TEXT = {
|
||||
after: '改后',
|
||||
reason: '理由',
|
||||
empty: '未填写',
|
||||
/** 改前是一个被驳回的值(保存后换成人工确认的新值):同导入预览「目标里这一项已经驳回」 */
|
||||
beforeRejected: (value: string) => `已驳回:${value}`,
|
||||
stateConfirm: '值不变,保存即确认',
|
||||
stateSame: '已是这个值',
|
||||
save: '保存到数据目录',
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Notice, Spinner, confirmDialog, isComposing, toast } from '../../compon
|
||||
import { useLeaveGuard } from '../../lib/leave'
|
||||
import { CATALOG_ASSISTANT_TEXT as T, CATALOG_STATUS_LABEL } from '../../lib/terms'
|
||||
import { Markdown } from '../../run/Markdown'
|
||||
import { patchValueText } from '../../run/catalogPatch'
|
||||
import { beforeStatusShown, patchBeforeText, patchValueText } from '../../run/catalogPatch'
|
||||
import {
|
||||
ASSISTANT_MAX_CHARS, ASSISTANT_MAX_SAVE, QUERY_ROWS_SHOWN, applyEvent, applyPreview, assistantChangesOf, blankColumnsOf, blankLeadOf,
|
||||
changeStateOf, changeWhere, dropPending, historyOf, mergeProposal, pendingForAssistant, pendingSubmit, pendingVersion, savedKey,
|
||||
@@ -495,9 +495,10 @@ function ChangeRow({ change: c, state, onToggle }: {
|
||||
</div>
|
||||
<dl className={clsx('mt-1 grid grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 leading-relaxed', off && 'opacity-70')}>
|
||||
<dt className="text-faint">{T.before}</dt>
|
||||
<dd className={clsx('break-words', c.before == null ? 'text-faint' : 'text-dim')} data-change-before="">
|
||||
{valueText(c.path, c.before)}
|
||||
{c.before != null && c.before_status && <span className="text-faint">({CATALOG_STATUS_LABEL[c.before_status]})</span>}
|
||||
<dd className={clsx('break-words', c.before == null || c.before_status === 'rejected' ? 'text-faint' : 'text-dim')} data-change-before=""
|
||||
data-change-before-status={c.before_status ?? undefined}>
|
||||
{patchBeforeText(c)}
|
||||
{beforeStatusShown(c) && <span className="text-faint">({CATALOG_STATUS_LABEL[c.before_status!]})</span>}
|
||||
</dd>
|
||||
<dt className="text-faint">{T.after}</dt>
|
||||
<dd className="break-words text-fg" data-change-after="">
|
||||
@@ -585,7 +586,7 @@ function PendingTray({ pending, open, onToggle, save, editing, onDrop, onClear,
|
||||
<div className="min-w-0 flex-1 leading-relaxed">
|
||||
<p className="break-words font-medium text-fg">{where}</p>
|
||||
<p className="break-words text-dim">
|
||||
<span className="text-faint">{T.before} </span>{valueText(p.path, p.before)}
|
||||
<span className="text-faint">{T.before} </span>{patchBeforeText(p)}
|
||||
<span className="text-faint"> → {T.after} </span><span className="text-fg">{valueText(p.path, p.after)}</span>
|
||||
</p>
|
||||
{p.reason && <p className="break-words text-faint"><span>{T.reason}:</span>{p.reason}</p>}
|
||||
|
||||
@@ -8,7 +8,8 @@ import { CatalogImpactList } from '../components/CatalogImpact'
|
||||
import { CATALOG_PATCH_TEXT as T, CATALOG_STATUS_LABEL, CATALOG_UI_TEXT as UT } from '../lib/terms'
|
||||
import type { CatalogPatchChange } from '../types'
|
||||
import {
|
||||
catalogTableHref, codeMeaning, patchSubmit, patchTarget, patchValueText, patchWhere, type CatalogPatch,
|
||||
beforeStatusShown, catalogTableHref, codeMeaning, patchBeforeText, patchSubmit, patchTarget, patchValueText, patchWhere,
|
||||
type CatalogPatch,
|
||||
} from './catalogPatch'
|
||||
|
||||
// ===========================================================================
|
||||
@@ -183,13 +184,15 @@ function ChangeRow({ change: c, dense }: { change: CatalogPatchChange; dense: bo
|
||||
</div>
|
||||
<dl className="mt-1 grid grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 text-2xs leading-relaxed">
|
||||
<dt className="text-faint">{T.before}</dt>
|
||||
<dd className={clsx('break-words', c.before == null ? 'text-faint' : 'text-dim')} data-patch-before="">
|
||||
{patchValueText(c.path, c.before)}
|
||||
{c.before != null && c.before_status && <span className="text-faint">({CATALOG_STATUS_LABEL[c.before_status]})</span>}
|
||||
<dd className={clsx('break-words', c.before == null || c.before_status === 'rejected' ? 'text-faint' : 'text-dim')} data-patch-before=""
|
||||
data-patch-before-status={c.before_status ?? undefined}>
|
||||
{patchBeforeText(c)}
|
||||
{beforeStatusShown(c) && <span className="text-faint">({CATALOG_STATUS_LABEL[c.before_status!]})</span>}
|
||||
</dd>
|
||||
<dt className="text-faint">{T.after}</dt>
|
||||
<dd className="break-words text-fg" data-patch-after="">
|
||||
{isCodes ? <CodesAfter before={c.before} after={c.after} /> : patchValueText(c.path, c.after)}
|
||||
{/* 被驳回的码值不算:保存时整项换成新的,改后的码值都是新加的 */}
|
||||
{isCodes ? <CodesAfter before={c.before_status === 'rejected' ? null : c.before} after={c.after} /> : patchValueText(c.path, c.after)}
|
||||
</dd>
|
||||
{c.reason && (
|
||||
<>
|
||||
|
||||
@@ -141,6 +141,20 @@ export function patchValueText(path: string, v: unknown): string {
|
||||
return typeof v === 'string' ? v : JSON.stringify(v)
|
||||
}
|
||||
|
||||
/**
|
||||
* 改前那一格(卡片、表助手的提案和待保存的修改都用它):被驳回的项写「已驳回:原值」——服务端把驳回的原值也交回来
|
||||
* (before_status 为 rejected),保存时照旧换成人工确认的新值;只写「未填写」就看不出原来有一个被驳回的值,和导入预览
|
||||
* 「目标里这一项已经驳回」对不上。别的照 patchValueText 写,没有值写「未填写」
|
||||
*/
|
||||
export function patchBeforeText(change: Pick<CatalogPatchChange, 'path' | 'before' | 'before_status'>): string {
|
||||
const text = patchValueText(change.path, change.before)
|
||||
return change.before_status === 'rejected' && change.before != null ? CATALOG_PATCH_TEXT.beforeRejected(text) : text
|
||||
}
|
||||
|
||||
/** 改前要不要跟一个状态(「(推断)」):有值、不是被驳回的(被驳回的状态已经写在 patchBeforeText 里) */
|
||||
export const beforeStatusShown = (change: Pick<CatalogPatchChange, 'before' | 'before_status'>) =>
|
||||
change.before != null && !!change.before_status && change.before_status !== 'rejected'
|
||||
|
||||
/** 交回保存、预览的那一份:路径、原样取值、理由 */
|
||||
export function patchSubmit(changes: CatalogPatchChange[]) {
|
||||
return changes.map((c) => ({ path: c.path, value: c.value, ...(c.reason ? { reason: c.reason } : {}) }))
|
||||
|
||||
Reference in New Issue
Block a user