Repository navigation
Draw changes made outside a keypress by redrawing when the tree invalidates [patch] - #203
Merged
Merged
Conversation
…invalidates [patch] UIApplication only rendered at startup, after a key and after a resize, and nothing listened to Invalidated, so a clock, progress value or status set by a background task stayed frozen until a key was pressed. The application now subscribes to the root's Invalidated (re-subscribing when RootElement changes) and sets an Interlocked redraw flag, which the input loop's poll tick draws on the loop thread. Invalidations a render pass raises on its own thread while arranging are ignored, so a pass never requests the next one. RequestRender() sets the same flag for hosts. Fixes #154 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GJ23oLAT8FnLaMo3MfBviR
|
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.



Fixes #154
What was wrong
UIApplicationrendered only at startup, after a key was handled, and when the poll tick saw a resize.Invalidate()bubbled up to the root, but nothing subscribed to the root'sInvalidated. A clock, progress value, or status line set by a background task therefore stayed frozen until the user pressed a key.Change
RootElementsetter subscribes to the root'sInvalidated, and unsubscribes from the old root when it changes. The handler only sets anInterlockedredraw flag. It never draws, because it can fire on any thread.ProcessInputAsyncnow renders when_redrawRequestedis set or the console has resized. All drawing stays on the loop thread, and latency is bounded byResizePollInterval(100 ms).Render()clears the flag when it starts. It also records which thread it is running on, so invalidations from its own arrange step, such as size assignments, are ignored. Without that, every pass would request the next one and the app would redraw at 10 Hz forever. That is the same flickerWaitingForInputWithoutAResizeDoesNotRedrawguards against.UIApplication.RequestRender()lets hosts that change state without going throughInvalidateset the same flag. It is on the class only, not onIUIApplication, so this is not a breaking interface change.Tests (new
UIApplicationInvalidationTests)TextChangedOffTheLoopThreadIsDrawnWithoutAKeypress: the issue's repro. ChangingTextElement.Textfrom another thread produces a render pass while the read stays pending.RequestRenderDrawsWithoutAKeypressARenderPassDoesNotRequestTheNextOne: with a nested tree and nothing changing, the app does not keep redrawing.With the fix reverted (keeping a no-op
RequestRenderso the tests compile), the first two fail by timeout. With the fix, the full suite passes (256/256) on 3 consecutive runs.🤖 Generated with Claude Code
https://claude.ai/code/session_01GJ23oLAT8FnLaMo3MfBviR
Generated by Claude Code