Skip to content

Coalesce stale focus raises during rapid focus movement#322

Open
corpooo wants to merge 1 commit intoacsandmann:mainfrom
corpooo:pr/focus-request-coalescing
Open

Coalesce stale focus raises during rapid focus movement#322
corpooo wants to merge 1 commit intoacsandmann:mainfrom
corpooo:pr/focus-request-coalescing

Conversation

@corpooo
Copy link
Copy Markdown
Contributor

@corpooo corpooo commented Mar 27, 2026

Summary

  • send an immediate quiet focus request for layout move-focus commands
  • supersede active and queued focus-bearing raise sequences when a newer focus target arrives
  • add tests for the immediate prefocus path and latest-focus-wins sequencing

Testing

  • cargo test test_newer_focus_request_supersedes_active_sequence -- --nocapture
  • cargo test test_latest_focus_request_replaces_older_queued_sequences -- --nocapture
  • cargo test move_focus_sends_immediate_quiet_raise_for_target_window -- --nocapture
  • cargo build --profile release-fast --bin rift

@acsandmann
Copy link
Copy Markdown
Owner

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfedbaf1ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +140 to +144
if let Err(e) = app_state.handle.send(Request::Raise(
vec![window_id],
CancellationToken::new(),
0,
Quiet::Yes,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep immediate MoveFocus raises cancellable

This direct send creates a standalone Request::Raise with a fresh CancellationToken and sequence_id 0, which means it is not tracked by RaiseManager and cannot be superseded when a newer focus target arrives. In rapid cross-app focus movement, the older immediate request can still finish later (notably when handle_raise_request is waiting on activation) and steal focus back from the newer target, reintroducing stale-focus behavior despite the new coalescing logic. Please route this through the same cancellation path as managed raise sequences (or otherwise keep a cancel handle for the latest immediate focus request).

Useful? React with 👍 / 👎.

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.

2 participants