fix: use counter for winbar spinner updates - #586
Open
jakubbortlik wants to merge 8 commits into
Open
Conversation
jakubbortlik
force-pushed
the
push-kxzrxtkxslqq
branch
from
August 28, 2026 18:03
8385392 to
7ab648c
Compare
Previously a transport failure, an empty response body, or unparseable JSON returned without running any callback, leaving callers unable to tell that the request had finished. Now exactly one callback runs for every outcome, including curl failing to spawn.
The handler was a nested anonymous function, which obscured the outcome branches and could not be exercised directly. Move it to M._make_on_exit and cover the branches with specs.
The module sends requests to the Go server rather than managing jobs, so name it for what it does: run_job becomes send_request, and the spec follows.
Redact the request body from the notifications that echo the curl command, since it can carry comment and MR text.
"error" states what the field holds, which reads better on the Lua side where it gates the on_error callback. This changes the wire format, so a response carrying the old key is still accepted, with a warning to rebuild, for users who supply their own binary via server.binary_provided.
last_updated doubled as the in-flight marker, so the timestamp disappeared while a refresh ran. Track the two states separately, and drive the spinner phase from vim.uv.hrtime so it advances with wall-clock time rather than with the number of winbar renders.
A single Boolean `updating` flag stopped the spinner as soon as the first of two overlapping refreshes finished, suggesting all work was done. An integer counter updates for each refresh individually, so the spinner runs until the last one completes.
jakubbortlik
force-pushed
the
push-kxzrxtkxslqq
branch
from
August 29, 2026 06:10
7ab648c to
f75a1a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this PR the spinner's phase came from a module-level spinner_index incremented once per winbar render, which ties the animation to redraw count rather than to time. That is merely imprecise with a single discussion tree window, but breaks once a second view renders its own copy of the tree: the two winbars share the counter, so each shows only a subset of the spinner characters and they pulse out of phase. Taking the phase from
vim.uv.hrtimemakes it a pure function of wall-clock time, so any number of winbars stay in step.Also, by tracking discussion tree updates with a counter, rather than the nil-as-flag on
last_updated, the spinner becomes a more reliable indicator of ongoing updates. Before this PR, when two updates happened to overlap, the spinner would stop moving after the first and before the second update finished, thus misleading users into believing all updates finished. With this PR, the spinner spins until the last ongoing update finishes.The time since the last update is no longer hidden when an update is in progress, which gives users a better idea of the progress if multiple updates are going on.
To be able to reliably decrement the counter, I've refactored the
run_jobfunction in thejob.luamodule heavily. It is now calledsend_requestand the module is calledclient.lua, to more clearly show the purpose of the module. Theon_errorcallback is now called on all failure paths, not just when the Go server returned an error message. The handling of vim.system output is extracted to a helper function which is more clearly structured and is covered by tests.DetailsinErrorResponse(cmd/app/response_types.go) is renamed toErrorto more clearly mark its intent in the lua client. This changes the wire format: a server response using the old key is still accepted, with a warning to rebuild, so users supplying their own binary viaserver.binary_providedaren't broken.Notifications that echo the curl command now redact the request body, which can contain comment and MR text. Users may notice REDACTED in
:messages.