Skip to content

Commit f559ea5

Browse files
committed
🤖 fix: show live bash output pane while executing
Change-Id: I8be7efa5ba17ca3b20a9cba58a435c5afcc65be6 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 73c9559 commit f559ea5

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/browser/components/tools/BashToolCall.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ interface BashToolCallProps {
3939
onSendToBackground?: () => void;
4040
}
4141

42+
const EMPTY_LIVE_OUTPUT = {
43+
stdout: "",
44+
stderr: "",
45+
truncated: false,
46+
};
47+
4248
export const BashToolCall: React.FC<BashToolCallProps> = ({
4349
workspaceId,
4450
toolCallId,
@@ -108,9 +114,14 @@ export const BashToolCall: React.FC<BashToolCallProps> = ({
108114
status === "completed" && result && "backgroundProcessId" in result ? "backgrounded" : status;
109115

110116
const resultHasOutput = typeof (result as { output?: unknown } | undefined)?.output === "string";
111-
const showLiveOutput = Boolean(
112-
liveOutput && !isBackground && (status === "executing" || !resultHasOutput)
113-
);
117+
118+
const hasLiveOutputSource = Boolean(workspaceId && toolCallId);
119+
const showLiveOutput =
120+
!isBackground &&
121+
hasLiveOutputSource &&
122+
(status === "executing" || (Boolean(liveOutput) && !resultHasOutput));
123+
124+
const liveOutputView = liveOutput ?? EMPTY_LIVE_OUTPUT;
114125
const liveLabelSuffix = status === "executing" ? " (live)" : " (tail)";
115126

116127
return (
@@ -176,9 +187,9 @@ export const BashToolCall: React.FC<BashToolCallProps> = ({
176187

177188
{expanded && (
178189
<ToolDetails>
179-
{showLiveOutput && liveOutput && (
190+
{showLiveOutput && (
180191
<>
181-
{liveOutput.truncated && (
192+
{liveOutputView.truncated && (
182193
<div className="text-muted px-2 text-[10px] italic">
183194
Live output truncated (showing last ~1MB)
184195
</div>
@@ -191,10 +202,10 @@ export const BashToolCall: React.FC<BashToolCallProps> = ({
191202
onScroll={(e) => updatePinned(e.currentTarget, stdoutPinnedRef)}
192203
className={cn(
193204
"px-2 py-1.5",
194-
liveOutput.stdout.length === 0 && "text-muted italic"
205+
liveOutputView.stdout.length === 0 && "text-muted italic"
195206
)}
196207
>
197-
{liveOutput.stdout.length > 0 ? liveOutput.stdout : "No output yet"}
208+
{liveOutputView.stdout.length > 0 ? liveOutputView.stdout : "No output yet"}
198209
</DetailContent>
199210
</DetailSection>
200211

@@ -205,10 +216,10 @@ export const BashToolCall: React.FC<BashToolCallProps> = ({
205216
onScroll={(e) => updatePinned(e.currentTarget, stderrPinnedRef)}
206217
className={cn(
207218
"px-2 py-1.5",
208-
liveOutput.stderr.length === 0 && "text-muted italic"
219+
liveOutputView.stderr.length === 0 && "text-muted italic"
209220
)}
210221
>
211-
{liveOutput.stderr.length > 0 ? liveOutput.stderr : "No output yet"}
222+
{liveOutputView.stderr.length > 0 ? liveOutputView.stderr : "No output yet"}
212223
</DetailContent>
213224
</DetailSection>
214225
</>
@@ -248,7 +259,7 @@ export const BashToolCall: React.FC<BashToolCallProps> = ({
248259
</>
249260
)}
250261

251-
{status === "executing" && !result && (
262+
{status === "executing" && !result && !showLiveOutput && (
252263
<DetailSection>
253264
<DetailContent className="px-2 py-1.5">
254265
Waiting for result

0 commit comments

Comments
 (0)