Skip to content

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Feb 6, 2026

Description

Introduces moving terminal command to run in the background

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

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.

  • New Features
    • Background job system with IDs, output capture, live streaming, and status tracking (max 5 concurrent; output capped at 1000 lines; auto-kill on exit).
    • Ctrl+B moves the current Bash execution to the background and returns the Job ID.
    • /jobs opens an interactive screen to view job details (status, duration, last output) and cancel running jobs.
    • CheckBackgroundJob tool returns a job’s status, exit code, and full output.
    • TUI shows “ctrl+b to background” while the Bash tool is running.

Written for commit 1d2cba8. Summary will update on new commits.

@uinstinct uinstinct marked this pull request as ready for review February 9, 2026 13:43
@uinstinct uinstinct requested a review from a team as a code owner February 9, 2026 13:43
@uinstinct uinstinct requested review from sestinj and removed request for a team February 9, 2026 13:43
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 9, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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);
}, []);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 9, 2026

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>
Fix with Cubic


if (job) {
resolve(
`Command moved to background. Job ID: ${job.id}\nOutput so far:\n${stdout}\nUse CheckBackgroundJob("${job.id}") to check status.`,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 9, 2026

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>
Suggested change
`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.`,
);
Fix with Cubic

return output;
};

const moveToBackground = () => {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 9, 2026

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>
Fix with Cubic

this.processes.set(jobId, child);

child.stdout?.on("data", (data: Buffer) => {
this.appendOutput(jobId, data.toString());
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 9, 2026

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>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant