Skip to content

move worktree created directory to home dir#148

Merged
Kitenite merged 2 commits intomainfrom
indigo-cloud-92
Nov 26, 2025
Merged

move worktree created directory to home dir#148
Kitenite merged 2 commits intomainfrom
indigo-cloud-92

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Nov 26, 2025

Summary by CodeRabbit

  • Refactor

    • Workspace worktrees are now created under a per-user folder in the home directory (.superset/worktrees) instead of the project directory.
  • Tests

    • Added end-to-end tests covering workspace creation: worktree path construction, worktree creation call, DB entries, tab order, and last-active workspace updates.
  • Style

    • Added new constants for the per-user superset and worktrees directory names.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 26, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Worktree creation now places new worktrees under the user's home directory at ~/.superset/worktrees/{branch}. Two new constants were added for the directory names. Router logic and tests were updated to construct and assert the new worktree path and to use the git util's three-argument createWorktree signature.

Changes

Cohort / File(s) Summary
Worktree path change
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
Use homedir() and constants to build worktree path as homedir()/.superset/worktrees/{branch}; adjusted import of homedir and constants.
Path constants
apps/desktop/src/shared/constants.ts
Added exported constants SUPERSET_DIR_NAME = ".superset" and WORKTREES_DIR_NAME = "worktrees".
Workspace creation tests & mocks
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
Updated tests and mocks for three-argument createWorktree(mainRepoPath, branch, worktreePath); added suite asserting create returns worktreePath, DB updates, workspace/tab associations, and that git mock is called with the computed home-based path.

Sequence Diagram

sequenceDiagram
    participant Router as Workspace Router
    participant OS as node:os (homedir)
    participant Git as Git Utils
    participant DB as Mock DB

    Note over Router,OS: Create workspace request
    Router->>OS: homedir()
    OS-->>Router: user home dir
    Router->>Router: build path: homedir()/.superset/worktrees/{branch}
    Router->>Git: createWorktree(mainRepoPath, branch, worktreePath)
    Git-->>Router: resolve
    Router->>DB: insert workspace + worktreePath + tab order
    DB-->>Router: confirm stored
    Router-->>Client: return workspace + worktreePath
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus areas:
    • Correctness of new path construction (use of homedir + constants) and cross-platform considerations.
    • Consistency between git util public signature and test mocks (three-arg createWorktree).
    • Tests' isolation and DB state assertions to ensure no flakiness.

Possibly related PRs

  • move worktree created directory to home dir #148 — touches same files and moves worktree creation into the user's home directory; directly related by same path/constant changes.
  • delete worktree #122 — modifies workspaces router and tests around worktree lifecycle (create/delete); related to router behavior and test mocks.
  • fix worktree setup #146 — expands create mutation behavior and also modifies worktreePath handling in the router; related to changes in returned data and path construction.

Poem

🐰 I hopped to homedir, soft and spry,
Built .superset/worktrees beneath the sky.
Branches find burrows, tidy and sweet—
Constants guide my paws; tests tap their feet. 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description only contains bullet points and does not follow the provided template structure with required sections like Description, Related Issues, Type of Change, Testing, and Additional Notes. Expand the description to follow the template format, including a detailed description section, link related issue #146, specify the change type, and document testing performed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'move worktree created directory to home dir' clearly and specifically describes the main change: relocating where worktrees are created from the project directory to the user's home directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0704303 and efe1523.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (2 hunks)

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.

@Kitenite Kitenite changed the title indigo cloud 92 move worktree created directory to home dir Nov 26, 2025
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

♻️ Duplicate comments (1)
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (1)

32-37: Use constants and consider operational implications of home directory storage.

As noted in apps/desktop/src/shared/constants.ts, the hardcoded strings ".superset" and "worktrees" should be replaced with the defined constants SUPERSET_DIR_NAME and WORKTREES_DIR_NAME.

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

32-37: Consider cleanup strategy for home-directory-based worktrees.

