Repository navigation
Conversation
Motivation: bindSessionProfile stores a cloned routing snapshot per parent session in a process-wide Map. Only an explicit clearSessionProfileBinding (never called in production) removed entries, so a long-lived extension host retained one snapshot per ended session for the life of the process. Approach: the Gentle AI session_shutdown hook now clears the ending session's binding whenever the shutdown reason is not "reload". Reload keeps the same session id, so its binding is preserved; other sessions are untouched. Impact is bounded memory growth in long-lived hosts; no user-visible routing behavior changes for live sessions. Validation: - node --experimental-strip-types --test tests/session-profile-binding.test.ts -> new test fails without the hook change (13 pass / 1 fail) and passes with it (14 pass / 0 fail). - node --experimental-strip-types --test tests/yolo-mode-runtime.test.ts tests/session-profile-*.test.ts -> 103 pass, 0 fail. - pnpm run typecheck -> no regressions. The test exercises reload and quit; new/resume/fork share the quit code path. Report: Gentleman-Programming#1707 Signed-off-by: Pujitha Paladugu <[email protected]> Assisted-by: claude-sonnet-5-5 (via Claude Code)
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shutdown binding cleanup extensions/gentle-ai.ts, tests/session-profile-binding.test.ts |
The shutdown hook clears the ending session’s binding for non-reload shutdowns. The integration test verifies that reload retains the binding, quit clears it, and another session’s binding remains. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
Suggested labels: type:bug
Suggested reviewers: danielgap, barbatdev
Merge Risk: 
Minimal · up to b7f0d
-
No concrete production failure or merge-blocking test gap is established by the reviewed change.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#1707requires ended-session bindings to be released or the store to be bounded.extensions/gentle-ai.tsnow callsclearSessionProfileBindingfor the ending session when the shutdown reason is not"reload". The test verifies reload preservation, quit cleanup, and isolation of another session. This meets the issue requirement.
Full details: Out of Scope Changes check
-
Explanation
The changes add shutdown cleanup and focused tests for the session profile binding store. The import, cleanup condition, and test assertions directly support issue
#1707. No unrelated change appears in the reviewed diff.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
carlosmoradev
left a comment
There was a problem hiding this comment.
LGTM. The fix is minimal and lands in the right place: one release inside the existing reason !== "reload" branch, keyed by the ending session's id, and the test pins that reload keeps the binding while other sessions stay untouched. I also checked the readers (lib/session-profile-freeze.ts:174 and the status paths in extensions/gentle-ai.ts): they all read with the live session's id.
One non-blocking question: if a subagent or background job of the ending session resolves routing after session_shutdown, it now falls back to pinnedEffectiveModelConfig/readModelConfig instead of the bound snapshot. I'd expect that to be benign, but did you consider in-flight work finishing after shutdown? I ran tests/session-profile-*.test.ts locally (99/99) but not typecheck, so I'm relying on your validation there.
|
No, I didn't trace in-flight work specifically. From the code, a late resolver after shutdown would hit the fallback at |
|
Thanks @pujitha24. The defect is real: One change before merge: the integration test deep-imports |
…tead of the SDK loader Drops the deep import of the SDK's internal extensions/loader.js; the test now registers the extension on a stub pi like the other gentle-ai tests and invokes the session_shutdown handler directly. Signed-off-by: Pujitha Paladugu <[email protected]>
Motivation: bindSessionProfile stores a cloned routing snapshot per parent
session in a process-wide Map. Only an explicit clearSessionProfileBinding
(never called in production) removed entries, so a long-lived extension host
retained one snapshot per ended session for the life of the process.
Approach: the Gentle AI session_shutdown hook now clears the ending session's
binding whenever the shutdown reason is not "reload". Reload keeps the same
session id, so its binding is preserved; other sessions are untouched.
Impact is bounded memory growth in long-lived hosts; no user-visible routing
behavior changes for live sessions.
Validation:
-> new test fails without the hook change (13 pass / 1 fail) and passes
with it (14 pass / 0 fail).
The test exercises reload and quit; new/resume/fork share the quit code path.
Report: #1707
Signed-off-by: Pujitha Paladugu [email protected]
Assisted-by: claude-sonnet-5-5 (via Claude Code)
Fixes #1707
Summary by CodeRabbit