Repository navigation
feat(web-shell): reveal full tool detail and auto-collapse finished tools #5088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d4d04ef
a91cc2b
db1970b
4ff3e03
35e6d8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,6 +154,10 @@ function buildUnifiedDiff(oldText: string, newText: string): string { | |
| const MAX_BASH_LINE_CHARS = 150; | ||
| const MAX_READ_LINES = 25; | ||
|
|
||
| // A description longer than this is likely ellipsised on a normal-width row, so | ||
| // the row becomes expandable to re-flow the full text into a wrapped block. | ||
| const DESCRIPTION_EXPAND_THRESHOLD = 60; | ||
|
|
||
| export function resolveShellOutputMaxLines( | ||
| settings: readonly DaemonSettingDescriptor[], | ||
| ): number { | ||
|
|
@@ -411,6 +415,10 @@ function getAgentDisplayInfo( | |
| } | ||
|
|
||
| function shouldAutoExpand(tool: ACPToolCall): boolean { | ||
| // Once a tool completes successfully, collapse it to its one-line summary so | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| // the transcript stays scannable; the user can click to reopen it. Failures | ||
| // stay expanded so the error output remains visible without an extra click. | ||
| if (tool.status === 'completed') return false; | ||
| const name = tool.toolName.toLowerCase(); | ||
| if (isAskUserQuestionToolName(tool.toolName)) return true; | ||
| if (name === 'write_file' || name === 'writefile') return true; | ||
|
|
@@ -465,6 +473,27 @@ function ToolHeaderExtra({ info }: { info: ToolHeaderExtraRenderInfo }) { | |
| ); | ||
| } | ||
|
|
||
| function isDescriptionExpandable(description: string): boolean { | ||
| return ( | ||
| description.length > DESCRIPTION_EXPAND_THRESHOLD || | ||
| description.includes('\n') | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] Consider adding a test with a description under 60 chars containing — qwen3.7-max via Qwen Code /review |
||
| ); | ||
| } | ||
|
|
||
| function ToggleChevron({ | ||
| expandable, | ||
| expanded, | ||
| }: { | ||
| expandable: boolean; | ||
| expanded: boolean; | ||
| }) { | ||
| return ( | ||
| <span className={styles.lineToggle} aria-hidden="true"> | ||
| {expandable ? (expanded ? '▾' : '▸') : ''} | ||
| </span> | ||
| ); | ||
| } | ||
|
|
||
| function getActiveTool(tools: ACPToolCall[]): ACPToolCall { | ||
| return ( | ||
| tools.find((t) => t.status === 'in_progress') ?? tools[tools.length - 1] | ||
|
|
@@ -611,6 +640,14 @@ export const ToolLine = memo(function ToolLine({ | |
| return () => clearInterval(id); | ||
| }, [isRunningAgent]); | ||
|
|
||
| // Collapse a regular tool to its one-line summary once it completes | ||
| // successfully. Agents are excluded — they keep whatever expand state the | ||
| // user chose, driven from their own panel — and failures stay open so the | ||
| // error output remains visible. | ||
| useEffect(() => { | ||
| if (!isAgent && tool.status === 'completed') setExpanded(false); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| }, [isAgent, tool.status]); | ||
|
|
||
| if (isAgent) { | ||
| if (hasApproval && onConfirm) { | ||
| return ( | ||
|
|
@@ -712,10 +749,16 @@ export const ToolLine = memo(function ToolLine({ | |
| isShellToolName(tool.toolName) || isWebFetchToolName(tool.toolName) | ||
| ? '' | ||
| : formatElapsed(tool.startTime, tool.endTime); | ||
| const expandable = hasExpandableContent(tool); | ||
|
|
||
| const name = tool.toolName.toLowerCase(); | ||
| const isTodo = name === 'todowrite'; | ||
| // A row expands when it has detail output (bash/diff/read content) or when | ||
| // its description is long enough to be ellipsised. When a long description is | ||
| // expanded we move it out of the header into a wrapped block below, so the | ||
| // header drops its single-line copy. | ||
| const descExpandable = !isTodo && isDescriptionExpandable(description); | ||
|
wenshao marked this conversation as resolved.
Resolved
|
||
| const expandable = !isTodo && (hasExpandableContent(tool) || descExpandable); | ||
| const relocateDescription = expanded && descExpandable; | ||
|
|
||
| if (hasApproval && onConfirm) { | ||
| return ( | ||
|
|
@@ -731,20 +774,24 @@ export const ToolLine = memo(function ToolLine({ | |
| className={`${styles.lineMain} ${expandable ? styles.lineExpandable : ''}`} | ||
| onClick={expandable ? () => setExpanded(!expanded) : undefined} | ||
| > | ||
| <ToggleChevron expandable={expandable} expanded={expanded} /> | ||
| <StatusIcon status={tool.status} /> | ||
| <span className={styles.lineName}>{displayName}</span> | ||
| <ToolHeaderExtra | ||
| info={{ | ||
| kind: getToolHeaderKind(tool), | ||
| tool, | ||
| displayName, | ||
| description, | ||
| description: relocateDescription ? '' : description, | ||
| elapsed, | ||
| workspaceCwd, | ||
| }} | ||
| /> | ||
| </div> | ||
| {isTodo && <TodoWriteContent tool={tool} />} | ||
| {relocateDescription && ( | ||
| <div className={styles.lineFullArg}>{description}</div> | ||
| )} | ||
| {!isTodo && !expanded && result && ( | ||
| <div className={styles.lineOutput}>{result}</div> | ||
| )} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,4 +170,24 @@ describe('toolFormatting', () => { | |
| ), | ||
| ).toBe('3 line(s)'); | ||
| }); | ||
|
|
||
| it('keeps long shell commands in full instead of capping at one line', () => { | ||
| const command = `echo ${'a'.repeat(200)}`; | ||
| expect( | ||
| getToolDescription( | ||
| tool({ toolName: 'run_shell_command', args: { command } }), | ||
| ), | ||
| ).toBe(command); | ||
| }); | ||
|
|
||
| it('still bounds a pathologically long description', () => { | ||
| const result = getToolDescription( | ||
| tool({ | ||
| toolName: 'run_shell_command', | ||
| args: { command: 'x'.repeat(5000) }, | ||
| }), | ||
| ); | ||
| expect(result.length).toBeLessThan(5000); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The assertion Consider tightening to — qwen3.7-max via Qwen Code /review |
||
| expect(result.endsWith('...')).toBe(true); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,18 @@ | |||||||||||||||||||||||||||||
| min-width: 0; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /* Leading disclosure column. Rendered (blank) for every tool row so names stay | ||||||||||||||||||||||||||||||
| aligned; shows ▸/▾ only when the row can expand. */ | ||||||||||||||||||||||||||||||
| .lineToggle { | ||||||||||||||||||||||||||||||
| width: 12px; | ||||||||||||||||||||||||||||||
| flex-shrink: 0; | ||||||||||||||||||||||||||||||
| font-size: 10px; | ||||||||||||||||||||||||||||||
| line-height: 1; | ||||||||||||||||||||||||||||||
| color: var(--text-dimmed); | ||||||||||||||||||||||||||||||
| text-align: center; | ||||||||||||||||||||||||||||||
| user-select: none; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .icon { | ||||||||||||||||||||||||||||||
| font-size: 13px; | ||||||||||||||||||||||||||||||
| flex-shrink: 0; | ||||||||||||||||||||||||||||||
|
|
@@ -110,6 +122,21 @@ | |||||||||||||||||||||||||||||
| line-height: 1.4; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /* Full, wrapped tool argument shown below the header when the row is expanded | ||||||||||||||||||||||||||||||
| (the header drops its single-line ellipsised copy). Aligns with the expanded | ||||||||||||||||||||||||||||||
| output block below it. */ | ||||||||||||||||||||||||||||||
| .lineFullArg { | ||||||||||||||||||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— qwen3.7-max via Qwen Code /review |
||||||||||||||||||||||||||||||
| margin-left: 16px; | ||||||||||||||||||||||||||||||
| margin-top: 2px; | ||||||||||||||||||||||||||||||
| font-size: 12px; | ||||||||||||||||||||||||||||||
| line-height: 1.4; | ||||||||||||||||||||||||||||||
| color: var(--text-secondary); | ||||||||||||||||||||||||||||||
| font-family: var(--font-mono); | ||||||||||||||||||||||||||||||
| white-space: pre-wrap; | ||||||||||||||||||||||||||||||
| word-break: break-word; | ||||||||||||||||||||||||||||||
| overflow-wrap: anywhere; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| .lineDetail { | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.