Repository navigation
Run account switching asynchronously - #18
Conversation
📝 WalkthroughWalkthroughThe account switch flow now clones the selected account, gates Git configuration on token availability, and performs credential and configuration updates inside a background loader. A new terminal helper animates progress while blocking work runs on a separate thread. ChangesAccount switch flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant handle_switch
participant apply_switch
participant raw_with_loader
participant GitCredentials
participant GitConfig
handle_switch->>apply_switch: pass cloned account
apply_switch->>raw_with_loader: run authentication and configuration closure
raw_with_loader->>GitCredentials: approve credentials when token exists
raw_with_loader->>GitConfig: update account and credential settings
raw_with_loader-->>apply_switch: return closure result
apply_switch-->>handle_switch: render success or aborted status
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@src/commands/list.rs`:
- Around line 492-495: Update the token-handling branch around
git_credential_reject and git_credential_approve to preserve the existing
credential until the replacement succeeds. Use an overwrite-safe approval flow,
or only reject the old credential after successful approval; if rejection must
happen first, restore it on approval failure before propagating the error.
In `@src/tui.rs`:
- Around line 87-101: Update the worker join handling in the TUI loop so panics
from the background operation do not unwind past run_loop and bypass
exit_cleanup. Replace both join().expect calls with thread::Result propagation
or equivalent panic capture, render an error for a failed worker, and ensure the
function returns through normal cleanup that restores terminal state.
🪄 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: 39287907-5a1b-4612-b0af-08949fd5d69e
📒 Files selected for processing (2)
src/commands/list.rssrc/tui.rs
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/tui.rs (1)
80-97: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winFix terminal layout corruption from frame wrapping.
When
framewraps back to0(after 10 iterations),frame > 0evaluates tofalse. This passes0asprev_counttoraw_render_lines, skipping the cursor movement and printing the loader on a new line. Over longer background operations, this permanently leaves duplicated lines on the screen and corrupts the TUI layout.Use a dedicated boolean flag to track whether it's the first render instead of relying on the frame index.
🐛 Proposed fix
- let mut frame = 0; + let mut frame = 0; + let mut rendered = false; let started_at = Instant::now(); while !handle.is_finished() && started_at.elapsed() < SHOW_DELAY { thread::sleep(Duration::from_millis(10)); } if handle.is_finished() { return handle.join(); } let shown_at = Instant::now(); while !handle.is_finished() || shown_at.elapsed() < MIN_VISIBLE_DURATION { let line = format!(" {} {}", FRAMES[frame].cyan(), message); - raw_render_lines(&mut stdout, &[line], usize::from(frame > 0)); + raw_render_lines(&mut stdout, &[line], usize::from(rendered)); + rendered = true; frame = (frame + 1) % FRAMES.len(); thread::sleep(FRAME_INTERVAL); }🤖 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 `@src/tui.rs` around lines 80 - 97, Update the loader rendering loop around raw_render_lines to track first-render state with a dedicated boolean flag rather than deriving prev_count from frame > 0. Initialize the flag before the loop, pass the appropriate previous-line count on every render including after FRAMES wraps, then clear the flag after the first render while preserving frame advancement.
🤖 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.
Outside diff comments:
In `@src/tui.rs`:
- Around line 80-97: Update the loader rendering loop around raw_render_lines to
track first-render state with a dedicated boolean flag rather than deriving
prev_count from frame > 0. Initialize the flag before the loop, pass the
appropriate previous-line count on every render including after FRAMES wraps,
then clear the flag after the first render while preserving frame advancement.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aabfd096-981f-4306-b9cb-0265091b275b
📒 Files selected for processing (3)
src/commands/list.rssrc/tui.rssrc/utils.rs
💤 Files with no reviewable changes (1)
- src/utils.rs
Summary by CodeRabbit