Skip to content

feat(setup): clone v2 host-service DBs alongside v1 local DB#3630

Merged
Kitenite merged 7 commits into
mainfrom
setup-script-v1-and-v2-database-cloning
Apr 22, 2026
Merged

feat(setup): clone v2 host-service DBs alongside v1 local DB#3630
Kitenite merged 7 commits into
mainfrom
setup-script-v1-and-v2-database-cloning

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Apr 21, 2026

Summary

  • Adds step_seed_host_dbs to .superset/setup.sh that clones every ~/.superset/host/<orgId>/host.db into superset-dev-data/host/<orgId>/host.db so v2 workspaces open with host-service state prefilled (projects, workspaces, terminals, PRs).
  • Mirrors the existing v1 local.db clone: copies -shm/-wal siblings, checkpoints the WAL on the copy, respects -f/--force, skips when source is absent.
  • Runs after step_seed_local_db and before step_seed_auth_token in main.sh (so the force-overwrite rm -rf superset-dev-data/ from the v1 seed happens first).

Test plan

  • Ran step_seed_host_dbs in this worktree — 3 orgs copied, resulting DBs open with expected host-service tables (projects, workspaces, terminal_sessions, pull_requests, __drizzle_migrations).
  • Clean-env smoke test: orgs missing a host.db are skipped; rerun without -f skips existing destinations; rerun with -f overwrites and clears stale WAL siblings.
  • End-to-end: create a v2 workspace from the desktop app and confirm the dev host-service sees the seeded org data.

Summary by cubic

Clone v2 host-service DBs and auto-pin accessible v2 workspaces in dev so v2 opens with prefilled data and a populated sidebar.

  • New Features

    • Added step_seed_host_dbs to clone per-org host.db from ~/.superset/host/<orgId>/ to superset-dev-data/host/<orgId>/; copies -shm/-wal, WAL checkpoints, and runs after the v1 local DB seed and before auth token seeding.
    • Added dev-only useDevSeedV2Sidebar to pin all accessible v2 workspaces once per worktree using a localStorage flag, avoiding per-origin localStorage issues.
  • Bug Fixes

    • Clean up partial host DB copies on failure so a lone host.db isn’t left behind, preventing false “already seeded” skips on the next run.

Written for commit 91d5f10. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Setup seeds per-organization host databases during initialization.
    • Dev desktop seeds/pins V2 workspaces into the dashboard sidebar on first run in development.
  • Improvements

    • Per-org overwrite control and safe-skip when source data is missing.
    • Robust DB copy handling, companion-file support, and WAL checkpointing after copy.
  • Bug Fixes

    • Setup step sequencing updated to include the new seeding phase.

Seeds ~/.superset/host/<orgId>/host.db into superset-dev-data/host/<orgId>/
so v2 workspaces open with host-service state prefilled, matching the
existing v1 local.db clone behavior.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a setup step to seed per-organization host SQLite DBs from ~/.superset/host into superset-dev-data/host, and a dev-only React hook useDevSeedV2Sidebar (exported and invoked in DashboardLayout) to seed/pin accessible v2 workspaces into the sidebar.

Changes

Cohort / File(s) Summary
Setup Control Flow
/.superset/lib/setup/main.sh
Inserted step_seed_host_dbs between local DB seeding and auth-token seeding; adjusted step numbering and failure behavior.
Host Database Seeding
/.superset/lib/setup/steps.sh
Added step_seed_host_dbs() to enumerate ~/.superset/host/<org>/host.db, copy host.db and optional -shm/-wal, respect FORCE_OVERWRITE_DATA (remove dest when set), skip when no source or existing dest (unless forced), fail on copy errors, perform WAL checkpoint, and report copied vs skipped counts.
Desktop Layout Init
apps/desktop/src/renderer/routes/_authenticated/_dashboard/layout.tsx
Calls new hook useDevSeedV2Sidebar() from DashboardLayout to trigger dev-only sidebar seeding side effects.
Dev Seed Hook Export
apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/index.ts
Adds re-export of useDevSeedV2Sidebar.
Dev Seed Hook Implementation
apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts
New React hook that, in development only, checks superset:dev:v2-sidebar-seeded in localStorage, inspects accessible v2 workspaces and local collection state, calls ensureWorkspaceInSidebar() per workspace when appropriate, sets seeding flag, and avoids re-seeding when already present.

Sequence Diagram(s)

