Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/kimi_cli/ui/shell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ async def run(self, command: str | None = None) -> bool:
continue

await self.run_soul_command(user_input.content)
console.print()
finally:
ensure_tty_sane()

Expand Down
25 changes: 16 additions & 9 deletions src/kimi_cli/ui/shell/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import asyncio
import base64
import getpass
import json
import mimetypes
import os
Expand Down Expand Up @@ -742,10 +741,10 @@ def _(buffer: Buffer) -> None:
self._status_refresh_task: asyncio.Task[None] | None = None

def _render_message(self) -> FormattedText:
symbol = PROMPT_SYMBOL if self._mode == PromptMode.AGENT else PROMPT_SYMBOL_SHELL
if self._mode == PromptMode.AGENT and self._thinking:
symbol = PROMPT_SYMBOL_THINKING
return FormattedText([("bold", f"{getpass.getuser()}@{KaosPath.cwd().name}{symbol} ")])
if self._mode == PromptMode.SHELL:
return FormattedText([("bold", f"{PROMPT_SYMBOL_SHELL} ")])
symbol = PROMPT_SYMBOL_THINKING if self._thinking else PROMPT_SYMBOL
return FormattedText([("", f"{symbol} ")])

def _apply_mode(self, event: KeyPressEvent | None = None) -> None:
# Apply mode to the active buffer (not the PromptSession itself)
Expand Down Expand Up @@ -883,6 +882,9 @@ def _render_bottom_toolbar(self) -> FormattedText:

fragments: list[tuple[str, str]] = []

fragments.append(("fg:#4d4d4d", "─" * columns))
fragments.append(("", "\n"))

now_text = datetime.now().strftime("%H:%M")
fragments.extend([("", now_text), ("", " " * 2)])
columns -= len(now_text) + 2
Expand Down Expand Up @@ -912,10 +914,15 @@ def _render_bottom_toolbar(self) -> FormattedText:
if current_toast_left.duration <= 0.0:
_toast_queues["left"].popleft()
else:
shortcuts = "ctrl-x: toggle mode"
if columns - len(right_text) > len(shortcuts) + 2:
fragments.extend([("", shortcuts), ("", " " * 2)])
columns -= len(shortcuts) + 2
shortcut_candidates = [
"ctrl-x: toggle mode | ctrl-j / alt-enter: newline",
"ctrl-j / alt-enter: newline",
]
for shortcuts in shortcut_candidates:
if columns - len(right_text) > len(shortcuts) + 2:
fragments.extend([("", shortcuts), ("", " " * 2)])
columns -= len(shortcuts) + 2
break

padding = max(1, columns - len(right_text))
fragments.append(("", " " * padding))
Expand Down
3 changes: 1 addition & 2 deletions src/kimi_cli/ui/shell/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import asyncio
import contextlib
import getpass
from collections import deque
from collections.abc import Sequence
from dataclasses import dataclass
Expand Down Expand Up @@ -63,7 +62,7 @@ async def replay_recent_history(

for turn in turns:
wire = Wire()
console.print(f"{getpass.getuser()}{PROMPT_SYMBOL} {message_stringify(turn.user_message)}")
console.print(f"{PROMPT_SYMBOL} {message_stringify(turn.user_message)}")
ui_task = asyncio.create_task(
visualize(wire.ui_side(merge=False), initial_status=StatusUpdate())
)
Expand Down
10 changes: 1 addition & 9 deletions src/kimi_cli/ui/shell/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
from typing import Any, NamedTuple, cast

import streamingjson # type: ignore[reportMissingTypeStubs]
from kosong.message import Message
from kosong.tooling import ToolError, ToolOk
from rich.console import Group, RenderableType
from rich.live import Live
from rich.markup import escape
from rich.padding import Padding
from rich.panel import Panel
from rich.spinner import Spinner
from rich.style import Style
from rich.text import Text
Expand All @@ -25,7 +23,6 @@
from kimi_cli.utils.aioqueue import QueueShutDown
from kimi_cli.utils.diff import format_unified_diff
from kimi_cli.utils.logging import logger
from kimi_cli.utils.message import message_stringify
from kimi_cli.utils.rich.columns import BulletColumns
from kimi_cli.utils.rich.markdown import Markdown
from kimi_cli.utils.rich.syntax import KimiSyntax
Expand Down Expand Up @@ -765,6 +762,7 @@ def compose(self) -> RenderableType:
blocks.append(self._current_approval_request_panel.render())
if self._current_question_panel:
blocks.append(self._current_question_panel.render())

blocks.append(self._status_block.render())
return Group(*blocks)

Expand All @@ -786,12 +784,6 @@ def dispatch_wire_message(self, msg: WireMessage) -> None:
match msg:
case TurnBegin():
self.flush_content()
console.print(
Panel(
Text(message_stringify(Message(role="user", content=msg.user_input))),
padding=(0, 1),
)
)
case TurnEnd():
pass
case CompactionBegin():
Expand Down
Loading