Skip to content

fix: wake the UI when a store write ends, close on SIGHUP, deterministic test pump - #145

Merged
klNuno merged 6 commits into
mainfrom
fix/2.0.2-robustness
Nov 23, 2026
Merged

klNuno merged 6 commits into
mainfrom
fix/2.0.2-robustness

Conversation

@klNuno

@klNuno klNuno commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Note

Clanker Claude Opus 5.5 is responding on behalf of meetsu

A note typed while a save is being written now reaches the disk right away instead of waiting for the next mouse move, and closing the terminal of a Linux or macOS session no longer loses pending saves.

what changed

  • The UI asks for one more frame when a store write ends, so a write queued behind it or a waiting restore runs at once (app/saves.rs).
  • The test pump draws a frame only when the app requests one and bounds the wait between frames, not a frame itself (app/tests/pump.rs).
  • backup_restore and native_regressions tests use that pump; a fixed 400 ms sleep became a wait for the debounce end.
  • SIGHUP runs the same close sequence as SIGTERM and SIGINT; a signal left ignored by the parent (nohup) stays ignored (window/signal.rs).
  • End-to-end unix tests send the signal to the installed handler and check the pending write is on disk (lib.rs).
  • A 2.0.0 or 2.0.1 local config without the owed Battle.net list still loads and keeps its fields (battle_net/tests.rs).

to question

The flaky macOS failures of backup_restore came from a 3 s budget that counted frame time: a single debug frame took up to 3.04 s on a loaded machine. The new pump exposed the missing wake in saves.rs, which the old 1 ms busy pump hid.

verified

  • build-safe node scripts/gates.mjs passed all seven gates, with 2,113 Rust tests passed, 40 Worker tests passed and 21 bundle tests passed.
  • app:: suite 30 runs under a 4-core CPU load: 0 failures; 2 of 30 failed before the saves.rs fix.
  • New tests red before, green after: a_slow_frame_is_not_a_hang, a_write_ending_under_the_boundary_wakes_the_restore, a_note_typed_while_its_store_writes_is_written_when_that_write_ends.
  • Unix signal tests: cargo check and cargo clippy -D warnings for Linux and macOS targets from Windows; they run for real in CI.
  • reviewed by GPT-6.2 Sol: 2 rounds, approved.
  • not verified: the original macOS CI failure does not reproduce on Windows with the old code; a few bounded waits remain unconverted (wait_held, shortcuts.rs, real_unreadable.rs).

Summary by CodeRabbit

  • Bug Fixes
    • The app now recognizes the Unix SIGHUP signal when ending a session, while respecting an inherited instruction to ignore that signal.
    • The interface now refreshes after save operations finish, so completed changes appear without waiting for another interaction.
  • Reliability
    • Improved handling of pending saves during backup and restore operations, helping preserve changes made while a save is in progress.

…epaint requests

The frame that reports a finished store write asked for no frame after it.
The write's store could hold a newer write already due, which the timed
repaint had left out while the store was writing, and a backup's drain had
already run earlier in that frame: both waited for an unrelated deadline or
the next input. pump_saves now asks for one more frame when a write ends.

The backup and native tests bounded their waits by wall clock with the
frames counted in, so one slow debug frame on a loaded runner failed a wait
that was only slow, and a frame drawn every millisecond hid lost wakeups.
The new pump draws a frame only when the app asks for one, through the
context's repaint observer, and bounds only the idle time between frames.
SIGHUP kept its default action, which ends the process before the pending
store writes are flushed (a closed terminal, a session that hangs up).
It now wakes the loop like SIGTERM and SIGINT. A signal the parent left
ignored (nohup) stays ignored. Tests drive the installed handler end to
end: the signal wakes the loop, the close runs and the pending write is
on disk.
The owed SavedAccountNames list has lived in the local config since #135.
Cover the file a user updating from 2.0.0 or 2.0.1 holds: it has other
local fields and no owed list, loads as an empty list, and keeps its
fields once the first list is written.
…se holds on unwind

The slow-frame regression asks for its next frame itself, so a late job
never counts as idle. The two wake regressions answer the note write in
place of the mock before the frame, instead of sleeping for the worker.
Their holds go through HeldCommands, now shared, so a failed assertion
releases them instead of hanging Jobs::drop.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add Unix SIGHUP handling and signal-disposition restoration. They also request a repaint after save completion, add shared helpers for UI frame-pumping tests, expand save and restore regression coverage, and test Battle.net configuration loading without an owed-account list.

Changes: Unix signal handling

Layer / File(s) Summary
Signal installation and shutdown tests
crates/accshift-egui/src/window/signal.rs, crates/accshift-egui/src/window/mod.rs, crates/accshift-egui/src/lib.rs, crates/accshift-egui/Cargo.toml
Signal handling now includes SIGHUP. Installation and teardown restore saved signal dispositions, and SIGHUP remains ignored when its prior disposition was ignored. Unix tests cover signal handling and persistence of a pending setting. Documentation and a dependency comment also list SIGHUP.

