Skip to content

fix(shell): exclude empty current session from session picker#1799

Merged
n-WN merged 2 commits intoMoonshotAI:mainfrom
n-WN:fix/session-picker-empty-check
Apr 8, 2026
Merged

fix(shell): exclude empty current session from session picker#1799
n-WN merged 2 commits intoMoonshotAI:mainfrom
n-WN:fix/session-picker-empty-check

Conversation

@n-WN
Copy link
Copy Markdown
Collaborator

@n-WN n-WN commented Apr 8, 2026

Related Issue

Follow-up to #1797 (merged). Resolves the remaining part of #1794.

Description

Session.list() already filters empty sessions, but SessionPickerApp._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 SessionPickerApp rewrite.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation. (N/A)

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +99 to +100
if not current.is_empty():
sessions.insert(0, current)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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)").
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@n-WN n-WN force-pushed the fix/session-picker-empty-check branch from f169af4 to 70903a4 Compare April 8, 2026 12:28
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).
@n-WN n-WN force-pushed the fix/session-picker-empty-check branch 2 times, most recently from eda7c8d to 9080f2b Compare April 8, 2026 12:31
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review


## 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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`.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@n-WN n-WN force-pushed the fix/session-picker-empty-check branch from 9080f2b to a923159 Compare April 8, 2026 12:34
@n-WN
Copy link
Copy Markdown
Collaborator Author

n-WN commented Apr 8, 2026

Real kimi-cli Verification

Empty current session is excluded from the picker. Sessions with titles or conversation history are displayed normally.

Test: fresh session → /sessions

demo

asciinema replay

Results:

  • Current empty session (no history, no title): not in list
  • Sessions with titles ("hi", "count slowly..."): displayed
  • Sessions with wire history but no custom title ("Untitled" from worktrees): displayed ✅ — is_empty() checks both conditions (no wire history AND no custom title)

@n-WN n-WN merged commit 9f38662 into MoonshotAI:main Apr 8, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant