Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions packages/cli/src/ui/hooks/useExecutionLifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export const useExecutionLifecycle = (
let cumulativeStdout: string | AnsiOutput = '';
let isBinaryStream = false;
let binaryBytesReceived = 0;
let lastTextUpdateTime = 0;

const initialToolDisplay: IndividualToolCallDisplay = {
callId,
Expand Down Expand Up @@ -436,7 +437,13 @@ export const useExecutionLifecycle = (
// AnsiOutput (PTY) is always the full state
cumulativeStdout = event.chunk;
}
shouldUpdate = true;
if (
Date.now() - lastTextUpdateTime >
OUTPUT_UPDATE_INTERVAL_MS
) {
shouldUpdate = true;
lastTextUpdateTime = Date.now();
}
Comment thread
ixchio marked this conversation as resolved.
break;
case 'binary_detected':
isBinaryStream = true;
Expand All @@ -445,7 +452,13 @@ export const useExecutionLifecycle = (
case 'binary_progress':
isBinaryStream = true;
binaryBytesReceived = event.bytesReceived;
shouldUpdate = true;
if (
Date.now() - lastTextUpdateTime >
OUTPUT_UPDATE_INTERVAL_MS
) {
shouldUpdate = true;
lastTextUpdateTime = Date.now();
}
break;
case 'exit':
// No action needed for exit event during streaming
Expand Down
17 changes: 14 additions & 3 deletions packages/core/src/tools/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ export class ShellToolInvocation extends BaseToolInvocation<
};
}
let cumulativeOutput: string | AnsiOutput = '';
let lastUpdateTime = Date.now();
let lastUpdateTime = 0;
let isBinaryStream = false;

const resetTimeout = () => {
Expand Down Expand Up @@ -524,8 +524,19 @@ export class ShellToolInvocation extends BaseToolInvocation<
switch (event.type) {
case 'data':
if (isBinaryStream) break;
cumulativeOutput = event.chunk;
shouldUpdate = true;
if (typeof event.chunk === 'string') {
if (typeof cumulativeOutput === 'string') {
cumulativeOutput += event.chunk;
} else {
cumulativeOutput = event.chunk;
}
} else {
// AnsiOutput (PTY) is always the full state
cumulativeOutput = event.chunk;
}
if (Date.now() - lastUpdateTime > OUTPUT_UPDATE_INTERVAL_MS) {
shouldUpdate = true;
}
Comment thread
ixchio marked this conversation as resolved.
break;
case 'binary_detected':
isBinaryStream = true;
Expand Down
Loading