Skip to content

Add a Monitoring background tasks state bounded by a family lease (build 41) - #48

Merged
ruban-24 merged 2 commits into
mainfrom
feature/v1-monitoring-background
Oct 23, 2026
Merged

ruban-24 merged 2 commits into
mainfrom
feature/v1-monitoring-background

Conversation

@ruban-24

Copy link
Copy Markdown
Owner

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: types shell, monitor, local_bash, background_shell.
  • background-agent: a subagent, teammate, workflow, or unknown type.
  • scheduled-tasks: no tasks, but a non-empty session_crons, so crons will start more turns. Only the array's length is read.

Ends at the work's own edge:

  • a later Stop or SubagentStop inventory that lists nothing;
  • a new prompt;
  • SessionEnd;
  • the agent process exiting, via the existing liveness filter.

idle_prompt and a manual /compact keep 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 for Settings.monitoringHoldLimit, which is 2 h. The family is the parent plus all its subagents, keyed on the parent record ID.

Menu

  • Labels: "Monitoring background tasks", then "No update in 2 h · Mac can sleep" once the lease lapses. Those two states show the state text alone on a single row, since the logo names the agent.
  • Header: "N agents are working · M monitoring", or "1 agent is monitoring background tasks" when only monitoring remains.
  • Folder counts: "… · 1 monitoring · 1 not reporting".

MenuSessionState.resolve uses the same MonitoringLease and family edges as decide().

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 /loop cron, that means the next firing.

Tests

854 pass. New and updated tests cover:

  • the lease per detail at its boundaries;
  • family renewal by a subagent's hook, and no renewal from another session;
  • a silent subagent record expiring, and being renewed by its parent;
  • foreground turns never being leased;
  • session_crons decoding: count, empty, absent, malformed;
  • local_bash and background_shell counting as shell work;
  • Stop with crons, and SubagentStop keeping crons;
  • idle_prompt keeping agent and cron monitoring;
  • a SubagentStop renewing the lease;
  • the menu states, labels and counts;
  • Stop Tracking not being undone by a turn that ends in monitoring.

Docs

  • AGENT-HOOK-CONTRACTS and ARCHITECTURE describe the sub-state, the lease and the cron handling.
  • RELEASE-NOTES: a new "Monitoring background tasks" Added bullet; the earlier background bullets are folded into it.
  • ATTENDED-UAT "Background work" cases 1–6 now cover the labels, the two-hour lapse, agent monitoring, /loop crons, and Stop Watching.

Verification

  • swift test --no-parallel: 854 pass.
  • All CI scripts pass locally.
  • Debug and Release builds succeed.
  • I checked the label fit in the design preview.

🤖 Generated with Claude Code

…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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T03:35:08.469897Z 0da4393 PR opened
🔒 Security Review ✅ Completed 2026-10-23T03:35:43.660313Z 0da4393 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread Sources/LetItBrewCore/Decision.swift
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>
@ruban-24
ruban-24 merged commit 1f92f7f into main Oct 23, 2026
4 of 5 checks passed
@ruban-24
ruban-24 deleted the feature/v1-monitoring-background branch October 23, 2026 06:23
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.

1 participant