Forward ResizeEvent to ViewModel input observable#219
Merged
Conversation
`TerminaApplication.ProcessEvent`'s `case ResizeEvent` short-circuited with `return;` after calling `_diffingTerminal?.ForceFullRefresh()`, so the event never reached `_inputSubject.OnNext(inputEvent)`. Pages and ViewModels subscribing via `ViewModel.Input.OfType<ResizeEvent>()` never received resize notifications, which blocks any width- or height-aware layout recomputation on terminal resize. Replace `return;` with `break;` so the event falls through to the `_inputSubject.OnNext` publish at the bottom of the method, matching the pattern `MouseScrollEvent` already uses a few cases below (handled-by-focused-scrollable returns, otherwise falls through). Internal `ForceFullRefresh` behavior is unchanged. Adds `ResizeEventRoutingTests` that dispatch a `ResizeEvent` through `ProcessEvent` (via reflection, mirroring `PasteToastRoutingTests`) and assert it surfaces on the ViewModel's `Input` observable. Two cases cover single-resize forwarding and back-to-back distinct resizes.
3 tasks
Aaronontheweb
added a commit
that referenced
this pull request
May 23, 2026
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.
Bug
TerminaApplication.ProcessEvent'scase ResizeEventshort-circuits withreturn;after calling_diffingTerminal?.ForceFullRefresh(), so the event never reaches_inputSubject.OnNext(inputEvent)at the bottom of the method. Pages and ViewModels that subscribe viaViewModel.Input.OfType<IInputEvent, ResizeEvent>()never receive resize notifications, even though the framework processes the event internally.This blocks any consumer that wants to recompute width- or height-sensitive layout on terminal resize — e.g., shortening status-bar text on narrow terminals, swapping wide/narrow key-hint variants, or rebuilding a width-aware truncation.
Compare with
MouseScrollEventa few cases below at line 647: when it isn't consumed by a focused scrollable, itbreaks to the fall-through_inputSubject.OnNext(inputEvent). The framework already established the right pattern;ResizeEventpredates it.Fix
One-line change:
return;→break;. InternalForceFullRefreshbehavior is unchanged; the event additionally surfaces on the publicInputobservable so consumers can subscribe.Test
Adds
tests/Termina.Tests/Input/ResizeEventRoutingTests.csthat mirrors the existingPasteToastRoutingTestsreflection pattern — dispatch aResizeEventthroughProcessEventand assert it surfaces on the ViewModel'sInputobservable. Two cases:ProcessEvent_ForwardsResizeEvent_ToViewModelInputObservable— single resize is observed with correct width/height.ProcessEvent_StillRefreshesDiffingTerminal_OnResize— two back-to-back distinct resizes each surface independently (locks in that the loop doesn't dedup/swallow on repeated dispatch).Downstream
Discovered while implementing terminal-size-aware approval prompt rendering in netclaw (#1132). The netclaw fix subscribes
ViewModel.Input.OfType<ResizeEvent>()to recompute width-sensitive layout, but the subscription was silently never firing in production — the bug masquerades as "resize handling works in tests but not in real terminals."Test plan
dotnet test tests/Termina.Tests— 1099/1099 pass (2 new + 1097 existing).MouseScrollEvent's existing break/fall-through pattern (TerminaApplication.cs:637-647).return;has been there since PR Implement diff-based rendering to eliminate screen flickering #61 (initial diff-rendering work), predating the_inputSubject.OnNextfall-through pattern that PR Add scrollbar, mouse wheel scroll, and paste features #138 established. Not a deliberate suppression.