Skip to content

fix(realtime): suppress deltas by originating tab instead of by user - #12

Merged
pulkitxm merged 7 commits into
mainfrom
fix/realtime-same-user
Jul 23, 2026
Merged

pulkitxm merged 7 commits into
mainfrom
fix/realtime-same-user

Conversation

@pulkitxm

Copy link
Copy Markdown
Member

Realtime deltas were dropped whenever the actor matched the signed in user, so two tabs of the same person never updated each other; suppression is now keyed on a per tab client id.

pulkitxm added 3 commits July 23, 2026 08:11
Deltas were dropped whenever the actor matched the signed in user, so two
tabs of the same person never updated each other. Every mutating request now
carries a per tab client id that rides through to the published SyncAction,
and the delta bridge skips only its own echo.
… my issues

The catch-all rendered a fake empty state for every unimplemented route, so
/docs, /views and /my-issues looked like real but empty pages. Unmatched
addresses now hit a plain not-found, my issues lists what is assigned to the
viewer across teams, and the sidebar only links to surfaces that exist.
The spec signs one user in, opens a second tab in the same browser context,
and asserts an issue, a comment and a reaction all reach the second tab with
no reload.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4ef607d5-5a82-4e9b-9a37-7830117cb10b

📥 Commits

Reviewing files that changed from the base of the PR and between cbfd9c7 and b74187e.

📒 Files selected for processing (1)
  • apps/web/src/features/issues/my-issues-view.test.tsx
📝 Walkthrough

Walkthrough

Adds per-tab origin identifiers to realtime issue updates, suppresses same-tab echoes, and adds cross-tab tests. It also introduces a My issues view and route, updates navigation links, adds a not-found page, and centralizes team issue queries.

Changes

Realtime origin synchronization

