Skip to content

Commit 95da34d

Browse files
authored
Fix command display in the approval required case (RooCodeInc#3636)
1 parent 8447670 commit 95da34d

File tree

3 files changed

+74
-15
lines changed

3 files changed

+74
-15
lines changed

.changeset/seven-ghosts-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Fix command display in the approval required case

webview-ui/package-lock.json

Lines changed: 55 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/components/chat/CommandExecution.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ interface CommandExecutionProps {
2323
export const CommandExecution = ({ executionId, text, icon, title }: CommandExecutionProps) => {
2424
const { terminalShellIntegrationDisabled = false } = useExtensionState()
2525

26+
const { command, output: parsedOutput } = useMemo(() => parseCommandAndOutput(text), [text])
27+
2628
// If we aren't opening the VSCode terminal for this command then we default
2729
// to expanding the command execution output.
2830
const [isExpanded, setIsExpanded] = useState(terminalShellIntegrationDisabled)
29-
30-
const { command: initialCommand, output: initialOutput } = useMemo(
31-
() => (text ? parseCommandAndOutput(text) : { command: "", output: "" }),
32-
[text],
33-
)
34-
35-
const [output, setOutput] = useState(initialOutput)
36-
const [command, setCommand] = useState(initialCommand)
31+
const [streamingOutput, setStreamingOutput] = useState("")
3732
const [status, setStatus] = useState<CommandExecutionStatus | null>(null)
3833

34+
// The command's output can either come from the text associated with the
35+
// task message (this is the case for completed commands) or from the
36+
// streaming output (this is the case for running commands).
37+
const output = streamingOutput || parsedOutput
38+
3939
const onMessage = useCallback(
4040
(event: MessageEvent) => {
4141
const message: ExtensionMessage = event.data
@@ -52,11 +52,10 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
5252

5353
switch (data.status) {
5454
case "started":
55-
setCommand(data.command)
5655
setStatus(data)
5756
break
5857
case "output":
59-
setOutput(data.output)
58+
setStreamingOutput(data.output)
6059
break
6160
case "fallback":
6261
setIsExpanded(true)
@@ -143,7 +142,11 @@ const OutputContainerInternal = ({ isExpanded, output }: { isExpanded: boolean;
143142

144143
const OutputContainer = memo(OutputContainerInternal)
145144

146-
const parseCommandAndOutput = (text: string) => {
145+
const parseCommandAndOutput = (text: string | undefined) => {
146+
if (!text) {
147+
return { command: "", output: "" }
148+
}
149+
147150
const index = text.indexOf(COMMAND_OUTPUT_STRING)
148151

149152
if (index === -1) {

0 commit comments

Comments
 (0)