Repository navigation
Add a Monitoring background tasks state bounded by a family lease (build 41) - #48
Conversation
…ild 41) When a Claude turn ends but its Stop still reports background shells, Monitor tasks or agent work, or non-empty session_crons that will start more turns, the session stays Working in a monitoring sub-state that holds the Mac awake, the lid closed included. It ends at the work's own edge: a later Stop or SubagentStop inventory listing nothing, a new prompt, SessionEnd, or the agent process exiting. idle_prompt and a manual compact keep it. MonitoringLease bounds it, and every subagent's own record: they stop holding once the session family, the parent and all its subagents, has sent no hook for Settings.monitoringHoldLimit (two hours). Any hook in the family renews it, including a SubagentStop that leaves other work. This replaces the one-hour background-shell bound and the unbounded background-agent hold, so a forgotten server or a killed subagent cannot keep the Mac awake indefinitely. The menu reads "Monitoring background tasks", then "No update in 2 h · Mac can sleep" once the lease lapses, and the header and folder counts show monitoring separately. A turn ending in monitoring no longer brings back a session the person stopped watching. session_crons is read only for its length; local_bash and background_shell count as shell work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0da43930e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A SubagentStop deletes the child's record, and without a background-task snapshot it left the parent untouched, so MonitoringLease forgot that family hook and a surviving sibling could stop holding early. The parent now records it as family_edge_at, which latestEdges includes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This adds a Monitoring background tasks sub-state of Working, modelled on Orca's. The user approved the spec after we compared it with Orca's implementation (
agent-lead-status-fold,claude-pane-hold-evidence,agent-awake-status-lease).Behavior
Enters when a Claude Stop still reports live work. That state holds the Mac awake like Working, with the lid closed too:
background-shell: typesshell,monitor,local_bash,background_shell.background-agent: a subagent, teammate, workflow, or unknown type.scheduled-tasks: no tasks, but a non-emptysession_crons, so crons will start more turns. Only the array's length is read.Ends at the work's own edge:
SessionEnd;idle_promptand a manual/compactkeep the state.Bound.
MonitoringLease(Decision.swift) applies to monitoring records and to every subagent child record. They stop holding once the session family has sent no hook forSettings.monitoringHoldLimit, which is 2 h. The family is the parent plus all its subagents, keyed on the parent record ID.background-shellbound from Bound background-shell holds and clear orphaned Claude work (build 38) #43 and the unboundedbackground-agenthold. Keep a stopped Claude turn's background work through idle_prompt (build 41) #46's agent narrowing is reverted, because the lease now bounds the agent hold.Menu
MenuSessionState.resolveuses the sameMonitoringLeaseand family edges asdecide().Stop Watching. A Stop or edge that only enters or renews monitoring no longer counts as a genuine work edge, so a stopped-watching session stays hidden. The next real turn still brings it back. For a
/loopcron, that means the next firing.Tests
854 pass. New and updated tests cover:
session_cronsdecoding: count, empty, absent, malformed;local_bashandbackground_shellcounting as shell work;idle_promptkeeping agent and cron monitoring;Docs
/loopcrons, and Stop Watching.Verification
swift test --no-parallel: 854 pass.🤖 Generated with Claude Code