Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"require-in-the-middle": "8.0.1",
"server-only": "^0.0.1",
"superjson": "^2.2.5",
"zod": "^4.1.13"
"zod": "^4.3.5"
},
"devDependencies": {
"@superset/typescript": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@electric-sql/client": "1.4.0",
"@electric-sql/client": "https://pkg.pr.new/@electric-sql/client@3724",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check the full package.json context around the specified lines
cat -n apps/api/package.json | head -50

Repository: superset-sh/superset

Length of output: 184


🏁 Script executed:

# List the directory structure to understand the project layout
git ls-files apps/api/ | head -30

Repository: superset-sh/superset

Length of output: 184


🏁 Script executed:

# Search for zod usage in the codebase to understand compatibility concerns
rg "from ['\"]zod['\"]|import.*zod" --type ts --type tsx --type js -A 2

Repository: superset-sh/superset

Length of output: 184


🏁 Script executed:

# Check if there are any version constraints or compatibility notes
rg "@electric-sql" --type ts --type tsx --type js -A 1 -B 1

Repository: superset-sh/superset

Length of output: 184


🌐 Web query:

pkg.pr.new package registry ephemeral builds dependency

💡 Result:

Brief summary — what pkg.pr.new does and how its ephemeral preview packages & dependencies work:

  • What it is: a GitHub App + CLI that publishes per-commit / per-PR preview releases to a temporary, npm‑compatible registry so you can install unreleased builds without publishing to npm. [1][2]

  • How to use it: run the CLI (npx pkg-pr-new publish) from a GitHub Actions workflow (supports monorepos/workspaces and templates for StackBlitz). The CLI produces installable URLs like npm i https://pkg.pr.new/@ or shorter compact forms when configured. [2][4]

  • Ephemeral storage / retention: preview packages are stored in Cloudflare R2; pkg.pr.new is intentionally temporary — unused packages are garbage‑collected (examples: cleanup rules removing packages not downloaded for ~1 month and older-than‑6‑months removals are used in implementations). This means previews are not permanent and may be removed after inactivity/time. [3]

  • Dependency handling: pkg.pr.new publishes packed artifacts (npm pack style). It has flags to influence packing and dependency behavior (e.g., --pnpm / --yarn, and a --peerDeps option to control how peerDependencies are represented). Installs from the preview registry are npm‑compatible so package managers resolve them the same way as normal tarball URLs. [2][4]

Sources:

  • Announcement / blog (overview, usage examples). [1]
  • pkg.pr.new GitHub repo (setup, CLI flags, URL formats, templates, workflow usage). [2]
  • Implementation notes / R2 storage & cleanup details (ephemeral retention). [3]
  • CLI/source code showing pack/peerDeps behavior. [4]

🌐 Web query:

zod version 4.3.5 npm registry stability

💡 Result:

Short answer: Zod 4.3.5 is part of Zod 4 (declared stable by the author) and has no known direct security vulnerabilities in public vulnerability databases; however there are recent build/packaging issues reported (module-federation warning / package.json metadata) you should test for your use-case. Sources:

  • Zod 4 is considered stable by the project. [1]
  • No known direct vulnerabilities for [email protected] (Snyk security scan). [2]
  • [email protected] metadata/packaging and related build issues have active GitHub reports (module federation / package.json version in dist). [3]
  • Registry/package listing showing recent 4.x releases. [4]

References:
[1] https://zod.dev/v4/versioning
[2] https://security.snyk.io/package/npm/zod%404.3.5
[3] colinhacks/zod#4656
[4] https://socket.dev/npm/package/zod


🌐 Web query:

@electric-sql/client npm package versions

💡 Result:

Latest published version: 1.0.10 (see npm). [1]

To list all published versions locally run:

  • npm view @electric-sql/client versions --json

Sources:

  • npm package page for @electric-sql/client. [1]
  • unpkg package files (package README and archive). [2]

Replace PR-hosted @electric-sql/client with published registry version; validate Zod v4 compatibility.

The pkg.pr.new registry publishes ephemeral preview packages with automatic garbage collection (removed after ~1 month of inactivity or 6+ months old), making it unsuitable for stable dependencies. Switch to the latest published version (@electric-sql/client@1.0.10 or newer from npm registry). Additionally, test Zod v4.3.5 behavior against your schemas to ensure compatibility with any v3→v4 breaking changes.

🤖 Prompt for AI Agents
In `@apps/api/package.json` at line 14, Replace the PR-hosted dependency entry
"@electric-sql/client": "https://pkg.pr.new/@electric-sql/client@3724" with the
published npm registry version (e.g. "@electric-sql/client": "1.0.10" or newer)
in package.json and run yarn/npm install to update lockfile; then run your test
suite and any integration flows that use the Electric client, and separately
validate Zod schemas against Zod v4.3.5 (upgrade Zod in package.json if needed)
to check for v3→v4 breaking changes and adjust schema definitions where failures
occur.

"@linear/sdk": "^68.1.0",
"@sentry/nextjs": "^10.32.1",
"@superset/auth": "workspace:*",
Expand All @@ -32,7 +32,7 @@
"react": "^19.2.3",
"react-dom": "^19.2.3",
"require-in-the-middle": "8.0.1",
"zod": "^4.1.13"
"zod": "^4.3.5"
},
"devDependencies": {
"@superset/typescript": "workspace:*",
Expand Down
20 changes: 2 additions & 18 deletions apps/api/src/app/api/electric/[...path]/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
repositories,
taskStatuses,
tasks,
users,
} from "@superset/db/schema";
import { eq, inArray, sql } from "drizzle-orm";
import type { PgColumn, PgTable } from "drizzle-orm/pg-core";
Expand Down Expand Up @@ -95,23 +94,8 @@ export async function buildWhereClause(
}

