Merge branch 'codex/20260831-show-progress-messages-a14f9c2d-show-progress-messages-a14f9c2d'
This commit is contained in:
@@ -72,7 +72,6 @@ const WINDOW_STEP = 100;
|
||||
const LONG_OUTPUT_CHARS = 4_000;
|
||||
const STREAMING_THINKING_WINDOW_CHARS = 16_000;
|
||||
const PROGRESS_PREVIEW_MAX_CHARS = 360;
|
||||
const PROGRESS_ROLL_CHAR_STEP = 6;
|
||||
|
||||
const NODE_STATUS_LABELS: Record<string, string> = {
|
||||
declared: '已声明',
|
||||
@@ -652,19 +651,19 @@ function toolActivityIcon(node: ConversationToolNode) {
|
||||
return <Hammer className={className} aria-hidden="true" />;
|
||||
}
|
||||
|
||||
function latestProgressLine(value: string): string | null {
|
||||
function firstProgressLine(value: string): string | null {
|
||||
const lines = value
|
||||
.split(/\r?\n/)
|
||||
.map((line) => line.trim())
|
||||
.filter(Boolean);
|
||||
const line = lines
|
||||
.at(-1)
|
||||
.at(0)
|
||||
?.replace(/\s+/g, ' ')
|
||||
.replace(/^#{1,6}\s+/, '')
|
||||
.replace(/^(?:[-*+]|\d+[.)])\s+/, '');
|
||||
if (!line) return null;
|
||||
return line.length > PROGRESS_PREVIEW_MAX_CHARS
|
||||
? `…${line.slice(-(PROGRESS_PREVIEW_MAX_CHARS - 1))}`
|
||||
? `${line.slice(0, PROGRESS_PREVIEW_MAX_CHARS - 1)}…`
|
||||
: line;
|
||||
}
|
||||
|
||||
@@ -699,22 +698,20 @@ const RollingProgressPreview = memo(function RollingProgressPreview({
|
||||
codeClassName?: string;
|
||||
}) {
|
||||
const viewportRef = useRef<HTMLSpanElement | null>(null);
|
||||
const revision = `${active ? 'active' : 'settled'}:${Math.floor(
|
||||
contentVersion / PROGRESS_ROLL_CHAR_STEP,
|
||||
)}`;
|
||||
const revision = `${active ? 'active' : 'settled'}:${text}`;
|
||||
const parts = progressInlineParts(text);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const viewport = viewportRef.current;
|
||||
if (!viewport) return;
|
||||
viewport.scrollLeft = viewport.scrollWidth;
|
||||
viewport.scrollLeft = 0;
|
||||
}, [contentVersion, text]);
|
||||
|
||||
useEffect(() => {
|
||||
const viewport = viewportRef.current;
|
||||
if (!viewport || typeof ResizeObserver === 'undefined') return;
|
||||
const observer = new ResizeObserver(() => {
|
||||
viewport.scrollLeft = viewport.scrollWidth;
|
||||
viewport.scrollLeft = 0;
|
||||
});
|
||||
observer.observe(viewport);
|
||||
return () => observer.disconnect();
|
||||
@@ -729,9 +726,9 @@ const RollingProgressPreview = memo(function RollingProgressPreview({
|
||||
className,
|
||||
)}
|
||||
data-progress-alignment="left"
|
||||
data-progress-origin="head"
|
||||
data-progress-update-motion={rollUpdates ? 'roll' : 'none'}
|
||||
data-progress-shimmer={active && shimmer ? 'true' : 'false'}
|
||||
data-progress-tail="true"
|
||||
data-roll-revision={rollUpdates ? revision : undefined}
|
||||
data-testid={testId}
|
||||
title={text}
|
||||
@@ -772,11 +769,11 @@ function contentBlocksProgressPreview(
|
||||
blocks: ConversationContentBlock[],
|
||||
fallback: string,
|
||||
): string {
|
||||
for (let index = blocks.length - 1; index >= 0; index -= 1) {
|
||||
for (let index = 0; index < blocks.length; index += 1) {
|
||||
const block = blocks[index];
|
||||
if (!block) continue;
|
||||
if (block.kind === 'image') return '图片附件';
|
||||
const preview = latestProgressLine(block.text);
|
||||
const preview = firstProgressLine(block.text);
|
||||
if (preview) return preview;
|
||||
}
|
||||
return fallback;
|
||||
@@ -823,14 +820,14 @@ function toolDetailsProgress(details: KnownToolDetails | undefined): string | nu
|
||||
}
|
||||
|
||||
function toolProgressPreview(node: ConversationToolNode): string {
|
||||
for (let index = node.output.length - 1; index >= 0; index -= 1) {
|
||||
for (let index = 0; index < node.output.length; index += 1) {
|
||||
const block = node.output[index];
|
||||
if (!block) continue;
|
||||
if (block.kind === 'image') return '已生成图片附件';
|
||||
const outputPreview = latestProgressLine(block.text);
|
||||
const outputPreview = firstProgressLine(block.text);
|
||||
if (outputPreview) return outputPreview;
|
||||
}
|
||||
return latestProgressLine(node.inputText)
|
||||
return firstProgressLine(node.inputText)
|
||||
?? toolDetailsProgress(node.details)
|
||||
?? statusLabel(node.status);
|
||||
}
|
||||
@@ -1150,7 +1147,7 @@ const ProcessThinking = memo(function ProcessThinking({
|
||||
streaming={streaming}
|
||||
rollUpdates={false}
|
||||
contentVersion={block.text.length}
|
||||
preview={latestProgressLine(block.text) ?? (
|
||||
preview={firstProgressLine(block.text) ?? (
|
||||
streaming ? 'Pi 正在形成思路…' : '思考已完成'
|
||||
)}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user