Skip to content

fix: reduce settings SSE noise#410

Merged
hsteude merged 3 commits into
mainfrom
rework-385-settings-sse-typecheck
May 13, 2026
Merged

fix: reduce settings SSE noise#410
hsteude merged 3 commits into
mainfrom
rework-385-settings-sse-typecheck

Conversation

@hsteude
Copy link
Copy Markdown
Contributor

@hsteude hsteude commented May 13, 2026

Summary

  • Supersedes fix: reduce settings SSE noise and restore typecheck #385 by reapplying the still-relevant settings SSE and typecheck fixes on current main.
  • Suspends inactive-project GlobalEventsProvider SSE connections while viewing settings routes.
  • Replaces typed-unsupported <Navigate replace> usage with imperative useNavigate(..., { replace: true }) redirects to preserve back-button behavior.

Original PR

Testing

  • bun run typecheck
  • bun run build
  • bunx eslint src/app.tsx src/context/global-events.tsx

Notes

  • Full bun run lint still fails on existing lint debt outside this change, including Solid ref no-unassigned-vars, empty blocks in context/server.tsx, and other pre-existing warnings/errors.

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

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 GlobalEventsProvider SSE connections while the current route is /settings.
  • Replace <Navigate replace> usage with imperative useNavigate(..., { 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 thread shared/proxy.ts Outdated
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")
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 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), s is already a ServerConfig, so the double-cast s as unknown as Record<string, unknown> unnecessarily discards type safety and forces obj.id as string access. 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>) }
            }

Comment thread app-prefixable/src/pages/layout.tsx Outdated
schedule();
onCleanup(() => clearTimeout(timer.id));
onCleanup(() => {
if (timer) clearTimeout(timer);
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 7 out of 7 changed files in this pull request and generated no new comments.

@hsteude hsteude merged commit e4a7915 into main May 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants