Frame process records and align the completed summary

This commit is contained in:
QQ 2026-11-28 14:49:36 +08:00
parent 0acf291002
commit a0366b91cc
7 changed files with 83 additions and 89 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,25 +1,19 @@
import { useRef } from 'react';
import css from './Reader.module.css'; import css from './Reader.module.css';
import { Disclosure } from './motion.js'; import { Disclosure } from './motion.js';
import { FoldSummaryText } from './LiveFold.js'; import { FoldSummaryText } from './LiveFold.js';
import { foldSummary } from './live-turn.js'; import { foldSummary } from './live-turn.js';
import { DiffStat } from './DiffPanel.js'; import { DiffStat } from './DiffPanel.js';
import { usePublishedHeight } from './StickyLane.js';
import type { LiveStep } from './live-turn.js'; import type { LiveStep } from './live-turn.js';
/** Keep process counts discoverable after the live-fold presentation retires. */ /** Keep process counts discoverable after the live-fold presentation retires. */
export function ClosedProcessSummary({ steps, open, onChange, controls }: { export function ClosedProcessSummary({ steps, open, onChange, controls }: {
steps: readonly LiveStep[]; open: boolean; onChange: (value: boolean) => void; controls: string; steps: readonly LiveStep[]; open: boolean; onChange: (value: boolean) => void; controls: string;
}) { }) {
const button = useRef<HTMLButtonElement>(null);
const lane = usePublishedHeight('--reader-summary-height');
if (!steps.length) return null; if (!steps.length) return null;
const summary = foldSummary(steps); const summary = foldSummary(steps);
return <div ref={lane} className={css.closedProcessSummary} data-reader-closed-summary={summary}> return <div className={`${css.closedProcessSummary} ${css.summaryRow}`} data-reader-closed-summary={summary}>
<div className={css.summaryRow}> <Disclosure open={open} onChange={onChange} controls={controls} ariaLabel="本轮过程详情"
<Disclosure open={open} onChange={onChange} controls={controls} buttonRef={button} ariaLabel="本轮过程详情" label={<FoldSummaryText summary={summary} motion={false} />} />
label={<FoldSummaryText summary={summary} motion={false} />} /> <DiffStat steps={steps} label={summary} />
<DiffStat steps={steps} label={summary} />
</div>
</div>; </div>;
} }

View File

