Skip to content

Commit 65cc681

Browse files
CopilotbadMade
andauthored
fix: keep cursor visible outside spinner redraw
Agent-Logs-Url: https://github.com/badMade/claw-code/sessions/471eb066-c5f1-4c5a-b0a2-716d65c2ac75 Co-authored-by: badMade <106821302+badMade@users.noreply.github.com>
1 parent ceaf93e commit 65cc681

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

.Jules/palette.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## 2026-03-31 - [Hide Cursor During Spinner]
22
**Learning:** In a CLI UI, terminal cursors can blink or block text during loading animations (like a spinner). Hiding the cursor makes the spinner look much cleaner.
3-
**Action:** When creating animations in terminal (e.g. `crossterm`), use `crossterm::cursor::Hide` when active and `crossterm::cursor::Show` when finished. Most importantly, use `Drop` traits in Rust to restore terminal state (`Show`) to avoid permanent terminal corruption on panic/early exit.
3+
**Action:** When creating terminal animations (e.g. `crossterm` spinner redraws), scope cursor hiding to each redraw (`Hide` + draw + `Show`) so interactive prompts never run with a hidden cursor.

rust/crates/rusty-claude-cli/src/render.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::fmt::Write as FmtWrite;
2-
use std::io::{self, IsTerminal, Write};
2+
use std::io::{self, Write};
33

44
use crossterm::cursor::{Hide, MoveToColumn, RestorePosition, SavePosition, Show};
55
use crossterm::style::{Color, Print, ResetColor, SetForegroundColor, Stylize};
@@ -74,7 +74,8 @@ impl Spinner {
7474
SetForegroundColor(theme.spinner_active),
7575
Print(format!("{frame} {label}")),
7676
ResetColor,
77-
RestorePosition
77+
RestorePosition,
78+
Show
7879
)?;
7980
out.flush()
8081
}
@@ -118,14 +119,6 @@ impl Spinner {
118119
}
119120
}
120121

121-
impl Drop for Spinner {
122-
fn drop(&mut self) {
123-
if io::stdout().is_terminal() {
124-
let _ = execute!(io::stdout(), Show);
125-
}
126-
}
127-
}
128-
129122
#[derive(Debug, Clone, PartialEq, Eq)]
130123
enum ListKind {
131124
Unordered,

0 commit comments

Comments
 (0)