feat: reload all browser tabs on server restart#70
Conversation
Send a `started` SSE event with the server PID on each client connection. The frontend remembers the PID and triggers a full page reload when it detects a different PID after reconnecting, ensuring all open tabs refresh on server restart rather than only the tab that initiated the restart.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds a server-identity handshake over SSE so the frontend can detect when it has reconnected to a different server process and force a full page reload. This aligns with mo’s “single instance + restart” behavior by ensuring all open tabs reload after a server restart.
Changes:
- Emit an initial
startedSSE event on each/ _/eventsconnection containing the server PID. - Track the first-seen PID in the frontend and trigger
window.location.reload()if a different PID is observed after reconnection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/server/server.go | Sends a started SSE event with the current PID immediately upon SSE connection. |
| internal/frontend/src/hooks/useSSE.ts | Listens for started and reloads the page when the server PID changes across reconnects. |
You can also share your feedback on Copilot code review. Take the survey.
Remove unnecessary nested fmt.Sprintf in started event. Add test to verify the SSE endpoint sends a started event with the server PID on connection.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
You can also share your feedback on Copilot code review. Take the survey.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
You can also share your feedback on Copilot code review. Take the survey.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
You can also share your feedback on Copilot code review. Take the survey.
Code Metrics Report
Details | | main (4b31307) | #70 (d518bca) | +/- |
|---------------------|----------------|---------------|-------|
+ | Coverage | 40.8% | 43.6% | +2.7% |
| Files | 29 | 29 | 0 |
| Lines | 2096 | 2109 | +13 |
+ | Covered | 856 | 920 | +64 |
+ | Code to Test Ratio | 1:0.5 | 1:0.5 | +0.0 |
| Code | 3483 | 3498 | +15 |
+ | Test | 1824 | 1912 | +88 |
| Test Execution Time | 32s | 32s | 0s |Code coverage of files in pull request scope (46.6% → 53.4%)
Reported by octocov |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
You can also share your feedback on Copilot code review. Take the survey.
Summary
startedSSE event containing the server PID when each client connectswindow.location.reload()when a different PID is detected after reconnection