Changesets · Branches · Tags · Compare
| Changeset | 44b20f765bd51becbfa94e21a23699027e4d78b3c2963ab7a03e285bf2109fd5 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-07-24 14:19 +02:00 |
| Committer | GitHub <noreply@github.com> · 2025-07-24 14:19 +02:00 |
| Parents | 0ecf3844803c, d3ae0cf0a47b |
3 files changed
added gui/src/pages/gui/ToolCallDiv/IndicatorBar.tsx +19 −0
| @@ -0,0 +1,19 @@ | ||
| 1 | +import { ChevronDownIcon } from "@heroicons/react/24/outline"; | |
| 2 | + | |
| 3 | +interface IndicatorBarProps { | |
| 4 | + text: string; | |
| 5 | + isExpanded: boolean; | |
| 6 | +} | |
| 7 | + | |
| 8 | +export function IndicatorBar({ text, isExpanded }: IndicatorBarProps) { | |
| 9 | + return ( | |
| 10 | + <div className="absolute left-0 right-0 top-0 z-10 flex h-8 items-start justify-center pt-1"> | |
| 11 | + <div className="border-border bg-editor text-description flex items-center gap-2 rounded border px-2 py-1 text-[11px] shadow-sm"> | |
| 12 | + <span>{text}</span> | |
| 13 | + <ChevronDownIcon | |
| 14 | + className={`text-description h-3 w-3 ${isExpanded ? "" : "rotate-180"}`} | |
| 15 | + /> | |
| 16 | + </div> | |
| 17 | + </div> | |
| 18 | + ); | |
| 19 | +} |
modified gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx +87 −68
| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | import { ToolCallState } from "core"; |
| 2 | -import styled from "styled-components"; | |
| 3 | -import { vscForeground } from "../../../components"; | |
| 2 | +import { useMemo } from "react"; | |
| 4 | 3 | import Ansi from "../../../components/ansiTerminal/Ansi"; |
| 5 | 4 | import StyledMarkdownPreview from "../../../components/StyledMarkdownPreview"; |
| 6 | 5 | import { useAppDispatch } from "../../../redux/hooks"; |
| 7 | 6 | import { moveTerminalProcessToBackground } from "../../../redux/thunks/moveTerminalProcessToBackground"; |
| 7 | +import { TerminalCollapsibleContainer } from "./TerminalCollapsibleContainer"; | |
| 8 | 8 | |
| 9 | 9 | interface RunTerminalCommandToolCallProps { |
| 10 | 10 | command: string; |
| @@ -12,64 +12,34 @@ | ||
| 12 | 12 | toolCallId: string | undefined; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -const CommandStatus = styled.div` | |
| 16 | - font-size: 12px; | |
| 17 | - color: var(--vscode-descriptionForeground, ${vscForeground}88); | |
| 18 | - margin-top: 8px; | |
| 19 | - display: flex; | |
| 20 | - align-items: center; | |
| 21 | - padding-left: 8px; | |
| 22 | - padding-right: 8px; | |
| 23 | -`; | |
| 24 | - | |
| 25 | -const StatusIcon = styled.span<{ | |
| 15 | +interface StatusIconProps { | |
| 26 | 16 | status: "running" | "completed" | "failed" | "background"; |
| 27 | -}>` | |
| 28 | - width: 8px; | |
| 29 | - height: 8px; | |
| 30 | - border-radius: 50%; | |
| 31 | - margin-right: 8px; | |
| 32 | - background-color: ${(props) => | |
| 33 | - props.status === "running" | |
| 34 | - ? "var(--vscode-testing-runAction, #4caf50)" | |
| 35 | - : props.status === "completed" | |
| 36 | - ? "var(--vscode-testing-iconPassed, #4caf50)" | |
| 37 | - : props.status === "background" | |
| 38 | - ? "var(--vscode-statusBarItem-prominentBackground, #2196f3)" | |
| 39 | - : "var(--vscode-testing-iconFailed, #f44336)"}; | |
| 40 | - ${(props) => | |
| 41 | - props.status === "running" ? "animation: pulse 1.5s infinite;" : ""} | |
| 42 | -`; | |
| 43 | - | |
| 44 | -// Waiting message styled for consistency | |
| 45 | -const WaitingMessage = styled.div` | |
| 46 | - padding: 8px; | |
| 47 | - padding-left: 16px; | |
| 48 | - padding-right: 16px; | |
| 49 | - margin-top: 8px; | |
| 50 | -`; | |
| 51 | - | |
| 52 | -// For consistency with the rest of the styled components | |
| 53 | -const AnsiWrapper = styled.div` | |
| 54 | - margin-top: 8px; | |
| 55 | -`; | |
| 56 | - | |
| 57 | -const BackgroundLink = styled.a` | |
| 58 | - font-size: 12px; | |
| 59 | - color: var(--vscode-textLink-foreground, #3794ff); | |
| 60 | - margin-left: 12px; | |
| 61 | - cursor: pointer; | |
| 62 | - text-decoration: none; | |
| 63 | - | |
| 64 | - &:hover { | |
| 65 | - text-decoration: underline; | |
| 66 | - } | |
| 67 | -`; | |
| 17 | +} | |
| 68 | 18 | |
| 69 | -// Just spacing between terminal components and the next toolcall | |
| 70 | -const TerminalContainer = styled.div` | |
| 71 | - margin-bottom: 16px; | |
| 72 | -`; | |
| 19 | +function StatusIcon({ status }: StatusIconProps) { | |
| 20 | + const getStatusColor = () => { | |
| 21 | + switch (status) { | |
| 22 | + case "running": | |
| 23 | + return "bg-success"; | |
| 24 | + case "completed": | |
| 25 | + return "bg-success"; | |
| 26 | + case "background": | |
| 27 | + return "bg-accent"; | |
| 28 | + case "failed": | |
| 29 | + return "bg-error"; | |
| 30 | + default: | |
| 31 | + return "bg-success"; | |
| 32 | + } | |
| 33 | + }; | |
| 34 | + | |
| 35 | + return ( | |
| 36 | + <span | |
| 37 | + className={`mr-2 h-2 w-2 rounded-full ${getStatusColor()} ${ | |
| 38 | + status === "running" ? "animate-pulse" : "" | |
| 39 | + }`} | |
| 40 | + /> | |
| 41 | + ); | |
| 42 | +} | |
| 73 | 43 | |
| 74 | 44 | export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) { |
| 75 | 45 | const dispatch = useAppDispatch(); |
| @@ -84,6 +54,42 @@ | ||
| 84 | 54 | const isRunning = props.toolCallState.status === "calling"; |
| 85 | 55 | const hasOutput = terminalContent.length > 0; |
| 86 | 56 | |
| 57 | + const displayLines = 15; | |
| 58 | + | |
| 59 | + // Process terminal content for line limiting | |
| 60 | + const processedTerminalContent = useMemo(() => { | |
| 61 | + if (!terminalContent) | |
| 62 | + return { | |
| 63 | + fullContent: "", | |
| 64 | + limitedContent: "", | |
| 65 | + totalLines: 0, | |
| 66 | + isLimited: false, | |
| 67 | + hiddenLinesCount: 0, | |
| 68 | + }; | |
| 69 | + | |
| 70 | + const lines = terminalContent.split("\n"); | |
| 71 | + const totalLines = lines.length; | |
| 72 | + | |
| 73 | + if (totalLines > displayLines) { | |
| 74 | + const lastTwentyLines = lines.slice(-displayLines); | |
| 75 | + return { | |
| 76 | + fullContent: terminalContent, | |
| 77 | + limitedContent: lastTwentyLines.join("\n"), | |
| 78 | + totalLines, | |
| 79 | + isLimited: true, | |
| 80 | + hiddenLinesCount: totalLines - displayLines, | |
| 81 | + }; | |
| 82 | + } | |
| 83 | + | |
| 84 | + return { | |
| 85 | + fullContent: terminalContent, | |
| 86 | + limitedContent: terminalContent, | |
| 87 | + totalLines, | |
| 88 | + isLimited: false, | |
| 89 | + hiddenLinesCount: 0, | |
| 90 | + }; | |
| 91 | + }, [terminalContent]); | |
| 92 | + | |
| 87 | 93 | // Determine status type |
| 88 | 94 | let statusType: "running" | "completed" | "failed" | "background" = |
| 89 | 95 | "completed"; |
| @@ -96,7 +102,7 @@ | ||
| 96 | 102 | } |
| 97 | 103 | |
| 98 | 104 | return ( |
| 99 | - <TerminalContainer> | |
| 105 | + <div className="mb-4"> | |
| 100 | 106 | {/* Command */} |
| 101 | 107 | <StyledMarkdownPreview |
| 102 | 108 | isRenderingInStepContainer |
| @@ -105,21 +111,33 @@ | ||
| 105 | 111 | |
| 106 | 112 | {/* Terminal output with ANSI support */} |
| 107 | 113 | {isRunning && !hasOutput && ( |
| 108 | - <WaitingMessage>Waiting for output...</WaitingMessage> | |
| 114 | + <div className="mt-2 px-4 py-2">Waiting for output...</div> | |
| 109 | 115 | )} |
| 110 | 116 | {hasOutput && ( |
| 111 | - <AnsiWrapper> | |
| 112 | - <Ansi>{terminalContent}</Ansi> | |
| 113 | - </AnsiWrapper> | |
| 117 | + <TerminalCollapsibleContainer | |
| 118 | + collapsible={processedTerminalContent.isLimited} | |
| 119 | + hiddenLinesCount={processedTerminalContent.hiddenLinesCount} | |
| 120 | + className="mt-2" | |
| 121 | + collapsedContent={ | |
| 122 | + <div className="mt-2"> | |
| 123 | + <Ansi>{processedTerminalContent.limitedContent}</Ansi> | |
| 124 | + </div> | |
| 125 | + } | |
| 126 | + expandedContent={ | |
| 127 | + <div className="mt-2"> | |
| 128 | + <Ansi>{processedTerminalContent.fullContent}</Ansi> | |
| 129 | + </div> | |
| 130 | + } | |
| 131 | + /> | |
| 114 | 132 | )} |
| 115 | 133 | |
| 116 | 134 | {/* Status information */} |
| 117 | 135 | {(statusMessage || isRunning) && ( |
| 118 | - <CommandStatus> | |
| 136 | + <div className="text-description mt-2 flex items-center px-2 text-xs"> | |
| 119 | 137 | <StatusIcon status={statusType} /> |
| 120 | 138 | {isRunning ? "Running" : statusMessage} |
| 121 | 139 | {isRunning && props.toolCallId && ( |
| 122 | - <BackgroundLink | |
| 140 | + <span | |
| 123 | 141 | onClick={() => { |
| 124 | 142 | // Dispatch the action to move the command to the background |
| 125 | 143 | dispatch( |
| @@ -128,12 +146,13 @@ | ||
| 128 | 146 | }), |
| 129 | 147 | ); |
| 130 | 148 | }} |
| 149 | + className="text-link ml-3 cursor-pointer text-xs no-underline hover:underline" | |
| 131 | 150 | > |
| 132 | 151 | Move to background |
| 133 | - </BackgroundLink> | |
| 152 | + </span> | |
| 134 | 153 | )} |
| 135 | - </CommandStatus> | |
| 154 | + </div> | |
| 136 | 155 | )} |
| 137 | - </TerminalContainer> | |
| 156 | + </div> | |
| 138 | 157 | ); |
| 139 | 158 | } |
added gui/src/pages/gui/ToolCallDiv/TerminalCollapsibleContainer.tsx +61 −0
| @@ -0,0 +1,61 @@ | ||
| 1 | +import { useState } from "react"; | |
| 2 | +import { IndicatorBar } from "./IndicatorBar"; | |
| 3 | + | |
| 4 | +interface TerminalCollapsibleContainerProps { | |
| 5 | + collapsedContent: React.ReactNode; | |
| 6 | + expandedContent: React.ReactNode; | |
| 7 | + className?: string; | |
| 8 | + collapsible?: boolean; | |
| 9 | + hiddenLinesCount?: number; | |
| 10 | +} | |
| 11 | + | |
| 12 | +export function TerminalCollapsibleContainer({ | |
| 13 | + collapsedContent, | |
| 14 | + expandedContent, | |
| 15 | + className = "", | |
| 16 | + collapsible = false, | |
| 17 | + hiddenLinesCount = 0, | |
| 18 | +}: TerminalCollapsibleContainerProps) { | |
| 19 | + const [isExpanded, setIsExpanded] = useState(false); | |
| 20 | + | |
| 21 | + if (!collapsible) { | |
| 22 | + return <div className={className}>{collapsedContent}</div>; | |
| 23 | + } | |
| 24 | + | |
| 25 | + return ( | |
| 26 | + <div className={`relative ${className}`}> | |
| 27 | + {/* Indicator bar - shows for both collapsed and expanded states */} | |
| 28 | + {((!isExpanded && hiddenLinesCount > 0) || | |
| 29 | + (isExpanded && collapsible)) && ( | |
| 30 | + <IndicatorBar | |
| 31 | + text={isExpanded ? "Collapse" : `+${hiddenLinesCount} more lines`} | |
| 32 | + isExpanded={isExpanded} | |
| 33 | + /> | |
| 34 | + )} | |
| 35 | + | |
| 36 | + {/* Clickable overlay covering the entire content area */} | |
| 37 | + {collapsible && ( | |
| 38 | + <div | |
| 39 | + onClick={(e) => { | |
| 40 | + e.preventDefault(); | |
| 41 | + e.stopPropagation(); | |
| 42 | + setIsExpanded(!isExpanded); | |
| 43 | + }} | |
| 44 | + className="absolute inset-0 z-20 cursor-pointer" | |
| 45 | + /> | |
| 46 | + )} | |
| 47 | + | |
| 48 | + {/* Content container with proper constraint for gradient */} | |
| 49 | + <div | |
| 50 | + className={`relative overflow-hidden rounded-lg ${collapsible ? "cursor-pointer" : ""}`} | |
| 51 | + > | |
| 52 | + {/* Gradient overlay on top of content - only when collapsed */} | |
| 53 | + {!isExpanded && hiddenLinesCount > 0 && ( | |
| 54 | + <div className="from-editor pointer-events-none absolute left-[9px] right-[9px] top-4 z-[5] h-[100px] rounded-t-md bg-gradient-to-b to-transparent" /> | |
| 55 | + )} | |
| 56 | + | |
| 57 | + {isExpanded ? expandedContent : collapsedContent} | |
| 58 | + </div> | |
| 59 | + </div> | |
| 60 | + ); | |
| 61 | +} |