fix: reduce settings SSE noise and restore typecheck#385
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces background SSE activity while users are on settings pages and addresses several TypeScript typing issues so bun run typecheck passes again.
Changes:
- Suspend per-project background SSE connections when the current route is a settings page.
- Centralize route tracking (active directory + pathname) at the app level and pass pathname down to
GlobalEventsProvider. - Fix assorted TS issues in the proxy SSE headers, theme media query listeners, entry mounting, and timer cleanup.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
shared/proxy.ts |
Builds SSE + CORS response headers via Headers to satisfy types and keep SSE headers explicit. |
app-prefixable/src/pages/layout.tsx |
Adjusts daily timer handling to avoid type issues around setTimeout return types. |
app-prefixable/src/entry.tsx |
Minor refactor of the mount element usage for type/clarity consistency. |
app-prefixable/src/context/theme.tsx |
Adds a typed legacy matchMedia listener path to satisfy TS and support older APIs. |
app-prefixable/src/context/server.tsx |
Fixes a TS cast issue when treating server configs as generic records. |
app-prefixable/src/context/global-events.tsx |
Disconnects/suspends background SSE connections on settings routes (and remote servers). |
app-prefixable/src/app.tsx |
Introduces useRouteState() and threads pathname into GlobalEventsProvider; adjusts index redirects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function DirectoryIndex() { | ||
| const params = useParams<{ dir: string }>() | ||
| return <Navigate href={getLastSessionHref(params.dir)} replace /> | ||
| return <Navigate href={getLastSessionHref(params.dir)} /> | ||
| } |
There was a problem hiding this comment.
Removing replace from this redirect changes browser history behavior: navigating to /:dir will now add an extra history entry before redirecting to the session route, which can create a back-button loop (back -> /:dir -> redirect forward again). If the router no longer supports replace on <Navigate>, consider implementing this redirect via useNavigate() with { replace: true } in an effect/onMount to preserve the previous semantics.
| const params = useParams<{ dir: string }>() | ||
| const href = getLastSessionHref(params.dir) | ||
| if (href === "session") return <Session /> | ||
| const id = href.replace(/^session\//, "") | ||
| return <Navigate href={id} replace /> | ||
| return <Navigate href={id} /> | ||
| } |
There was a problem hiding this comment.
Same as above: dropping replace here will push an extra history entry when redirecting from /session to the last session id, which can make back navigation bounce between the index route and the redirected route. If replace isn't available on <Navigate>, switch to an imperative navigate(href, { replace: true }) redirect to avoid polluting history.
Summary
/eventrequestsGlobalEventsProviderbun run typecheckpasses againTesting