From 88b5f330dcf095e9da5d1c27568b1a1a90471069 Mon Sep 17 00:00:00 2001 From: destire-mio <248462155+destire-mio@users.noreply.github.com> Date: Sat, 1 Aug 2026 01:05:26 +0800 Subject: [PATCH 1/2] fix(webui): make long tool output collapsible --- ...26-07-31-export-collapsible-tool-output.md | 63 ++++++++ .../components/toolcalls/GenericToolCall.tsx | 46 +----- .../components/toolcalls/ShellToolCall.css | 8 + .../toolcalls/ShellToolCall.stories.tsx | 2 +- .../toolcalls/ShellToolCall.test.tsx | 153 ++++++++++++++++++ .../components/toolcalls/ShellToolCall.tsx | 34 +++- .../toolcalls/ThinkToolCall.test.tsx | 102 ++++++++++++ .../components/toolcalls/ThinkToolCall.tsx | 19 ++- .../shared/CollapsibleOutput.test.tsx | 82 ++++++++++ .../toolcalls/shared/CollapsibleOutput.tsx | 63 ++++++++ .../src/components/toolcalls/shared/index.ts | 1 + 11 files changed, 521 insertions(+), 52 deletions(-) create mode 100644 .qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md create mode 100644 packages/webui/src/components/toolcalls/ShellToolCall.test.tsx create mode 100644 packages/webui/src/components/toolcalls/ThinkToolCall.test.tsx create mode 100644 packages/webui/src/components/toolcalls/shared/CollapsibleOutput.test.tsx create mode 100644 packages/webui/src/components/toolcalls/shared/CollapsibleOutput.tsx diff --git a/.qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md b/.qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md new file mode 100644 index 00000000000..31e5a8f9eab --- /dev/null +++ b/.qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md @@ -0,0 +1,63 @@ +# Export Collapsible Tool Output + +## Scope + +Verify that long shell output and long `think` tool content keep their full +text in the shared WebUI while remaining collapsed by default. This covers the +HTML export viewer and the other consumers of `@qwen-code/webui`. + +## Baseline + +A released global `qwen` executable was not available in this environment, so +the before-change `/export` dry-run could not be performed. Source inspection +on `upstream/main` reproduces the loss: `ShellToolCall` and `ThinkToolCall` +replace content after 500 characters with an ellipsis. + +## Manual Scenario + +1. Export a session containing a successful Bash or Execute tool call whose + output is longer than 500 characters and ends with a unique marker. +2. Open the exported HTML and find the tool call. +3. Confirm the output is collapsed and has a `Show more` control. +4. Expand it and confirm the unique tail marker is visible, then collapse it + again. +5. Repeat with a `think` tool call longer than 500 characters. + +## Regression Checks + +- Content of exactly 500 characters has no new toggle. +- Both Bash and Execute variants preserve the full output. +- A long single-line Shell result remains horizontally scrollable after it is + expanded. +- Clicking a shell toggle does not invoke the surrounding OUT-row action. +- Clicking the shell OUT row still opens the complete output. +- Error, empty-output, and short-thinking paths remain unchanged. +- Toggle buttons expose their expanded state to assistive technology. + +## Automated Verification + +```bash +cd packages/webui +npx vitest run \ + src/components/toolcalls/shared/CollapsibleOutput.test.tsx \ + src/components/toolcalls/ShellToolCall.test.tsx \ + src/components/toolcalls/ThinkToolCall.test.tsx +npm run typecheck +npm run lint +npm run build +``` + +## Results + +- Failure-first run: 3 long-output cases failed because their tail markers + were absent; the 500-character boundary and short-thinking cases passed. +- Focused regression run: 3 files and 7 tests passed. +- A headless Chrome layout probe confirmed that handing overflow from the OUT + `
` to its scroll container changes the container from
+ `clientWidth/scrollWidth = 200/200` to `200/831` for both Bash and Execute.
+- Full WebUI run: 30 files and 398 tests passed with Node.js 24.
+- WebUI lint, typecheck, and production build passed.
+- A normal local `/export` smoke test was not used as proof because the
+ generated page loads the published WebUI package from unpkg rather than the
+ worktree bundle. Component tests and the local WebUI build cover this change
+ until a release build is available for the manual scenario.
diff --git a/packages/webui/src/components/toolcalls/GenericToolCall.tsx b/packages/webui/src/components/toolcalls/GenericToolCall.tsx
index b73820c754b..d20f7561022 100644
--- a/packages/webui/src/components/toolcalls/GenericToolCall.tsx
+++ b/packages/webui/src/components/toolcalls/GenericToolCall.tsx
@@ -6,8 +6,9 @@
* Generic tool call component - handles all tool call types as fallback
*/
-import { useState, type FC } from 'react';
+import type { FC } from 'react';
import {
+ CollapsibleOutput,
ToolCallContainer,
ToolCallCard,
ToolCallRow,
@@ -20,44 +21,8 @@ import type { BaseToolCallProps } from './shared/index.js';
import { getToolDisplayLabel } from './labelUtils.js';
import { MarkdownRenderer } from '../messages/MarkdownRenderer/MarkdownRenderer.js';
-const COLLAPSED_HEIGHT = 200;
const EXPAND_THRESHOLD = 400;
-const CollapsibleOutput: FC<{ content: string }> = ({ content }) => {
- const [isExpanded, setIsExpanded] = useState(false);
- const isLongContent = content.length > EXPAND_THRESHOLD;
-
- return (
-
-
-
-
- {isLongContent && (
-
-
-
- )}
-
- );
-};
-
/**
* Generic tool call component that can display any tool call type
* Used as fallback for unknown tool call kinds
@@ -101,7 +66,12 @@ export const GenericToolCall: FC = ({
{operationText}
-
+ EXPAND_THRESHOLD}
+ className="text-[13px] opacity-90"
+ >
+
+
);
diff --git a/packages/webui/src/components/toolcalls/ShellToolCall.css b/packages/webui/src/components/toolcalls/ShellToolCall.css
index bf4ec3c56f6..df1efba39f0 100644
--- a/packages/webui/src/components/toolcalls/ShellToolCall.css
+++ b/packages/webui/src/components/toolcalls/ShellToolCall.css
@@ -89,6 +89,10 @@
box-sizing: border-box;
}
+.bash-toolcall-output-subtle .bash-toolcall-pre {
+ overflow: visible;
+}
+
.bash-toolcall-error-content {
color: #c74e39;
}
@@ -180,6 +184,10 @@
box-sizing: border-box;
}
+.execute-toolcall-output-subtle .execute-toolcall-pre {
+ overflow: visible;
+}
+
.execute-toolcall-error-content {
color: #c74e39;
}
diff --git a/packages/webui/src/components/toolcalls/ShellToolCall.stories.tsx b/packages/webui/src/components/toolcalls/ShellToolCall.stories.tsx
index 1ff26c4e330..2f005528698 100644
--- a/packages/webui/src/components/toolcalls/ShellToolCall.stories.tsx
+++ b/packages/webui/src/components/toolcalls/ShellToolCall.stories.tsx
@@ -129,7 +129,7 @@ export const ExecuteWithDescription: Story = {
};
/**
- * Execute variant with long output (truncated)
+ * Execute variant with long, collapsible output
*/
export const ExecuteLongOutput: Story = {
args: {
diff --git a/packages/webui/src/components/toolcalls/ShellToolCall.test.tsx b/packages/webui/src/components/toolcalls/ShellToolCall.test.tsx
new file mode 100644
index 00000000000..4c7ec638643
--- /dev/null
+++ b/packages/webui/src/components/toolcalls/ShellToolCall.test.tsx
@@ -0,0 +1,153 @@
+/**
+ * @license
+ * Copyright 2025 Qwen Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+// @vitest-environment jsdom
+
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { PlatformProvider } from '../../context/PlatformContext.js';
+import { ShellToolCall } from './ShellToolCall.js';
+
+const shellToolCallStyles = readFileSync(
+ resolve(process.cwd(), 'src/components/toolcalls/ShellToolCall.css'),
+ 'utf8',
+);
+
+describe('ShellToolCall collapsible output', () => {
+ let container: HTMLDivElement | null = null;
+ let root: Root | null = null;
+
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ if (root) {
+ act(() => root?.unmount());
+ root = null;
+ }
+ if (container) {
+ container.remove();
+ container = null;
+ }
+ });
+
+ const renderToolCall = (
+ kind: 'bash' | 'execute',
+ output: string,
+ openTempFile = vi.fn(),
+ ) => {
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+
+ act(() => {
+ root?.render(
+ () => {},
+ openTempFile,
+ }}
+ >
+
+ ,
+ );
+ });
+
+ return openTempFile;
+ };
+
+ it.each(['bash', 'execute'] as const)(
+ 'preserves and expands the full %s output without opening a temp file',
+ (kind) => {
+ const tailMarker = '__OUTPUT_TAIL__';
+ const output = `${'x'.repeat(501)}${tailMarker}`;
+ const openTempFile = renderToolCall(kind, output);
+
+ expect(container?.textContent).toContain(tailMarker);
+
+ const toggle = container?.querySelector(
+ 'button[aria-label="Expand output"]',
+ ) as HTMLButtonElement;
+ expect(toggle).not.toBeNull();
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+ const collapsibleContent = container?.querySelector(
+ '.toolcall-collapsible-output-content',
+ ) as HTMLDivElement;
+ expect(collapsibleContent.style.maxHeight).toBe('60px');
+ expect(collapsibleContent.style.maskImage).toContain('40px');
+ expect(collapsibleContent.style.maskImage).toContain('60px');
+ const outputContainer = container?.querySelector(
+ `.${kind}-toolcall-output-subtle`,
+ ) as HTMLDivElement;
+ const outputPre = outputContainer.querySelector('pre') as HTMLPreElement;
+ expect(outputPre).not.toBeNull();
+ expect(shellToolCallStyles).toContain(
+ `.${kind}-toolcall-output-subtle .${kind}-toolcall-pre {\n overflow: visible;\n}`,
+ );
+
+ act(() => {
+ toggle.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ });
+
+ expect(toggle.getAttribute('aria-expanded')).toBe('true');
+ expect(toggle.textContent).toContain('Collapse');
+ expect(collapsibleContent.style.maxHeight).toBe('');
+ expect(openTempFile).not.toHaveBeenCalled();
+
+ act(() => {
+ toggle.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ });
+
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+ expect(collapsibleContent.style.maxHeight).toBe('60px');
+ expect(openTempFile).not.toHaveBeenCalled();
+
+ const outRow = Array.from(
+ container?.querySelectorAll(`.${kind}-toolcall-row`) ?? [],
+ ).find((row) => row.textContent?.includes('OUT'));
+ expect(outRow).toBeDefined();
+
+ act(() => {
+ outRow?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ });
+
+ expect(openTempFile).toHaveBeenCalledWith(
+ output,
+ `${kind}-output-${kind}-1`,
+ );
+ },
+ );
+
+ it('does not add a toggle at the 500-character boundary', () => {
+ renderToolCall('bash', 'x'.repeat(500));
+
+ expect(
+ container?.querySelector('button[aria-label="Expand output"]'),
+ ).toBeNull();
+ });
+});
diff --git a/packages/webui/src/components/toolcalls/ShellToolCall.tsx b/packages/webui/src/components/toolcalls/ShellToolCall.tsx
index 37a5fbe7316..7094d627d31 100644
--- a/packages/webui/src/components/toolcalls/ShellToolCall.tsx
+++ b/packages/webui/src/components/toolcalls/ShellToolCall.tsx
@@ -9,6 +9,7 @@
import type { FC } from 'react';
import {
+ CollapsibleOutput,
ToolCallContainer,
CopyButton,
safeTitle,
@@ -211,8 +212,7 @@ const ShellToolCallImpl: FC = ({
// Success with output
if (textOutputs.length > 0) {
const output = textOutputs.join('\n');
- const truncatedOutput =
- output.length > 500 ? output.substring(0, 500) + '...' : output;
+ const isCollapsible = output.length > 500;
return (
= ({
style={{ cursor: 'pointer' }}
>
OUT
-
-
-
- {truncatedOutput}
-
-
+
+ {isCollapsible ? (
+
+
+
+ {output}
+
+
+
+ ) : (
+
+
+ {output}
+
+
+ )}
diff --git a/packages/webui/src/components/toolcalls/ThinkToolCall.test.tsx b/packages/webui/src/components/toolcalls/ThinkToolCall.test.tsx
new file mode 100644
index 00000000000..ea2ecce312b
--- /dev/null
+++ b/packages/webui/src/components/toolcalls/ThinkToolCall.test.tsx
@@ -0,0 +1,102 @@
+/**
+ * @license
+ * Copyright 2025 Qwen Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+// @vitest-environment jsdom
+
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import { ThinkToolCall } from './ThinkToolCall.js';
+
+describe('ThinkToolCall collapsible output', () => {
+ let container: HTMLDivElement | null = null;
+ let root: Root | null = null;
+
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ });
+
+ afterEach(() => {
+ if (root) {
+ act(() => root?.unmount());
+ root = null;
+ }
+ if (container) {
+ container.remove();
+ container = null;
+ }
+ });
+
+ const renderThoughts = (thoughts: string) => {
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+
+ act(() => {
+ root?.render(
+ ,
+ );
+ });
+ };
+
+ it('preserves long thoughts and exposes expand and collapse controls', () => {
+ const tailMarker = '__THOUGHT_TAIL__';
+ renderThoughts(`${'x'.repeat(501)}${tailMarker}`);
+
+ expect(container?.textContent).toContain(tailMarker);
+
+ const toggle = container?.querySelector(
+ 'button[aria-label="Expand output"]',
+ ) as HTMLButtonElement;
+ expect(toggle).not.toBeNull();
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+ const collapsibleContent = container?.querySelector(
+ '.toolcall-collapsible-output-content',
+ ) as HTMLDivElement;
+ expect(collapsibleContent.style.maxHeight).toBe('200px');
+
+ act(() => {
+ toggle.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ });
+
+ expect(toggle.getAttribute('aria-expanded')).toBe('true');
+ expect(toggle.textContent).toContain('Collapse');
+ expect(collapsibleContent.style.maxHeight).toBe('');
+
+ act(() => {
+ toggle.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ });
+
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+ expect(toggle.textContent).toContain('Show more');
+ expect(collapsibleContent.style.maxHeight).toBe('200px');
+ });
+
+ it('keeps short thoughts in the compact layout without a toggle', () => {
+ renderThoughts('short thought');
+
+ expect(container?.textContent).toContain('short thought');
+ expect(container?.querySelector('.toolcall-card')).toBeNull();
+ expect(
+ container?.querySelector('button[aria-label="Expand output"]'),
+ ).toBeNull();
+ });
+});
diff --git a/packages/webui/src/components/toolcalls/ThinkToolCall.tsx b/packages/webui/src/components/toolcalls/ThinkToolCall.tsx
index 7d041d80c34..aecb203b428 100644
--- a/packages/webui/src/components/toolcalls/ThinkToolCall.tsx
+++ b/packages/webui/src/components/toolcalls/ThinkToolCall.tsx
@@ -8,6 +8,7 @@
import type { FC } from 'react';
import {
+ CollapsibleOutput,
ToolCallContainer,
ToolCallCard,
ToolCallRow,
@@ -50,15 +51,23 @@ export const ThinkToolCall: FC = ({
const isLong = thoughts.length > 200;
if (isLong) {
- const truncatedThoughts =
- thoughts.length > 500 ? thoughts.substring(0, 500) + '...' : thoughts;
+ const isCollapsible = thoughts.length > 500;
return (
-
- {truncatedThoughts}
-
+ {isCollapsible ? (
+
+ {thoughts}
+
+ ) : (
+
+ {thoughts}
+
+ )}
);
diff --git a/packages/webui/src/components/toolcalls/shared/CollapsibleOutput.test.tsx b/packages/webui/src/components/toolcalls/shared/CollapsibleOutput.test.tsx
new file mode 100644
index 00000000000..11569a427a2
--- /dev/null
+++ b/packages/webui/src/components/toolcalls/shared/CollapsibleOutput.test.tsx
@@ -0,0 +1,82 @@
+/**
+ * @license
+ * Copyright 2025 Qwen Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+// @vitest-environment jsdom
+
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import { CollapsibleOutput } from './CollapsibleOutput.js';
+
+describe('CollapsibleOutput', () => {
+ let container: HTMLDivElement | null = null;
+ let root: Root | null = null;
+
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ });
+
+ afterEach(() => {
+ if (root) {
+ act(() => root?.unmount());
+ root = null;
+ }
+ if (container) {
+ container.remove();
+ container = null;
+ }
+ });
+
+ it('toggles the collapsed height while preserving all children', () => {
+ act(() => {
+ root?.render(
+
+ full content with __TAIL__
+ ,
+ );
+ });
+
+ expect(container?.textContent).toContain('__TAIL__');
+ const content = container?.querySelector(
+ '.toolcall-collapsible-output-content',
+ ) as HTMLDivElement;
+ const toggle = container?.querySelector(
+ 'button[aria-label="Expand output"]',
+ ) as HTMLButtonElement;
+ expect(content.style.maxHeight).toBe('200px');
+ expect(content.style.maskImage).toContain('140px');
+ expect(content.style.maskImage).toContain('200px');
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+
+ act(() => {
+ toggle.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ });
+
+ expect(content.style.maxHeight).toBe('');
+ expect(toggle.getAttribute('aria-expanded')).toBe('true');
+ });
+
+ it('does not clip or show a toggle when content is not collapsible', () => {
+ act(() => {
+ root?.render(
+
+ short content
+ ,
+ );
+ });
+
+ const content = container?.querySelector(
+ '.toolcall-collapsible-output-content',
+ ) as HTMLDivElement;
+ expect(content.style.maxHeight).toBe('');
+ expect(container?.querySelector('button')).toBeNull();
+ });
+});
diff --git a/packages/webui/src/components/toolcalls/shared/CollapsibleOutput.tsx b/packages/webui/src/components/toolcalls/shared/CollapsibleOutput.tsx
new file mode 100644
index 00000000000..4e73f141e01
--- /dev/null
+++ b/packages/webui/src/components/toolcalls/shared/CollapsibleOutput.tsx
@@ -0,0 +1,63 @@
+/**
+ * @license
+ * Copyright 2025 Qwen Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { useState, type FC, type ReactNode } from 'react';
+
+interface CollapsibleOutputProps {
+ children: ReactNode;
+ isCollapsible: boolean;
+ collapsedHeight?: number;
+ fadeStart?: number;
+ className?: string;
+}
+
+/**
+ * Renderer-agnostic wrapper for long tool output.
+ */
+export const CollapsibleOutput: FC = ({
+ children,
+ isCollapsible,
+ collapsedHeight = 200,
+ fadeStart = 140,
+ className = '',
+}) => {
+ const [isExpanded, setIsExpanded] = useState(false);
+
+ return (
+
+
+ {children}
+
+ {isCollapsible && (
+
+
+
+ )}
+
+ );
+};
diff --git a/packages/webui/src/components/toolcalls/shared/index.ts b/packages/webui/src/components/toolcalls/shared/index.ts
index aa1e696e969..8030ec4bfb3 100644
--- a/packages/webui/src/components/toolcalls/shared/index.ts
+++ b/packages/webui/src/components/toolcalls/shared/index.ts
@@ -14,6 +14,7 @@ export {
LocationsList,
} from './LayoutComponents.js';
export type { ToolCallContainerProps } from './LayoutComponents.js';
+export { CollapsibleOutput } from './CollapsibleOutput.js';
// Copy utilities
export { handleCopyToClipboard, CopyButton } from './copyUtils.js';
From f8d16811dc5eb16b6b4d11e7cc182556b54b011a Mon Sep 17 00:00:00 2001
From: destire-mio <248462155+destire-mio@users.noreply.github.com>
Date: Sat, 1 Aug 2026 11:30:27 +0800
Subject: [PATCH 2/2] fix(webui): contain collapsible shell output
---
...26-07-31-export-collapsible-tool-output.md | 30 +++++--
.../e2e/webui-tool-output-layout-harness.html | 37 ++++++++
.../e2e/webui-tool-output-layout-harness.tsx | 38 ++++++++
.../e2e/webui-tool-output-layout.spec.ts | 74 +++++++++++++++
.../toolcalls/GenericToolCall.test.tsx | 90 +++++++++++++++++++
.../components/toolcalls/ShellToolCall.css | 8 ++
.../toolcalls/ShellToolCall.test.tsx | 16 ----
.../components/toolcalls/ShellToolCall.tsx | 17 ++--
8 files changed, 279 insertions(+), 31 deletions(-)
create mode 100644 packages/web-shell/client/e2e/webui-tool-output-layout-harness.html
create mode 100644 packages/web-shell/client/e2e/webui-tool-output-layout-harness.tsx
create mode 100644 packages/web-shell/client/e2e/webui-tool-output-layout.spec.ts
create mode 100644 packages/webui/src/components/toolcalls/GenericToolCall.test.tsx
diff --git a/.qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md b/.qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md
index 31e5a8f9eab..fc3c7b688dc 100644
--- a/.qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md
+++ b/.qwen/e2e-tests/2026-07-31-export-collapsible-tool-output.md
@@ -29,6 +29,8 @@ replace content after 500 characters with an ellipsis.
- Both Bash and Execute variants preserve the full output.
- A long single-line Shell result remains horizontally scrollable after it is
expanded.
+- A collapsible Shell result does not widen the enclosing message container,
+ and its toggle remains inside the visible message bounds.
- Clicking a shell toggle does not invoke the surrounding OUT-row action.
- Clicking the shell OUT row still opens the complete output.
- Error, empty-output, and short-thinking paths remain unchanged.
@@ -40,23 +42,41 @@ replace content after 500 characters with an ellipsis.
cd packages/webui
npx vitest run \
src/components/toolcalls/shared/CollapsibleOutput.test.tsx \
+ src/components/toolcalls/GenericToolCall.test.tsx \
src/components/toolcalls/ShellToolCall.test.tsx \
src/components/toolcalls/ThinkToolCall.test.tsx
+npm test
npm run typecheck
npm run lint
npm run build
+
+cd ../sdk-typescript
+npm run build
+
+cd ../web-shell
+npm run lint
+npm run typecheck
+npm run test:e2e:smoke
```
## Results
- Failure-first run: 3 long-output cases failed because their tail markers
were absent; the 500-character boundary and short-thinking cases passed.
-- Focused regression run: 3 files and 7 tests passed.
-- A headless Chrome layout probe confirmed that handing overflow from the OUT
- `` to its scroll container changes the container from
- `clientWidth/scrollWidth = 200/200` to `200/831` for both Bash and Execute.
-- Full WebUI run: 30 files and 398 tests passed with Node.js 24.
+- Focused component regression run: 4 files and 9 tests passed.
+- Failure-first Playwright run: both Bash and Execute failed because their
+ output boxes expanded to roughly 5.7k pixels, leaving no internal horizontal
+ overflow to scroll.
+- Post-fix Playwright run: both Bash and Execute passed in real Chromium. The
+ output scroll width exceeds its client width in collapsed and expanded
+ states, the enclosing message has no horizontal overflow, the toggle remains
+ visible, and the output accepts a non-zero horizontal scroll position.
+- Full web-shell Playwright smoke run: 26 tests passed, including both new
+ WebUI layout cases.
+- Full WebUI run: 31 files and 400 tests passed with Node.js 24.
- WebUI lint, typecheck, and production build passed.
+- Web-shell lint and typecheck passed; the latter was run after generating the
+ SDK declarations required by that package. All changed files pass Prettier.
- A normal local `/export` smoke test was not used as proof because the
generated page loads the published WebUI package from unpkg rather than the
worktree bundle. Component tests and the local WebUI build cover this change
diff --git a/packages/web-shell/client/e2e/webui-tool-output-layout-harness.html b/packages/web-shell/client/e2e/webui-tool-output-layout-harness.html
new file mode 100644
index 00000000000..d617f4ab955
--- /dev/null
+++ b/packages/web-shell/client/e2e/webui-tool-output-layout-harness.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+ WebUI tool output layout harness
+
+
+
+
+
+
+
diff --git a/packages/web-shell/client/e2e/webui-tool-output-layout-harness.tsx b/packages/web-shell/client/e2e/webui-tool-output-layout-harness.tsx
new file mode 100644
index 00000000000..e080a0ac181
--- /dev/null
+++ b/packages/web-shell/client/e2e/webui-tool-output-layout-harness.tsx
@@ -0,0 +1,38 @@
+/**
+ * @license
+ * Copyright 2025 Qwen Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React from 'react';
+import ReactDOM from 'react-dom/client';
+import { ChatViewer, type ChatMessageData } from '@qwen-code/webui';
+
+const params = new URLSearchParams(window.location.search);
+const kind = params.get('kind') === 'execute' ? 'execute' : 'bash';
+const output = `${'0123456789'.repeat(82)}__${kind.toUpperCase()}_TAIL__`;
+
+const message: ChatMessageData = {
+ uuid: `${kind}-layout-message`,
+ timestamp: '2026-07-31T00:00:00.000Z',
+ type: 'tool_call',
+ toolCall: {
+ toolCallId: `${kind}-layout-tool-call`,
+ kind,
+ title: 'Run layout regression fixture',
+ status: 'completed',
+ rawInput: { command: 'printf long-output' },
+ content: [
+ {
+ type: 'content',
+ content: { type: 'text', text: output },
+ },
+ ],
+ },
+};
+
+ReactDOM.createRoot(document.getElementById('root')!).render(
+
+
+ ,
+);
diff --git a/packages/web-shell/client/e2e/webui-tool-output-layout.spec.ts b/packages/web-shell/client/e2e/webui-tool-output-layout.spec.ts
new file mode 100644
index 00000000000..22e7367342c
--- /dev/null
+++ b/packages/web-shell/client/e2e/webui-tool-output-layout.spec.ts
@@ -0,0 +1,74 @@
+/**
+ * @license
+ * Copyright 2025 Qwen Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { expect, test, type Locator } from '@playwright/test';
+
+for (const kind of ['bash', 'execute'] as const) {
+ test(`keeps collapsible ${kind} output inside the message layout @smoke`, async ({
+ page,
+ }) => {
+ await page.setViewportSize({ width: 800, height: 900 });
+ await page.goto(`/e2e/webui-tool-output-layout-harness.html?kind=${kind}`);
+
+ const messages = page.locator('.chat-viewer-messages');
+ const output = page.locator(`.${kind}-toolcall-output-subtle`);
+ const toggle = page.locator('button[aria-expanded]');
+
+ await expect(messages).toBeVisible();
+ await expect(output).toBeVisible();
+ await expect(toggle).toBeVisible();
+ await expect(toggle).toHaveAttribute('aria-label', 'Expand output');
+
+ const collapsed = await readOverflowMetrics(messages, output);
+ expect(collapsed.outputScrollWidth).toBeGreaterThan(
+ collapsed.outputClientWidth,
+ );
+ expect(collapsed.messagesScrollWidth).toBe(collapsed.messagesClientWidth);
+
+ const messagesBox = await messages.boundingBox();
+ const toggleBox = await toggle.boundingBox();
+ if (!messagesBox || !toggleBox) {
+ throw new Error('Expected visible message and toggle bounding boxes.');
+ }
+ expect(toggleBox.x).toBeGreaterThanOrEqual(messagesBox.x);
+ expect(toggleBox.x + toggleBox.width).toBeLessThanOrEqual(
+ messagesBox.x + messagesBox.width,
+ );
+
+ await toggle.click();
+ await expect(toggle).toHaveAttribute('aria-expanded', 'true');
+
+ const expanded = await readOverflowMetrics(messages, output);
+ expect(expanded.outputScrollWidth).toBeGreaterThan(
+ expanded.outputClientWidth,
+ );
+ expect(expanded.messagesScrollWidth).toBe(expanded.messagesClientWidth);
+
+ const reachableScrollLeft = await output.evaluate((element) => {
+ element.scrollLeft = element.scrollWidth;
+ return element.scrollLeft;
+ });
+ expect(reachableScrollLeft).toBeGreaterThan(0);
+ });
+}
+
+async function readOverflowMetrics(messages: Locator, output: Locator) {
+ const messagesMetrics = await messages.evaluate((element) => ({
+ clientWidth: element.clientWidth,
+ scrollWidth: element.scrollWidth,
+ }));
+ const outputMetrics = await output.evaluate((element) => ({
+ clientWidth: element.clientWidth,
+ scrollWidth: element.scrollWidth,
+ }));
+
+ return {
+ messagesClientWidth: messagesMetrics.clientWidth,
+ messagesScrollWidth: messagesMetrics.scrollWidth,
+ outputClientWidth: outputMetrics.clientWidth,
+ outputScrollWidth: outputMetrics.scrollWidth,
+ };
+}
diff --git a/packages/webui/src/components/toolcalls/GenericToolCall.test.tsx b/packages/webui/src/components/toolcalls/GenericToolCall.test.tsx
new file mode 100644
index 00000000000..e4bbc64e752
--- /dev/null
+++ b/packages/webui/src/components/toolcalls/GenericToolCall.test.tsx
@@ -0,0 +1,90 @@
+/**
+ * @license
+ * Copyright 2025 Qwen Team
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+// @vitest-environment jsdom
+
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import { GenericToolCall } from './GenericToolCall.js';
+
+describe('GenericToolCall collapsible output', () => {
+ let container: HTMLDivElement | null = null;
+ let root: Root | null = null;
+
+ beforeEach(() => {
+ (
+ globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }
+ ).IS_REACT_ACT_ENVIRONMENT = true;
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ });
+
+ afterEach(() => {
+ if (root) {
+ act(() => root?.unmount());
+ root = null;
+ }
+ if (container) {
+ container.remove();
+ container = null;
+ }
+ });
+
+ const renderOutput = (output: string) => {
+ act(() => {
+ root?.render(
+ ,
+ );
+ });
+ };
+
+ it('preserves and collapses output longer than 400 characters', () => {
+ const tailMarker = '__GENERIC_TAIL__';
+ renderOutput(`${'x'.repeat(401)}${tailMarker}`);
+
+ expect(container?.textContent).toContain(tailMarker);
+ const content = container?.querySelector(
+ '.toolcall-collapsible-output-content',
+ ) as HTMLDivElement;
+ expect(content.classList.contains('text-[13px]')).toBe(true);
+ expect(content.classList.contains('opacity-90')).toBe(true);
+ expect(content.style.maxHeight).toBe('200px');
+ expect(
+ container?.querySelector('button[aria-label="Expand output"]'),
+ ).not.toBeNull();
+ });
+
+ it('does not add a toggle at the 400-character boundary', () => {
+ const output = 'x'.repeat(400);
+ renderOutput(output);
+
+ expect(container?.textContent).toContain(output);
+ const content = container?.querySelector(
+ '.toolcall-collapsible-output-content',
+ ) as HTMLDivElement;
+ expect(content.classList.contains('text-[13px]')).toBe(true);
+ expect(content.classList.contains('opacity-90')).toBe(true);
+ expect(content.style.maxHeight).toBe('');
+ expect(
+ container?.querySelector('button[aria-label="Expand output"]'),
+ ).toBeNull();
+ });
+});
diff --git a/packages/webui/src/components/toolcalls/ShellToolCall.css b/packages/webui/src/components/toolcalls/ShellToolCall.css
index df1efba39f0..cc5b6c84123 100644
--- a/packages/webui/src/components/toolcalls/ShellToolCall.css
+++ b/packages/webui/src/components/toolcalls/ShellToolCall.css
@@ -65,6 +65,10 @@
overflow: hidden;
}
+.bash-toolcall-row-content.bash-toolcall-full {
+ min-width: 0;
+}
+
.bash-toolcall-pre {
margin-block: 0;
overflow: hidden;
@@ -161,6 +165,10 @@
overflow: hidden;
}
+.execute-toolcall-row-content.execute-toolcall-full {
+ min-width: 0;
+}
+
.execute-toolcall-pre {
margin-block: 0;
overflow: hidden;
diff --git a/packages/webui/src/components/toolcalls/ShellToolCall.test.tsx b/packages/webui/src/components/toolcalls/ShellToolCall.test.tsx
index 4c7ec638643..f62823a3577 100644
--- a/packages/webui/src/components/toolcalls/ShellToolCall.test.tsx
+++ b/packages/webui/src/components/toolcalls/ShellToolCall.test.tsx
@@ -6,19 +6,12 @@
// @vitest-environment jsdom
-import { readFileSync } from 'node:fs';
-import { resolve } from 'node:path';
import { act } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { PlatformProvider } from '../../context/PlatformContext.js';
import { ShellToolCall } from './ShellToolCall.js';
-const shellToolCallStyles = readFileSync(
- resolve(process.cwd(), 'src/components/toolcalls/ShellToolCall.css'),
- 'utf8',
-);
-
describe('ShellToolCall collapsible output', () => {
let container: HTMLDivElement | null = null;
let root: Root | null = null;
@@ -101,15 +94,6 @@ describe('ShellToolCall collapsible output', () => {
expect(collapsibleContent.style.maxHeight).toBe('60px');
expect(collapsibleContent.style.maskImage).toContain('40px');
expect(collapsibleContent.style.maskImage).toContain('60px');
- const outputContainer = container?.querySelector(
- `.${kind}-toolcall-output-subtle`,
- ) as HTMLDivElement;
- const outputPre = outputContainer.querySelector('pre') as HTMLPreElement;
- expect(outputPre).not.toBeNull();
- expect(shellToolCallStyles).toContain(
- `.${kind}-toolcall-output-subtle .${kind}-toolcall-pre {\n overflow: visible;\n}`,
- );
-
act(() => {
toggle.dispatchEvent(new MouseEvent('click', { bubbles: true }));
});
diff --git a/packages/webui/src/components/toolcalls/ShellToolCall.tsx b/packages/webui/src/components/toolcalls/ShellToolCall.tsx
index 7094d627d31..7dc3aa510a4 100644
--- a/packages/webui/src/components/toolcalls/ShellToolCall.tsx
+++ b/packages/webui/src/components/toolcalls/ShellToolCall.tsx
@@ -213,6 +213,11 @@ const ShellToolCallImpl: FC = ({
if (textOutputs.length > 0) {
const output = textOutputs.join('\n');
const isCollapsible = output.length > 500;
+ const outputContent = (
+
+ {output}
+
+ );
return (
= ({
collapsedHeight={60}
fadeStart={40}
>
-
-
- {output}
-
-
+ {outputContent}
) : (
-
-
- {output}
-
-
+ outputContent
)}