Skip to content

refactor(platform): Keep one due, not a copy per cfg arm - #923

Merged
omesser merged 1 commit into
mainfrom
refactor/358-platform-due
Sep 23, 2026
Merged

omesser merged 1 commit into
mainfrom
refactor/358-platform-due

Conversation

@omesser

@omesser omesser commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Why

platform.rs carried two copies of fn due, one under #[cfg(unix)] and one
under #[cfg(not(unix))]. Both wait 500ms and mark the read; the unix copy
spelled the interval USABLE_FRAME_REFRESH and the Windows copy inlined
Duration::from_millis(500). Item 8 of #358.

What changed

One due, no cfg, beside the USABLE_FRAME_REFRESH it reads. The refresh that
follows the check is what actually differs per platform, and it already sits at
each call site: macOS posts to the main thread, X11 and Windows read where they
stand. No trait and no type to express that (#172). USABLE_FRAME_REFRESH loses
its #[cfg(unix)] for the same reason.

Not here: X11 window_class (#351, #356).

How to verify

cargo test -p ai-buddy --all-targets (538 pass), cargo test -p ai-buddy-core,
cargo clippy --all-targets -- -D warnings, node --test tests/*.test.js
(304 pass), all on macOS.

The not(unix) arm is not built here and I am not claiming it compiles.
cargo check -p ai-buddy --target x86_64-pc-windows-msvc on this Mac dies in
ring's C build (fatal error: 'assert.h' file not found) long before it
reaches platform.rs. CI's windows job is the check that matters for it.

Notes

#915 edits the Windows window_source a few lines above the copy this deletes.
Whichever lands second rebases.

Refs #358

— Claude Code agent, on @omesser's behalf.

🤖 Generated with Claude Code

Both arms waited 500ms and marked the read. Only the refresh that
follows differs, and that already lives at each call site.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omesser

omesser commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

CLEARED @ 810c111e — Standards+Spec vs #358 item 8. poteto-mode gate.

Spec

Done-when met:

  • One due, no cfg. USABLE_FRAME_REFRESH ungated for the same reason (Windows stops inlining Duration::from_millis(500)).
  • Refresh action stays at each call site: macOS run_on_main_thread, X11 and Windows sync read_displays.
  • No trait / no type for the hop (Split the long files along existing seams, without new traits #172).
  • X11 window_class correctly out of scope.

DisplayOnlySource in the issue text is historical wording. It is already one Wayland WindowSource, not a second cfg-split of due. This PR does not need to touch it.

Standards

Laziness Protocol: delete the copy, do not invent a platform trait. Comments on due earn their lines (same interval; differing refresh stays at the site). Deleted cfg docs that claimed Windows was special for the wait were wrong once both arms matched.

Proof

CI green including windows (the real not(unix) check the PR body correctly refused to claim from a Mac cross-compile). Call sites verified in tip platform.rs (macOS / X11 / Windows all call the one due).

Soft: #915 is dirty against main and edits nearby Windows window_source; whichever lands second rebases. Base is behind the #922 merge but mergeable_state is clean (no file overlap).

Do not merge without Oded’s explicit yes. After merge, #358 Remaining is empty → close #358 completed (Architect will update the issue body).

— Cursor agent (Architect), on @omesser's behalf.

@omesser
omesser merged commit a3faf45 into main Sep 23, 2026
5 checks passed
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