fix(tui): collapse direct shell output
This commit is contained in:
parent
cbcf191fdb
commit
8454f94dbe
1 changed files with 9 additions and 12 deletions
|
|
@ -1607,24 +1607,21 @@ function RevertMessage(props: {
|
||||||
|
|
||||||
function ShellMessage(props: { message: Extract<SessionMessageInfo, { type: "shell" }> }) {
|
function ShellMessage(props: { message: Extract<SessionMessageInfo, { type: "shell" }> }) {
|
||||||
const { themeV2 } = useTheme().contextual("elevated")
|
const { themeV2 } = useTheme().contextual("elevated")
|
||||||
|
const ctx = use()
|
||||||
const output = createMemo(() => stripAnsi(props.message.output?.output.trim() ?? ""))
|
const output = createMemo(() => stripAnsi(props.message.output?.output.trim() ?? ""))
|
||||||
|
const [expanded, setExpanded] = createSignal(false)
|
||||||
|
const maxLines = 10
|
||||||
|
const maxChars = createMemo(() => maxLines * Math.max(20, ctx.width - 6))
|
||||||
|
const collapsed = createMemo(() => collapseToolOutput(output(), maxLines, maxChars()))
|
||||||
|
const limited = createMemo(() => (expanded() ? output() : collapsed().output))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box
|
<BlockTool onClick={collapsed().overflow ? () => setExpanded((value) => !value) : undefined}>
|
||||||
border={["left"]}
|
|
||||||
paddingTop={1}
|
|
||||||
paddingBottom={1}
|
|
||||||
paddingLeft={2}
|
|
||||||
gap={1}
|
|
||||||
backgroundColor={themeV2.background()}
|
|
||||||
customBorderChars={SplitBorder.customBorderChars}
|
|
||||||
borderColor={themeV2.background()}
|
|
||||||
>
|
|
||||||
<text fg={themeV2.text()}>$ {props.message.command}</text>
|
<text fg={themeV2.text()}>$ {props.message.command}</text>
|
||||||
<Show when={output()}>
|
<Show when={output()}>
|
||||||
<text fg={themeV2.text.subdued()}>{output()}</text>
|
<text fg={themeV2.text.subdued()}>{limited()}</text>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</BlockTool>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue