Skip to content

feat(repl): show agent name and session ID in spinner, usage line, and initial prompt#164

Merged
dobesv merged 1 commit into
mainfrom
agent-name-status-prompt-tweaks
Apr 5, 2026
Merged

feat(repl): show agent name and session ID in spinner, usage line, and initial prompt#164
dobesv merged 1 commit into
mainfrom
agent-name-status-prompt-tweaks

Conversation

@dobesv

@dobesv dobesv commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Summary

Improves REPL status visibility by showing the agent name and session ID prominently in the spinner, usage line, and at session start — instead of burying them in the input prompt.

Changes

Spinner during generation

Before: ⠋ Generating [📥 39 📤 12248 💾 246516]...
After: ⠋ my-agent ▸ my-session 📥 39 📤 12248 💾 246516

  • Spinner braille animation replaces the 🤖 icon
  • Removed trailing animated dots
  • Removed square brackets around usage stats
  • Extra spacing between agent/session info and stats

Usage line after LLM response

Before: [📥 39 📤 12248 💾 246516]
After: 🤖 my-agent ▸ my-session 📥 39 📤 12248 💾 246516 💬 5432(12%)

  • Shows agent name and session ID with 🤖 prefix
  • Includes context window usage (💬 tokens(percent%)) previously only in right prompt
  • No square brackets, better spacing

Input prompt

Before: agent>session/agent) with right-side token stats
After: > (clean cyan arrow)

Agent/session info moved to status lines above; right prompt emptied to avoid interfering with input.

Multiline indicator

Before: ... on continuation lines
After: (empty) — makes copy/pasting multi-line inputs much easier

Session start

Before: (nothing)
After: 🤖 my-agent ▸ my-session printed before first prompt

Files Changed

  • src/config/mod.rs — Simplified LEFT/RIGHT_PROMPT, added render_status_line(prefix)
  • src/client/common.rs — Updated spinner_label() to use status line
  • src/repl/mod.rs — Updated usage display, added initial status line
  • src/main.rs — Updated usage display for CMD mode
  • src/repl/prompt.rs — Removed multiline ... indicator
  • src/utils/spinner.rs — Removed trailing animated dots

Summary by CodeRabbit

  • UI Improvements
    • Simplified spinner output (removed animated trailing dots and extra padding)
    • Removed multiline prompt indicator
    • Show agent/session status alongside completion usage in prompts and on startup
    • Display completion token usage with optional percentage
    • Consolidated status/usage/context into a single dimmed line for cleaner stderr output

@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@dobesv has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 31 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 31 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 32634fc2-39e1-4bbd-a2b5-74855b985a21

📥 Commits

Reviewing files that changed from the base of the PR and between 85ce312 and 40d937a.

📒 Files selected for processing (6)
  • src/client/common.rs
  • src/config/mod.rs
  • src/main.rs
  • src/repl/mod.rs
  • src/repl/prompt.rs
  • src/utils/spinner.rs
📝 Walkthrough

Walkthrough

Adds a centralized status renderer (Config::render_status_line) and uses it to build composite status/usage/context lines across spinner, REPL startup/ask flows, and main directive output; spinner output formatting is simplified and the multiline prompt indicator was changed to an empty string.

Changes

Cohort / File(s) Summary
Config / Status
src/config/mod.rs
Added pub fn render_status_line(&self, prefix: &str) -> String; simplified compile-time prompt defaults (fixed cyan left prompt, empty right prompt).
Spinner / Client
src/client/common.rs, src/utils/spinner.rs
spinner_label now uses config.render_status_line("") and conditions spinner text on status + completion usage; spinner frame output no longer appends trailing-dot animation or padded dots.
REPL output & startup
src/repl/mod.rs, src/repl/prompt.rs
Prints startup status line when present; ask/command flows build a composite dimmed line from render_status_line("🤖"), display usage, and context token stats; removed multiline indicator content (now ""); adjusted newline behavior.
Main / Directive output
src/main.rs
When no tool results, prints a composed dimmed line assembled from render_status_line("🤖"), display usage, and context token stats; reads config once and drops borrow after printing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant REPL
    participant Config
    participant Session
    participant Spinner
    participant Stderr

    User->>REPL: start
    REPL->>Config: render_status_line("🤖")
    Config-->>REPL: status
    alt status non-empty
        REPL->>Stderr: print dimmed status line
    end

    User->>REPL: submit prompt
    REPL->>Session: completion_usage(), tokens_usage()
    Session-->>REPL: usage + token stats
    REPL->>Config: render_status_line("")
    Config-->>REPL: status
    REPL->>Spinner: spinner_label(status, completion_usage)
    Spinner-->>Stderr: render frame + message
    REPL->>Stderr: print composed dimmed (status + usage + context)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through code with tiny feet,
Status lines now tidy, neat and sweet,
No trailing dots, just clear report,
Agent and session in one short retort,
I nibble bugs and bounce—what a treat! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main changes: showing agent name and session ID in spinner, usage line, and initial prompt, which aligns with the core objectives of improving REPL status visibility.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent-name-status-prompt-tweaks

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/repl/mod.rs (1)

1166-1199: Consider extracting duplicated status/usage line composition.

The logic for building the composite status/usage/context line (lines 1167-1198) is nearly identical to src/main.rs (lines 518-550). This duplication increases maintenance burden and risk of divergence.

Consider adding a helper method to Config, e.g., render_usage_line(&self, usage: &CompletionTokenUsage) -> String, that encapsulates this composition logic.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/repl/mod.rs` around lines 1166 - 1199, The duplicated
status/usage/context composition should be moved into a new Config method
(suggested signature: render_usage_line(&self, usage: &CompletionTokenUsage) ->
String) that mirrors the logic in this diff: read status via
self.render_status_line("🤖"), get session completion_usage() or fall back to
the passed usage, compute context_stats from session.tokens_usage() (formatting
percent > 0.0 vs not), and join non-empty parts with the same spacing; then
replace the block in src/repl/mod.rs with a simple call that does let
config_read = config.read(); let line = config_read.render_usage_line(&usage);
if !line.is_empty() { eprintln!("{}", dimmed_text(&line)); } drop(config_read);
ensuring you reuse existing symbols render_status_line, session,
completion_usage, tokens_usage, and dimmed_text so both src/repl/mod.rs and
src/main.rs call the new Config::render_usage_line to remove duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main.rs`:
- Around line 537-548: The output building logic for the status line omits a
separator before context_stats, causing inconsistent spacing; update the code
that pushes context_stats (the variable context_stats into line_parts) to
include a leading space (e.g., push format!(" {}", context_stats)) or otherwise
ensure a consistent separator when adding to line_parts so that status,
display_usage, and context_stats are joined with proper spacing before calling
dimmed_text(&line_parts.join("")).

In `@src/repl/mod.rs`:
- Around line 1186-1198: The output concatenation omits spacing before
context_stats causing words/emoji to run together; update the pushes that add
context_stats (in the block that builds line_parts using variables status,
display_usage, context_stats) to prepend appropriate spacing (e.g., same spacing
style used for display_usage) so that when line_parts.join("") is passed to
dimmed_text the pieces are separated. Ensure you modify the push for
context_stats (not the join) to use a formatted string with a leading space.

---

Nitpick comments:
In `@src/repl/mod.rs`:
- Around line 1166-1199: The duplicated status/usage/context composition should
be moved into a new Config method (suggested signature: render_usage_line(&self,
usage: &CompletionTokenUsage) -> String) that mirrors the logic in this diff:
read status via self.render_status_line("🤖"), get session completion_usage() or
fall back to the passed usage, compute context_stats from session.tokens_usage()
(formatting percent > 0.0 vs not), and join non-empty parts with the same
spacing; then replace the block in src/repl/mod.rs with a simple call that does
let config_read = config.read(); let line =
config_read.render_usage_line(&usage); if !line.is_empty() { eprintln!("{}",
dimmed_text(&line)); } drop(config_read); ensuring you reuse existing symbols
render_status_line, session, completion_usage, tokens_usage, and dimmed_text so
both src/repl/mod.rs and src/main.rs call the new Config::render_usage_line to
remove duplication.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c7b0675b-690a-4af5-8ad3-bd746a3ee22f

📥 Commits

Reviewing files that changed from the base of the PR and between 3b51f44 and 0ebe887.

📒 Files selected for processing (6)
  • src/client/common.rs
  • src/config/mod.rs
  • src/main.rs
  • src/repl/mod.rs
  • src/repl/prompt.rs
  • src/utils/spinner.rs

