Skip to content

Updated tabs engine code to enable batch syncing - #7793

Open
lougeniaC64 wants to merge 1 commit into
mainfrom
tabs-engine-refactor
Open

lougeniaC64 wants to merge 1 commit into
mainfrom
tabs-engine-refactor

Conversation

@lougeniaC64

@lougeniaC64 lougeniaC64 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Updating the tab engine's implementation of stage_incoming so that the forthcoming sync batching PR doesn't require stage_incoming to be called at least once regardless of whether there are no incoming records. This includes:

  • only calling remove_old_pending_closures if there are incoming records
  • moving remove_stale_clients to the remove_stale_clients function

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@lougeniaC64
lougeniaC64 marked this pull request as ready for review November 17, 2026 19:53

@mhammond mhammond left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems quite good, just that one semantic change I'm not sure about. @skhamis wdyt?

// device's record changes, so there's then nothing to clean up either.
if !remote_tabs.is_empty() {
storage.replace_remote_tabs(&remote_tabs)?;
storage.remove_old_pending_closures(&remote_tabs)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a semantic change iiuc - previously, even with no incoming tabs, we would remove pending commands older than REMOTE_COMMAND_TTL_MS. It not immediately obvious this matters in practice, but also not clear why it was made - ie, I'm not sure it is wrong, but also not sure it is particularly relevant to what this PR is addressing?


// Completed "close tab" requests are resolved when the device's record
// arrives: `stage_incoming` cleans them up, without waiting for `apply()`.
#[test]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just to be sure, these tests both worked without the changes? (which seems fine, just trying to understand the scope of this)

if let Some(conn) = self.open_if_exists()? {
if let Some(last_sync) = last_sync {
let client_ttl_ms = (TABS_CLIENT_TTL as i64) * 1000;
// On desktop, a quick write temporarily sets the last_sync to FAR_FUTURE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not directly related to this patch, but related to the new test for this, I think this comment is now stale and should be updated - desktop no longer does that.

// last-sync at FAR_FUTURE. Measured from that, every client would look
// stale, so `remove_stale_clients` must leave them all alone.
#[test]
fn test_remove_stale_clients_ignores_far_future_last_sync() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a little torn about this - it's not directly related to the PR, and is testing what's now redundant code, but OTOH it is testing a real path - so let's keep this test but update the comment above and we can just treat it as a ride-along improvement.

This branch has not been deployed

No deployments
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