Moving worktrees to the user's home directory (~/.superset/worktrees/) means they persist independently of project lifecycle and could accumulate over time. Consider implementing:

  • A cleanup mechanism for orphaned worktrees when projects are removed
  • Documentation or UI to inform users of this storage location
  • Periodic checks for disk usage or stale worktrees
  • Migration path for existing worktrees in the old location (if applicable)
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts (1)

116-158: Well-structured test with good coverage.

The test correctly validates:

  • Path construction using homedir()
  • Function call arguments
  • Returned workspace properties
  • Database state updates

For consistency, consider using the constants from apps/desktop/src/shared/constants.ts:

+import { SUPERSET_DIR_NAME, WORKTREES_DIR_NAME } from "shared/constants";
 import { homedir } from "node:os";
 import { join } from "node:path";
 const expectedPath = join(
   homedir(),
-  ".superset",
-  "worktrees",
+  SUPERSET_DIR_NAME,
+  WORKTREES_DIR_NAME,
   "test-branch-123",
 );
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5345c71 and 0704303.

📒 Files selected for processing (3)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts (3 hunks)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (2 hunks)
  • apps/desktop/src/shared/constants.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Apply Biome formatting, linting, and import organization at the root level for all code files

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/shared/constants.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Avoid using any type; use type-safe approaches instead, unless necessary
Ensure TypeScript type checking passes across all packages using bun run typecheck

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/shared/constants.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
apps/**/*.{tsx,ts}

📄 CodeRabbit inference engine (AGENTS.md)

apps/**/*.{tsx,ts}: Structure React applications with one folder per component following the pattern: ComponentName/ComponentName.tsx with index.ts barrel export
Co-locate component dependencies (hooks, utils, constants, tests, stories) next to the file using them

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/shared/constants.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
apps/desktop/**/*.{ts,tsx,js,jsx}

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

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/shared/constants.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
apps/desktop/**/*.{ts,tsx}

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

apps/desktop/**/*.{ts,tsx}: Please 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

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/shared/constants.ts
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
apps/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Co-locate tests with their corresponding components (e.g., Component.test.tsx next to Component.tsx)

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
apps/desktop/**/*.test.{ts,tsx,js,jsx}

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

apps/desktop/**/*.test.{ts,tsx,js,jsx}: Tests should have one assert per test
Tests should be readable
Tests should be fast
Tests should be independent
Tests should be repeatable

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
🧠 Learnings (5)
📚 Learning: 2025-11-24T21:32:46.559Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T21:32:46.559Z
Learning: Applies to apps/desktop/src/main/lib/*-ipcs.ts : Implement Electron IPC handlers in dedicated files under apps/desktop/src/main/lib/ (e.g., workspace-ipcs.ts, terminal-ipcs.ts)

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
📚 Learning: 2025-11-24T21:32:46.559Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T21:32:46.559Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables from monorepo root .env file in apps/desktop/src/main/index.ts before any imports with override: true

Applied to files:

  • apps/desktop/src/shared/constants.ts
📚 Learning: 2025-11-24T21:33:13.244Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.244Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : Please use alias as defined in `tsconfig.json` when possible

Applied to files:

  • apps/desktop/src/shared/constants.ts
📚 Learning: 2025-11-24T21:33:13.244Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.244Z
Learning: Applies to apps/desktop/**/*.test.{ts,tsx,js,jsx} : Tests should be independent

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
📚 Learning: 2025-11-24T21:33:13.244Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.244Z
Learning: Applies to apps/desktop/**/*.test.{ts,tsx,js,jsx} : Tests should be repeatable

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts
🧬 Code graph analysis (1)
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.test.ts (1)
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (1)
  • createWorkspacesRouter (15-428)
⏰ 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/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (1)

1-1: LGTM!

The import of homedir is appropriate for the new home-directory-based worktree storage.

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

1-2: LGTM!

The imports are appropriate for constructing and validating the expected home-directory-based worktree path.


59-62: LGTM!

The mock signature correctly reflects the updated createWorktree function that now accepts the worktree path as a third argument.

Comment thread apps/desktop/src/shared/constants.ts
@Kitenite Kitenite merged commit 745251a into main Nov 26, 2025
0 of 5 checks passed
@Kitenite Kitenite deleted the indigo-cloud-92 branch November 26, 2025 18:16
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