From a3c066a47305ec33b42832b89176a23e6cfa6ab4 Mon Sep 17 00:00:00 2001 From: 404kidwiz <404kidwiz@gmail.com> Date: Sun, 21 Jun 2026 20:23:11 -0400 Subject: [PATCH] Keep post-auth routing compatible with React lint Move pending MCP redirect parsing out of JSX construction so the route component keeps rendering pure while preserving the same fallback behavior. Constraint: React lint forbids constructing JSX inside try/catch because render errors are not caught that way. Rejected: Suppress the eslint rule | The helper is smaller and keeps the rule useful. Confidence: high Scope-risk: narrow Directive: Preserve the one-shot sessionStorage consume behavior for interrupted MCP OAuth redirects. Tested: pnpm --filter @memwal/app lint; pnpm --filter @memwal/app build; cargo test in services/server; cargo test in services/indexer Not-tested: Live OAuth MCP redirect flow in browser --- apps/app/src/App.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/app/src/App.tsx b/apps/app/src/App.tsx index 5e0e0586..9f1ad14a 100644 --- a/apps/app/src/App.tsx +++ b/apps/app/src/App.tsx @@ -221,6 +221,16 @@ function RoutePending() { * Shared with ConnectMcp.tsx (kept as a literal there to avoid a circular import). */ const MCP_CONNECT_STORAGE_KEY = 'memwal_mcp_connect' +function parsePendingMcpConnectPath(pending: string) { + try { + const params = JSON.parse(pending) as Record + const qs = new URLSearchParams(params).toString() + return qs ? `/connect/mcp?${qs}` : null + } catch { + return null + } +} + /** Lands here after a successful sign-in (the OAuth redirect_uri is the app * root). If a /connect/mcp flow was interrupted by that redirect, resume it * by restoring the saved query string; otherwise go to the dashboard. */ @@ -229,11 +239,8 @@ function PostAuthRedirect() { if (pending) { // Consume once — prevents a redirect loop on later visits to `/`. sessionStorage.removeItem(MCP_CONNECT_STORAGE_KEY) - try { - const params = JSON.parse(pending) as Record - const qs = new URLSearchParams(params).toString() - if (qs) return - } catch { /* fall through to dashboard */ } + const resumePath = parsePendingMcpConnectPath(pending) + if (resumePath) return } return }