feat: add support for lualine & fidget#3
Conversation
📝 WalkthroughWalkthroughThe pull request introduces status tracking functionality to the CodeRabbit module by adding a new Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes 🚥 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. 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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lua/coderabbit/review.lua (1)
133-166:⚠️ Potential issue | 🔴 CriticalDo not clear the active job before the cancelled process has actually exited.
M.stop()setsstate.job_id = nilimmediately, butcli.cancel()is asynchronous. That means a second review can start before the first job'son_exitruns, and when that old callback finally arrives it will wipe the new run's state and may emit the wrong completion/error notifications or callon_review_completefor the cancelled run.Suggested fix
local state = { job_id = nil, findings = {}, cwd = nil, start_time = nil, fidget_handle = nil, last_notify_time = nil, + cancelling = false, } function M.run(opts) opts = opts or {} @@ state.findings = {} state.cwd = vim.fn.getcwd() + state.cancelling = false local cfg = config.get() @@ on_exit = function(code, stderr) + local was_cancelling = state.cancelling state.job_id = nil state.start_time = nil state.last_notify_time = nil + state.cancelling = false + + if was_cancelling then + return + end if code == -1 then fidget_finish("timed out") vim.notify("CodeRabbit: Review timed out", vim.log.levels.ERROR) return @@ function M.stop() if state.job_id then + state.cancelling = true fidget_finish("cancelled") cli.cancel(state.job_id) - state.job_id = nil vim.notify("CodeRabbit: Review cancelled", vim.log.levels.INFO) else vim.notify("CodeRabbit: No review in progress", vim.log.levels.WARN) end endAlso applies to: 171-176
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lua/coderabbit/review.lua` around lines 133 - 166, The current code clears state.job_id, state.start_time and state.last_notify_time immediately in M.stop() while cli.cancel() is async, which lets a new review start and then have the old on_exit wipe the new state; instead, stop clearing state in M.stop() and move/keep the clearing logic inside the on_exit callback (the function named on_exit) so it only clears if the exiting job matches the current state.job_id (e.g., compare a captured job_id or use a passed job identifier to ensure on_exit only resets state when state.job_id == exiting_job_id); apply the same change to the other similar cancellation block that clears state immediately (the block referenced around lines 171-176).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lua/coderabbit/config.lua`:
- Line 6: The default timeout was set to 0 which disables the timeout path in
lua/coderabbit/cli.lua and can hang the `cr` process; change the default
`timeout` value in lua/coderabbit/config.lua from 0 to a finite sensible default
(e.g., 30 seconds) and ensure the CLI logic in lua/coderabbit/cli.lua continues
to read the `timeout` config (not treating 0 as the only timeout case). Update
the `timeout` variable in config.lua and verify any code paths that check
`timeout` (the timeout handling in cli.lua) treat positive values as the timeout
to enforce.
---
Outside diff comments:
In `@lua/coderabbit/review.lua`:
- Around line 133-166: The current code clears state.job_id, state.start_time
and state.last_notify_time immediately in M.stop() while cli.cancel() is async,
which lets a new review start and then have the old on_exit wipe the new state;
instead, stop clearing state in M.stop() and move/keep the clearing logic inside
the on_exit callback (the function named on_exit) so it only clears if the
exiting job matches the current state.job_id (e.g., compare a captured job_id or
use a passed job identifier to ensure on_exit only resets state when
state.job_id == exiting_job_id); apply the same change to the other similar
cancellation block that clears state immediately (the block referenced around
lines 171-176).
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 938a8215-2568-40f3-b2f9-28ed7a92d2f8
📒 Files selected for processing (3)
lua/coderabbit/config.lualua/coderabbit/init.lualua/coderabbit/review.lua
Description
Add support for fidget.nvim display & lualine progress
Screenshots/Images
fidget.nvim


lualine.nvim
Summary by CodeRabbit
Release Notes
New Features
Chores