fix(prompt): drop superseded background renders via generation stamp - #91
Merged
Conversation
A stale background render could finish and apply after a newer one had already landed, since results were applied in whatever order they arrived rather than dispatch order. An in-repo render (git status, toolchain-version items) is reliably slower than a plain directory's render, so leaving a repo would often show the old repo's git status and right-prompt items well after cd, clearing only once a later render happened to win the race. Stamp each dispatched render with a generation number and drop any result whose stamp doesn't match the latest dispatch, so a superseded render can no longer overwrite a fresher one.
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.
Summary
cd-ing out of a git repo, the prompt kept showing the old repo's git status and right-prompt items (node/rustc version, etc.), sometimes for a long, unpredictable time before clearing on its own.fish -ctakes real time to start up, so two renders could be in flight at once. Whichever finished last won, not whichever was dispatched last — and an in-repo render (git status forks, toolchain-version items) is reliably slower than a plain directory's render, so the stale one usually finished last._tide_render_gen, a plain in-memory global, no universal variables involved) and drop any result whose stamp doesn't match the latest dispatch, so a superseded render can no longer overwrite a fresher one.Test plan
mise run lintmise run test(full littlecheck suite, includingtests/fish_prompt.test.fishandtests/fish_prompt_transient.test.fish)prompt_varstays correctcdinto a git repo with toolchain files, thencd .., confirm the prompt updates promptly and stays correct across repeats