Repository navigation
fix(core): preserve approvals across location cleanup - #46509
kitlangton wants to merge 1 commit into
Conversation
|
Live check on packages/core/src/location-activity.ts (PR head 7b73f20): the sweep used to invalidate every expired location. A permission wait owns the Location without Session activity, so after the TTL the cache detaches while the borrower is still alive. Reopen shows a spinner and zero pending approvals. Fix: skip eviction when rcMap refCount > 0, and run the check + delete under References.PreventSchedulerYield so a new borrower cannot sneak in between. Regression advances 61 virtual minutes and asserts the same Location.Service stays discoverable, then evicts after Scope.close. Drive repro + preload in script/repro/hidden-approval*. MERGEABLE/CLEAN. 0 comments. I would merge. Scope note from the PR body is right: stranded executions on an already-running server are not retroactively reattached. No ask to widen that here. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Why
Returning to a session that has waited for permission for over an hour can show an active spinner with no approval to answer. The automatic location sweep invalidates its cache entry despite the running session still borrowing it. The old permission service remains alive with the waiting tool, while subsequent API reads see a different instance with no pending requests.
What Changes
Automatic cleanup now skips locations with outstanding references. The expired entry remains eligible for cleanup on the next sweep after its final borrower releases it. The reference check and cache removal run without an automatic scheduler yield between them.
Demo
comparison.mp4
Matched OpenCode Drive runs: left is base
b0402f5a34, right is fix7b73f20fcc. Both use the same isolated project, simulated model, realglobtool, permission service, production TUI, and Enter interaction. A timing-only Bun preload shortens the real automatic cleanup timeout from one hour to eight seconds, swept every second. No manual invalidation or staged UI is used. The shorter clip holds its final frame briefly to align the comparison.The runnable fixture and instructions are in
script/repro/hidden-approval.md.Scope
This fixes automatic location eviction while resources are borrowed. It does not change permission policy, restart recovery, or explicit debug invalidation. Existing stranded executions in an already-running server are not retroactively reattached.
Verification