Layer / File(s) Summary
Origin metadata propagation
packages/shared/src/events/index.ts, packages/core/src/realtime/*, apps/web/src/lib/query/*, apps/web/src/lib/api/handler.ts
Sync actions accept validated optional origin client IDs, API requests send per-tab identifiers, and published actions preserve that metadata.
Per-tab echo handling and sync validation
apps/web/src/lib/realtime/*, apps/web/src/lib/query/sync*
DeltaBridge suppresses actions from the current tab instead of the current user, while stale and duplicate delta behavior is covered by tests.
Cross-tab propagation coverage
apps/web/e2e/same-user-tabs.spec.ts
Adds an end-to-end flow covering issue, comment, and reaction propagation between two tabs.

Issue navigation and personal issue view

Layer / File(s) Summary
My issues aggregation and rendering
apps/web/src/features/issues/my-issues-view*, apps/web/src/lib/query/use-issues.ts, apps/web/src/app/(app)/my-issues/page.tsx
Fetches issues across teams, filters and sorts assignments, renders loading and empty states, and exposes the My issues route with tests.
Navigation and fallback routes
apps/web/src/lib/navigation.ts, apps/web/src/app/not-found.tsx
Filters unbuilt navigation links, replaces team routes with Board and Active cycle entries, and adds a not-found page linking to My issues.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TabA
  participant apiFetch
  participant APIHandler
  participant RealtimePublisher
  participant TabB
  TabA->>apiFetch: Send mutation with x-orbit-client-id
  apiFetch->>APIHandler: Forward origin client ID
  APIHandler->>RealtimePublisher: Publish action with originClientId
  RealtimePublisher->>TabB: Deliver sync action
  TabB->>TabB: Apply delta through DeltaBridge
Loading

Possibly related PRs

  • Noveum/orbit#11: Touches the realtime sync pipeline, DeltaBridge self-echo handling, and cross-viewer/tab propagation coverage.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main realtime suppression change from user-based to tab-based origin tracking.
Description check ✅ Passed The description directly matches the PR’s per-tab client ID realtime suppression change.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/realtime-same-user

Comment @coderabbitai help to get the list of available commands.

@pulkitxm

Copy link
Copy Markdown
Member Author

Before

apps/web/e2e/same-user-tabs.spec.ts run against the old suppression (skip when action.actor is the signed in user), same dev server, same seed:

Running 1 test using 1 worker
  x  1 e2e/same-user-tabs.spec.ts:12:1 > one user in two tabs of the same browser sees issues, comments and reactions live (21.5s)

    Error: expect(locator).toBeVisible() failed
    Locator: getByText('Same user tabs 761079')
    Expected: visible
    Timeout: 20000ms
    Error: element(s) not found

     33 |   await expect(tabA.getByText(title)).toBeVisible();
     34 |
    >35 |   await expect(tabB.getByText(title)).toBeVisible({ timeout: PROPAGATION_TIMEOUT });
        |                                       ^
  1 failed

After

Running 2 tests using 1 worker
  v  1 e2e/issues.spec.ts:14:1 > two viewers see issue, board and comment changes without reloading (5.1s)
  v  2 e2e/same-user-tabs.spec.ts:12:1 > one user in two tabs of the same browser sees issues, comments and reactions live (2.7s)

  2 passed (8.4s)

One user, two tabs in the same browser context. Tab A creates the issue, tab B receives it with no reload:

board

Same story for a comment and a reaction:

detail

Mechanism

Every tab holds one random id for its lifetime (apps/web/src/lib/query/client-id.ts, module singleton over crypto.getRandomValues, so it also works outside a secure context). apiFetch sends it as x-orbit-client-id on every request. publish() in apps/web/src/lib/api/handler.ts validates that header and stamps originClientId on the actions it publishes, so all 21 route handler call sites are covered without threading an argument through every service. The delta bridge skips an action only when action.originClientId matches this tab. originClientId is optional in syncActionSchema, so publishers that do not set it (the MCP server, background jobs) stay valid and their deltas are always applied.

Cache patches were already idempotent and the syncId guard already rejected incoming <= existing. Both now have explicit tests: a late delta cannot revert newer local state, and a repeated insert or reaction does not duplicate.

Placeholder removal

(app)/[...slug]/page.tsx rendered "Nothing here yet ... Create issue" for every unimplemented route. It is gone. Unmatched addresses now hit a real app/not-found.tsx with a 404 status. That file sits at the root rather than inside the (app) group because Next only routes unmatched URLs to the root not-found, a group level one would never render for /docs.

Two consequences handled here:

  • /my-issues was served by that placeholder, and it is the post login landing plus the g m target. It is now a real page listing what is assigned to the viewer across every team, reusing the per team issue query so realtime patches apply to it too.
  • For /views and /docs I chose the flag: NavLink.unbuilt hides them from the sidebar until the routes land, so nothing in the shell points at a 404. Deleting unbuilt: true in apps/web/src/lib/navigation.ts restores each entry. The same pass corrected two team links that pointed at routes that never existed (/team/x/cycles, /team/x/projects).

not found and my issues

@coderabbitai coderabbitai 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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/features/issues/my-issues-view.test.ts`:
- Around line 38-60: Add a view-level test for MyIssuesView that supplies issue
results from multiple teams, verifies they are merged, and asserts the combined
issues are rendered. Keep the existing assignedTo unit tests unchanged and
exercise the route/query integration rather than only the extracted filter.

In `@apps/web/src/lib/query/use-issues.ts`:
- Around line 30-44: Update teamIssuesQuery so its queryFn follows the API
response’s nextCursor until no cursor remains, fetching each subsequent page and
aggregating all page.issues into the returned readonly Issue[]; preserve the
existing abort signal, teamId, and TEAM_ISSUE_LIMIT parameters for every
request.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1e36255e-b195-469f-82db-7065ab73413b

📥 Commits

Reviewing files that changed from the base of the PR and between e39b9fb and 4e65186.

📒 Files selected for processing (19)
  • apps/web/e2e/same-user-tabs.spec.ts
  • apps/web/src/app/(app)/[...slug]/page.tsx
  • apps/web/src/app/(app)/my-issues/page.tsx
  • apps/web/src/app/not-found.tsx
  • apps/web/src/features/issues/my-issues-view.test.ts
  • apps/web/src/features/issues/my-issues-view.tsx
  • apps/web/src/lib/api/handler.ts
  • apps/web/src/lib/navigation.ts
  • apps/web/src/lib/query/client-id.ts
  • apps/web/src/lib/query/fetcher.ts
  • apps/web/src/lib/query/sync.test.ts
  • apps/web/src/lib/query/sync.ts
  • apps/web/src/lib/query/use-issues.ts
  • apps/web/src/lib/realtime/delta-bridge.test.tsx
  • apps/web/src/lib/realtime/delta-bridge.tsx
  • apps/web/src/lib/realtime/provider.tsx
  • packages/core/src/realtime/publisher.test.ts
  • packages/core/src/realtime/publisher.ts
  • packages/shared/src/events/index.ts
💤 Files with no reviewable changes (2)
  • apps/web/src/app/(app)/[...slug]/page.tsx
  • apps/web/src/lib/query/sync.ts

Comment thread apps/web/src/lib/query/use-issues.ts Resolved

@coderabbitai coderabbitai 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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/features/issues/my-issues-view.test.tsx`:
- Around line 135-141: Add a test alongside the existing empty-state case in the
my-issues view suite using a ready workspace with uncached team queries, and
assert that the pending branch renders “Loading your issues.” Keep the settled
empty-state assertions unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 93828ef6-91ce-4b3d-9708-00f75b7879eb

📥 Commits

Reviewing files that changed from the base of the PR and between 5920118 and cbfd9c7.

📒 Files selected for processing (1)
  • apps/web/src/features/issues/my-issues-view.test.tsx

The suite only exercised the settled empty state, so the pending branch
could regress without a failure.
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