Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/ui/ConnectApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export function ConnectApp(props: ConnectAppProps): React.ReactElement {
[items, expanded],
)
const hasCollapsible = useMemo(
() => items.some((it) => it.kind === 'tool_result' && it.text.split('\n').length > COLLAPSE_LINES),
() => items.some((it) => isCollapsible(it)),
[items],
)

Expand Down Expand Up @@ -351,16 +351,25 @@ export function ConnectApp(props: ConnectAppProps): React.ReactElement {
</Box>
)}
{inputActive && hasCollapsible && (
<Text dimColor>ctrl+r to {expanded ? 'collapse' : 'expand'} tool output</Text>
<Text dimColor>ctrl+r to {expanded ? 'collapse' : 'expand'} long output</Text>
)}
</Box>
</Box>
)
}

// Tool-result bodies collapse to this many lines until ctrl+r expands them.
// Long bodies collapse to this many lines until ctrl+r expands them.
const COLLAPSE_LINES = 6

// Which items collapse when long: tool results and user turns (the latter carry
// the re-injected run context, which is bulky). Assistant prose stays full.
function isCollapsible(item: TranscriptItem): boolean {
return (
(item.kind === 'tool_result' || item.kind === 'user') &&
item.text.split('\n').length > COLLAPSE_LINES
)
}

// Colour + weight for each transcript item kind, matched loosely to Claude Code.
function styleFor(item: TranscriptItem): {
gutterColor?: string
Expand Down Expand Up @@ -409,10 +418,10 @@ const TranscriptLine = React.memo(function TranscriptLine({
)
}

// Tool results can be long; collapse to a compact body with a "+N lines"
// marker unless ctrl+r has expanded the transcript.
// Long tool results and user turns collapse to a compact body with a
// "+N lines" marker unless ctrl+r has expanded the transcript.
const clamped =
item.kind === 'tool_result' && !expanded
!expanded && isCollapsible(item)
? clampLines(item.text, COLLAPSE_LINES)
: { body: item.text, more: 0 }

Expand Down
Loading