Merge branch 'codex/20260831-show-progress-messages-a14f9c2d-show-progress-messages-a14f9c2d'

This commit is contained in:
inman
2026-09-01 11:46:31 +08:00
4 changed files with 150 additions and 41 deletions

View File

@@ -221,7 +221,7 @@ async function installCodingFirstChatHost(
output: [{
kind: 'text',
id: 'browser-output-e2e',
text: `${'Checking browser runtime state and the latest navigation checkpoint. '.repeat(5)}Browser ready`,
text: `${'Checking browser runtime state and the latest navigation checkpoint. '.repeat(8)}Browser ready`,
status: 'complete',
}],
details: { schema: 'agent-browser.v1', action: 'status' },
@@ -731,13 +731,13 @@ test('PI feature UI isolates Conversations and exposes queue, interaction, model
await expect(activeProcess).toHaveAttribute('open', '');
await expect(activeProcess.locator('summary').first()).toContainText('处理中');
const activeThinking = page.getByLabel('思考过程');
await expect(activeThinking).toContainText('Preparing the smallest safe next step.');
await expect(activeThinking).not.toContainText('Inspecting the project before responding.');
await expect(activeThinking).toContainText('Inspecting the project before responding.');
await expect(activeThinking).not.toContainText('Preparing the smallest safe next step.');
await expect(activeThinking).toHaveAttribute('data-collapsed-lines', '1');
await expect(activeThinking).toHaveAttribute('data-expanded', 'false');
await expect(activeThinking).toHaveAttribute('data-streaming', 'true');
const activeThinkingPreview = activeThinking.getByTestId('process-progress-preview');
await expect(activeThinkingPreview).toHaveAttribute('data-progress-tail', 'true');
await expect(activeThinkingPreview).toHaveAttribute('data-progress-origin', 'head');
await expect(activeThinkingPreview).toHaveAttribute('data-progress-alignment', 'left');
await expect(activeThinkingPreview).toHaveAttribute('data-progress-update-motion', 'none');
await expect(activeThinkingPreview).not.toHaveAttribute('data-roll-revision');
@@ -769,6 +769,7 @@ test('PI feature UI isolates Conversations and exposes queue, interaction, model
await expect(activeCommentary).toHaveClass(/text-foreground/);
const activeCommentaryPreview = activeCommentary.getByTestId('process-progress-preview');
await expect(activeCommentaryPreview).toContainText('Durable assistant response');
await expect(activeCommentaryPreview).toHaveAttribute('data-progress-origin', 'head');
await expect(activeCommentaryPreview).toHaveClass(/text-foreground/);
await expect(activeCommentaryPreview).not.toHaveClass(/text-muted-foreground/);
await expect(activeCommentaryPreview).toHaveAttribute('data-progress-shimmer', 'false');
@@ -787,9 +788,11 @@ test('PI feature UI isolates Conversations and exposes queue, interaction, model
const compactToolSummary = compactTool.locator('> summary');
await expect(compactTool).not.toHaveAttribute('open', '');
await expect(compactToolSummary).toHaveAttribute('data-collapsed-lines', '1');
await expect(compactTool.getByTestId('tool-progress-preview')).toContainText('Browser ready');
await expect(compactTool.getByTestId('tool-progress-preview'))
.toHaveAttribute('data-progress-tail', 'true');
.toContainText('Checking browser runtime state');
await expect(compactTool.getByTestId('tool-progress-preview')).not.toContainText('Browser ready');
await expect(compactTool.getByTestId('tool-progress-preview'))
.toHaveAttribute('data-progress-origin', 'head');
const toolProgressViewport = compactTool.getByTestId('tool-progress-preview');
await expect(toolProgressViewport).toHaveAttribute('data-progress-alignment', 'left');
await expect(toolProgressViewport).toHaveAttribute('data-progress-shimmer', 'false');
@@ -801,10 +804,7 @@ test('PI feature UI isolates Conversations and exposes queue, interaction, model
scrollWidth: element.scrollWidth,
}));
expect(toolProgressScroll.scrollWidth).toBeGreaterThan(toolProgressScroll.clientWidth);
expect(Math.abs(
toolProgressScroll.scrollLeft
- (toolProgressScroll.scrollWidth - toolProgressScroll.clientWidth),
)).toBeLessThanOrEqual(2);
expect(Math.abs(toolProgressScroll.scrollLeft)).toBeLessThanOrEqual(2);
const compactToolBounds = await compactToolSummary.boundingBox();
expect(compactToolBounds).not.toBeNull();
expect(compactToolBounds!.height).toBeLessThanOrEqual(33);

View File

@@ -303,8 +303,8 @@ describe('CodingConversationTimeline', () => {
expect(within(process).getByText('处理中')).toBeVisible();
const thinking = screen.getByLabelText('思考过程');
const thinkingPreview = within(thinking).getByTestId('process-progress-preview');
expect(thinkingPreview).toHaveTextContent('最后确认本轮只读取、不修改项目内容。');
expect(thinkingPreview).toHaveAttribute('data-progress-tail', 'true');
expect(thinkingPreview).toHaveTextContent('先确认 project.json 项目边界,再读取配置。');
expect(thinkingPreview).toHaveAttribute('data-progress-origin', 'head');
expect(thinkingPreview).toHaveAttribute('data-progress-alignment', 'left');
expect(thinkingPreview).toHaveAttribute('data-progress-update-motion', 'none');
expect(thinkingPreview).not.toHaveAttribute('data-roll-revision');
@@ -315,7 +315,7 @@ describe('CodingConversationTimeline', () => {
expect(thinkingPreview).toHaveClass('text-left');
expect(thinkingPreview.firstElementChild).toHaveClass('inline-flex');
expect(thinkingPreview.firstElementChild).not.toHaveClass('absolute', 'right-0');
expect(thinking).not.toHaveTextContent('先确认 project.json 项目边界,再读取配置。');
expect(thinking).not.toHaveTextContent('最后确认本轮只读取、不修改项目内容。');
expect(thinking).toHaveAttribute('data-collapsed-lines', '1');
expect(thinking).toHaveAttribute('data-expanded', 'false');
expect(thinking).toHaveAttribute('data-streaming', 'true');
@@ -340,19 +340,19 @@ describe('CodingConversationTimeline', () => {
expect(processNote).toHaveAttribute('data-collapsed-lines', '1');
expect(processNote).toHaveClass('max-h-[1.65em]', 'overflow-hidden');
const commentaryPreview = within(processNote).getByTestId('process-progress-preview');
expect(commentaryPreview).toHaveTextContent('让我看看 index.html 当前的实际内容:');
expect(commentaryPreview).toHaveTextContent('好的,两件事都办:先再试一次产品素材服务,然后整体优化手机移动端体验。');
expect(commentaryPreview).toHaveAttribute('data-progress-origin', 'head');
expect(commentaryPreview).toHaveClass('text-foreground');
expect(commentaryPreview).not.toHaveClass('text-muted-foreground/75');
expect(within(commentaryPreview).getByText('index.html')).toHaveClass('text-foreground');
expect(within(commentaryPreview).getByText('index.html')).not.toHaveClass('text-muted-foreground');
expect(commentaryPreview).toHaveAttribute('data-progress-shimmer', 'false');
expect(commentaryPreview).toHaveAttribute('data-progress-update-motion', 'none');
expect(commentaryPreview).not.toHaveAttribute('data-roll-revision');
expect(commentaryPreview.querySelector('.streaming-progress-shimmer')).not.toBeInTheDocument();
expect(commentaryPreview.querySelector('.streaming-progress-roll')).not.toBeInTheDocument();
expect(processNote).not.toHaveTextContent('好的,两件事都办');
expect(processNote).not.toHaveTextContent('让我看看 index.html 当前的实际内容:');
fireEvent.click(screen.getByRole('button', { name: '展开过程说明' }));
expect(screen.getByText(/好的,两件事都办/).closest('[data-testid="coding-process-group"]')).toBe(process);
expect(within(processNote).getByText('index.html').tagName).toBe('CODE');
expect(within(processNote).getByTestId('assistant-markdown')).toHaveClass('text-foreground');
expect(within(processNote).getByTestId('assistant-markdown')).not.toHaveClass('text-muted-foreground');
fireEvent.click(screen.getByRole('button', { name: '收起过程说明' }));
@@ -362,8 +362,8 @@ describe('CodingConversationTimeline', () => {
expect(tool.querySelector('summary')).toHaveClass('h-8', 'overflow-hidden');
const toolPreview = within(tool).getByTestId('tool-progress-preview');
const initialToolRevision = toolPreview.getAttribute('data-roll-revision');
expect(toolPreview).toHaveTextContent('正在读取入口文件…');
expect(toolPreview).toHaveAttribute('data-progress-tail', 'true');
expect(toolPreview).toHaveTextContent('已定位项目根目录');
expect(toolPreview).toHaveAttribute('data-progress-origin', 'head');
expect(toolPreview).toHaveAttribute('data-progress-alignment', 'left');
expect(toolPreview).toHaveAttribute('data-progress-update-motion', 'roll');
expect(toolPreview).toHaveAttribute('data-progress-shimmer', 'true');
@@ -387,21 +387,21 @@ describe('CodingConversationTimeline', () => {
}));
expect(within(thinking).getByTestId('process-progress-preview'))
.toHaveTextContent('正在确认最新入口 main.ts。');
.toHaveTextContent('先确认 project.json 项目边界,再读取配置。');
expect(within(thinking).getByTestId('process-progress-preview'))
.not.toHaveAttribute('data-roll-revision');
expect(within(thinking).getByTestId('process-progress-preview')
.querySelector('.streaming-progress-roll')).not.toBeInTheDocument();
expect(within(processNote).getByTestId('process-progress-preview'))
.toHaveTextContent('正在整理最新结论。');
.toHaveTextContent('好的,两件事都办:先再试一次产品素材服务,然后整体优化手机移动端体验。');
expect(within(processNote).getByTestId('process-progress-preview'))
.toHaveClass('text-foreground');
expect(within(processNote).getByTestId('process-progress-preview'))
.toHaveAttribute('data-progress-shimmer', 'false');
expect(within(tool).getByTestId('tool-progress-preview'))
.toHaveTextContent('正在追踪最新工具输出main.ts 已读取。');
expect(within(tool).getByTestId('tool-progress-preview'))
.not.toHaveAttribute('data-roll-revision', initialToolRevision);
.toHaveTextContent('已定位项目根目录');
expect(within(tool).getByTestId('tool-progress-preview').getAttribute('data-roll-revision'))
.toBe(initialToolRevision);
fireEvent.click(tool.querySelector('summary')!);
await waitFor(() => expect(tool).toHaveAttribute('open'));
@@ -447,7 +447,12 @@ describe('CodingConversationTimeline', () => {
stopReason: 'tool-use' as const,
blocks: [
{ kind: 'thinking' as const, id: 'thinking-completed-process', text: '先读取配置,再核对入口。', status: 'streaming' as const },
{ kind: 'text' as const, id: 'preamble-completed-process', text: '我先检查项目配置。', status: 'complete' as const },
{
kind: 'text' as const,
id: 'preamble-completed-process',
text: '我先检查项目配置。\n\n现在开始核对 `index.html` 入口文件。',
status: 'complete' as const,
},
],
},
{
@@ -502,6 +507,29 @@ describe('CodingConversationTimeline', () => {
.toHaveAttribute('data-progress-shimmer', 'false');
expect(within(settledThinking).getByTestId('process-progress-preview')
.querySelector('.streaming-progress-shimmer')).not.toBeInTheDocument();
const completedCommentary = document.querySelector(
'[data-node-id="message-work-completed-process"][data-node-kind="assistant-commentary"]',
)!;
const completedCommentaryViewport = within(completedCommentary as HTMLElement)
.getByLabelText('过程说明');
expect(completedCommentaryViewport).toHaveAttribute('data-streaming', 'false');
expect(completedCommentaryViewport).toHaveAttribute('data-expanded', 'false');
expect(within(completedCommentaryViewport).getByTestId('process-progress-preview'))
.toHaveTextContent('我先检查项目配置。');
expect(within(completedCommentaryViewport).getByTestId('process-progress-preview'))
.toHaveAttribute('data-progress-origin', 'head');
expect(completedCommentaryViewport).not.toHaveTextContent('现在开始核对 index.html 入口文件。');
const completedCommentaryToggle = within(completedCommentary as HTMLElement)
.getByRole('button', { name: '展开过程说明' });
expect(completedCommentaryToggle).toHaveAttribute('aria-expanded', 'false');
fireEvent.click(completedCommentaryToggle);
expect(completedCommentaryViewport).toHaveAttribute('data-expanded', 'true');
expect(completedCommentaryViewport).toHaveTextContent('我先检查项目配置。');
expect(completedCommentaryViewport).toHaveTextContent('现在开始核对 index.html 入口文件。');
expect(within(completedCommentaryViewport).getByText('index.html').tagName).toBe('CODE');
fireEvent.click(within(completedCommentary as HTMLElement)
.getByRole('button', { name: '收起过程说明' }));
expect(completedCommentaryViewport).toHaveAttribute('data-expanded', 'false');
const tool = screen.getByText('读取项目配置').closest('details')!;
expect(tool).not.toHaveAttribute('open');
fireEvent.click(tool.querySelector('summary')!);