fix(tui): keep the current session across logout and provider removal - #3129
fix(tui): keep the current session across logout and provider removal#3129liruifengv wants to merge 3 commits into
Conversation
Logging out of (or removing) the provider used by the current session closed the session and reset the session id, so a subsequent login started a fresh empty session and the previous one appeared lost. Keep the session open: only the model display is cleared, and the next turn fails with model.not_configured until the user logs in again or picks another model. Re-login heals the session via setModel.
🦋 Changeset detectedLatest commit: c74db87 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9ead16ea6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Logging out with the session retained zeroes the footer's context counters, and re-login with the same model alias is a setModel no-op, so nothing restored them: the footer stayed at zero and the cache-expiry hint misjudged the next prompt. Call syncRuntimeState after setModel in the existing-session branch of activateModelAfterLogin so contextTokens/contextUsage recover even on a no-op model change.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11d229657c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A provider logout that retains the session zeroes the footer's context counters, but performModelSwitch only mapped model/thinking from session.getStatus() and the v2 model-change event only republishes the model and its context limit — so healing the session via /model (the recovery hinted by the logout warning) left contextTokens/contextUsage at zero. Republish the counters from the live status on switch.
Related Issue
Internal fix reported from the field (no tracking issue): a user's session appeared to lose its task after logout → re-login; investigation traced it to the logout flow closing the session. See Problem below.
Problem
Logging out of the provider the current session is using (via
/logout, or deleting it in the provider manager) silently closed the session: the session id was reset, the goal box disappeared, and the next login started a brand-new empty session. The previous session stayed intact on disk, but nothing told the user it existed or how to get back (/resume), so in-flight work (goals, context) looked lost.Sessions are not tied to an account elsewhere in the product —
/modelalready switches providers freely mid-session — so closing the session on logout has no consistency justification; it is just historical behavior from the original provider-picker rework.What changed
/logoutof the active provider no longer closes the session; it only clears the model display and shows a warning:Logged out from X. Current model is unavailable — /login or /model to continue./logout(and no longer wipe session state unconditionally when removing the OAuth provider while it is not the active one).clearActiveSessionAfterLogoutcontroller method.LLM not set, send "/login" to login(both engines); an active goal merely pauses (Paused after model configuration error). Re-login heals the session through the existingsession.setModel()path, so logout → login now preserves the conversation end to end.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.