Comment thread src/main.rs
Comment thread src/repl/mod.rs
@dobesv dobesv force-pushed the agent-name-status-prompt-tweaks branch 3 times, most recently from f1b6f3d to 85ce312 Compare April 5, 2026 00:30
@dobesv dobesv enabled auto-merge (squash) April 5, 2026 00:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/config/mod.rs`:
- Around line 2091-2106: The status-line code currently always injects a leading
space when prefix is empty and unconditionally calls extract_agent() to compute
agent_name; change the logic so you only call extract_agent() when you actually
need it (i.e., when self.agent is None AND prefix is non-empty) to avoid extra
work on the spinner path, and change the final formatting to avoid a leading
space by conditionally inserting the prefix+space only when prefix is non-empty
(use prefix.is_empty() to choose between "" and format!("{} ", prefix)) while
keeping the existing match arms for agent_name/session_name and the
TEMP_AGENT_NAME check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a1a0610-821f-4bc9-90b0-4cc0330a83ea

📥 Commits

Reviewing files that changed from the base of the PR and between f1b6f3d and 85ce312.

📒 Files selected for processing (6)
  • src/client/common.rs
  • src/config/mod.rs
  • src/main.rs
  • src/repl/mod.rs
  • src/repl/prompt.rs
  • src/utils/spinner.rs
✅ Files skipped from review due to trivial changes (2)
  • src/repl/prompt.rs
  • src/utils/spinner.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/client/common.rs
  • src/main.rs
  • src/repl/mod.rs

Comment thread src/config/mod.rs Outdated
Comment on lines +2091 to +2106
let agent_name = if let Some(agent) = &self.agent {
Some(agent.name().to_string())
} else {
let agent = self.extract_agent();
if agent.name() != TEMP_AGENT_NAME {
Some(agent.name().to_string())
} else {
None
}
};
let session_name = self.session.as_ref().map(|s| s.name().to_string());
match (agent_name, session_name) {
(Some(agent), Some(session)) => format!("{} {} ▸ {}", prefix, agent, session),
(Some(agent), None) => format!("{} {}", prefix, agent),
(None, Some(session)) => format!("{} {}", prefix, session),
(None, None) => String::new(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Handle empty prefix without injecting a leading space (and avoid extract_agent() on spinner path).

Line 2103–Line 2105 always insert a space before content, so render_status_line("") yields a leading whitespace (e.g., " my-agent ▸ my-session"). Also, Line 2094 does extra work by calling extract_agent() when only an agent name is needed.

Proposed patch
 pub fn render_status_line(&self, prefix: &str) -> String {
-    let agent_name = if let Some(agent) = &self.agent {
-        Some(agent.name().to_string())
-    } else {
-        let agent = self.extract_agent();
-        if agent.name() != TEMP_AGENT_NAME {
-            Some(agent.name().to_string())
-        } else {
-            None
-        }
-    };
+    let agent_name = self
+        .agent
+        .as_ref()
+        .map(|agent| agent.name().to_string())
+        .or_else(|| {
+            self.session
+                .as_ref()
+                .and_then(|s| s.agent_name().map(ToString::to_string))
+                .filter(|name| name != TEMP_AGENT_NAME)
+        });
+
     let session_name = self.session.as_ref().map(|s| s.name().to_string());
-    match (agent_name, session_name) {
-        (Some(agent), Some(session)) => format!("{} {} ▸ {}", prefix, agent, session),
-        (Some(agent), None) => format!("{} {}", prefix, agent),
-        (None, Some(session)) => format!("{} {}", prefix, session),
-        (None, None) => String::new(),
-    }
+    let body = match (agent_name, session_name) {
+        (Some(agent), Some(session)) => format!("{agent} ▸ {session}"),
+        (Some(agent), None) => agent,
+        (None, Some(session)) => session,
+        (None, None) => return String::new(),
+    };
+
+    if prefix.is_empty() {
+        body
+    } else {
+        format!("{prefix} {body}")
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/config/mod.rs` around lines 2091 - 2106, The status-line code currently
always injects a leading space when prefix is empty and unconditionally calls
extract_agent() to compute agent_name; change the logic so you only call
extract_agent() when you actually need it (i.e., when self.agent is None AND
prefix is non-empty) to avoid extra work on the spinner path, and change the
final formatting to avoid a leading space by conditionally inserting the
prefix+space only when prefix is non-empty (use prefix.is_empty() to choose
between "" and format!("{} ", prefix)) while keeping the existing match arms for
agent_name/session_name and the TEMP_AGENT_NAME check.

@dobesv dobesv force-pushed the agent-name-status-prompt-tweaks branch from 85ce312 to 165f0a3 Compare April 5, 2026 00:34
…d initial prompt

- Spinner now shows: ⠋ <agent_name> ▸ <session_id>    📥 N  📤 N  💾 N
  The spinner animation replaces the 🤖 icon during generation.
  Removed trailing dots from spinner animation.

- Usage line after LLM response now shows:
  🤖 <agent_name> ▸ <session_id>   📥 N  📤 N  💾 N  💬 tokens(percent%)
  with extra spacing between the agent/session info and the stats.
  Removed square brackets around usage stats.

- Simplified LEFT_PROMPT to just '> ' (removed agent/session name from
  user input prompt since they're now shown in the status/usage lines)

- Emptied RIGHT_PROMPT (moved context window usage to the usage line
  to avoid interfering with user input)

- Removed multiline '...' indicator to make copy/pasting multi-line
  inputs easier

- Added initial session/agent status line (🤖 agent ▸ session) printed
  when REPL starts, before the first prompt
@dobesv dobesv force-pushed the agent-name-status-prompt-tweaks branch from 165f0a3 to 40d937a Compare April 5, 2026 00:35
@dobesv dobesv merged commit 9b66e10 into main Apr 5, 2026
4 checks passed
@dobesv dobesv deleted the agent-name-status-prompt-tweaks branch April 5, 2026 00:40
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.

1 participant