sequenceDiagram
  participant Setup as Setup Script
  participant Src as Source FS (~/.superset/host)
  participant Dest as Dest FS (superset-dev-data/host)
  participant DB as sqlite3

  Setup->>Src: enumerate org dirs, locate host.db
  alt no sources
    Setup->>Setup: step_skipped (no host DBs)
  else sources found
    loop per org
      Setup->>Dest: check existing host.db
      alt FORCE_OVERWRITE_DATA=1
        Setup->>Dest: remove existing host.db, -shm, -wal
      else
        Setup->>Setup: skip org (exists)
      end
      Src->>Dest: copy host.db (+ -shm/-wal if present)
      Dest->>DB: PRAGMA wal_checkpoint(TRUNCATE)
      DB-->>Dest: checkpoint result
    end
    Setup->>Setup: report counts (copied/skipped) or fail on error
  end
Loading
sequenceDiagram
  participant Browser as Browser (DashboardLayout)
  participant Hook as useDevSeedV2Sidebar
  participant API as Workspace Store / Collections
  participant Sidebar as Sidebar Manager (ensureWorkspaceInSidebar)

  Browser->>Hook: invoke on layout mount
  Hook->>Hook: check NODE_ENV and localStorage flag
  alt not dev or already seeded
    Hook-->>Browser: no-op
  else
    Hook->>API: read accessibleWorkspaces and local collection state
    alt local state has entries
      Hook->>Hook: set localStorage flag, no pinning
    else
      loop per workspace
        Hook->>Sidebar: ensureWorkspaceInSidebar(workspace.id, workspace.projectId)
      end
      Hook->>Hook: set localStorage flag "1"
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through folders, one by one,
Copying hosts till the job was done.
WALs tucked neat, checkpoints in tune,
Sidebars seeded by the light of the moon.
A tiny hop for tidy run.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding v2 host-service DB cloning alongside v1 local DB cloning in the setup process.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description covers all required template sections: clear description of changes, related objectives, type of change (new feature), test plan with checkmarks, and helpful context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch setup-script-v1-and-v2-database-cloning

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR extends the dev-environment setup script to clone v2 host-service SQLite databases (one per org) from ~/.superset/host/<orgId>/host.db into superset-dev-data/host/<orgId>/host.db, so that v2 workspaces open with pre-populated host-service state (projects, workspaces, terminals, PRs).

Key changes:

  • steps.sh: Adds step_seed_host_dbs, which iterates org directories under ~/.superset/host/, copies host.db plus its -shm/-wal siblings, checkpoints the WAL on the copy, and correctly handles missing sources, force-overwrite (-f), and per-org skip logic.
  • main.sh: Inserts step_seed_host_dbs as Step 5, between the existing step_seed_local_db (Step 4) and step_seed_auth_token (Step 6), which is the correct ordering so that the force-overwrite rm -rf superset-dev-data/ in the v1 seed step runs before the new step tries to write into that directory.
  • The implementation closely mirrors the existing step_seed_local_db pattern, making it easy to reason about.

Confidence Score: 5/5

Safe to merge — the new step is a well-scoped dev-only utility that mirrors an established pattern and degrades gracefully when sources are absent.

The implementation is a faithful port of the existing step_seed_local_db pattern with correct ordering, proper quoting, force-overwrite handling, and WAL safety. The only finding is a trivial off-by-one comment on the Neon branch step number.

No files require special attention.

Important Files Changed

Filename Overview
.superset/lib/setup/main.sh Correctly inserts step_seed_host_dbs as Step 5 between the local-DB seed and the auth-token seed; minor duplicate "Step 6" comment on the Neon branch step.
.superset/lib/setup/steps.sh Adds step_seed_host_dbs which faithfully mirrors the step_seed_local_db pattern: skips absent sources, respects -f/--force, clears stale WAL siblings before overwrite, copies main+shm+wal, and checkpoints the copy's WAL.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[setup_main] --> B[step_seed_local_db]
    B -->|force=1| B1["rm -rf superset-dev-data/"]
    B1 --> B2[Copy ~/.superset/local.db → superset-dev-data/local.db]
    B --> C[step_seed_host_dbs]
    C --> C1{~/.superset/host/ exists?}
    C1 -->|No| C2[warn + step_skipped]
    C1 -->|Yes| C3[Collect org dirs with host.db]
    C3 --> C4{Any host.db found?}
    C4 -->|No| C5[warn + step_skipped]
    C4 -->|Yes| C6[mkdir -p superset-dev-data/host/]
    C6 --> C7[For each org_id]
    C7 --> C8{dest exists & not force?}
    C8 -->|Yes| C9[warn + skip org]
    C8 -->|No| C10[rm -f stale WAL siblings if force]
    C10 --> C11[cp host.db + -shm + -wal]
    C11 --> C12[sqlite3 PRAGMA wal_checkpoint TRUNCATE]
    C12 --> C7
    C7 -->|done| C13[success seeded/skipped count]
    C13 --> D[step_seed_auth_token]
