harden quit teardown and scale-change font reload#241
Merged
forketyfork merged 2 commits intomainfrom Feb 24, 2026
Merged
Conversation
Issue: Quitting after the session persistence rollout caused crash reports during shutdown, and a follow-up run surfaced another quit-time failure. We also needed a focused audit for similar lifecycle hazards in runtime teardown and resize paths. Solution: Add a one-shot guard so UI teardown cannot run twice across mixed error and normal unwind paths, and keep persistence finalization explicit at runtime end. Make scale-change font reload transactional so new fonts are acquired before old ones are released, then run resize through a single ordered reload/resize flow. Add targeted runtime tests that lock in teardown guard behavior, transactional swap semantics, and resize behavior for changed, unchanged, and failing reload paths.
There was a problem hiding this comment.
Pull request overview
Hardens runtime shutdown and window-resize/scale-change lifecycles by making UI teardown one-shot, making font reload transactional, and routing resize logic through a single ordered path to avoid error-path resource hazards.
Changes:
- Add a one-shot teardown guard to ensure
UiRoot.deinit()executes at most once across mixederrdefer/deferunwind paths. - Refactor DPI scale-change handling to transactionally reload terminal/UI fonts (initialize both first, then swap/deinit old) and unify resize sequencing.
- Make persistence finalization explicit at the end of
run()(witherrdeferfor error exits), and add targeted unit tests plus architecture notes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/app/runtime.zig | Implements guarded UI teardown, transactional font swapping, unified scale-change resize flow, and adds unit tests for the new helpers. |
| docs/ARCHITECTURE.md | Documents the shutdown ordering, one-shot teardown guard, explicit persistence finalization, and transactional font reload/resize sequencing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Issue: The zwanzig dependency was pinned to v0.10.0 and needed updating to the latest release. Solution: Updated the URL and hash in build.zig.zon to v0.11.0 using zig fetch --save and confirmed the build passes with the new version.
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.
Solution
This hardens two shutdown and resize lifecycles that were vulnerable on error paths.
The runtime now guarantees UI teardown executes at most once, even when both
errdeferanddeferare active in the same scope.Font reload during scale changes is now transactional: both replacement fonts are initialized first, and only then are old resources swapped out and released.
Window resize handling is also routed through one ordered path (
reload-if-needed, thenresize) so changed-scale and unchanged-scale events follow the same control flow.Targeted tests were added for one-shot teardown, transactional swap behavior, and scale-change resize sequencing including reload failure handling.
Also bumps the
zwanzigdependency from v0.10.0 to v0.11.0. Build verified to pass.Issue linkage: no issue yet for this hotfix fast-path; linkage will be added during mandatory cleanup.
Test plan