Save and restore coordination

Layer / File(s) Summary
Repaint after save completion
crates/accshift-egui/src/app/saves.rs
pump_saves requests another repaint after a save is reported completed or gone. Waiting saves do not trigger a repaint.
Shared frame-pump and held-command helpers
crates/accshift-egui/src/app/tests.rs, crates/accshift-egui/src/app/tests/held.rs, crates/accshift-egui/src/app/tests/pump.rs, crates/accshift-egui/src/app/tests/native_regressions.rs
Tests share helpers for pumping frames until a condition holds and tracking held mock commands. Native regression tests use the shared frame-pump helper.
Save and restore regression coverage
crates/accshift-egui/src/app/tests/backup_restore.rs, crates/accshift-egui/src/app/tests/native_regressions.rs
Backup and restore tests use the shared helpers and cover save completion during a restore drain, edits during an in-flight save, and other UI wait conditions.

Battle.net configuration loading

Layer / File(s) Summary
Local configuration regression test
crates/accshift-core/src/platforms/battle_net/tests.rs
A test checks that a local configuration without owed_saved_accounts loads with an empty owed list and unchanged fresh accounts. It also checks that saving the first owed account preserves the path override.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant UnixSignal
  participant SignalWatcher
  participant AppSession
  participant SettingsStore
  UnixSignal->>SignalWatcher: deliver SIGTERM or SIGHUP
  SignalWatcher->>AppSession: notify session-ending loop
  AppSession->>SettingsStore: persist pending closeToTray setting
Loading

Possibly related PRs

  • klNuno/accshift#126: PR #126 adds the restore path that waits for running saves. This PR adds regression coverage for a completed write waking that restore wait.
Merge Risk: Minimal · up to 4cdaa

This change makes saves and restores progress without waiting for unrelated UI input, and it runs the normal close sequence on SIGHUP. The Battle.net config tests cover older configs that lack the owed-accounts list. No concrete merge-blocking risk was found; the main remaining uncertainty is a possible false timeout in a test helper.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names three changes: waking the UI when a store write ends, closing on SIGHUP, and a deterministic test pump. The changeset covers all three: saves.rs requests a repaint when save jobs finis…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names three changes: waking the UI when a store write ends, closing on SIGHUP, and a deterministic test pump. The changeset covers all three: saves.rs requests a repaint when save jobs finish, signal.rs and lib.rs add SIGHUP handling with tests, and the new pump.rs helpers replace the busy test loops. The title is specific and accurate, though it lists three items and is somewhat long at 82 characters.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 417bf6a9-f834-41fa-ae69-7c75bc9f8b8f
Commits

Reviewing files that changed from the base of the PR and between 2100389 and 4cdaa42.

Files selected for processing: 11

  • crates/accshift-core/src/platforms/battle_net/tests.rs
  • crates/accshift-egui/Cargo.toml
  • crates/accshift-egui/src/app/saves.rs
  • crates/accshift-egui/src/app/tests.rs
  • crates/accshift-egui/src/app/tests/backup_restore.rs
  • crates/accshift-egui/src/app/tests/held.rs
  • crates/accshift-egui/src/app/tests/native_regressions.rs
  • crates/accshift-egui/src/app/tests/pump.rs
  • crates/accshift-egui/src/lib.rs
  • crates/accshift-egui/src/window/mod.rs
  • crates/accshift-egui/src/window/signal.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@mtsu-patrol mtsu-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

@mtsu-patrol

mtsu-patrol Bot commented Nov 23, 2026

Copy link
Copy Markdown

A note typed while its store is busy now reaches disk on the next frame instead of waiting for another input, and closing a Unix terminal now runs the normal close sequence instead of ending with writes pending. The test loop now draws only when the app asks for a frame, so a slow frame no longer looks like a hang.

No comments posted: the reviewers raised no finding.

Review details
  • Model: muse-spark-1.3-contributor
  • Compared commits: 2100389 to 4cdaa42
  • Execution: tests could run in a disposable Linux sandbox
  • Files reviewed: 11 of 11
  • Duration: 6 min 36 s
Commands run (11)

Runtime testing was blocked by missing toolchain: sandbox had no cargo/rustc or cc/gcc, apt has no sources/lock (non-root), and zig download URL returned 404, so cargo test for accshift-core/egui (battle_net, saves wake, pump, signal) and the app entry point could not be built or driven. Installed rustup stable (cargo 1.100.0) but still no C linker for crates with build scripts (rusqlite bundled, ring). No tests passed/failed to report; no reproduced defect.

passed · exit 0 · 0 s