Loading

Comments Outside Diff (1)

  1. .superset/lib/setup/main.sh, line 49 (link)

    P2 Duplicate step number in comment

    After inserting the new Step 5 (Seed host-service DBs), the Neon branch step is still labeled "Step 6", which collides with the auth-token step above it.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: .superset/lib/setup/main.sh
    Line: 49
    
    Comment:
    **Duplicate step number in comment**
    
    After inserting the new Step 5 (Seed host-service DBs), the Neon branch step is still labeled "Step 6", which collides with the auth-token step above it.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: .superset/lib/setup/main.sh
Line: 49

Comment:
**Duplicate step number in comment**

After inserting the new Step 5 (Seed host-service DBs), the Neon branch step is still labeled "Step 6", which collides with the auth-token step above it.

```suggestion
  # Step 7: Setup Neon branch
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat(setup): clone v2 host-service DBs a..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.superset/lib/setup/main.sh (1)

44-74: ⚠️ Potential issue | 🟡 Minor

Renumber remaining step comments — duplicate "Step 6" and off-by-one after the insertion.

You bumped auth-token to Step 6 (line 44), but the comments on lines 49, 54, 59, 64, and 69 still say Step 6/7/8/9/10. They should shift to 7/8/9/10/11 so the numbering stays unique and monotonic. Doc-only, no runtime impact.

📝 Proposed fix
-  # Step 6: Setup Neon branch
+  # Step 7: Setup Neon branch
   if ! step_setup_neon_branch; then
     step_failed "Setup Neon branch"
   fi
 
-  # Step 7: Allocate port base (file-backed)
+  # Step 8: Allocate port base (file-backed)
   if ! allocate_port_base; then
     step_failed "Allocate port base"
   fi
 
-  # Step 8: Start Electric SQL
+  # Step 9: Start Electric SQL
   if ! step_start_electric; then
     step_failed "Start Electric SQL"
   fi
 
-  # Step 9: Write .env file
+  # Step 10: Write .env file
   if ! step_write_env; then
     step_failed "Write .env file"
   fi
 
-  # Step 10: Setup local MCP in .mcp.json (opt-in)
+  # Step 11: Setup local MCP in .mcp.json (opt-in)
   if [ "$SETUP_LOCAL_MCP" = "1" ]; then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.superset/lib/setup/main.sh around lines 44 - 74, Update the inline step
comments so they remain sequential after inserting step_seed_auth_token: change
the comment above step_setup_neon_branch to "Step 7", allocate_port_base to
"Step 8", step_start_electric to "Step 9", step_write_env to "Step 10", and the
conditional for step_setup_local_mcp to "Step 11"; locate these near the calls
to step_setup_neon_branch, allocate_port_base, step_start_electric,
step_write_env, and step_setup_local_mcp in the same block that calls
step_seed_auth_token and step_failed and adjust only the comment text.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.superset/lib/setup/main.sh:
- Around line 44-74: Update the inline step comments so they remain sequential
after inserting step_seed_auth_token: change the comment above
step_setup_neon_branch to "Step 7", allocate_port_base to "Step 8",
step_start_electric to "Step 9", step_write_env to "Step 10", and the
conditional for step_setup_local_mcp to "Step 11"; locate these near the calls
to step_setup_neon_branch, allocate_port_base, step_start_electric,
step_write_env, and step_setup_local_mcp in the same block that calls
step_seed_auth_token and step_failed and adjust only the comment text.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b968aed0-b9b9-4fa4-b545-587a5b6a709b

📥 Commits

Reviewing files that changed from the base of the PR and between 1456892 and 890c7d3.

📒 Files selected for processing (2)
  • .superset/lib/setup/main.sh
  • .superset/lib/setup/steps.sh

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

The v2 sidebar reads pinned-workspace state from renderer localStorage
(`v2WorkspaceLocalState`, etc.), which lives in the per-app userData dir.
Each dev worktree gets a fresh `Superset (<workspace>)` userData → empty
sidebar even when the cloud + host.db clones have plenty of accessible
workspaces. Copy `Local Storage/` from the prod app's userData using APFS
clonefile so prod can keep running.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.superset/lib/setup/steps.sh:
- Around line 663-681: When a copy in the for-loop (in
.superset/lib/setup/steps.sh around the block using source_db, dest_db and
copy_failed) fails you must remove any partially copied dest files so a future
run doesn't see a lone host.db; modify the error path so when copy_failed is set
(or immediately after a cp fails inside the loop) you delete dest_file and also
remove any of "${dest_db}", "${dest_db}-shm", and "${dest_db}-wal" that may have
been created before returning 1, then return the non-zero status as before.
- Around line 730-732: The removal block that runs when force_overwrite is "1"
currently ignores failures from rm -rf and must fail fast: after attempting to
remove "$dest_local_storage" (when [ -d "$dest_local_storage" ] && [
"$force_overwrite" = "1" ]), check the rm exit status and if it failed, emit an
error and exit with a non‑zero status so the script does not continue
(preventing mixing production Local Storage with stale files); update the block
around dest_local_storage and force_overwrite to perform this check and exit on
failure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 175c2d5a-7163-4a5b-ba71-18dce0352ac9

📥 Commits

Reviewing files that changed from the base of the PR and between 890c7d3 and 9f0442e.

📒 Files selected for processing (2)
  • .superset/lib/setup/main.sh
  • .superset/lib/setup/steps.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • .superset/lib/setup/main.sh

Comment thread .superset/lib/setup/steps.sh
Comment thread .superset/lib/setup/steps.sh Outdated
Comment on lines +730 to +732
if [ -d "$dest_local_storage" ] && [ "$force_overwrite" = "1" ]; then
rm -rf "$dest_local_storage"
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fail if forced renderer-state deletion fails.

With -f, continuing after a failed rm -rf can merge prod Local Storage into stale LevelDB files instead of replacing them.

🛠️ Proposed fix
   if [ -d "$dest_local_storage" ] && [ "$force_overwrite" = "1" ]; then
-    rm -rf "$dest_local_storage"
+    if ! rm -rf "$dest_local_storage"; then
+      error "Failed to remove existing renderer state at $dest_local_storage"
+      return 1
+    fi
   fi
📝 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
if [ -d "$dest_local_storage" ] && [ "$force_overwrite" = "1" ]; then
rm -rf "$dest_local_storage"
fi
if [ -d "$dest_local_storage" ] && [ "$force_overwrite" = "1" ]; then
if ! rm -rf "$dest_local_storage"; then
error "Failed to remove existing renderer state at $dest_local_storage"
return 1
fi
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.superset/lib/setup/steps.sh around lines 730 - 732, The removal block that
runs when force_overwrite is "1" currently ignores failures from rm -rf and must
fail fast: after attempting to remove "$dest_local_storage" (when [ -d
"$dest_local_storage" ] && [ "$force_overwrite" = "1" ]), check the rm exit
status and if it failed, emit an error and exit with a non‑zero status so the
script does not continue (preventing mixing production Local Storage with stale
files); update the block around dest_local_storage and force_overwrite to
perform this check and exit on failure.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".superset/lib/setup/steps.sh">

<violation number="1" location=".superset/lib/setup/steps.sh:731">
P2: If `rm -rf "$dest_local_storage"` fails (e.g. permissions, locked file), the script silently continues to `cp`, merging new LevelDB files on top of stale ones instead of cleanly replacing them. Check the return code and bail out on failure.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread .superset/lib/setup/steps.sh Outdated
Drop the renderer-state file-copy approach (Chromium localStorage is
per-origin: dev runs on http://localhost:<port>, prod is file://, so
copying the leveldb seeds the wrong namespace). Instead, add a small
dev-only hook in the dashboard layout that pins every accessible v2
workspace once per worktree's userData. A localStorage flag prevents
re-pinning workspaces the user has explicitly unpinned later.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts (1)

21-29: Move useAccessibleV2Workspaces() behind a dev-only guard to prevent database queries in production.

useAccessibleV2Workspaces() calls useLiveQuery(), which subscribes to database changes and executes on every render. Even though the seeding effect returns early in production, this hook runs before the NODE_ENV check, adding unnecessary database overhead outside development. Either wrap this component in a dev-only condition, or pass a conditional flag to prevent the query execution in production.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts`
around lines 21 - 29, The call to useAccessibleV2Workspaces() runs its
useLiveQuery subscription even in production; move or gate it so it only runs in
development: inside useDevSeedV2Sidebar, defer calling
useAccessibleV2Workspaces() (and thus useLiveQuery) until after the env.NODE_ENV
=== "development" check (or modify useAccessibleV2Workspaces to accept a boolean
skip flag and pass skip = env.NODE_ENV !== "development"); update references to
accessibleWorkspaces/ensureWorkspaceInSidebar/collections accordingly so the
effect early-returns when SEED_FLAG_KEY is set but no DB query runs in
production.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts`:
- Around line 21-29: The call to useAccessibleV2Workspaces() runs its
useLiveQuery subscription even in production; move or gate it so it only runs in
development: inside useDevSeedV2Sidebar, defer calling
useAccessibleV2Workspaces() (and thus useLiveQuery) until after the env.NODE_ENV
=== "development" check (or modify useAccessibleV2Workspaces to accept a boolean
skip flag and pass skip = env.NODE_ENV !== "development"); update references to
accessibleWorkspaces/ensureWorkspaceInSidebar/collections accordingly so the
effect early-returns when SEED_FLAG_KEY is set but no DB query runs in
production.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 96bae676-6d59-49a5-86db-1a0f00f08a5e

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0442e and 23f38e6.

📒 Files selected for processing (5)
  • .superset/lib/setup/main.sh
  • .superset/lib/setup/steps.sh
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/layout.tsx
  • apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/index.ts
  • apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .superset/lib/setup/main.sh

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".superset/lib/setup/main.sh">

<violation number="1" location=".superset/lib/setup/main.sh:44">
P1: `step_seed_renderer_state` is missing from `setup_main`, so renderer Local Storage seeding no longer runs before auth token seeding.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

step_failed "Seed host-service DBs"
fi

# Step 6: Seed auth token into superset-dev-data/
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 22, 2026

Choose a reason for hiding this comment

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

P1: step_seed_renderer_state is missing from setup_main, so renderer Local Storage seeding no longer runs before auth token seeding.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .superset/lib/setup/main.sh, line 44:

<comment>`step_seed_renderer_state` is missing from `setup_main`, so renderer Local Storage seeding no longer runs before auth token seeding.</comment>

<file context>
@@ -41,12 +41,7 @@ setup_main() {
-  fi
-
-  # Step 7: Seed auth token into superset-dev-data/
+  # Step 6: Seed auth token into superset-dev-data/
   if ! step_seed_auth_token; then
     step_failed "Seed auth token"
</file context>
Suggested change
# Step 6: Seed auth token into superset-dev-data/
# Step 6: Seed Electron renderer Local Storage from prod userData
if ! step_seed_renderer_state; then
step_failed "Seed renderer state"
fi
# Step 7: Seed auth token into superset-dev-data/
Fix with Cubic

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts (1)

17-36: LGTM — dev-only seeding logic is well-guarded.

The ordering of guards (NODE_ENV → flag → empty accessible list → existing local state) is correct, and setting SEED_FLAG_KEY when pre-existing v2 sidebar state is detected cleanly avoids clobbering a user who has already curated their sidebar. The docstring nicely explains the per-origin localStorage rationale.

One optional nit: collections is the entire context object and will almost certainly have a new identity on each provider render, so this effect re-runs frequently. It's harmless because the early-return on the flag short-circuits immediately, but you could narrow the dependency to collections.v2WorkspaceLocalState.state.size (or read it via a ref) to make the intent clearer and avoid needlessly re-executing the guards.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts`
around lines 17 - 36, The effect in useDevSeedV2Sidebar re-runs unnecessarily
because the dependency includes the whole collections object; change the
dependency to the specific value you care about
(collections.v2WorkspaceLocalState.state.size) or read that size into a ref and
depend on the ref instead so the effect only reruns when the local-state size
changes; keep accessibleWorkspaces and ensureWorkspaceInSidebar in the
dependency array and leave SEED_FLAG_KEY and the logic in useDevSeedV2Sidebar
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts`:
- Around line 17-36: The effect in useDevSeedV2Sidebar re-runs unnecessarily
because the dependency includes the whole collections object; change the
dependency to the specific value you care about
(collections.v2WorkspaceLocalState.state.size) or read that size into a ref and
depend on the ref instead so the effect only reruns when the local-state size
changes; keep accessibleWorkspaces and ensureWorkspaceInSidebar in the
dependency array and leave SEED_FLAG_KEY and the logic in useDevSeedV2Sidebar
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0f22458-1ba5-4396-985e-445dba42f5d5

📥 Commits

Reviewing files that changed from the base of the PR and between 8ba5548 and c30e8ef.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/routes/_authenticated/hooks/useDevSeedV2Sidebar/useDevSeedV2Sidebar.ts

If host.db copies but a -wal/-shm sibling fails, leaving the lone host.db
in place would make the next non-force run skip the org as "already seeded."
Wipe the per-org dest before returning the error.

Caught by coderabbitai on PR #3630.
@Kitenite Kitenite merged commit 52e9e75 into main Apr 22, 2026
14 checks passed
@Kitenite Kitenite deleted the setup-script-v1-and-v2-database-cloning branch April 22, 2026 17:31
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.

1 participant