fix: reduce settings SSE noise#410
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces unnecessary background SSE traffic while users are on settings routes, and re-applies several typecheck-oriented fixes from the superseded PR (#385) onto current main.
Changes:
- Suspend inactive-project
GlobalEventsProviderSSE connections while the current route is/settings. - Replace
<Navigate replace>usage with imperativeuseNavigate(..., { replace: true })redirects. - Minor type-safety and runtime robustness tweaks across proxy SSE headers, theme media query listeners, timer cleanup, and entry mounting.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
shared/proxy.ts |
Refactors CORS/SSE header construction using Headers for SSE responses. |
app-prefixable/src/pages/layout.tsx |
Simplifies midnight reschedule timer tracking and cleanup typing. |
app-prefixable/src/entry.tsx |
Uses a mount alias for the root element consistently in render/error paths. |
app-prefixable/src/context/theme.tsx |
Improves typing/compat handling for legacy matchMedia listeners. |
app-prefixable/src/context/server.tsx |
Adjusts casting to satisfy typechecking when reading persisted server metadata. |
app-prefixable/src/context/global-events.tsx |
Adds pathname-driven suspension of background per-project SSE connections on settings routes. |
app-prefixable/src/app.tsx |
Introduces useRouteState() and switches redirects to imperative navigation; passes pathname to GlobalEventsProvider. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+124
to
+134
| if (isSSE) { | ||
| if (!response.ok) { | ||
| console.error("[Proxy] SSE error:", response.status, response.statusText) | ||
| return new Response(response.body, { status: response.status, headers: corsHeaders }) | ||
| } | ||
|
|
||
| const headers = new Headers(corsHeaders) | ||
| headers.set("Content-Type", "text/event-stream") | ||
| headers.set("Cache-Control", "no-cache") | ||
| headers.set("Connection", "keep-alive") | ||
| headers.set("X-Accel-Buffering", "no") |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
app-prefixable/src/context/server.tsx:82
- After
.filter(isValidServerEntry),sis already aServerConfig, so the double-casts as unknown as Record<string, unknown>unnecessarily discards type safety and forcesobj.id as stringaccess. Prefer using the strongly-typed fields directly (e.g.s.id,s.authMethod) or a single, minimal cast if you truly need index access.
.filter(isValidServerEntry)
.map((s) => {
const obj = s as unknown as Record<string, unknown>
// Prefer credentials from sessionStorage; fall back to authMethod stub
if (creds[obj.id as string]) {
return { ...s, auth: normalizeAuth({ auth: creds[obj.id as string] } as unknown as Record<string, unknown>) }
}
| schedule(); | ||
| onCleanup(() => clearTimeout(timer.id)); | ||
| onCleanup(() => { | ||
| if (timer) clearTimeout(timer); |
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
main.GlobalEventsProviderSSE connections while viewing settings routes.<Navigate replace>usage with imperativeuseNavigate(..., { replace: true })redirects to preserve back-button behavior.Original PR
Testing
bun run typecheckbun run buildbunx eslint src/app.tsx src/context/global-events.tsxNotes
bun run lintstill fails on existing lint debt outside this change, including Solid refno-unassigned-vars, empty blocks incontext/server.tsx, and other pre-existing warnings/errors.