feat: re-echo condensed user prompt in chat log
Shows user input as a compact one-liner ("You: prompt text") instead of
a full panel. Multi-line input is collapsed to the first line with a
"(+N lines)" suffix, and long lines are truncated at 120 chars.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,10 @@ class SneakyCodeApp(App):
|
|||||||
event.input.record(user_input)
|
event.input.record(user_input)
|
||||||
log = self.query_one("#chat-log", RichLog)
|
log = self.query_one("#chat-log", RichLog)
|
||||||
|
|
||||||
|
# Echo user prompt (condensed for multi-line)
|
||||||
|
from app.utils.display import render_user_message
|
||||||
|
log.write(render_user_message(user_input))
|
||||||
|
|
||||||
# Handle slash commands
|
# Handle slash commands
|
||||||
if user_input.startswith("/"):
|
if user_input.startswith("/"):
|
||||||
await self._handle_slash_command(user_input, log)
|
await self._handle_slash_command(user_input, log)
|
||||||
|
|||||||
@@ -44,9 +44,22 @@ if TYPE_CHECKING:
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def render_user_message(content: str) -> Panel:
|
def render_user_message(content: str) -> Text:
|
||||||
"""Render a user message as a styled panel."""
|
"""Render a condensed user prompt as a single styled line.
|
||||||
return Panel(content, title="You", border_style="cyan", expand=False)
|
|
||||||
|
Multi-line input is collapsed to the first line with a line count suffix.
|
||||||
|
Long single lines are truncated.
|
||||||
|
"""
|
||||||
|
lines = content.splitlines()
|
||||||
|
first = lines[0] if lines else content
|
||||||
|
max_len = 120
|
||||||
|
if len(first) > max_len:
|
||||||
|
first = first[:max_len] + "…"
|
||||||
|
suffix = f" (+{len(lines) - 1} lines)" if len(lines) > 1 else ""
|
||||||
|
text = Text()
|
||||||
|
text.append("You: ", style="bold cyan")
|
||||||
|
text.append(first + suffix, style="cyan")
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def render_assistant_message(content: str) -> Panel:
|
def render_assistant_message(content: str) -> Panel:
|
||||||
@@ -223,8 +236,8 @@ def print_success(message: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def print_user_message(content: str) -> None:
|
def print_user_message(content: str) -> None:
|
||||||
"""Print a user message in a styled panel."""
|
"""Print a condensed user prompt line."""
|
||||||
console.print(Panel(content, title="You", border_style="cyan", expand=False))
|
console.print(render_user_message(content))
|
||||||
|
|
||||||
|
|
||||||
def print_assistant_message(content: str) -> None:
|
def print_assistant_message(content: str) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user