@ -152,7 +152,15 @@
.processSeamRow .disclosureButton { min-height: 24px; padding-block: 2px; font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-tertiary); } .processSeamRow .disclosureButton { min-height: 24px; padding-block: 2px; font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-tertiary); }
.flowCell:has(> .flowCellInner > [data-reader-seam-after]) > .flowCellInner { padding-bottom: 0; } .flowCell:has(> .flowCellInner > [data-reader-seam-after]) > .flowCellInner { padding-bottom: 0; }
.processFrame { min-width: 0; } .processFrame { min-width: 0; }
.toolActivity { min-width: 0; color: var(--dsw-alias-label-secondary); } .toolActivity { color: var(--dsw-alias-label-secondary); }
.toolActivity, .processCard {
min-width: 0;
padding: 4px 8px;
border: 1px solid var(--dsw-alias-border-l2);
border-radius: 12px;
background: var(--dsw-alias-bg-module-platform);
}
.processCard { padding: 8px 12px; }
.nativeToolRow { min-width: 0; } .nativeToolRow { min-width: 0; }
.rowSeparator { flex: none; width: 2px; height: 2px; margin: 0 8px; border-radius: 1px; background: var(--dsw-alias-label-caption); } .rowSeparator { flex: none; width: 2px; height: 2px; margin: 0 8px; border-radius: 1px; background: var(--dsw-alias-label-caption); }
.nativeToolSummary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); font-size: 14px; line-height: 24px; } .nativeToolSummary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); font-size: 14px; line-height: 24px; }
@ -370,9 +378,7 @@
scroll-margin-block: 16px calc(var(--dsh-composer-height, 152px) + 16px); scroll-margin-block: 16px calc(var(--dsh-composer-height, 152px) + 16px);
} }
.reasonHeading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 16px 0; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; } .reasonHeading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 16px 0; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; }
.reasonCard[data-overflow=false][data-expanded=false] { border-color: transparent; border-radius: 0; background: transparent; } .reasonCard[data-overflow=false][data-expanded=false] .reasonText { padding-bottom: 10px; }
.reasonCard[data-overflow=false][data-expanded=false] .reasonHeading { padding: 0; }
.reasonCard[data-overflow=false][data-expanded=false] .reasonText { padding: 4px 0 0 22px; }
.reasonLabel { font-weight: 500; } .reasonLabel { font-weight: 500; }
.reasonViewport { .reasonViewport {
position: relative; position: relative;
@ -594,32 +600,40 @@
it too. The toolbar is z-index 7, above the lane's 6, so its buttons still it too. The toolbar is z-index 7, above the lane's 6, so its buttons still
render on top of the extension. */ render on top of the extension. */
.turnProcessSticky { box-shadow: 0 -14px 0 var(--dsw-alias-bg-base), var(--reader-control-width, 148px) 0 0 var(--dsw-alias-bg-base), 0 -14px 0 var(--dsw-alias-bg-layer-1, transparent), var(--reader-control-width, 148px) 0 0 var(--dsw-alias-bg-layer-1, transparent), 0 -14px 0 Canvas, var(--reader-control-width, 148px) 0 0 Canvas; } .turnProcessSticky { box-shadow: 0 -14px 0 var(--dsw-alias-bg-base), var(--reader-control-width, 148px) 0 0 var(--dsw-alias-bg-base), 0 -14px 0 var(--dsw-alias-bg-layer-1, transparent), var(--reader-control-width, 148px) 0 0 var(--dsw-alias-bg-layer-1, transparent), 0 -14px 0 Canvas, var(--reader-control-width, 148px) 0 0 Canvas; }
.turnStickyLanes .turnProcessSticky, .turnStickyLanes .closedProcessSummary { position: static; top: auto; z-index: auto; } .turnStickyLanes .turnProcessSticky { position: static; top: auto; z-index: auto; }
.turnProcessSticky:has(> .closedProcessSummary) {
width: 100%;
gap: 8px;
box-shadow: none;
}
.turnProcessSticky:has(> .closedProcessSummary) > .disclosure { flex: 0 0 auto; }
.closedProcessSummary.summaryRow { flex: 1 1 auto; flex-wrap: nowrap; }
/* The same summary row stays in flow until it reaches the measured top lane. */ /* The same summary row stays in flow until it reaches the measured top lane. */
.flowCell[data-flow-summary], .closedProcessSummary { position: sticky; top: calc(var(--reader-toolbar-height, var(--reader-lane-block, 40px)) + var(--reader-status-height, var(--reader-lane-block, 40px))); z-index: 5; overflow: visible; box-sizing: border-box; min-height: var(--reader-lane-block, 40px); padding-block: 4px; background: var(--dsw-alias-bg-base); border-bottom: 0; } .flowCell[data-flow-summary] { position: sticky; top: calc(var(--reader-toolbar-height, var(--reader-lane-block, 40px)) + var(--reader-status-height, var(--reader-lane-block, 40px))); z-index: 5; overflow: visible; box-sizing: border-box; min-height: var(--reader-lane-block, 40px); padding-block: 4px; background: var(--dsw-alias-bg-base); border-bottom: 0; }
/* Keep the official CodeBlock banner's internal z-index inside its wrapper so Reader lanes stay above it. */ /* Keep the official CodeBlock banner's internal z-index inside its wrapper so Reader lanes stay above it. */
.root :global(.md-code-block) { z-index: 0; } .root :global(.md-code-block) { z-index: 0; }
/* Keep native code actions below the pinned Reader lanes. */ /* Keep native code actions below the pinned Reader lanes. */
.turnStickyRegion:has(> .turnStickyLanes > .closedProcessSummary), .turnStickyRegion:has(.flowCell[data-flow-summary]) { --reader-code-summary-height: var(--reader-summary-height, var(--reader-lane-block, 40px)); } .turnStickyRegion:has(.flowCell[data-flow-summary]) { --reader-code-summary-height: var(--reader-summary-height, var(--reader-lane-block, 40px)); }
.root :global(.md-code-block > :has(+ [data-code-block-content])) { top: calc(max(var(--reader-toolbar-height, 40px), var(--reader-status-height, 0px)) + var(--reader-status-height, 0px) + var(--reader-code-summary-height, 0px)); } .root :global(.md-code-block > :has(+ [data-code-block-content])) { top: calc(max(var(--reader-toolbar-height, 40px), var(--reader-status-height, 0px)) + var(--reader-status-height, 0px) + var(--reader-code-summary-height, 0px)); }
.flowCell[data-flow-summary] { box-shadow: 0 -16px 0 var(--dsw-alias-bg-base), 0 -16px 0 var(--dsw-alias-bg-layer-1, transparent), 0 -16px 0 Canvas; } .flowCell[data-flow-summary] { box-shadow: 0 -16px 0 var(--dsw-alias-bg-base), 0 -16px 0 var(--dsw-alias-bg-layer-1, transparent), 0 -16px 0 Canvas; }
.closedProcessSummary { box-shadow: 0 -14px 0 var(--dsw-alias-bg-base), 0 -14px 0 var(--dsw-alias-bg-layer-1, transparent), 0 -14px 0 Canvas; }
.foldControl { display: inline-flex; align-items: center; gap: 0; padding: 2px; border-radius: 8px; background: var(--dsw-alias-bg-module-platform); } .foldControl { display: inline-flex; align-items: center; gap: 0; padding: 2px; border-radius: 8px; background: var(--dsw-alias-bg-module-platform); }
.foldStop { border: 0; background: transparent; color: var(--dsw-alias-label-secondary); padding: 2px 8px; border-radius: 6px; white-space: nowrap; font: inherit; font-size: 12px; line-height: 18px; cursor: pointer; } .foldStop { border: 0; background: transparent; color: var(--dsw-alias-label-secondary); padding: 2px 8px; border-radius: 6px; white-space: nowrap; font: inherit; font-size: 12px; line-height: 18px; cursor: pointer; }
.foldStop[data-on] { background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); } .foldStop[data-on] { background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); }
.flowCell[data-flow-summary] > .flowCellInner { padding-bottom: 0; } .flowCell[data-flow-summary] > .flowCellInner { padding-bottom: 0; }
.flowCell[data-flow-summary] .disclosureButton, .closedProcessSummary .disclosureButton { width: auto; max-width: 100%; } .flowCell[data-flow-summary] .disclosureButton, .closedProcessSummary .disclosureButton { width: auto; max-width: 100%; }
.flowCell[data-flow-summary] .foldSummary, .closedProcessSummary .foldSummary { min-width: 0; } .flowCell[data-flow-summary] .foldSummary, .closedProcessSummary .foldSummary { min-width: 0; }
/* Fold summaries put the thinking count first when the group includes reasoning. */ .disclosureButton:has([data-reader-fold-summary]),
.disclosureButton[aria-expanded=false]:has([data-reader-fold-summary^="思考×"]) { .turnProcessSticky > .disclosure > .disclosureButton {
margin-left: 0; margin-left: 0;
padding-inline: 12px; padding-inline: 12px;
max-width: 100%; max-width: 100%;
border: 1px solid var(--dsw-alias-border-l2);
border-radius: var(--dsw-radius-xl, 22px); border-radius: var(--dsw-radius-xl, 22px);
background: color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent); background: color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);
color: var(--dsw-alias-label-secondary); color: var(--dsw-alias-label-secondary);
} }
.disclosureButton[aria-expanded=false]:has([data-reader-fold-summary^="思考×"]):hover { .disclosureButton:has([data-reader-fold-summary]):hover,
.turnProcessSticky > .disclosure > .disclosureButton:hover {
background: color-mix(in srgb, var(--dsw-alias-label-primary) 13%, transparent); background: color-mix(in srgb, var(--dsw-alias-label-primary) 13%, transparent);
} }
.turnProcessSticky > .disclosure { flex: 1 1 auto; min-width: 0; } .turnProcessSticky > .disclosure { flex: 1 1 auto; min-width: 0; }
@ -636,8 +650,7 @@
.turnStickyLanes, .turnStickyLanes,
.turnProcessSticky, .turnProcessSticky,
.liveFoldContainer, .liveFoldContainer,
.flowCell[data-flow-summary], .flowCell[data-flow-summary] {
.closedProcessSummary {
background-color: Canvas; background-color: Canvas;
background-image: var(--reader-lane-plate); background-image: var(--reader-lane-plate);
background-repeat: no-repeat; background-repeat: no-repeat;
@ -683,8 +696,7 @@
} }
/* The z-index ladder is mode-independent: skin mode only drops the plate, so /* The z-index ladder is mode-independent: skin mode only drops the plate, so
a glass reader keeps exactly the same footer precedence as an opaque one. */ a glass reader keeps exactly the same footer precedence as an opaque one. */
.root[data-reader-glass] .flowCell[data-flow-summary], .root[data-reader-glass] .flowCell[data-flow-summary] {
.root[data-reader-glass] .closedProcessSummary {
box-shadow: none; box-shadow: none;
position: static; position: static;
z-index: auto; z-index: auto;
@ -706,7 +718,7 @@
} }
/* Skin mode paints no plates of the reader's own: cards, panels and frames go /* Skin mode paints no plates of the reader's own: cards, panels and frames go
fully transparent so the skin behind them stays visible. */ fully transparent so the skin behind them stays visible. */
.root[data-reader-glass] .reasonCard { .root[data-reader-glass] :is(.reasonCard, .toolActivity, .processCard) {
background: transparent; background: transparent;
border-color: color-mix(in srgb, var(--dsw-alias-border-l1, rgba(128,128,128,.35)) 65%, transparent); border-color: color-mix(in srgb, var(--dsw-alias-border-l1, rgba(128,128,128,.35)) 65%, transparent);
} }

