fix(cli): eliminate flicker in transfer progress renderer#2647
Conversation
✅ Deploy Preview for ocm-website canceled.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR refactors the progress bar visualization component to use internal buffering instead of direct streaming writes. A new ChangesProgress Bar Rendering Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
✨ 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 |
Two causes of flicker in the bar visualizer: 1. HandleEvent() called renderLocked() on every node state change, racing the 80ms animation ticker. Rapid node completions (e.g. 3 in <80ms) caused 3 full clear+redraw cycles in quick succession. Fix: events now mutate state only; the animation ticker is the sole render driver. 2. Each render frame was written as multiple separate fmt.Fprint calls (clear lines, header, events, bar), letting the terminal paint partial frames between syscalls. Fix: the full frame is built into a strings.Builder and flushed in a single io.WriteString. Also bumps the animation interval from 80ms to 100ms (12.5 → 10 redraws/sec) since the higher rate is imperceptible and adds unnecessary syscall pressure. On-behalf-of: @SAP <jakob.moeller@sap.com> Signed-off-by: Jakob Möller <contact@jakob-moeller.com> On-behalf-of: @SAP <jakob.moeller@sap.com>
173b0ed to
c54d94f
Compare
piotrjanik
left a comment
There was a problem hiding this comment.
Oh, it really helped. Looks much nicer :D GJ!
…nent-model#2647) Co-authored-by: Gergely Bräutigam <gergely.brautigam@sap.com> Signed-off-by: Jakob Möller <contact@jakob-moeller.com> d15958c
…nent-model#2647) Co-authored-by: Gergely Bräutigam <gergely.brautigam@sap.com> Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
…nent-model#2647) Co-authored-by: Gergely Bräutigam <gergely.brautigam@sap.com> Signed-off-by: Jakob Möller <contact@jakob-moeller.com> Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
Problem
ocm transfer component-versionflickers visibly during transfer. Two independent causes:1. Dual render paths racing each other
HandleEvent()calledrenderLocked()synchronously on every node state change, while the animation goroutine independently firesrenderLocked()every 80ms. Rapid node completions (e.g. 3 nodes finishing within 5ms) triggered 3 fullclearLines() + redrawcycles in quick succession, colliding with the background ticker and producing visible cursor jumping.2. Partial-frame writes
Each render frame was written to the terminal as multiple separate
fmt.Fprintcalls — clear lines, then header, then each event line, then the progress bar. The terminal could paint partial frames between syscalls, causing a visible flash.Fix
Event ingestion decoupled from rendering (
bar_visualizer.go):HandleEvent()now only mutates state. The animation ticker is the sole render driver — at most 10 redraws/sec regardless of event rate. The 100ms lag between a node completing and it appearing on screen is imperceptible.Single-write frames (
bar_visualizer.go): The full frame (cursor movements, header, events, bar) is assembled into astrings.Builderand flushed with a singleio.WriteStringcall. The terminal sees a complete frame or nothing.Animation interval (
animation.go): 80ms → 100ms. 12.5 redraws/sec was imperceptible over 10 and added unnecessary syscall pressure.Test plan
go test ./cli/internal/render/progress/bar/...passesocm transfer component-version <source> <target>against a registry with several components — no flicker during node completions, smooth spinner animation