Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/kimi_cli/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ async def refresh(self) -> None:
self.title = f"Untitled ({self.id})"
self.updated_at = self.context_file.stat().st_mtime if self.context_file.exists() else 0.0

if self.state.custom_title:
self.title = f"{self.state.custom_title} ({self.id})"
return

try:
async for record in self.wire_file.iter_records():
wire_msg = record.to_wire_message()
Expand Down
1 change: 1 addition & 0 deletions src/kimi_cli/session_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SessionState(BaseModel):
approval: ApprovalStateData = Field(default_factory=ApprovalStateData)
dynamic_subagents: list[DynamicSubagentSpec] = Field(default_factory=_default_dynamic_subagents)
additional_dirs: list[str] = Field(default_factory=list)
custom_title: str | None = None
plan_mode: bool = False
plan_session_id: str | None = None
plan_slug: str | None = None
Expand Down
18 changes: 18 additions & 0 deletions src/kimi_cli/ui/shell/slash.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,24 @@ async def new(app: Shell, args: str):
raise Reload(session_id=session.id)


@registry.command(name="title")
async def title(app: Shell, args: str):
"""Set or show the session title"""
soul = ensure_kimi_soul(app)
if soul is None:
return
session = soul.runtime.session
if not args.strip():
console.print(f"Session title: {session.title}")
return

new_title = args.strip()
session.state.custom_title = new_title
session.save_state()
Comment on lines +446 to +447
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve titled empty sessions before /new cleanup

Persisting custom_title here does not make the session non-empty, but Session.is_empty() still only checks wire/context history and /new deletes empty current sessions. As a result, if a user sets /title on a fresh session and then runs /new before sending any message, the renamed session gets deleted and the saved title is lost, which undermines the new title persistence behavior.

Useful? React with 👍 / 👎.

session.title = f"{new_title} ({session.id})"
console.print(f"[green]Session title set to: {new_title}[/green]")


@registry.command(name="sessions", aliases=["resume"])
async def list_sessions(app: Shell, args: str):
"""List sessions and resume optionally"""
Expand Down
Loading