View File

@ -168,7 +168,7 @@ const ProcessNode = memo(function ProcessNode({ useChat, t, nodeKey, open, motio
} }
else if (isNode(node, 'compaction')) content = <CompactionDivider data={node.data} />; else if (isNode(node, 'compaction')) content = <CompactionDivider data={node.data} />;
else if (isNode(node, 'command')) content = <JsonBlock label="命令记录" payload={node.data} truncatedLabel={truncatedJsonLabel} />; else if (isNode(node, 'command')) content = <JsonBlock label="命令记录" payload={node.data} truncatedLabel={truncatedJsonLabel} />;
return content && <ProcessFragment open={open} motion={motion} onRead={onRead} returnFocusTo={returnFocusTo} nodeKey={nodeKey} framed>{content}</ProcessFragment>; return content && <ProcessFragment open={open} motion={motion} onRead={onRead} returnFocusTo={returnFocusTo} nodeKey={nodeKey} framed><div className={css.processCard}>{content}</div></ProcessFragment>;
}); });
const MainNode = memo(function MainNode({ useChat, nodeKey, boundary, pinned, processOpen: _processOpen = false, ...render }: SeatProps) { const MainNode = memo(function MainNode({ useChat, nodeKey, boundary, pinned, processOpen: _processOpen = false, ...render }: SeatProps) {
@ -606,12 +606,12 @@ const TurnGroup = memo(function TurnGroup({ group, motion, autoFold, pinnedKeys,
{startsWithUser && <BlockBoundary><MainNode {...shared} useChat={props.useChat} boundary={boundary} nodeKey={group.keys[0]} /></BlockBoundary>} {startsWithUser && <BlockBoundary><MainNode {...shared} useChat={props.useChat} boundary={boundary} nodeKey={group.keys[0]} /></BlockBoundary>}
<div className={css.turnStickyRegion} data-reader-sticky-region> <div className={css.turnStickyRegion} data-reader-sticky-region>
{(showStatusLane || showClosedSummary) && <div className={css.turnStickyLanes}> {(showStatusLane || showClosedSummary) && <div className={css.turnStickyLanes}>
{showStatusLane && <StickyLane kind="status" className={css.turnProcessSticky}> <StickyLane kind="status" className={css.turnProcessSticky}>
<Disclosure open={expanded} onChange={setExpanded} controls={flowId} buttonRef={processButton} {showStatusLane && <Disclosure open={expanded} onChange={setExpanded} controls={flowId} buttonRef={processButton}
label={<GroupStatus group={group} useChat={props.useChat} pending={interaction} motion={motion} />} /> label={<GroupStatus group={group} useChat={props.useChat} pending={interaction} motion={motion} />} />}
</StickyLane>} {showClosedSummary && <ClosedProcessSummary open={expanded} onChange={setExpanded} controls={flowId}
{showClosedSummary && <ClosedProcessSummary open={expanded} onChange={setExpanded} controls={flowId} steps={steps.filter(step => step.kind !== 'user' && step.kind !== 'body')} />}
steps={steps.filter(step => step.kind !== 'user' && step.kind !== 'body')} />} </StickyLane>
</div>} </div>}
<ChoreographedFlow id={flowId} frame={presentation} motion={motion} enabled={autoFold && boundary.status === 'open' && !holdingSelection} <ChoreographedFlow id={flowId} frame={presentation} motion={motion} enabled={autoFold && boundary.status === 'open' && !holdingSelection}
urgent={hasTurnError || interaction !== undefined || !sessionRunning} open={foldOpenByKey} processOpen={expanded} urgent={hasTurnError || interaction !== undefined || !sessionRunning} open={foldOpenByKey} processOpen={expanded}

View File

@ -60,17 +60,6 @@ export function publishLaneHeight(el: HTMLElement, property: string, scoped: Lan
}; };
} }
export function usePublishedHeight(property: string) {
const owners = useContext(LaneOwnerContext);
const ref = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
const el = ref.current;
if (!el) return;
return publishLaneHeight(el, property, owners);
}, [owners, property]);
return ref;
}
export function useSummaryLane(ref: { readonly current: HTMLElement | null }, active: boolean) { export function useSummaryLane(ref: { readonly current: HTMLElement | null }, active: boolean) {
const owners = useContext(LaneOwnerContext); const owners = useContext(LaneOwnerContext);
useLayoutEffect(() => { useLayoutEffect(() => {

View File

@ -10,6 +10,7 @@ import { test } from 'vitest';
*/ */
const source = await readFile(new URL('../src/client/reader-plugin.tsx', import.meta.url), 'utf8'); const source = await readFile(new URL('../src/client/reader-plugin.tsx', import.meta.url), 'utf8');
const seat = await readFile(new URL('../src/client/chat-view-seat.ts', import.meta.url), 'utf8'); const seat = await readFile(new URL('../src/client/chat-view-seat.ts', import.meta.url), 'utf8');
const reader = await readFile(new URL('../src/client/Reader.tsx', import.meta.url), 'utf8');
const blocks = await readFile(new URL('../src/client/Blocks.tsx', import.meta.url), 'utf8'); const blocks = await readFile(new URL('../src/client/Blocks.tsx', import.meta.url), 'utf8');
const readerCss = await readFile(new URL('../src/client/Reader.module.css', import.meta.url), 'utf8'); const readerCss = await readFile(new URL('../src/client/Reader.module.css', import.meta.url), 'utf8');
const markdown = await readFile(new URL('../src/client/markdown/MarkdownText.tsx', import.meta.url), 'utf8'); const markdown = await readFile(new URL('../src/client/markdown/MarkdownText.tsx', import.meta.url), 'utf8');
@ -52,3 +53,14 @@ test('the optional user-image slot has a low-priority renderer', () => {
assert.match(blocks, /loadUrl=\{loadImage\}/u); assert.match(blocks, /loadUrl=\{loadImage\}/u);
assert.match(blocks, /src=\{image\.preview\.url\}/u); assert.match(blocks, /src=\{image\.preview\.url\}/u);
}); });
test('short thoughts, tools and folded process summaries keep visible cards', () => {
assert.doesNotMatch(readerCss, /\.reasonCard\[data-overflow=false\][^{}]*\{[^}]*background:\s*transparent/u);
assert.match(readerCss, /\.toolActivity, \.processCard \{[^}]*border:/u);
assert.match(readerCss, /\.disclosureButton:has\(\[data-reader-fold-summary\]\)[^{}]*\{[^}]*border:/u);
});
test('completed timing and record summary share one measured status lane', () => {
assert.match(reader, /<StickyLane kind="status"[^>]*>[\s\S]*?<GroupStatus[\s\S]*?<ClosedProcessSummary[\s\S]*?<\/StickyLane>/u);
assert.match(readerCss, /\.closedProcessSummary\.summaryRow \{[^}]*flex-wrap: nowrap/u);
});