Skip to content

feat(shell): add /new slash command to start and switch to a fresh session#1268

Merged
RealKai42 merged 3 commits intomainfrom
kaiyi/research-clear-new-cmd
Feb 27, 2026
Merged

feat(shell): add /new slash command to start and switch to a fresh session#1268
RealKai42 merged 3 commits intomainfrom
kaiyi/research-clear-new-cmd

Conversation

@RealKai42
Copy link
Copy Markdown
Collaborator

@RealKai42 RealKai42 commented Feb 27, 2026

Summary

  • add a new shell-level slash command: /new
  • create a fresh session from the current work directory and switch to it via Reload(session_id=…)
  • print a confirmation message when switching
  • keep /new scoped to shell commands only (not shell-mode registry or soul-level registry)

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.

Open with Devin

Copilot AI review requested due to automatic review settings February 27, 2026 06:40
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: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a shell-level /new slash command to create a fresh session rooted at the current work directory, switch to it via Reload(session_id=...), and clean up the current session directory when it’s empty (to avoid orphaned empty sessions).

Changes:

  • Add /new command in the shell slash-command registry to create a new session and trigger a reload into it (with an on-screen confirmation).
  • Implement empty-current-session cleanup when chaining /new.
  • Add UI/conv tests covering /new registration scope, reload behavior, persistence, and cleanup semantics.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/kimi_cli/ui/shell/slash.py Registers /new (shell registry only), creates a new Session, optionally deletes the current empty session, prints confirmation, and raises Reload(session_id=...).
tests/ui_and_conv/test_shell_slash_commands.py Adds coverage for /new registry placement, reload/session creation, disk persistence, and empty-session cleanup behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

assert len(set(ids)) == 3

async def test_returns_early_without_kimi_soul(self) -> None:
"""When soul is not a KimiSoul, the command should silently return."""
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The test docstring/comment says the command should “silently return” when app.soul isn’t a KimiSoul, but _ensure_kimi_soul() currently prints [red]KimiSoul required[/red] before returning None. Update the wording (or assert on output if “silent” is the intended behavior).

Suggested change
"""When soul is not a KimiSoul, the command should silently return."""
"""When soul is not a KimiSoul, the command should return early without raising Reload."""

Copilot uses AI. Check for mistakes.
@RealKai42 RealKai42 merged commit 6c093c9 into main Feb 27, 2026
18 checks passed
@RealKai42 RealKai42 deleted the kaiyi/research-clear-new-cmd branch February 27, 2026 07:00
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.

2 participants