feat(repl): show agent name and session ID in spinner, usage line, and initial prompt#164
Conversation
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds a centralized status renderer ( Changes
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
src/client/common.rssrc/config/mod.rssrc/main.rssrc/repl/mod.rssrc/repl/prompt.rssrc/utils/spinner.rs
f1b6f3d to
85ce312
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
src/client/common.rssrc/config/mod.rssrc/main.rssrc/repl/mod.rssrc/repl/prompt.rssrc/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
| 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(), |
There was a problem hiding this comment.
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.
85ce312 to
165f0a3
Compare
…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
165f0a3 to
40d937a
Compare
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 💾 246516Usage line after LLM response
Before:
[📥 39 📤 12248 💾 246516]After:
🤖 my-agent ▸ my-session 📥 39 📤 12248 💾 246516 💬 5432(12%)Input prompt
Before:
agent>session/agent)with right-side token statsAfter:
>(clean cyan arrow)Agent/session info moved to status lines above; right prompt emptied to avoid interfering with input.
Multiline indicator
Before:
...on continuation linesAfter: (empty) — makes copy/pasting multi-line inputs much easier
Session start
Before: (nothing)
After:
🤖 my-agent ▸ my-sessionprinted before first promptFiles Changed
src/config/mod.rs— Simplified LEFT/RIGHT_PROMPT, addedrender_status_line(prefix)src/client/common.rs— Updatedspinner_label()to use status linesrc/repl/mod.rs— Updated usage display, added initial status linesrc/main.rs— Updated usage display for CMD modesrc/repl/prompt.rs— Removed multiline...indicatorsrc/utils/spinner.rs— Removed trailing animated dotsSummary by CodeRabbit