-
Notifications
You must be signed in to change notification settings - Fork 999
feat(desktop): show existing disk worktrees in Open Workspace modal #1154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5ac7736
67248fb
71766f9
0489ea1
425a893
5b4afd1
69262fe
613fcc2
9029658
deb5dd0
a405f34
0aff777
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { | |||||||||||||||||||||||||||||||||
| checkNeedsRebase, | ||||||||||||||||||||||||||||||||||
| fetchDefaultBranch, | ||||||||||||||||||||||||||||||||||
| getDefaultBranch, | ||||||||||||||||||||||||||||||||||
| listExternalWorktrees, | ||||||||||||||||||||||||||||||||||
| refreshDefaultBranch, | ||||||||||||||||||||||||||||||||||
| } from "../utils/git"; | ||||||||||||||||||||||||||||||||||
| import { fetchGitHubPRStatus } from "../utils/github"; | ||||||||||||||||||||||||||||||||||
|
|
@@ -166,5 +167,38 @@ export const createGitStatusProcedures = () => { | |||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| getExternalWorktrees: publicProcedure | ||||||||||||||||||||||||||||||||||
| .input(z.object({ projectId: z.string() })) | ||||||||||||||||||||||||||||||||||
| .query(async ({ input }) => { | ||||||||||||||||||||||||||||||||||
| const project = getProject(input.projectId); | ||||||||||||||||||||||||||||||||||
| if (!project) { | ||||||||||||||||||||||||||||||||||
| return []; | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+171
to
+176
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd /tmp/repo && find . -name "git-status.ts" -path "*/trpc/routers/workspaces/procedures/*" 2>/dev/nullRepository: superset-sh/superset Length of output: 123 🏁 Script executed: cd /tmp/repo && git ls-files | grep -E "git-status\.ts$"Repository: superset-sh/superset Length of output: 123 🏁 Script executed: cd /tmp/repo && find . -path "*/apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.ts" 2>/dev/nullRepository: superset-sh/superset Length of output: 123 🏁 Script executed: git ls-files | grep "git-status.ts"Repository: superset-sh/superset Length of output: 133 🏁 Script executed: find . -type f -name "git-status.ts" 2>/dev/null | head -20Repository: superset-sh/superset Length of output: 135 🏁 Script executed: fd "git-status.ts" 2>/dev/nullRepository: superset-sh/superset Length of output: 133 🏁 Script executed: wc -l apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsRepository: superset-sh/superset Length of output: 137 🏁 Script executed: sed -n '1,30p' apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsRepository: superset-sh/superset Length of output: 933 🏁 Script executed: sed -n '165,185p' apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsRepository: superset-sh/superset Length of output: 628 🏁 Script executed: sed -n '1,50p' apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsRepository: superset-sh/superset Length of output: 1519 🏁 Script executed: rg "throw new" apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.ts -A 2Repository: superset-sh/superset Length of output: 308 🏁 Script executed: rg "TRPCError" apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsRepository: superset-sh/superset Length of output: 46 🏁 Script executed: rg "TRPCError" apps/desktop/src/lib/trpc/ --type ts --type tsx -lRepository: superset-sh/superset Length of output: 91 🏁 Script executed: head -5 apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.ts && echo "---" && sed -n '20,50p' apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsRepository: superset-sh/superset Length of output: 1220 🏁 Script executed: find apps/desktop/src/lib/trpc/routers -name "*.ts" -o -name "*.tsx" | head -5 | xargs grep -l "TRPCError"Repository: superset-sh/superset Length of output: 48 🏁 Script executed: grep -n "import.*TRPCError" apps/desktop/src/lib/trpc/**/*.ts 2>/dev/null | head -10Repository: superset-sh/superset Length of output: 46 🏁 Script executed: find apps/desktop/src/lib/trpc -name "*.ts" | head -3 | xargs catRepository: superset-sh/superset Length of output: 4707 🏁 Script executed: sed -n '1,10p' apps/desktop/src/lib/trpc/index.ts 2>/dev/null || sed -n '1,10p' apps/desktop/src/lib/trpc.ts 2>/dev/null || echo "Checking directory structure..."Repository: superset-sh/superset Length of output: 377 🏁 Script executed: ls -la apps/desktop/src/lib/trpc/Repository: superset-sh/superset Length of output: 293 🏁 Script executed: cat apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsRepository: superset-sh/superset Length of output: 5431 Use TRPCError.NOT_FOUND for missing projects. Returning an empty list for an invalid projectId hides an error path and bypasses standard tRPC handling. Throw 🐛 Suggested fix+import { TRPCError } from "@trpc/server";
import { z } from "zod";- if (!project) {
- return [];
- }
+ if (!project) {
+ throw new TRPCError({
+ code: "NOT_FOUND",
+ message: `Project ${input.projectId} not found`,
+ });
+ }Per coding guidelines for 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const allWorktrees = await listExternalWorktrees(project.mainRepoPath); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const trackedWorktrees = localDb | ||||||||||||||||||||||||||||||||||
| .select({ path: worktrees.path }) | ||||||||||||||||||||||||||||||||||
| .from(worktrees) | ||||||||||||||||||||||||||||||||||
| .where(eq(worktrees.projectId, input.projectId)) | ||||||||||||||||||||||||||||||||||
| .all(); | ||||||||||||||||||||||||||||||||||
| const trackedPaths = new Set(trackedWorktrees.map((wt) => wt.path)); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return allWorktrees | ||||||||||||||||||||||||||||||||||
| .filter((wt) => { | ||||||||||||||||||||||||||||||||||
| if (wt.path === project.mainRepoPath) return false; | ||||||||||||||||||||||||||||||||||
| if (wt.isBare) return false; | ||||||||||||||||||||||||||||||||||
| if (wt.isDetached) return false; | ||||||||||||||||||||||||||||||||||
| if (!wt.branch) return false; | ||||||||||||||||||||||||||||||||||
| if (trackedPaths.has(wt.path)) return false; | ||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||
| .map((wt) => ({ | ||||||||||||||||||||||||||||||||||
| path: wt.path, | ||||||||||||||||||||||||||||||||||
| // biome-ignore lint/style/noNonNullAssertion: filtered above | ||||||||||||||||||||||||||||||||||
| branch: wt.branch!, | ||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.