Repository navigation
fix: allow concurrent workspace exports - #159
Conversation
📝 WalkthroughWalkthroughSessionManager now enforces mutual exclusion between workspace export and active turns via a per-session reference-counted export-in-progress flag. New guards in ChangesExport Concurrency Control
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@coding-agent/src/coding_agent/ui/session_manager.py`:
- Line 508: The _session_workspace_export_counts dict is not cleaned when
sessions are removed, causing memory leaks; update all session-removal paths to
remove the session's entry (use pop(session_id, None) or conditional del) for
_session_workspace_export_counts. Specifically, in _remove_session_async_no_lock
add cleanup alongside the existing _session_turn_locks cleanup (referencing
_session_turn_locks and _remove_session_async_no_lock), and likewise remove the
session key in remove_session and clear_sessions after their existing cleanup
logic (referencing remove_session and clear_sessions) so the export-count entry
is always cleared when a session is deleted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3be62c4b-e069-4209-ab52-fcbaa0670442
📒 Files selected for processing (3)
coding-agent/src/coding_agent/ui/session_manager.pycoding-agent/tests/ui/test_session_manager_public_api.pycoding-agent/tests/ui/test_session_manager_runtime.py
| self._lock = asyncio.Lock() | ||
| self._store_io_guard = asyncio.Lock() | ||
| self._session_turn_locks: dict[str, asyncio.Lock] = {} | ||
| self._session_workspace_export_counts: dict[str, int] = {} |
There was a problem hiding this comment.
Clean up export count dict when sessions are removed.
The _session_workspace_export_counts dictionary is never cleaned up when sessions are removed via _remove_session_async_no_lock (line 994 cleans _session_turn_locks but not this dict), remove_session (line 1344), or clear_sessions (line 1360). This will leak memory if sessions are repeatedly created and destroyed.
🧹 Proposed fix to add cleanup in all session removal paths
Add cleanup in _remove_session_async_no_lock after line 994:
await self._release_owner_lease_for_session(session_id)
self._approval_stores.pop(session_id, None)
self._session_turn_locks.pop(session_id, None)
+ self._session_workspace_export_counts.pop(session_id, None)Add cleanup in remove_session after line 1344:
self._approval_stores.pop(session_id, None)
self._session_turn_locks.pop(session_id, None)
+ self._session_workspace_export_counts.pop(session_id, None)Add cleanup in clear_sessions after line 1360:
self._session_cache.clear()
self._approval_stores.clear()
self._session_turn_locks.clear()
+ self._session_workspace_export_counts.clear()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@coding-agent/src/coding_agent/ui/session_manager.py` at line 508, The
_session_workspace_export_counts dict is not cleaned when sessions are removed,
causing memory leaks; update all session-removal paths to remove the session's
entry (use pop(session_id, None) or conditional del) for
_session_workspace_export_counts. Specifically, in _remove_session_async_no_lock
add cleanup alongside the existing _session_turn_locks cleanup (referencing
_session_turn_locks and _remove_session_async_no_lock), and likewise remove the
session key in remove_session and clear_sessions after their existing cleanup
logic (referencing remove_session and clear_sessions) so the export-count entry
is always cleared when a session is deleted.
Summary
Dogfood context
Concurrent remote result/diff/patch calls exposed a 409
turn already in progresson patch. The patch endpoint was contending with diff/archive through the session turn lock even though both are read-only workspace export operations.Validation
Summary by CodeRabbit
Release Notes