case "auth.users": {
const orgMembers = await db.query.members.findMany({
where: eq(members.organizationId, organizationId),
columns: { userId: true },
});
if (orgMembers.length === 0) {
return { fragment: "1 = 0", params: [] };
}
const userIds = [...new Set(orgMembers.map((m) => m.userId))];
const whereExpr = inArray(sql`${sql.identifier(users.id.name)}`, userIds);
const qb = new QueryBuilder();
const { sql: query, params } = qb
.select()
.from(users)
.where(whereExpr)
.toSQL();
const fragment = query.replace(/^select .* from .* where\s+/i, "");
return { fragment, params };
const fragment = `$1 = ANY("organization_ids")`;
return { fragment, params: [organizationId] };
}

default:
Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/trpc/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ export const createContext = async ({
const session = await auth.api.getSession({
headers: req.headers,
});
return createTRPCContext({ session });
return createTRPCContext({
session,
auth,
headers: req.headers,
});
};
11 changes: 7 additions & 4 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@electric-sql/client": "1.4.0",
"@electric-sql/client": "https://pkg.pr.new/@electric-sql/client@3724",
"@hookform/resolvers": "^5.2.2",
Comment on lines +39 to +40
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e

echo "=== Checking PR-hosted `@electric-sql/client` package ==="
if curl -Ifs https://pkg.pr.new/@electric-sql/client@3724 > /dev/null 2>&1; then
  echo "`@electric-sql/client`@3724 is accessible"
else
  echo "`@electric-sql/client`@3724 is NOT accessible"
fi

echo ""
echo "=== Checking npm package availability ==="

# Check each package version
packages=(
  "@hookform/[email protected]"
  "[email protected]"
  "@tanstack/[email protected]"
  "@tanstack/[email protected]"
  "@vercel/[email protected]"
  "[email protected]"
)

if command -v npm >/dev/null 2>&1; then
  for pkg in "${packages[@]}"; do
    version=$(npm view "$pkg" version 2>/dev/null || echo "NOT FOUND")
    echo "$pkg: $version"
  done
else
  echo "npm not available; checking via curl to registry"
  for pkg in "${packages[@]}"; do
    pkg_name=$(echo "$pkg" | cut -d'@' -f1-$(echo "$pkg" | grep -o '@' | wc -l))
    pkg_version=$(echo "$pkg" | rev | cut -d'@' -f1 | rev)
    result=$(curl -s "https://registry.npmjs.org/${pkg_name}/${pkg_version}" | grep -q '"version"' && echo "EXISTS" || echo "NOT FOUND")
    echo "$pkg: $result"
  done
fi

Repository: superset-sh/superset

Length of output: 184


🌐 Web query:

@hookform/resolvers npm registry version 5.2.2

💡 Result:

Yes — @hookform/resolvers version 5.2.2 is published. Install with:

npm install @hookform/resolvers@5.2.2

Sources: npm registry / package data. [1][2]

References

  • npm package listing (jsDelivr/npm): version 5.2.2. [1]
  • Package overview / registry snapshot (Socket.dev). [2]

🌐 Web query:

react-hook-form npm registry version 7.71.1

💡 Result:

react-hook-form version 7.71.1 is published on the npm registry. Install with:

npm install [email protected]

You can verify the published version via the package registry listings. [1][2]

Sources:

  1. Snyk package page for react-hook-form (shows latest 7.71.1). [1]
  2. Socket / package listing for react-hook-form (version activity). [2]

🌐 Web query:

@vercel/blob npm registry version 2.0.0

💡 Result:

Yes — @vercel/blob@2.0.0 is published on the npm registry. See the package.json for v2.0.0 and CDN listings. [1][2][3]

You can install it with:
npm install @vercel/blob@2.0.0

Sources:

  • package.json for @vercel/blob@2.0.0 (unpkg). [1]
  • jsDelivr package page showing v2.0.0. [2]
  • Snyk package page listing latest version 2.0.0. [3]

🌐 Web query:

zod npm registry version 4.3.5

💡 Result:

zod version 4.3.5 is published to the npm registry (published Jan 4, 2026). Install with:

npm install [email protected]

Sources: [1][2][3]

References
[1] Socket package page showing version 4.3.5. (socket.dev)
[2] Yarn package page (lists 4.3.5, Jan 4, 2026). (classic.yarnpkg.com)
[3] Snyk package page for zod (latest 4.3.5). (security.snyk.io)

Citations:


🌐 Web query:

@tanstack/react-db npm registry

💡 Result:

Yes — @tanstack/react-db is published on the npm registry.

  • Install: npm i @tanstack/react-db. [1][2]
  • Repository: github.com/TanStack/db. [3]
  • Docs (React adapter + usage): tanstack.com/db (React docs). [2]
  • npm package page (metadata, version, downloads, license): @tanstack/react-db on npm. [1]

Sources:
[1] npm package page for @tanstack/react-db.
[2] TanStack DB docs — React adapter / installation.
[3] TanStack DB GitHub repository.


🌐 Web query:

@electric-sql/client PR-hosted package pkg.pr.new 3724

💡 Result:

I’m missing context — do you want the pkg.pr.new preview URL for PR #3724 of the @electric-sql/client repo, or information about a specific preview package build (logs, artifacts, or install command)? Which repo/PR link should I look up?


🌐 Web query:

@tanstack/react-db version 0.1.64 npm

💡 Result:

Yes — @tanstack/react-db v0.1.64 has been released (listed in release tracking). [1][2]

Sources:

  • Release listing (newreleases.io) showing @tanstack/react-db@0.1.64. [1]
  • jsDelivr package index (shows nearby versions for @tanstack/react-db). [2]

🌐 Web query:

@tanstack/electric-db-collection version 0.2.24 npm

💡 Result:

I couldn't find an npm release for @tanstack/electric-db-collection at version 0.2.24. The npm package page shows v0.1.12 (recently published). A package index (socket.dev) lists up to v0.2.19 as the latest. [1][2]

Sources:

  • npm package page for @tanstack/electric-db-collection (shows v0.1.12). [1]
  • Socket.dev package index (lists v0.2.19 as latest). [2]

🌐 Web query:

electric-sql/client pkg.pr.new preview package

💡 Result:

I’m not sure what you mean by “pkg.pr.new.” Do you want:

  • information about the @electric-sql/client preview package on npm (latest preview/experimental releases), or
  • instructions for installing a preview/prerelease package for Electric (e.g., an npm tag like next/canary/experimental), or
  • something else (link, changelog, or how to test a preview)?

Tell me which and I’ll fetch the exact package name, version, and install command.


@tanstack/electric-db-collection version mismatch: 0.2.24 does not exist.

Most dependencies verify successfully (@hookform/resolvers@5.2.2, [email protected], @vercel/blob@2.0.0, [email protected], @tanstack/react-db@0.1.64 are all published), but @tanstack/electric-db-collection@0.2.24 is not available in the npm registry—the latest release is v0.2.19. Update the version in package.json or confirm the intended version. The PR-hosted @electric-sql/client@3724 package cannot be verified through public sources and should be tested in your build/deployment pipeline.

🤖 Prompt for AI Agents
In `@apps/desktop/package.json` around lines 39 - 40, The package.json lists an
unavailable dependency version: update the `@tanstack/electric-db-collection`
entry (referenced alongside "@electric-sql/client" and "@hookform/resolvers") to
a published version (e.g., change 0.2.24 to the latest published v0.2.19) or
confirm and pin the intended release; also ensure the PR-hosted
"@electric-sql/client@3724" reference is validated in your CI/build pipeline or
replaced with a verifiable package before merging.

"@monaco-editor/react": "^4.7.0",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-label": "^2.1.8",
Expand All @@ -49,15 +50,16 @@
"@superset/ui": "workspace:*",
"@t3-oss/env-core": "^0.13.8",
"@tanstack/db": "^0.5.16",
"@tanstack/electric-db-collection": "^0.2.20",
"@tanstack/react-db": "^0.1.60",
"@tanstack/electric-db-collection": "0.2.24",
"@tanstack/react-db": "0.1.64",
"@tanstack/react-query": "^5.90.10",
"@tanstack/react-router": "^1.147.3",
"@tanstack/react-table": "^8.21.3",
"@trpc/client": "^11.7.1",
"@trpc/react-query": "^11.7.1",
"@trpc/server": "^11.7.1",
"@types/express": "^5.0.5",
"@vercel/blob": "^2.0.0",
"@xterm/addon-canvas": "^0.7.0",
"@xterm/addon-clipboard": "^0.1.0",
"@xterm/addon-fit": "^0.10.0",
Expand Down Expand Up @@ -107,6 +109,7 @@
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^19.2.3",
"react-hook-form": "^7.71.1",
"react-icons": "^5.5.0",
"react-markdown": "^10.1.0",
"react-mosaic-component": "^6.1.1",
Expand All @@ -124,7 +127,7 @@
"trpc-electron": "^0.1.2",
"tw-animate-css": "^1.4.0",
"unique-names-generator": "^4.7.1",
"zod": "^4.1.13",
"zod": "^4.3.5",
"zustand": "^5.0.8"
},
"devDependencies": {
Expand Down
14 changes: 5 additions & 9 deletions apps/desktop/src/lib/trpc/routers/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import {

export const createAuthRouter = () => {
return router({
getStoredToken: publicProcedure.query(async () => {
return await loadToken();
}),
getStoredToken: publicProcedure.query(() => loadToken()),

persistToken: publicProcedure
.input(
Expand Down Expand Up @@ -63,10 +61,10 @@ export const createAuthRouter = () => {
const state = crypto.randomBytes(32).toString("base64url");
stateStore.set(state, Date.now());

// Clean up old states (older than 10 minutes)
const tenMinutesAgo = Date.now() - 10 * 60 * 1000;
// Clean up expired states (10 minutes)
const cutoff = Date.now() - 10 * 60 * 1000;
for (const [s, ts] of stateStore) {
if (ts < tenMinutesAgo) stateStore.delete(s);
if (ts < cutoff) stateStore.delete(s);
}

const connectUrl = new URL(
Expand All @@ -86,9 +84,7 @@ export const createAuthRouter = () => {
}),

signOut: publicProcedure.mutation(async () => {
try {
await fs.unlink(TOKEN_FILE);
} catch {}
await fs.unlink(TOKEN_FILE).catch(() => {});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n apps/desktop/src/lib/trpc/routers/auth/index.ts | head -100

Repository: superset-sh/superset

Length of output: 3227


Don't silently ignore token deletion failures. Swallowing unlink errors can leave a valid token on disk while reporting success. At minimum log with context, and distinguish between expected (file not found) and unexpected errors.

🐛 Suggested fix (log + fail on unexpected errors)
-			await fs.unlink(TOKEN_FILE).catch(() => {});
+			await fs.unlink(TOKEN_FILE).catch((err: NodeJS.ErrnoException) => {
+				if (err?.code !== "ENOENT") {
+					console.warn("[auth/signOut] failed to delete token file", err);
+					throw err;
+				}
+			});
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await fs.unlink(TOKEN_FILE).catch(() => {});
await fs.unlink(TOKEN_FILE).catch((err: NodeJS.ErrnoException) => {
if (err?.code !== "ENOENT") {
console.warn("[auth/signOut] failed to delete token file", err);
throw err;
}
});
🤖 Prompt for AI Agents
In `@apps/desktop/src/lib/trpc/routers/auth/index.ts` at line 87, Replace the
silent swallow of fs.unlink(TOKEN_FILE).catch(() => {}) so that deletion
failures are handled: call fs.unlink(TOKEN_FILE) inside a try/catch (or attach
.catch(err => { ... })), log the error with context including TOKEN_FILE when
err.code !== 'ENOENT', and surface or rethrow unexpected errors instead of
returning success; treat ENOENT as non-fatal (optional debug log) but log and
fail on other errors. Use the existing TOKEN_FILE identifier and the surrounding
auth router function where the unlink is called to locate and update the code.

return { success: true };
}),
});
Expand Down
33 changes: 33 additions & 0 deletions apps/desktop/src/lib/trpc/routers/cache/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { session } from "electron";
import { env } from "main/env.main";
import { publicProcedure, router } from "../..";

export const createCacheRouter = () => {
return router({
clearElectricCache: publicProcedure.mutation(async () => {
try {
// Clear all storage (including HTTP cache) for the API origin only
// This targets Electric shape responses without clearing app assets
await session.defaultSession.clearStorageData({
origin: env.NEXT_PUBLIC_API_URL,
});

console.log(
"[cache] Cleared Electric cache for origin:",
env.NEXT_PUBLIC_API_URL,
);

return { success: true };
} catch (error) {
console.error("[cache] Failed to clear Electric cache:", error);
Comment on lines +11 to +22
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cd apps/desktop/src/lib/trpc/routers/cache && cat -n index.ts | head -30

Repository: superset-sh/superset

Length of output: 1135


🏁 Script executed:

rg "\[cache" apps/desktop --type ts --type tsx -A 1 | head -50

Repository: superset-sh/superset

Length of output: 91


🏁 Script executed:

rg "NEXT_PUBLIC_API_URL" --type ts --type tsx | head -20

Repository: superset-sh/superset

Length of output: 91


🏁 Script executed:

rg "\[.*\/.*\]" apps/desktop --type ts -B 1 -A 1 | head -40

Repository: superset-sh/superset

Length of output: 144


🏁 Script executed:

rg "clearStorageData" --type ts -B 3 -A 3

Repository: superset-sh/superset

Length of output: 659


🏁 Script executed:

rg "NEXT_PUBLIC_API_URL" --type ts -B 2 -A 2 | head -30

Repository: superset-sh/superset

Length of output: 1615


🏁 Script executed:

rg "console\.(log|error)" apps/desktop/src/lib/trpc --type ts -A 0 | head -30

Repository: superset-sh/superset

Length of output: 3024


🏁 Script executed:

rg "\[domain.*operation\]|\[.*\/.*\] " apps --type ts -A 0 | head -40

Repository: superset-sh/superset

Length of output: 189


🏁 Script executed:

cat packages/trpc/src/env.ts | grep -A 2 -B 2 "NEXT_PUBLIC_API_URL"

Repository: superset-sh/superset

Length of output: 265


🏁 Script executed:

rg "console\.(log|error)" apps/desktop/src/lib/trpc --type ts -B 1 -A 1 | grep "\[" | head -20

Repository: superset-sh/superset

Length of output: 2797


🏁 Script executed:

cat apps/desktop/src/lib/trpc/routers/workspaces/utils/shell-env.ts | grep console.log | head -5

Repository: superset-sh/superset

Length of output: 206


🏁 Script executed:

python3 << 'EOF'
# Check if NEXT_PUBLIC_API_URL is validated as a full URL
import re
test_urls = [
    "https://api.example.com",
    "https://api.example.com/path",
    "https://api.example.com:3000",
]
for url in test_urls:
    parsed = url.split('?')[0].split('#')[0]  # Remove query/fragment
    origin = parsed.rsplit('/', 1)[0] if '/' in parsed[8:] else parsed  # Simple extraction
    print(f"URL: {url}")
    print(f"  Would use origin: {origin}")
    print(f"  Different from URL: {origin != url}")
    print()
EOF

Repository: superset-sh/superset

Length of output: 150


🏁 Script executed:

cat apps/desktop/src/lib/trpc/routers/cache/index.ts | head -35

Repository: superset-sh/superset

Length of output: 993


🏁 Script executed:

cd apps/desktop && cat tsconfig.json | grep -A 20 "paths"

Repository: superset-sh/superset

Length of output: 322


🏁 Script executed:

rg "new URL" apps/desktop --type ts -B 2 -A 2 | head -20

Repository: superset-sh/superset

Length of output: 1530


Update log prefix to follow [domain/operation] convention and normalize API origin.

Per coding guidelines, log prefixes should use [domain/operation] format. The current [cache] prefix needs updating to [cache/clear]. Additionally, clearStorageData expects an origin (protocol + domain + port); if NEXT_PUBLIC_API_URL includes a path, it may not work correctly. Use new URL(...).origin to extract the origin safely.

🛠️ Suggested update
-				await session.defaultSession.clearStorageData({
-					origin: env.NEXT_PUBLIC_API_URL,
-				});
-
-				console.log(
-					"[cache] Cleared Electric cache for origin:",
-					env.NEXT_PUBLIC_API_URL,
-				);
+				const apiOrigin = new URL(env.NEXT_PUBLIC_API_URL).origin;
+				await session.defaultSession.clearStorageData({ origin: apiOrigin });
+
+				console.log("[cache/clear] Cleared Electric cache for origin:", apiOrigin);
🤖 Prompt for AI Agents
In `@apps/desktop/src/lib/trpc/routers/cache/index.ts` around lines 11 - 22,
Update the logging prefix and normalize the API origin before calling
session.defaultSession.clearStorageData: replace the "[cache]" prefix in the
console.log and console.error calls with "[cache/clear]" and compute the origin
via new URL(env.NEXT_PUBLIC_API_URL).origin (use that variable when calling
session.defaultSession.clearStorageData and in the log message) to ensure
clearStorageData receives a protocol+host+port origin; leave the try/catch and
return { success: true } behavior intact.

return {
success: false,
error:
error instanceof Error ? error.message : "Failed to clear cache",
};
}
}),
});
};

export type CacheRouter = ReturnType<typeof createCacheRouter>;
2 changes: 2 additions & 0 deletions apps/desktop/src/lib/trpc/routers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { router } from "..";
import { createAnalyticsRouter } from "./analytics";
import { createAuthRouter } from "./auth";
import { createAutoUpdateRouter } from "./auto-update";
import { createCacheRouter } from "./cache";
import { createChangesRouter } from "./changes";
import { createConfigRouter } from "./config";
import { createExternalRouter } from "./external";
Expand All @@ -23,6 +24,7 @@ export const createAppRouter = (getWindow: () => BrowserWindow | null) => {
analytics: createAnalyticsRouter(),
auth: createAuthRouter(),
autoUpdate: createAutoUpdateRouter(),
cache: createCacheRouter(),
window: createWindowRouter(getWindow),
projects: createProjectsRouter(getWindow),
workspaces: createWorkspacesRouter(),
Expand Down
28 changes: 28 additions & 0 deletions apps/desktop/src/renderer/lib/api-trpc-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { AppRouter } from "@superset/trpc";
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client";
import { env } from "renderer/env.renderer";
import superjson from "superjson";
import { getAuthToken } from "./auth-client";

/**
* HTTP tRPC client for calling the API server.
* Uses bearer token authentication like the auth client.
* For mutations only - for fetching data we already have electric
*/
export const apiTrpcClient = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: `${env.NEXT_PUBLIC_API_URL}/api/trpc`,
transformer: superjson,
headers: () => {
const token = getAuthToken();
if (token) {
return {
Authorization: `Bearer ${token}`,
};
}
return {};
},
}),
],
});
5 changes: 5 additions & 0 deletions apps/desktop/src/renderer/routes/_authenticated/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const Route = createFileRoute("/_authenticated")({
function AuthenticatedLayout() {
const { data: session } = authClient.useSession();
const isSignedIn = !!session?.user;
const activeOrganizationId = session?.session?.activeOrganizationId;
const navigate = useNavigate();
const utils = electronTrpc.useUtils();

Expand Down Expand Up @@ -61,6 +62,10 @@ function AuthenticatedLayout() {
return <Navigate to="/sign-in" replace />;
}

if (!activeOrganizationId) {
return <Navigate to="/create-organization" replace />;
}

return (
<DndProvider manager={dragDropManager}>
<CollectionsProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Spinner } from "@superset/ui/spinner";
import { createContext, type ReactNode, useContext, useMemo } from "react";
import { authClient } from "renderer/lib/auth-client";
import { getCollections } from "./collections";
Expand All @@ -20,11 +19,7 @@ export function CollectionsProvider({ children }: { children: ReactNode }) {
}, [activeOrganizationId]);

if (!collections) {
return (
<div className="flex items-center justify-center h-screen">
<Spinner className="size-8" />
</div>
);
return null;
}

return (
Expand Down
Loading