Skip to content

Add background commands and desktop notifications - #85

Merged
nasser1941 merged 1 commit into
mainfrom
feat/long-running
Oct 5, 2026
Merged

nasser1941 merged 1 commit into
mainfrom
feat/long-running

Conversation

@nasser1941

Copy link
Copy Markdown
Owner

Closes #51.

What

  • Background commands (src/lcode/jobs.py):
    • Starting one: 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.
    • /jobs lists them and /jobs stop <id> stops one. Subagents share the session's jobs. api.close_agent stops them all, which covers the terminal, -p, the Python API and lcode acp.
  • Leftovers of &: 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 use background=true. Commands like a & b & wait are unaffected.
  • Notifications (src/lcode/notify.py): notify-send on Linux, osascript on macOS, and the terminal bell otherwise.
    • When: a request runs longer than notify_after seconds (30) and finishes, or lcode waits for an answer during such a request (a permission question or a plan).
    • Where: only in terminal sessions, not -p, the API or editors.
    • Settings: notify (on by default) and notify_after.
    • The notification hooks keep working, now through the same Agent.waiting / Agent.finished.
  • Docs: Background commands and Notifications sections in the usage guide, plus the settings, the tools table and /jobs.

Tests

  • tests/test_jobs.py (9 tests):
    • a job running until stopped, its children included;
    • the output cap;
    • the model starting, reading and stopping a job through the tools;
    • jobs stopping at session end and from /jobs;
    • leftovers of & being stopped, while a & b & wait is unaffected;
    • plan mode;
    • the notification commands and the bell fallback;
    • when long requests and waits notify, and when they don't;
    • plan approvals notifying.
  • Real runs with Qwen3.6 35B through Ollama (-p, yolo):
    • "Start a web server … check it with curl … read its output … stop it": the first version of the tool description let the model use its own & and kill.
    • With the clearer description: 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.
    • Notification: a terminal session with notify_after = 1. dbus-monitor showed the Notify call ("lcode is done", with the request and its 15 s).

🤖 Generated with Claude Code

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>
@nasser1941
nasser1941 merged commit 4f889b5 into main Oct 5, 2026
12 checks passed
@nasser1941
nasser1941 deleted the feat/long-running branch October 5, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long-running work: finish notifications and background commands

1 participant