-
Notifications
You must be signed in to change notification settings - Fork 805
Revert "feat: add --sessions/--list-sessions CLI options & fix CJK shorten" #1608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,14 +7,14 @@ | |
| import uuid | ||
| from dataclasses import dataclass | ||
| from pathlib import Path | ||
| from textwrap import shorten | ||
|
|
||
|
Comment on lines
9
to
11
|
||
| from kaos.path import KaosPath | ||
| from kosong.message import Message | ||
|
|
||
| from kimi_cli.metadata import WorkDirMeta, load_metadata, save_metadata | ||
| from kimi_cli.session_state import SessionState, load_session_state, save_session_state | ||
| from kimi_cli.utils.logging import logger | ||
| from kimi_cli.utils.string import shorten | ||
| from kimi_cli.wire.file import WireFile | ||
| from kimi_cli.wire.types import TurnBegin | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| from collections.abc import Sequence | ||
| from datetime import datetime | ||
| from pathlib import Path | ||
| from textwrap import shorten | ||
| from typing import TYPE_CHECKING, cast | ||
|
|
||
| import aiofiles | ||
|
|
@@ -13,7 +14,6 @@ | |
| from kimi_cli.soul.message import is_system_reminder_message, system | ||
| from kimi_cli.utils.message import message_stringify | ||
| from kimi_cli.utils.path import sanitize_cli_path | ||
| from kimi_cli.utils.string import shorten | ||
| from kimi_cli.wire.types import ( | ||
| AudioURLPart, | ||
| ContentPart, | ||
|
|
@@ -66,12 +66,12 @@ def _extract_tool_call_hint(args_json: str) -> str: | |
| for key in _HINT_KEYS: | ||
| val = args.get(key) | ||
| if isinstance(val, str) and val.strip(): | ||
| return shorten(val, width=60) | ||
| return shorten(val, width=60, placeholder="…") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This now relies on Useful? React with 👍 / 👎. |
||
|
|
||
| # Fallback: first short string value | ||
| for val in args.values(): | ||
| if isinstance(val, str) and 0 < len(val) <= 80: | ||
| return shorten(val, width=60) | ||
| return shorten(val, width=60, placeholder="…") | ||
|
|
||
| return "" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -951,11 +951,12 @@ async def generate_session_title( | |
| if not user_message: | ||
| return GenerateTitleResponse(title="Untitled") | ||
|
|
||
| from kimi_cli.utils.string import shorten | ||
| # Fallback title from user message (used if AI generation fails) | ||
| from textwrap import shorten | ||
|
|
||
| user_text = user_message.strip() | ||
| user_text = " ".join(user_text.split()) | ||
| fallback_title = shorten(user_text, width=50) or "Untitled" | ||
| fallback_title = shorten(user_text, width=50, placeholder="...") or "Untitled" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎.
Comment on lines
+954
to
+959
|
||
|
|
||
| # If AI generation failed too many times, use fallback and mark as generated | ||
| if metadata.title_generate_attempts >= 3: | ||
|
|
@@ -1017,7 +1018,7 @@ async def generate_session_title( | |
| title = generated_title | ||
| ai_generated = True | ||
| elif generated_title: | ||
| title = shorten(generated_title, width=50) | ||
| title = shorten(generated_title, width=50, placeholder="...") | ||
| ai_generated = True | ||
|
|
||
| except Exception as e: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,11 +129,10 @@ def _derive_title_from_wire(session_dir: Path) -> str: | |
|
|
||
| try: | ||
| import json | ||
| from textwrap import shorten | ||
|
|
||
|
Comment on lines
131
to
133
|
||
| from kosong.message import Message | ||
|
|
||
| from kimi_cli.utils.string import shorten | ||
|
|
||
| with open(wire_file, encoding="utf-8") as f: | ||
| for line in f: | ||
| line = line.strip() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Replacing custom
shortenwithtextwrap.shortenbreaks CJK text truncation in session titlesThe custom
shortenfunction (removed fromsrc/kimi_cli/utils/string.py) was specifically designed to fall back to a hard character cut for CJK text without word boundaries (spaces). Python'stextwrap.shortenonly breaks at whitespace, so when CJK text exceeds the width and contains no ASCII spaces, it returns only the placeholder instead of truncated content.Demonstration of the regression
The old custom function would return the first 49 characters +
"…"placeholder.At
src/kimi_cli/session.py:101-104,shorten(text, width=50)uses the default' [...]'placeholder (6 chars). For a CJK user prompt like"请帮我分析这段代码的安全问题并给出修复方案和最佳实践建议确保上线安全"(>50 chars, no spaces), the session title becomes' [...] (session-id)'— conveying zero information about the session content. The same regression affectssrc/kimi_cli/web/store/sessions.py:149,src/kimi_cli/web/api/sessions.py:959,src/kimi_cli/web/api/sessions.py:1021,src/kimi_cli/utils/export.py:69, andsrc/kimi_cli/utils/export.py:234.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.