-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: bash tool execution in background #10285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 issues found across 20 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="extensions/cli/src/ui/JobsSelector.tsx">
<violation number="1" location="extensions/cli/src/ui/JobsSelector.tsx:49">
P2: Polling effect uses a stale closure: viewMode/selectedJob aren’t in the dependency array, so the interval never sees updates and detail view auto-refresh won’t run.</violation>
</file>
<file name="extensions/cli/src/tools/runTerminalCommand.ts">
<violation number="1" location="extensions/cli/src/tools/runTerminalCommand.ts:225">
P2: After moving the process to background, stdout/stderr/data listeners are never detached, so they keep appending to captured buffers and updating chat history even though the tool call is resolved, causing memory growth and spurious updates.</violation>
<violation number="2" location="extensions/cli/src/tools/runTerminalCommand.ts:242">
P2: Backgrounding a command returns unbounded stdout without applying the existing truncation limits, which can overflow context if the process has produced large output before backgrounding.</violation>
</file>
<file name="extensions/cli/src/services/BackgroundJobService.ts">
<violation number="1" location="extensions/cli/src/services/BackgroundJobService.ts:72">
P2: Output capture decodes each Buffer chunk with toString(), which can corrupt multi‑byte characters split across chunks. Use StringDecoder or setEncoding on the streams to preserve UTF‑8 sequences across chunk boundaries.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| }, 1000); | ||
|
|
||
| return () => clearInterval(interval); | ||
| }, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Polling effect uses a stale closure: viewMode/selectedJob aren’t in the dependency array, so the interval never sees updates and detail view auto-refresh won’t run.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/ui/JobsSelector.tsx, line 49:
<comment>Polling effect uses a stale closure: viewMode/selectedJob aren’t in the dependency array, so the interval never sees updates and detail view auto-refresh won’t run.</comment>
<file context>
@@ -0,0 +1,201 @@
+ }, 1000);
+
+ return () => clearInterval(interval);
+ }, []);
+
+ useInput((input, key) => {
</file context>
|
|
||
| if (job) { | ||
| resolve( | ||
| `Command moved to background. Job ID: ${job.id}\nOutput so far:\n${stdout}\nUse CheckBackgroundJob("${job.id}") to check status.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Backgrounding a command returns unbounded stdout without applying the existing truncation limits, which can overflow context if the process has produced large output before backgrounding.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/tools/runTerminalCommand.ts, line 242:
<comment>Backgrounding a command returns unbounded stdout without applying the existing truncation limits, which can overflow context if the process has produced large output before backgrounding.</comment>
<file context>
@@ -187,6 +222,34 @@ IMPORTANT: To edit files, use Edit/MultiEdit tools instead of bash commands (sed
+
+ if (job) {
+ resolve(
+ `Command moved to background. Job ID: ${job.id}\nOutput so far:\n${stdout}\nUse CheckBackgroundJob("${job.id}") to check status.`,
+ );
+ } else {
</file context>
| `Command moved to background. Job ID: ${job.id}\nOutput so far:\n${stdout}\nUse CheckBackgroundJob("${job.id}") to check status.`, | |
| const truncationResult = truncateOutputFromStart(stdout, { maxChars, maxLines }); | |
| const outputSoFar = truncationResult.wasTruncated | |
| ? appendParallelLimitNote(truncationResult.output) | |
| : truncationResult.output; | |
| resolve( | |
| `Command moved to background. Job ID: ${job.id}\nOutput so far:\n${outputSoFar}\nUse CheckBackgroundJob("${job.id}") to check status.`, | |
| ); |
| return output; | ||
| }; | ||
|
|
||
| const moveToBackground = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: After moving the process to background, stdout/stderr/data listeners are never detached, so they keep appending to captured buffers and updating chat history even though the tool call is resolved, causing memory growth and spurious updates.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/tools/runTerminalCommand.ts, line 225:
<comment>After moving the process to background, stdout/stderr/data listeners are never detached, so they keep appending to captured buffers and updating chat history even though the tool call is resolved, causing memory growth and spurious updates.</comment>
<file context>
@@ -187,6 +222,34 @@ IMPORTANT: To edit files, use Edit/MultiEdit tools instead of bash commands (sed
return output;
};
+ const moveToBackground = () => {
+ if (isResolved) return;
+ isResolved = true;
</file context>
| this.processes.set(jobId, child); | ||
|
|
||
| child.stdout?.on("data", (data: Buffer) => { | ||
| this.appendOutput(jobId, data.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Output capture decodes each Buffer chunk with toString(), which can corrupt multi‑byte characters split across chunks. Use StringDecoder or setEncoding on the streams to preserve UTF‑8 sequences across chunk boundaries.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/services/BackgroundJobService.ts, line 72:
<comment>Output capture decodes each Buffer chunk with toString(), which can corrupt multi‑byte characters split across chunks. Use StringDecoder or setEncoding on the streams to preserve UTF‑8 sequences across chunk boundaries.</comment>
<file context>
@@ -0,0 +1,218 @@
+ this.processes.set(jobId, child);
+
+ child.stdout?.on("data", (data: Buffer) => {
+ this.appendOutput(jobId, data.toString());
+ });
+
</file context>
Description
Introduces moving terminal command to run in the background
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
feat.mp4
Tests
[ What tests were added or updated to ensure the changes work as expected? ]
Continue Tasks:▶️ 1 queued — View all
Summary by cubic
Run Bash tool commands in the background from the CLI. Press Ctrl+B to background a running command, monitor with /jobs or the CheckBackgroundJob tool; foreground runs now stream live output and background output is capped at 1000 lines.
Written for commit 1d2cba8. Summary will update on new commits.