Skip to content

[Fix] Realtime Event Filtering#1150

Merged
RichardAnderson merged 1 commit into
vitodeploy:4.xfrom
RichardAnderson:fix/realtime-filtering
Jun 6, 2026
Merged

[Fix] Realtime Event Filtering#1150
RichardAnderson merged 1 commit into
vitodeploy:4.xfrom
RichardAnderson:fix/realtime-filtering

Conversation

@RichardAnderson

@RichardAnderson RichardAnderson commented Jun 6, 2026

Copy link
Copy Markdown
Member

Filters realtime events to avoid unnecessary refreshes

Summary by CodeRabbit

  • New Features

    • Real-time updates now properly scope to specific resources (servers, sites, backups, scripts, etc.), ensuring users see only relevant updates for their current context.
    • Real-time subscriptions now handle creation of new records in paginated lists.
  • Bug Fixes

    • Improved data caching for server logs to enhance performance based on server and site context.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e2d9405-c0af-4c40-80bc-2d8c4420a47e

📥 Commits

Reviewing files that changed from the base of the PR and between 51418db and 99008ac.

📒 Files selected for processing (15)
  • resources/js/hooks/use-socket-events.ts
  • resources/js/pages/backups/files.tsx
  • resources/js/pages/backups/index.tsx
  • resources/js/pages/commands/show.tsx
  • resources/js/pages/php/index.tsx
  • resources/js/pages/redirects/index.tsx
  • resources/js/pages/scripts/show.tsx
  • resources/js/pages/server-logs/components/logs.tsx
  • resources/js/pages/server-logs/index.tsx
  • resources/js/pages/server-ssls/index.tsx
  • resources/js/pages/servers/installing.tsx
  • resources/js/pages/services/index.tsx
  • resources/js/pages/sites/logs.tsx
  • resources/js/pages/workers/index.tsx
  • resources/js/types/server-log.d.ts

📝 Walkthrough

Walkthrough

This PR extends the useRealtime hook with an optional scope parameter to filter realtime events, updates the ServerLog type to make site_id explicitly nullable, and applies scope-filtered subscriptions across all pages to constrain realtime updates to their respective server, site, or resource contexts.

Changes

Realtime Scoping Enhancement

Layer / File(s) Summary
useRealtime Hook Enhancement with Scope Filtering
resources/js/hooks/use-socket-events.ts
useRealtime accepts optional scope?: Partial<T> parameter and filters created events so they apply only when incoming data matches all scope key-value pairs. Existing updated and deleted behavior is unchanged.
Type Contract and Cache Scoping
resources/js/types/server-log.d.ts, resources/js/pages/server-logs/components/logs.tsx
ServerLog.site_id becomes required but nullable (number | null). React Query cache keys expand to include server.id, site?.id, and currentPage for proper cache separation.
Scope-Filtered Subscriptions Across Pages
resources/js/pages/backups/index.tsx, resources/js/pages/backups/files.tsx, resources/js/pages/commands/show.tsx, resources/js/pages/php/index.tsx, resources/js/pages/redirects/index.tsx, resources/js/pages/scripts/show.tsx, resources/js/pages/server-logs/index.tsx, resources/js/pages/server-ssls/index.tsx, resources/js/pages/servers/installing.tsx, resources/js/pages/services/index.tsx, resources/js/pages/sites/logs.tsx, resources/js/pages/workers/index.tsx
All pages update useRealtime calls to pass context-specific scope filters: server_id, site_id, backup_id, command_id, script_id, is_remote, or conditional combinations. Sites logs additionally imports the hook and replaces static page.props.logs with realtime-derived state.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Events now filter by scope so fine,
Each page receives just its own design,
No more mixing signals cross the wire,
Real-time updates climb ever higher! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding filtering to realtime events to prevent unnecessary refreshes, which is reflected across all modified files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@RichardAnderson RichardAnderson merged commit 7290703 into vitodeploy:4.x Jun 6, 2026
4 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.

2 participants