Add realtime invalidation for web views#4
Draft
mjc wants to merge 1 commit into
Draft
Conversation
fc69268 to
8c1ab9f
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a websocket-based “realtime invalidation” channel so mounted web UI views can refetch via their existing HTTP loaders when issue/project data changes, and removes/relaxes prior 15s polling in several views.
Changes:
- Backend: adds a
RealtimeHub+/api/events/wswebsocket endpoint (cookie-session auth + origin policy) and emits invalidation events from REST + MCP write paths. - Frontend: establishes a single reconnecting websocket in
App.svelteand dispatches events into the existingstartAutoRefreshhelper. - Frontend: replaces refresh-on-everything polling with event-filtered refresh logic in some views, and removes polling in others.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/routes/ProjectActivity.svelte | Switches auto-refresh to event-filtered invalidation instead of fixed polling. |
| web/src/routes/PlanList.svelte | Removes polling from plan list auto-refresh. |
| web/src/routes/PlanDetail.svelte | Removes polling from plan detail auto-refresh. |
| web/src/routes/PageList.svelte | Removes polling from page list auto-refresh. |
| web/src/routes/IssueList.svelte | Switches issues list auto-refresh to event-filtered invalidation instead of fixed polling. |
| web/src/routes/IssueDetail.svelte | Adds busy-guarded invalidation refresh and binds editor mode to prevent disruptive reloads. |
| web/src/lib/autoRefresh.svelte.ts | Adds realtime event integration, coalescing/pending refresh behavior, and refresh failure logging. |
| web/src/App.svelte | Adds websocket connect/reconnect logic and dispatches invalidation events into the app. |
| src/realtime.rs | Introduces the realtime hub, event enum, and websocket servicing loop. |
| src/mcp/tools.rs | Emits realtime invalidation events from MCP write operations (issues/projects/relations/comments). |
| src/mcp/mod.rs | Wires a shared RealtimeHub into MCP so writes can emit invalidation events. |
| src/main.rs | Registers the realtime module, shares the hub across REST + MCP routers, and adjusts CORS/auth skip logic. |
| src/authz_coverage_tests.rs | Updates REST manifest coverage to account for the websocket endpoint. |
| src/api/projects.rs | Emits project invalidation events for create/update/delete/reorder. |
| src/api/mod.rs | Adds /api/events/ws route and websocket auth/origin validation helpers. |
| src/api/issues.rs | Emits issue invalidation events for create/update/delete/link/unlink + adds a realtime emission test. |
| src/api/comments.rs | Emits issue invalidation events on issue-comment create/update/delete. |
| src/api/attachments.rs | Updates tests/apps to include the realtime hub extension. |
| Cargo.toml | Enables Axum websocket support. |
| Cargo.lock | Locks new websocket-related transitive dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7da9d43 to
fd03b18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a small realtime invalidation path for the web UI: writes broadcast that affected issue/project data changed, and mounted views refetch through their existing HTTP loaders. The socket does not stream canonical object state or try to merge data client-side.
This keeps the change scoped to the delay called out in #3 while covering both write paths that can change what the UI is showing: REST handlers and MCP tools.
What Changed
/api/events/wsendpoint backed by the existing browser session cookie.Origin, same-origin browser requests, or explicitly configured origins are accepted.Deliberate Scope
This is invalidation-only realtime. HTTP remains the source of truth for view data.