Add a patch for throttling/pacing of statusline updates#453
Conversation
📝 WalkthroughWalkthroughAdds configurable throttling for statusline updates: new settings and types, UI controls, a patch that rewrites statusline update logic into a proper throttle or fixed-interval implementation, documentation updates, and wiring the new patch into the patch registry and application flow. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as User
participant UI as Settings UI (rgba(66, 135, 245, 0.5))
participant PatchSys as Patch System (rgba(90, 200, 90, 0.5))
participant FS as File System (rgba(200, 200, 200, 0.5))
participant App as Statusline Code (App) (rgba(245, 166, 35, 0.5))
participant Timer as Timer/Interval (rgba(255, 99, 132, 0.5))
User ->> UI: Set throttle ms / fixed-interval
UI ->> PatchSys: Provide config (misc.statuslineThrottleMs/useFixedInterval)
PatchSys ->> PatchSys: Generate rewrite (throttle or interval)
PatchSys ->> FS: Write patched file(s)
User ->> App: Trigger generation
App ->> Timer: Start throttle/interval controller
Timer ->> App: Periodic/allowed updates
App ->> User: Update statusline at controlled pace
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
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)
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
🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 377-408: Correct the "Configation via UI:" typo to "Configuration
via UI:" and add meaningful alt text for the three image tags shown
(assets/statusline_update_interval_150ms.gif,
assets/statusline_update_throttle_1s.gif, and assets/statusline_ui_config.png)
to satisfy MD045; update the caption lines where the images appear so each image
tag includes an alt string describing the screenshot/demo (e.g., "150ms interval
demo", "1000ms throttle demo", "Statusline UI configuration").
In `@src/patches/index.ts`:
- Around line 584-592: The current call to writeStatuslineUpdateThrottle can
receive 0 or negative from config.settings.misc?.statuslineThrottleMs which may
cause a hot loop; clamp this value to a safe minimum before passing it (e.g.,
const MIN_STATUSLINE_THROTTLE_MS = 50 and use
Math.max(config.settings.misc?.statuslineThrottleMs ?? 300,
MIN_STATUSLINE_THROTTLE_MS)), and pass the clamped value to
writeStatuslineUpdateThrottle while still forwarding
config.settings.misc?.statuslineUseFixedInterval; reference the
'statusline-update-throttle' entry and writeStatuslineUpdateThrottle to
implement the clamp and keep behavior stable when <=0 is provided.
🧹 Nitpick comments (2)
src/patches/statuslineUpdateThrottle.ts (1)
76-88: Tighten the patch regex to avoid over-matching minified code.The
.{0,1000}/.{0,200}spans are quite permissive; consider anchoring to more specific tokens (e.g., statement boundaries) so the patch doesn’t drift to unrelated sections as minified layouts evolve.Based on learnings: In patches under src/patches/, assume code works with minified, original Claude Code installations. Patch regexes must be strict and match the minified format exactly (ignore formatting differences like whitespace/newlines).
src/patches/index.ts (1)
181-186: Align patch grouping with conditional application.This patch is listed under
PatchGroup.ALWAYS_APPLIED, but it’s conditionally applied (Line 591). Consider moving it toMISC_CONFIGURABLEor removing the condition so--list-patchesand results align with expectations.Possible adjustment
- group: PatchGroup.ALWAYS_APPLIED, + group: PatchGroup.MISC_CONFIGURABLE,
5af7a56 to
bcb5239
Compare
Summary by CodeRabbit