Skip to content

fix(core): preserve progressing sessions during location cleanup - #51583

Open
khoaHyh wants to merge 4 commits into
anomalyco:v2from
khoaHyh:session-progress-eviction
Open

khoaHyh wants to merge 4 commits into
anomalyco:v2from
khoaHyh:session-progress-eviction

Conversation

@khoaHyh

@khoaHyh khoaHyh commented Sep 27, 2026 •

Copy link
Copy Markdown

Issue for this PR

Fixes #51343 (progressing Sessions and owned shell/subagent work). Related: #48691, #44471.

Type of change

  • Bug fix

What does this PR do?

Release inactive Sessions without interrupting other progressing Sessions or killing their foreground/background work.

Special things to note

  • The timeout remains one hour; unrelated Sessions and viewing do not extend an unanswered question or permission.
  • Shell/subagent ownership uses existing process-local lifetimes, not durable running markers; children retain their own stall timeout.
  • No timeout configuration, PTY lifetime, or reconnect-modal changes are included.

Change outline

 inactivity sweep
- directory deadline expires → interrupt every session there
+ Session progress or human input → renew only its Session deadline
+ live shell → retain its Session and original Location through cleanup
+ live foreground/background subagent → retain its parent
+ last owned work cleans up → start a fresh one-hour idle window
+ expired Session → interrupt only its execution and cancel its requests
+ idle Location → evict only when no execution/process still needs it

How did you verify your code works?

  • Ran the nine related core test files: 162 passed, 19 skipped; six shell-syntax failures also reproduce on the unchanged synced baseline with macOS /bin/bash 3.2.
  • Replaced the inactivity cases and extended an existing Session-shell test. Real execution/forms/SQLite and a file-gated process cover isolation, owned work, child stalls, and fresh idle windows; the shell/child regressions fail with ownership hooks removed. Timing uses virtual advances, not an hour-long soak. Browser verification is in-process RPC, not a physical browser or live provider.
  • Root bun run check passed: 36/36 typecheck tasks, lint warnings but no errors. git diff --check passed.

Screenshots / recordings

Earlier isolated TUI demonstration: simulated streams drive 3 same-directory Sessions; C's unanswered question expires while A and B continue. The inactivity timeout was temporarily 5 seconds with a 250 ms sweep; neither the override nor simulation harness is included in this PR.

session-inactivity-clean.mp4

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@khoaHyh
khoaHyh force-pushed the session-progress-eviction branch from 6b274e8 to 8e2ac2f Compare September 27, 2026 04:44
@khoaHyh
khoaHyh marked this pull request as ready for review September 27, 2026 04:47
@khoaHyh
khoaHyh force-pushed the session-progress-eviction branch from 8e2ac2f to 0fa120d Compare September 27, 2026 05:53
@thiago-carneiro

thiago-carneiro commented Oct 1, 2026 •

Copy link
Copy Markdown

One policy note: the 1h bound on unanswered questions preserves the exact failure #51343 reports. I measured a pending question waiting 5462.9s (~91 min) before the idle eviction killed it — a human answering at 1h15 would still lose the run.

#50499's approach (renew the deadline while a form/permission is pending, explicit Stop still interrupts) also covers the fairness case you're solving — it protects co-owners of a directory where another session waits (there's a test for exactly that). Any appetite for dropping the bound for human waits and keeping your per-session progress signal for everything else?

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants