Skip to content

feat(reborn): REPL UX — thinking spinner + markdown rendering - #6289

Open
loopstring wants to merge 1 commit into
mainfrom
feat/reborn-repl-ux
Open

loopstring wants to merge 1 commit into
mainfrom
feat/reborn-repl-ux

Conversation

@loopstring

@loopstring loopstring commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Standalone on main.

Summary

The CLI REPL blocked silently during a turn and printed raw markdown. Two self-contained UX fixes:

  • Spinner: animated ⠋ thinking… on stderr while the (blocking) turn runs, cleared when the reply lands. No-op for non-interactive/piped runs (stdout stays byte-clean).
  • Markdown rendering: when stdout is a terminal, render the reply's markdown to ANSI (bold, code, lists, headers) via termimad; raw text otherwise so piping is unchanged.

Applies to both run --message and interactive repl.

Not included (follow-up)

Real token streaming — the REPL uses the blocking send_user_message_with_cancellation; streaming needs a CLI-facing subscribe surface on the runtime (the WebUI already streams via SSE).

Verification

fmt + clippy clean; run_with_spinner unit test (value passes through in shown/hidden modes). Spinner/markdown render only on a real TTY (not capturable in CI), but the send→render path executes end-to-end.

Files

  • crates/ironclaw_reborn_cli/Cargo.toml (adds termimad)
  • crates/ironclaw_reborn_cli/src/runtime/mod.rs

@ironloopai

ironloopai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

🔎 IronLoop Review Status

Head: 25a4c2f431d94e0f12c689315084f4303954da6b
Result: One or more review results were superseded by a newer PR head.
Next: Run @ironloopai review on the latest PR head.
Updated: 2026-07-20T00:48:17.157Z

Current reviewers:

Reviewer State Verdict Findings Last update
ironloop/common-reviewer (reviewer) Superseded N/A N/A 2026-07-20T00:48:10.779Z
Reviewer summaries
Reviewer Detail
ironloop/common-reviewer (reviewer) Superseded by a newer PR head. New head: 25a4c2f. Previous verdict: Changes requested.
Recent activity
Time Reviewer State Detail
2026-07-19T20:54:16.923Z ironloop/common-reviewer (reviewer) Queued Accepted review request for head 84ff5cf.
2026-07-19T20:54:16.923Z ironloop/common-reviewer (reviewer) Queued Waiting for this reviewer lane to become available.
2026-07-19T20:54:16.954Z ironloop/common-reviewer (reviewer) Started Reviewer worker started.
2026-07-19T20:54:20.036Z ironloop/common-reviewer (reviewer) Workspace ready Prepared isolated checkout (merge_ref) at f78ced2.
2026-07-19T20:57:46.656Z ironloop/common-reviewer (reviewer) Result captured Changes requested; 1 blocking finding.
2026-07-19T20:57:46.656Z ironloop/common-reviewer (reviewer) Completed Review completed and terminal status was persisted.
2026-07-20T00:48:10.779Z ironloop/common-reviewer (reviewer) Superseded A newer PR head replaced this review (25a4c2f).
Available commands
  • @ironloopai help
  • @ironloopai agents
  • @ironloopai review
  • @ironloopai review --agent <agent>
Run metadata

Admission: webhook accepted the request and IronLoop persisted reviewer state before this projection.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI adds termimad, conditionally displays stderr spinners during message requests, and renders assistant Markdown only for terminal stdout. One-shot and REPL flows use the updated behavior, with tests covering spinner result preservation.

Changes

Terminal-aware CLI output

Layer / File(s) Summary
Terminal-aware message flows
crates/ironclaw_reborn_cli/src/runtime/mod.rs
One-shot and REPL message sending conditionally show spinners and pass stdout terminal status to reply printing.
Spinner and Markdown rendering support
crates/ironclaw_reborn_cli/src/runtime/mod.rs, crates/ironclaw_reborn_cli/Cargo.toml
Adds the conditional spinner helper, optional termimad Markdown rendering, and a unit test for preserving wrapped future results.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Runtime
  participant Spinner
  participant ReplyOutput
  CLI->>Runtime: Send user message
  Runtime->>Spinner: Await request with conditional spinner
  Spinner-->>Runtime: Return assistant reply
  Runtime->>ReplyOutput: Print reply with terminal render flag
Loading

Suggested reviewers: henrypark133

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and verification, but it omits most required template sections like change type, linked issue, impact, rollback, and checklists. Fill in the required template sections: change type, linked issue, validation checklist, security/database/rollback/blast-radius fields, trust-boundary checklist, and review follow-through.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main UX change: spinner plus markdown rendering in the reborn CLI.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/reborn-repl-ux

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added size: M 50-199 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: regular 2-5 merged PRs labels Jul 19, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces an animated spinner on stderr while waiting for assistant replies and adds markdown rendering support using the termimad crate when stdout is a terminal. The feedback suggests ensuring the spinner is only displayed when stderr is a terminal to prevent ANSI escape sequences from corrupting redirected logs, and setting the tokio interval's missed tick behavior to Skip to avoid rapid spinner flickering if the executor thread is delayed.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +375 to +383
let result = run_with_spinner(
stdin_is_tty,
runtime.send_user_message_with_cancellation(
conversation,
&text,
cancellation.clone(),
)
.await
{
Ok(reply) if reply.is_successful_final_reply() => print_reply(&reply),
Ok(reply) if stdin_is_tty => print_reply(&reply),
),
)
.await;

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.

medium

If stdin is a TTY but stderr is redirected to a file (e.g., ironclaw-reborn repl 2> stderr.log), passing stdin_is_tty directly to run_with_spinner will cause it to write ANSI escape sequences into the redirected stderr stream. To prevent log corruption, only show the spinner if both stdin and stderr are terminals.

Suggested change
let result = run_with_spinner(
stdin_is_tty,
runtime.send_user_message_with_cancellation(
conversation,
&text,
cancellation.clone(),
)
.await
{
Ok(reply) if reply.is_successful_final_reply() => print_reply(&reply),
Ok(reply) if stdin_is_tty => print_reply(&reply),
),
)
.await;
let result = run_with_spinner(
stdin_is_tty && std::io::stderr().is_terminal(),
runtime.send_user_message_with_cancellation(
conversation,
&text,
cancellation.clone(),
),
)
.await;

}
const FRAMES: [&str; 10] = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
tokio::pin!(fut);
let mut ticker = tokio::time::interval(Duration::from_millis(90));

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.

medium

By default, tokio::time::interval uses MissedTickBehavior::Burst. If the executor thread is blocked or delayed, the ticker will accumulate missed ticks and burst them rapidly once it yields, causing the spinner to flicker or spin extremely fast. Setting the missed tick behavior to Skip ensures a smooth and consistent animation.

Suggested change
let mut ticker = tokio::time::interval(Duration::from_millis(90));
let mut ticker = tokio::time::interval(Duration::from_millis(90));
ticker.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);

@ironloopai ironloopai 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.

❌ IronLoop Review: reviewer

Review at a glance

Verdict Blocking Notes Inline Head
❌ Changes requested 1 0 1 84ff5cf35777

Head: 84ff5cf3577757d4c5c3e8a51dee2dc72b908933
Next: Fix the blocking findings, push the PR branch, then re-run this reviewer.

Run details

Status: Current
Needs human: no
Needs validation: no

Summary

The terminal UX branches lack caller-level regression coverage required for this production-wired CLI behavior change.

Findings

Blocking: 1 / Notes: 0

Blocking findings

1. ❌ [MEDIUM] Exercise terminal rendering through the CLI

Location: crates/ironclaw_reborn_cli/src/runtime/mod.rs:329
The added test only proves that run_with_spinner returns its future's value; it never exercises either TTY branch or captures output. There is consequently no regression coverage that run --message/the REPL emits and clears the spinner only in the intended modes, renders markdown on a terminal, and preserves raw output when piped. Add a PTY/subprocess test or an injectable terminal/output seam that drives the command paths and asserts both terminal and piped behavior.

Developer follow-up

After fixing this feedback:

  1. Push the fix to this PR branch.
  2. Re-run this reviewer with @ironloopai review --agent reviewer if you only changed this reviewer's findings.
  3. Re-run all reviewers with @ironloopai review when the fix may affect multiple areas.

