Repository navigation
Conversation
Every TUI tab attaches its runtime and session to the session manager (AttachRuntime), but closing a tab only cancelled the supervisor context: the manager cleans up on session deletion, so in --listen mode each closed tab leaked its runtime, session, attach context, follow-up injector and recall handler for the process lifetime. Add SessionManager.DetachRuntime, symmetric with AttachRuntime: remove the entry, cancel the attach context, clear the recall handler and drop the injector and event log, leaving the persisted session alone and attachable again. The TUI spawner's cleanup, run by Supervisor.CloseSession, calls it. Signed-off-by: PerryLink <novelnexusai@outlook.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
--listenmode every TUI tab attaches its runtime to the serving session manager (AttachRuntime), but closing a tab only cancels the supervisor's session context: the session manager drops entries only on session deletion (DeleteSession→finishSessionDeletion), so per closed tab the runtime, the session, the attach context (context.WithCancel(context.WithoutCancel(ctx))), the follow-up injector closure and the recall handler all stay reachable for the process lifetime (#4909).Fix
SessionManager.DetachRuntime(sessionID), symmetric withAttachRuntime: removes the runtime entry, cancels the attach context, clears the runtime's recall handler and drops the follow-up injector, key cache and the session's event log. The persisted session is untouched, and — unlikeDeleteSession— the event log is not marked permanently deleted, so the session can be attached again (a reopened tab).Supervisor.CloseSessionalready runs off the lock, now calls it, so closing a tab releases its runtime.recallCoordinatorOptreturns the detach function alongside the app option.Tests
pkg/server/session_detach_test.go:TestDetachRuntime_CleansUpAttachedState— after attach + injector + event source: the runtime entry is gone, the attach context is cancelled, the recall handler is cleared, the injector and event log are dropped; the stored session survives, and re-attaching works (the event log is not blacklisted the way deletion blacklists it).TestDetachRuntime_UnknownSessionIsNoop.go test ./pkg/server/ ./pkg/tui/service/supervisor/ ./cmd/root/passes, andgo vet ./pkg/server/ ./cmd/root/is clean.Closes #4909