Skip to content

feat(platform): replace live reload with granular SSE config file events#942

Merged
larryro merged 4 commits into
mainfrom
feat/config-file-events-sse
Apr 2, 2026
Merged

feat(platform): replace live reload with granular SSE config file events#942
larryro merged 4 commits into
mainfrom
feat/config-file-events-sse

Conversation

@larryro

@larryro larryro commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the full-page live reload mechanism with a structured SSE-based config file watcher that pushes granular change events (agents, automations, integrations, branding) to the frontend
  • Migrate config queries from imperative useAction + useState + useEffect patterns to reactive TanStack Query hooks with automatic cache invalidation via SSE events
  • Mutations now optimistically update the query cache on write, giving instant UI feedback

Test plan

  • Verify SSE connection establishes on dashboard load (/api/config-events endpoint)
  • Edit an agent JSON file on disk and confirm the agents table updates without a full page reload
  • Edit automation, integration, and branding config files and confirm respective UI sections update reactively
  • Create/update/delete an agent via the UI and confirm optimistic cache updates appear immediately
  • Confirm no full-page reloads occur during normal config file changes in dev mode

Summary by CodeRabbit

  • New Features

    • Added real-time synchronization of configuration changes across the app via Server-Sent Events.
    • Enabled structured responses for agents.
  • Improvements

    • Enhanced data caching and refresh mechanisms for agents, workflows, integrations, and branding.
    • Improved consistency of configuration updates after save/delete operations.

larryro added 3 commits April 2, 2026 11:32
Replace the full-page live reload mechanism with a structured SSE-based
config file watcher that pushes granular change events to the frontend.
Queries now invalidate their TanStack Query caches on relevant file
changes instead of triggering a full page reload, and mutations
optimistically update the cache on write.
Switch agent detail and chat agent list from imperative action calls
to reactive query hooks (useReadAgent, useListAgents) so the UI
automatically updates when SSE config file events arrive. Pluralize
config watcher event types to match directory names and sync the
editor context with external changes when no unsaved edits exist.
Replace imperative useAction + useState + useEffect pattern with the
useListAgents react-query hook, enabling automatic cache invalidation
via SSE events instead of manual reload callbacks.

@greptile-apps greptile-apps 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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Remove export from ConfigChangeEvent, parseConfigChange, and
ConfigWatcher since they are only used within config-watcher.ts.
Fixes Knip CI failure.
@larryro larryro merged commit 2f2c659 into main Apr 2, 2026
15 checks passed
@larryro larryro deleted the feat/config-file-events-sse branch April 2, 2026 05:00
@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR comprehensively refactors data-fetching patterns across the platform by replacing manual useAction + useState + useEffect implementations with a centralized useActionQuery hook that leverages React Query for caching and state management. It removes window.__taleLastSaveAt timestamp assignments used for save-suppression tracking. Additionally, the PR introduces file-system watching infrastructure (createConfigWatcher) and a Server-Sent Events endpoint (/api/file-events) to broadcast real-time config changes, replacing manual window events with React Query query invalidation as the primary cache invalidation mechanism. The changes span agents, automations, branding, integrations, and chat features, including hook refactors in queries and mutations layers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.63% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: replacing live reload with granular SSE config file events, which is the primary architectural shift across the entire changeset.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/config-file-events-sse

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

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