let reply = runtime
.send_user_message_with_cancellation(conversation, text, cancellation)
.await?;
let reply = run_with_spinner(

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.

The only new test checks generic future passthrough, not this production CLI path. Please add caller-level terminal/piped output coverage (via PTY/subprocess or an injectable terminal/output seam) for the spinner and markdown branches.

The CLI REPL blocked silently while a turn ran and printed the raw
markdown of the reply. Two self-contained UX fixes:

- Spinner: show an animated `⠋ thinking…` on stderr while the (blocking)
  turn runs, cleared when the reply lands. No-op for non-interactive/piped
  runs so stdout stays byte-clean.
- Markdown: when stdout is a terminal, render the assistant reply's
  markdown to ANSI (bold, code, lists, headers) via termimad; otherwise
  emit raw text so piping is unchanged.

Applies to both the one-shot `run --message` and interactive `repl` paths.

Not included (follow-up): real token streaming — the REPL uses the
blocking `send_user_message_with_cancellation`; streaming needs a
CLI-facing subscribe surface on the runtime (the WebUI already streams
via SSE).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/ironclaw_reborn_cli/src/runtime/mod.rs`:
- Around line 372-386: Update the REPL loop’s run_with_spinner invocation to
enable the spinner only when both stdin_is_tty and stderr is a terminal,
matching the send_once behavior. Preserve the existing cancellation, reply
handling, and render_markdown logic.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cfe6b30f-0299-4dfd-ab8b-a3c7f658153e

📥 Commits

Reviewing files that changed from the base of the PR and between 084ae45 and 25a4c2f.

📒 Files selected for processing (2)
  • crates/ironclaw_reborn_cli/Cargo.toml
  • crates/ironclaw_reborn_cli/src/runtime/mod.rs

Comment on lines +372 to +386
let render_markdown = std::io::stdout().is_terminal();
let result = run_with_spinner(
stdin_is_tty,
runtime.send_user_message_with_cancellation(
conversation,
&text,
cancellation.clone(),
)
.await
{
Ok(reply) if reply.is_successful_final_reply() => print_reply(&reply),
Ok(reply) if stdin_is_tty => print_reply(&reply),
),
)
.await;
match result {
Ok(reply) if reply.is_successful_final_reply() => {
print_reply(&reply, render_markdown)
}
Ok(reply) if stdin_is_tty => print_reply(&reply, render_markdown),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Disable spinner when stderr is redirected.

In the REPL loop, the spinner is enabled based solely on stdin_is_tty. If the user redirects stderr (e.g., ironclaw repl 2> log.txt), the spinner's ANSI clear codes (\r\x1b[K) and frames will corrupt the redirected log file. Ensure the spinner is only shown when stderr is also a terminal, matching the safe behavior implemented in send_once.

🐛 Proposed fix to protect redirected stderr
                         let render_markdown = std::io::stdout().is_terminal();
                         let result = run_with_spinner(
-                            stdin_is_tty,
+                            stdin_is_tty && std::io::stderr().is_terminal(),
                             runtime.send_user_message_with_cancellation(
                                 conversation,
                                 &text,
                                 cancellation.clone(),
                             ),
                         )
                         .await;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let render_markdown = std::io::stdout().is_terminal();
let result = run_with_spinner(
stdin_is_tty,
runtime.send_user_message_with_cancellation(
conversation,
&text,
cancellation.clone(),
)
.await
{
Ok(reply) if reply.is_successful_final_reply() => print_reply(&reply),
Ok(reply) if stdin_is_tty => print_reply(&reply),
),
)
.await;
match result {
Ok(reply) if reply.is_successful_final_reply() => {
print_reply(&reply, render_markdown)
}
Ok(reply) if stdin_is_tty => print_reply(&reply, render_markdown),
let render_markdown = std::io::stdout().is_terminal();
let result = run_with_spinner(
stdin_is_tty && std::io::stderr().is_terminal(),
runtime.send_user_message_with_cancellation(
conversation,
&text,
cancellation.clone(),
),
)
.await;
match result {
Ok(reply) if reply.is_successful_final_reply() => {
print_reply(&reply, render_markdown)
}
Ok(reply) if stdin_is_tty => print_reply(&reply, render_markdown),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/ironclaw_reborn_cli/src/runtime/mod.rs` around lines 372 - 386, Update
the REPL loop’s run_with_spinner invocation to enable the spinner only when both
stdin_is_tty and stderr is a terminal, matching the send_once behavior. Preserve
the existing cancellation, reply handling, and render_markdown logic.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: regular 2-5 merged PRs risk: low Changes to docs, tests, or low-risk modules size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants