Skip to content

feat: reload all browser tabs on server restart#70

Merged
k1LoW merged 9 commits intomainfrom
reload-all-browsers-on-restart
Mar 6, 2026
Merged

feat: reload all browser tabs on server restart#70
k1LoW merged 9 commits intomainfrom
reload-all-browsers-on-restart

Conversation

@k1LoW
Copy link
Copy Markdown
Owner

@k1LoW k1LoW commented Mar 6, 2026

Summary

  • Send a started SSE event containing the server PID when each client connects
  • Frontend remembers the PID on first connection and triggers window.location.reload() when a different PID is detected after reconnection
  • This ensures all open browser tabs reload on server restart, not just the tab that clicked the restart button
  • Network-only disconnects (same PID) do not cause unnecessary reloads

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.
@github-actions

This comment has been minimized.

@k1LoW k1LoW self-assigned this Mar 6, 2026
@k1LoW k1LoW requested a review from Copilot March 6, 2026 04:00
@k1LoW k1LoW added the enhancement New feature or request label Mar 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 started SSE event on each / _/events connection 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.

Comment thread internal/server/server.go
Comment thread internal/server/server.go Outdated
k1LoW added 3 commits March 6, 2026 13:14
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.
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/server/server_test.go
Comment thread internal/server/server_test.go
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/server/server_test.go Outdated
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/frontend/src/hooks/useSSE.ts
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/frontend/src/hooks/useSSE.test.ts Outdated
Comment thread internal/frontend/src/hooks/useSSE.test.ts Outdated
Comment thread internal/frontend/src/hooks/useSSE.test.ts Outdated
Comment thread internal/frontend/src/hooks/useSSE.test.ts
Comment thread internal/frontend/src/hooks/useSSE.test.ts
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/server/server_test.go Outdated
Comment thread internal/frontend/src/hooks/useSSE.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

Code Metrics Report

main (4b31307) #70 (d518bca) +/-
Coverage 40.8% 43.6% +2.7%
Code to Test Ratio 1:0.5 1:0.5 +0.0
Test Execution Time 32s 32s 0s
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%)

Files Coverage +/- Status
internal/frontend/src/hooks/useSSE.ts 85.7% +85.7% modified
internal/server/server.go 52.0% +3.9% modified

Reported by octocov

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@k1LoW k1LoW merged commit bc05e20 into main Mar 6, 2026
7 checks passed
@k1LoW k1LoW deleted the reload-all-browsers-on-restart branch March 6, 2026 09:28
@github-actions github-actions Bot mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants