Skip to content

fix(desktop): copy gitignored .superset/ to worktrees#549

Merged
AviPeltz merged 2 commits intosuperset-sh:mainfrom
andreasasprou:fix-gitignored-superset-config
Dec 31, 2025
Merged

fix(desktop): copy gitignored .superset/ to worktrees#549
AviPeltz merged 2 commits intosuperset-sh:mainfrom
andreasasprou:fix-gitignored-superset-config

Conversation

@andreasasprou
Copy link
Copy Markdown
Contributor

@andreasasprou andreasasprou commented Dec 30, 2025

Summary

Fixes the bug where gitignored .superset/ directories don't exist in new worktrees, causing setup scripts to fail.

Before: Users following the docs tip to add .superset/ to .gitignore would get zsh: no such file or directory: ./.superset/setup.rb when creating workspaces.

After: Gitignored .superset/ is automatically copied from main repo to new worktrees.

Details

The Problem

The scripts documentation suggested adding .superset/ to .gitignore for personal configs. However, git worktrees only contain tracked files, so gitignored directories don't exist in worktrees. This caused setup commands like ./.superset/setup.sh to fail.

The Fix

Added copySupersetConfigToWorktree() that runs after worktree creation:

  • Checks if .superset/ exists in main repo
  • Checks if .superset/ exists in worktree (it won't if gitignored)
  • If exists in main but not worktree, copies the entire directory

Also updated the docs tip to clarify this behavior:

"Add .superset/ to your .gitignore for personal configs - Superset will automatically copy it to new worktrees"

Test Plan

  1. Create a project with .superset/config.json containing {"setup": ["./.superset/setup.sh"]}
  2. Create .superset/setup.sh with some test command (e.g., echo "setup ran")
  3. Add .superset/ to .gitignore
  4. Create a new workspace
  5. Verify setup script runs successfully ✅

Files Changed

Modified

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts - Added copySupersetConfigToWorktree() function
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts - Call copy function after worktree creation
  • apps/marketing/src/app/scripts/page.tsx - Updated docs tip to explain auto-copy behavior

Summary by CodeRabbit

  • New Features

    • Superset personal configuration and setup files are now automatically copied into newly created worktrees so workspace setup scripts are available without manual steps.
  • Documentation

    • Tips updated to encourage committing .superset/ to share workspace setup and add guidance to use environment variables for machine-specific values.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

Copies the .superset directory from the main repository into newly created worktrees when missing, updates setup config lookup to use PROJECT_SUPERSET_DIR_NAME + CONFIG_FILE_NAME, invokes the copy during worktree creation, and updates marketing tips about sharing .superset and using env vars.

Changes

Cohort / File(s) Summary
Worktree setup utils
apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
Adds copySupersetConfigToWorktree(mainRepoPath, worktreePath): void that computes .superset paths using PROJECT_SUPERSET_DIR_NAME, copies source → destination with cpSync when dest is missing, logs errors (non-throwing); loadSetupConfig now locates the config via PROJECT_SUPERSET_DIR_NAME + CONFIG_FILE_NAME instead of a hardcoded path.
Worktree creation flow
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
Imports and calls copySupersetConfigToWorktree(project.mainRepoPath, worktreePath) immediately after creating a new worktree so gitignored .superset contents are present in the worktree.
Marketing text
apps/marketing/src/app/scripts/page.tsx
Updates tips: encourages committing .superset/ to share workspace setup and adds advice to prefer environment variables for machine-specific values (content-only change).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped from repo to tree,
With .superset bundled carefully,
I dropped configs where worktrees roam,
And whispered: "use env vars for home,"
Now every branch feels more like home 🥕✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding functionality to copy the gitignored .superset/ directory to worktrees, addressing the core bug fix.
Description check ✅ Passed The description comprehensively covers all template sections with clear problem statement, solution explanation, implementation details, test plan, and file changes list.
✨ Finishing touches
  • 📝 Generate docstrings

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.

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: 0

🧹 Nitpick comments (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts (1)

5-5: Consider using the new constant in loadSetupConfig for consistency.

The loadSetupConfig function on line 32 hardcodes ".superset" while a constant SUPERSET_CONFIG_DIR is now defined. Using the constant would improve maintainability.

🔎 Proposed refactor
 export function loadSetupConfig(mainRepoPath: string): SetupConfig | null {
-	const configPath = join(mainRepoPath, ".superset", "config.json");
+	const configPath = join(mainRepoPath, SUPERSET_CONFIG_DIR, "config.json");

Also applies to: 32-32

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42dc9ec and 73e498e.

📒 Files selected for processing (3)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/marketing/src/app/scripts/page.tsx
🧰 Additional context used
📓 Path-based instructions (3)
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc
Use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from @trpc/server/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use type safety and avoid any types unless absolutely necessary in TypeScript files

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/marketing/src/app/scripts/page.tsx
apps/desktop/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Move Node.js functionality needed in Electron renderer to src/main/lib/ and communicate via IPC

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
🧠 Learnings (1)
📚 Learning: 2025-12-28T01:56:39.031Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T01:56:39.031Z
Learning: Applies to apps/desktop/src/**/*.{ts,tsx} : Move Node.js functionality needed in Electron renderer to `src/main/lib/` and communicate via IPC

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
🧬 Code graph analysis (1)
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts (1)
  • copySupersetConfigToWorktree (12-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (3)
apps/marketing/src/app/scripts/page.tsx (1)

185-186: Documentation accurately reflects the new behavior.

The updated tip clearly communicates that .superset/ will be automatically copied to new worktrees, helping users understand that their gitignored personal configs will work seamlessly.

apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (1)

127-129: LGTM! Well-placed and clearly documented.

The function call is correctly positioned after the worktree is created on disk and before setup scripts run, ensuring gitignored .superset/ directories are available when needed.

apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts (1)

7-29: LGTM! Solid implementation with appropriate error handling.

The function correctly implements the copy logic with proper existence checks and best-effort error handling. The approach of only copying when the destination is missing ensures it won't overwrite any manual changes in worktrees.

When .superset/ is gitignored, it doesn't exist in new worktrees since
git only includes tracked files. This caused setup scripts like
'./.superset/setup.sh' to fail with 'no such file or directory'.

Now .superset/ is automatically copied from the main repo to worktrees
if it exists in main but not in the worktree.
@andreasasprou andreasasprou force-pushed the fix-gitignored-superset-config branch from 73e498e to a7a8ca7 Compare December 30, 2025 07:24
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: 0

🧹 Nitpick comments (2)
apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts (2)

11-28: Consider returning success status or throwing errors for better error propagation.

The function currently logs errors but returns void, preventing the caller from detecting copy failures. If the copy fails, the worktree will be created but setup scripts will be missing, yet the UI may not reflect this issue.

Consider one of these approaches:

  • Return boolean to indicate success/failure
  • Throw errors and let the caller decide whether to fail worktree creation or show a warning
🔎 Option 1: Return boolean for success status
 export function copySupersetConfigToWorktree(
 	mainRepoPath: string,
 	worktreePath: string,
-): void {
+): boolean {
 	const mainSupersetDir = join(mainRepoPath, PROJECT_SUPERSET_DIR_NAME);
 	const worktreeSupersetDir = join(worktreePath, PROJECT_SUPERSET_DIR_NAME);
 
 	// Only copy if it exists in main repo but not in worktree
 	if (existsSync(mainSupersetDir) && !existsSync(worktreeSupersetDir)) {
 		try {
 			cpSync(mainSupersetDir, worktreeSupersetDir, { recursive: true });
+			return true;
 		} catch (error) {
 			console.error(
 				`Failed to copy ${PROJECT_SUPERSET_DIR_NAME} to worktree: ${error instanceof Error ? error.message : String(error)}`,
 			);
+			return false;
 		}
 	}
+	return true; // Nothing to copy or already exists
 }

11-11: Optional: Consider renaming to reflect that entire directory is copied.

The function name copySupersetConfigToWorktree suggests only the config file is copied, but it copies the entire .superset directory (including setup scripts and other files). Consider a more descriptive name like copySupersetDirToWorktree for clarity.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73e498e and a7a8ca7.

📒 Files selected for processing (3)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/marketing/src/app/scripts/page.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/marketing/src/app/scripts/page.tsx
🧰 Additional context used
📓 Path-based instructions (3)
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc
Use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from @trpc/server/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use type safety and avoid any types unless absolutely necessary in TypeScript files

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
apps/desktop/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Move Node.js functionality needed in Electron renderer to src/main/lib/ and communicate via IPC

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
🧠 Learnings (1)
📚 Learning: 2025-12-28T01:56:39.031Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T01:56:39.031Z
Learning: Applies to apps/desktop/src/**/*.{ts,tsx} : Move Node.js functionality needed in Electron renderer to `src/main/lib/` and communicate via IPC

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts
🧬 Code graph analysis (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts (2)
apps/desktop/src/shared/constants.ts (2)
  • PROJECT_SUPERSET_DIR_NAME (33-33)
  • CONFIG_FILE_NAME (35-35)
apps/desktop/src/shared/types/config.ts (1)
  • SetupConfig (1-4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (2)
apps/desktop/src/lib/trpc/routers/workspaces/utils/setup.ts (2)

31-35: LGTM! Good refactoring to use shared constants.

Using PROJECT_SUPERSET_DIR_NAME and CONFIG_FILE_NAME constants instead of hardcoded strings improves maintainability and ensures consistency across the codebase.


1-1: Node.js version is compatible with cpSync.

Electron 39.1.2 bundles Node.js v22.21.1, which fully supports cpSync (available since Node.js v16.7.0). No compatibility concerns.

Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz left a comment

Choose a reason for hiding this comment

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

lgtm 👍

Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz left a comment

Choose a reason for hiding this comment

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

Wait actually on second thought it might be better to just remove the .gitignore comment from the docs because .superset probably shouldn't be .gitignored. If you make a change in a worktree to your setup/teardown script and gitignore .superset it, the changes wont be pushed to main which seems like confusing behavior. Let me know your thoughts, I could be wrong here.

but we could also keep this and then just add a change getting rid of the comment in the docs, so we have the best of both worlds?

Replace advice to gitignore .superset/ with guidance to commit it.
The gitignore advice caused the original issue - gitignored files don't
exist in worktrees. Now we recommend committing the config and using
environment variables for machine-specific values.

The copySupersetConfigToWorktree fallback remains as a safety net.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz left a comment

Choose a reason for hiding this comment

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

i added a doc change and i think its good to merge now

@AviPeltz AviPeltz merged commit 7eb30e4 into superset-sh:main Dec 31, 2025
10 of 13 checks passed
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: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7a8ca7 and 63775d2.

📒 Files selected for processing (1)
  • apps/marketing/src/app/scripts/page.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use type safety and avoid any types unless absolutely necessary in TypeScript files

Files:

  • apps/marketing/src/app/scripts/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build

Comment on lines +177 to 186
Commit{" "}
<code className="text-amber-500 dark:text-amber-400">
.superset/
</code>{" "}
to your{" "}
<code className="text-amber-500 dark:text-amber-400">
.gitignore
</code>{" "}
if you don&apos;t want to share configs
to share workspace setup with your team
</li>
<li>
For machine-specific values, use environment variables in your
scripts instead of hardcoding paths
</li>
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 | 🟡 Minor

Document the automatic .superset/ copying behavior.

The tips recommend committing .superset/ but don't mention the automatic copying behavior that this PR introduces. According to the PR objectives, the documentation should clarify that users can either commit .superset/ or keep it gitignored and Superset will automatically copy it to new worktrees.

Consider adding a tip that explains this fallback mechanism so users who prefer to gitignore .superset/ understand it will still work in worktrees.

📝 Suggested documentation addition
 			<li>
 				Commit{" "}
 				<code className="text-amber-500 dark:text-amber-400">
 					.superset/
 				</code>{" "}
 				to share workspace setup with your team
 			</li>
+			<li>
+				If{" "}
+				<code className="text-amber-500 dark:text-amber-400">
+					.superset/
+				</code>{" "}
+				is gitignored, Superset will automatically copy it from your main
+				repository to new worktrees
+			</li>
 			<li>
 				For machine-specific values, use environment variables in your
 				scripts instead of hardcoding paths
 			</li>
📝 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
Commit{" "}
<code className="text-amber-500 dark:text-amber-400">
.superset/
</code>{" "}
to your{" "}
<code className="text-amber-500 dark:text-amber-400">
.gitignore
</code>{" "}
if you don&apos;t want to share configs
to share workspace setup with your team
</li>
<li>
For machine-specific values, use environment variables in your
scripts instead of hardcoding paths
</li>
Commit{" "}
<code className="text-amber-500 dark:text-amber-400">
.superset/
</code>{" "}
to share workspace setup with your team
</li>
<li>
If{" "}
<code className="text-amber-500 dark:text-amber-400">
.superset/
</code>{" "}
is gitignored, Superset will automatically copy it from your main
repository to new worktrees
</li>
<li>
For machine-specific values, use environment variables in your
scripts instead of hardcoding paths
</li>
🤖 Prompt for AI Agents
In apps/marketing/src/app/scripts/page.tsx around lines 177 to 186, add a new
list item documenting the automatic .superset/ copying behavior introduced by
this PR: state that users can either commit .superset/ to the repo or keep it
gitignored — Superset will automatically copy a .superset/ directory into new
worktrees as a fallback so workspaces still get the default config; insert this
as an additional <li> immediately after the existing items and keep the note
concise and mention machine-specific values should still use env vars.

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