fix(shell): exclude empty current session from session picker#1799
fix(shell): exclude empty current session from session picker#1799n-WN merged 2 commits intoMoonshotAI:mainfrom
Conversation
| if not current.is_empty(): | ||
| sessions.insert(0, current) |
There was a problem hiding this comment.
🟡 Header displays "SESSIONS (1 of 0)" when current session is empty and no other sessions exist
When current.is_empty() is true (line 99) and no other sessions are returned by Session.list/Session.list_all (which already filter out empty sessions at src/kimi_cli/session.py:267), self._sessions becomes an empty list. _build_values (line 103-105) correctly falls back to the _EMPTY_SESSION_ID placeholder, and _sync_radio_list sets _selected_index = 0. However, _header_fragments (line 141) computes total = len(self._sessions) which is 0, while selected = _selected_index + 1 which is 1. The header then renders as SESSIONS (1 of 0). Before this PR, self._sessions always contained at least the current session, so this path was unreachable.
Prompt for agents
The _header_fragments method at line 139-146 computes `total = len(self._sessions)`, but when self._sessions is empty the radio list still has one placeholder entry (the _EMPTY_SESSION_ID sentinel). This mismatch causes "SESSIONS (1 of 0)" to display. The fix should make the header aware of the empty state — either by using len(self._radio_list.values) instead of len(self._sessions) for the total count (and filtering out the sentinel), or by showing a different header string when self._sessions is empty (e.g. hiding the counter entirely or showing "SESSIONS (0)").
Was this helpful? React with 👍 or 👎 to provide feedback.
f169af4 to
70903a4
Compare
Session.list() already filters empty sessions, but the current session was unconditionally inserted at index 0, bypassing this check. Now only insert the current session if it has content (wire history or custom title).
eda7c8d to
9080f2b
Compare
docs/en/release-notes/changelog.md
Outdated
|
|
||
| ## Unreleased | ||
|
|
||
| - Shell: Exclude empty current session from `/sessions` picker — sessions with no conversation history or custom title are no longer shown in the session list |
There was a problem hiding this comment.
🟡 English changelog manually edited instead of being auto-generated via sync script
docs/AGENTS.md states: "The English changelog (docs/en/release-notes/changelog.md) is auto-generated from the root CHANGELOG.md. Do not edit it manually." This PR directly adds a line to docs/en/release-notes/changelog.md (line 7) instead of only editing the root CHANGELOG.md and running npm run sync to propagate the change. While the content happens to be identical, this violates the documented authoring workflow and sets a precedent for manual drift.
Prompt for agents
Remove the manual edit to `docs/en/release-notes/changelog.md` and instead run `npm run sync` (from the `docs/` directory) after editing the root `CHANGELOG.md`. The sync script at `docs/scripts/sync-changelog.mjs` will auto-generate the English changelog from the root file. This keeps the workflow consistent with the rule in `docs/AGENTS.md`.
Was this helpful? React with 👍 or 👎 to provide feedback.
9080f2b to
a923159
Compare
Real kimi-cli VerificationEmpty current session is excluded from the picker. Sessions with titles or conversation history are displayed normally. Test: fresh session → /sessionsResults:
|

Related Issue
Follow-up to #1797 (merged). Resolves the remaining part of #1794.
Description
Session.list()already filters empty sessions, butSessionPickerApp._load_sessions()unconditionally inserts the current session at index 0, bypassing this check. An empty current session (no wire history, no custom title) now won't appear in the picker.This was originally part of #1792, which is now superseded by #1797's
SessionPickerApprewrite.Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation. (N/A)