-
Notifications
You must be signed in to change notification settings - Fork 22
🤖 feat: add local background bash process execution #749
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
Open
ethanndickson
wants to merge
13
commits into
main
Choose a base branch
from
bash-background-execution-param
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,125
−27
Open
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
78e19d3
🤖 feat: add background bash process execution
ethanndickson ef2bc7b
🤖 fix: block background execution for SSH/remote workspaces
ethanndickson e252065
🤖 fix: preserve killed status when onExit callback fires
ethanndickson d681ceb
🤖 fix: convert signal-terminated processes to non-zero exit codes
ethanndickson caf0c3e
🤖 refactor: extract BackgroundExecutor interface for runtime-agnostic…
ethanndickson 2dd5e75
🤖 fix: register background executors for existing workspaces after re…
ethanndickson fbb4a9d
🤖 refactor: lazy executor pattern for background processes
ethanndickson 8a7d8f7
🤖 refactor: move background execution to Runtime interface
ethanndickson 8bcee44
🤖 refactor: gate background tools and extract LocalBackgroundHandle
ethanndickson d39f405
🤖 fix: report correct exit codes for signal-terminated background pro…
ethanndickson 51dfcfd
🤖 fix: correctly detect signal-killed processes in isRunning()
ethanndickson c5571f9
fix: use separate TextDecoders per stream in background process
ethanndickson a57049c
fix: terminate background processes on app quit
ethanndickson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /** | ||
| * Background process execution abstraction. | ||
| * | ||
| * This interface allows BackgroundProcessManager to work with different | ||
| * execution backends (local processes, SSH remote processes, etc.) | ||
| */ | ||
|
|
||
| /** | ||
| * Configuration for background execution | ||
| */ | ||
| export interface BackgroundExecConfig { | ||
| /** Working directory for command execution */ | ||
| cwd: string; | ||
| /** Environment variables to inject */ | ||
| env?: Record<string, string>; | ||
| /** Process niceness level (-20 to 19) */ | ||
| niceness?: number; | ||
| } | ||
|
|
||
| /** | ||
| * Handle to a background process. | ||
| * Abstracts away whether process is local or remote. | ||
| */ | ||
| export interface BackgroundHandle { | ||
| /** | ||
| * Register callback for stdout lines. | ||
| * For local: called in real-time as output arrives. | ||
| * For SSH: called when output is polled/read. | ||
| */ | ||
| onStdout(callback: (line: string) => void): void; | ||
|
|
||
| /** | ||
| * Register callback for stderr lines. | ||
| */ | ||
| onStderr(callback: (line: string) => void): void; | ||
|
|
||
| /** | ||
| * Register callback for process exit. | ||
| * @param callback Receives exit code (128+signal for signal termination) | ||
| */ | ||
| onExit(callback: (exitCode: number) => void): void; | ||
|
|
||
| /** | ||
| * Check if process is still running. | ||
| * For local: checks ChildProcess.exitCode | ||
| * For SSH: runs `kill -0 $PID` on remote | ||
| */ | ||
| isRunning(): Promise<boolean>; | ||
|
|
||
| /** | ||
| * Terminate the process (SIGTERM → wait → SIGKILL). | ||
| * For local: process.kill(-pid, signal) | ||
| * For SSH: ssh "kill -TERM -$PID" | ||
| */ | ||
| terminate(): Promise<void>; | ||
|
|
||
| /** | ||
| * Clean up resources (called after process exits or on error). | ||
| * For local: disposes ChildProcess | ||
| * For SSH: removes remote temp files | ||
| */ | ||
| dispose(): Promise<void>; | ||
| } | ||
|
|
||
| /** | ||
| * Result of spawning a background process | ||
| */ | ||
| export type BackgroundSpawnResult = | ||
| | { success: true; handle: BackgroundHandle } | ||
| | { success: false; error: string }; | ||
|
|
||
| /** | ||
| * Executor interface for spawning background processes. | ||
| * | ||
| * Implementations: | ||
| * - LocalBackgroundExecutor: Uses BashExecutionService for local processes | ||
| * - SSHBackgroundExecutor: Uses nohup/setsid + file-based output (TODO) | ||
| */ | ||
| export interface BackgroundExecutor { | ||
| /** | ||
| * Spawn a background process. | ||
| * @param script Bash script to execute | ||
| * @param config Execution configuration | ||
| * @returns BackgroundHandle on success, or error | ||
| */ | ||
| spawn(script: string, config: BackgroundExecConfig): Promise<BackgroundSpawnResult>; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.