Skip to content

fix(prompt): drop superseded background renders via generation stamp - #91

Merged
plttn merged 1 commit into
mainfrom
push-uvmsvnptuqnm
Jul 23, 2026
Merged

fix(prompt): drop superseded background renders via generation stamp#91
plttn merged 1 commit into
mainfrom
push-uvmsvnptuqnm

Conversation

@plttn

@plttn plttn commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • After 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.
  • Root cause: background render jobs could finish out of order. The "kill the previous job" check only catches a job that has already started writing its scratch file, but fish -c takes 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.
  • Fix: stamp each dispatched render with a generation number (_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 lint
  • mise run test (full littlecheck suite, including tests/fish_prompt.test.fish and tests/fish_prompt_transient.test.fish)
  • Isolated logic test reproducing the exact race (stale generation landing after a fresh one) confirms the stale result is dropped and prompt_var stays correct
  • Manual: cd into a git repo with toolchain files, then cd .., confirm the prompt updates promptly and stays correct across repeats

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.
@plttn
plttn merged commit 9703caf into main Jul 23, 2026
7 checks passed
@plttn
plttn deleted the push-uvmsvnptuqnm branch July 23, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant