Drop a stale active-instance pin instead of failing forever#1266
Drop a stale active-instance pin instead of failing forever#1266lgarczyn wants to merge 1 commit into
Conversation
A pin outlives the editor it names. While it stayed pinned it also suppressed auto-select. Every later call then failed with no_unity_session. Neither waiting nor relaunching the editor recovered. The editor re-registers under its own name, not the name the pin holds. The pin is now dropped once another instance is registered. An empty registry means a domain reload is in flight, so the pin is kept.
📝 WalkthroughWalkthrough
ChangesStale pin cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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.
🧹 Nitpick comments (1)
Server/src/transport/unity_instance_middleware.py (1)
215-243: 🚀 Performance & Scalability | 🔵 TrivialStale-pin detection adds a
PluginHub.get_sessions()round-trip to every HTTP request with a pinned instance.The logic is correct — empty registry preserves the pin, a registered pin is kept, and a stale pin is dropped and cleared. However,
_drop_stale_pincalls_discover_instances(which callsPluginHub.get_sessions) on every request that has a non-nullactive_instance, even when the pin is valid. This adds a network round-trip to the hot path alongside the existingPluginHub._resolve_session_idcall at line 403.Consider caching the discovery result for a short TTL (similar to the
_tool_visibility_refresh_interval_secondspattern already used in this class) or reusing the session data fetched here to avoid the redundant_resolve_session_idcall when the pin is confirmed valid.
[medium_effort_and_high_reward]🤖 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 `@Server/src/transport/unity_instance_middleware.py` around lines 215 - 243, The _drop_stale_pin path performs an extra PluginHub.get_sessions round-trip on every request with an active pin. Add short-TTL caching for _discover_instances using the class’s existing _tool_visibility_refresh_interval_seconds pattern, or reuse the fetched session data through the subsequent request flow to avoid redundant discovery/resolution when the pin is valid; preserve empty-registry and stale-pin clearing behavior.
🤖 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.
Nitpick comments:
In `@Server/src/transport/unity_instance_middleware.py`:
- Around line 215-243: The _drop_stale_pin path performs an extra
PluginHub.get_sessions round-trip on every request with an active pin. Add
short-TTL caching for _discover_instances using the class’s existing
_tool_visibility_refresh_interval_seconds pattern, or reuse the fetched session
data through the subsequent request flow to avoid redundant discovery/resolution
when the pin is valid; preserve empty-registry and stale-pin clearing behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5adc114b-949f-4895-b72a-f095dd01dd9d
📒 Files selected for processing (2)
Server/src/transport/unity_instance_middleware.pyServer/tests/test_stale_instance_pin.py
A pin outlives the editor it names.
While it stayed pinned it also suppressed auto-select. Every later call then failed with no_unity_session. Neither waiting nor relaunching the editor recovered. The editor re-registers under its own name, not the name the pin holds. The pin is now dropped once another instance is registered. An empty registry means a domain reload is in flight, so the pin is kept.
Description
Type of Change
Changes Made
Compatibility / Package Source
#beta,#main, tag, branch, orfile:):Packages/packages-lock.json(if using a Git package URL):Testing/Screenshots/Recordings
cd Server && uv run pytest tests/ -v)Documentation Updates
tools/UPDATE_DOCS_PROMPT.md(recommended)Related Issues
Additional Notes
Summary by CodeRabbit