ls -R /work | head -n 200; echo ---; cat /work/README.md 2>/dev/null | head -n 200; echo ---; cat /work/package.json 2>/dev/null | head -n 100; echo ---; cat /work/Cargo.toml 2>/dev/null | head -n 100

passed · exit 0 · 0 s

git diff --stat HEAD~1 2>/dev/null || git diff --stat HEAD 2>/dev/null; echo ===; git log --oneline -5; echo ===; ls crates/accshift-egui/src/app/tests/; echo ===; cat crates/accshift-egui/Cargo.toml | head -n 80

passed · exit 0 · 0 s

git diff --stat 2100389452d4f2ef321a13936268059e8d91df4d..HEAD; echo ===; git log --oneline 2100389452d4f2ef321a13936268059e8d91df4d..HEAD

failed · exit 127 · 0 s

cargo test -p accshift-core --lib platforms::battle_net::tests -- --nocapture 2>&1 | tail -n 80
/bin/bash: line 1: cargo: command not found

failed · exit 1 · 0 s

which rustc; ls /root/.cargo/bin/ 2>&1 | head; ls /usr/local/cargo/bin/ 2>&1 | head; ls ~/.rustup/toolchains/ 2>&1 | head; echo PATH=$PATH; find / -maxdepth 4 -name cargo -type f 2>/dev/null | head
/bin/bash: line 1: which: command not found
ls: cannot access '/root/.cargo/bin/': No such file or directory
ls: cannot access '/usr/local/cargo/bin/': No such file or directory
ls: cannot access '/work/.patrol-home/.rustup/toolchains/': No such file or directory
PATH=/usr/local/bin:/usr/bin:/bin

passed · exit 0 · 0 s

ls / /opt /usr/local/bin 2>&1 | head -n 100; echo ===; ls /work; echo ===; env | head -n 30; echo ===; ls /github 2>&1 | head; node --version 2>&1 | head; python3 --version 2>&1 | head

passed · exit 0 · 9 s

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh && sh /tmp/rustup.sh -y --profile minimal --default-toolchain stable 2>&1 | tail -n 20; echo EXIT=$?; ls ~/.cargo/bin/ 2>&1 | head; ~/.cargo/bin/cargo --version 2>&1 | head

failed · exit 127 · 0 s

export PATH="$HOME/.cargo/bin:$PATH"; ls /usr/bin/*cc* /usr/bin/*gcc* 2>&1 | head; apt-get update 2>&1 | tail -n 5; apt-get install -y gcc pkg-config libssl-dev 2>&1 | tail -n 20; gcc --version 2>&1 | head; cc --version 2>&1 | head
ls: cannot access '/usr/bin/*cc*': No such file or directory
ls: cannot access '/usr/bin/*gcc*': No such file or directory
Reading package lists...
W: Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory)
W: Unable to read /etc/apt/sources.list.d/ - DirectoryExists (2: No such file or directory)
W: Unable to read /etc/apt/sources.list - RealFileExists (2: No such file or directory)
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (2: No such file or directory)
W: Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (2: No such file or directory)
W: Unable to read /etc/apt/sources.list.d/ - DirectoryExists (2: No such file or directory)
W: Unable to read /etc/apt/sources.list - RealFileExists (2: No such file or directory)
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (2: No such file or directory)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
/bin/bash: line 1: gcc: command not found
/bin/bash: line 1: cc: command not found

passed · exit 0 · 0 s

id 2>&1; uname -m 2>&1; cat /etc/os-release 2>&1 | head -n 20; ls -la / 2>&1 | head -n 30; find / -maxdepth 5 -name "*clang*" -o -name "*zig*" 2>/dev/null | head; echo ===; ls /usr/local/lib/ 2>&1 | head -n 30

passed · exit 0 · 0 s

export PATH="$HOME/.cargo/bin:$PATH"; ls /usr/bin/ | head -n 100; echo ===; ls ~/.rustup/toolchains/*/lib/rustlib/x86_64-unknown-linux-gnu/bin/ 2>&1 | head -n 30; rustc --print target-list 2>&1 | head; echo ===; cat /work/crates/accshift-core/Cargo.toml | head -n 80

passed · exit 0 · 0 s

export PATH="$HOME/.cargo/bin:$PATH"; cat /work/Cargo.toml | head -n 120; echo ===; grep -r "rusqlite\|ring\|openssl\|bundled" /work/Cargo.toml /work/Cargo.lock 2>/dev/null | head -n 20; echo ===; curl -sI https://ziglang.org/download/0.14.1/zig-linux-x86_64-0.14.1.tar.xz | head -n 10

@klNuno
klNuno merged commit a0cf621 into main Nov 23, 2026
9 checks passed
@klNuno
klNuno deleted the fix/2.0.2-robustness branch November 23, 2026 15:18
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