Repository navigation
Add background commands and desktop notifications - #85
Merged
Merged
Conversation
bash with background=true starts a process that keeps running (a dev server, a watcher) and returns a job id; bash_output reads what it printed since last time and bash_stop stops its process group, in the sandbox too. /jobs lists them, subagents share them, and they all stop when the session ends. What a foreground command leaves running with & is stopped when it ends, and lcode no longer waits for such leftovers to close the output: the model is told to use background=true instead. lcode shows a desktop notification (notify-send, osascript, or the terminal bell) when a request that ran longer than notify_after seconds is done, or waits for an answer during one, plan approvals included. Settings: notify and notify_after. Closes #51 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #51.
What
src/lcode/jobs.py):bash(command, background=true)starts the process in its own process group. lcode keeps its output (capped at 1M characters) and returns a job id with the first output; a command that ends at once says so.bash_output(id)returns what's new since the last read, with the job's status. It's allowed in plan mode.bash_stop(id)stops the process group: SIGTERM, then SIGKILL. In the sandbox it stops the container process too./jobslists them and/jobs stop <id>stops one. Subagents share the session's jobs.api.close_agentstops them all, which covers the terminal,-p, the Python API andlcode acp.&: a foreground command that starts something with&no longer hangs until the timeout while that process holds the output open. Once the command itself has ended (lcode's marker arrives), lcode waits half a second, stops what the command left running, and tells the model to usebackground=true. Commands likea & b & waitare unaffected.src/lcode/notify.py):notify-sendon Linux,osascripton macOS, and the terminal bell otherwise.notify_afterseconds (30) and finishes, or lcode waits for an answer during such a request (a permission question or a plan).-p, the API or editors.notify(on by default) andnotify_after.Agent.waiting/Agent.finished./jobs.Tests
tests/test_jobs.py(9 tests):/jobs;&being stopped, whilea & b & waitis unaffected;-p, yolo):&andkill.bash(python3 -m http.server 8765, background=true),curl,bash_output,bash_stop. The answer quoted the server's access log, and the port was closed afterwards.notify_after = 1.dbus-monitorshowed theNotifycall ("lcode is done", with the request and its 15 s).🤖 Generated with Claude Code