From 1d762e44c2dae8c06fb2acb921d2f21f2453ed38 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 3 Dec 2025 22:16:15 -0800 Subject: [PATCH 1/3] feat(desktop): use unique-names-generator for workspace names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace hardcoded word lists with the unique-names-generator library for generating workspace branch names. This increases naming variety from ~22,500 combinations to ~490,000+ (1,400 adjectives × 350 animals × 100 numbers). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/desktop/package.json | 1 + .../lib/trpc/routers/workspaces/utils/git.ts | 51 +++++-------------- bun.lock | 5 +- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/apps/desktop/package.json b/apps/desktop/package.json index e665c56def8..3237a6683be 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -83,6 +83,7 @@ "superjson": "^2.2.5", "tailwind-merge": "^3.4.0", "trpc-electron": "^0.1.2", + "unique-names-generator": "^4.7.1", "zod": "^4.1.12", "zustand": "^5.0.8" }, diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts index c49a2a9cf75..13e72100a80 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts @@ -1,49 +1,22 @@ import { mkdir } from "node:fs/promises"; import { join } from "node:path"; import simpleGit from "simple-git"; +import { + adjectives, + animals, + uniqueNamesGenerator, +} from "unique-names-generator"; export function generateBranchName(): string { - const adjectives = [ - "azure", - "crimson", - "emerald", - "golden", - "indigo", - "jade", - "lavender", - "magenta", - "navy", - "olive", - "pearl", - "rose", - "silver", - "teal", - "violet", - ]; - - const nouns = [ - "cloud", - "forest", - "mountain", - "ocean", - "river", - "storm", - "sunset", - "thunder", - "wave", - "wind", - "meadow", - "canyon", - "glacier", - "valley", - "peak", - ]; - - const adjective = adjectives[Math.floor(Math.random() * adjectives.length)]; - const noun = nouns[Math.floor(Math.random() * nouns.length)]; + const name = uniqueNamesGenerator({ + dictionaries: [adjectives, animals], + separator: "-", + length: 2, + style: "lowerCase", + }); const number = Math.floor(Math.random() * 100); - return `${adjective}-${noun}-${number}`; + return `${name}-${number}`; } export async function createWorktree( diff --git a/bun.lock b/bun.lock index a7f17a50519..e2bdc6bb9a5 100644 --- a/bun.lock +++ b/bun.lock @@ -69,7 +69,7 @@ }, "apps/desktop": { "name": "@superset/desktop", - "version": "0.0.1", + "version": "0.0.3", "dependencies": { "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", @@ -124,6 +124,7 @@ "superjson": "^2.2.5", "tailwind-merge": "^3.4.0", "trpc-electron": "^0.1.2", + "unique-names-generator": "^4.7.1", "zod": "^4.1.12", "zustand": "^5.0.8", }, @@ -2751,6 +2752,8 @@ "unique-filename": ["unique-filename@2.0.1", "", { "dependencies": { "unique-slug": "^3.0.0" } }, "sha512-ODWHtkkdx3IAR+veKxFV+VBkUMcN+FaqzUUd7IZzt+0zhDZFPFxhlqwPF3YQvMHx1TD0tdgYl+kuPnJ8E6ql7A=="], + "unique-names-generator": ["unique-names-generator@4.7.1", "", {}, "sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow=="], + "unique-slug": ["unique-slug@3.0.0", "", { "dependencies": { "imurmurhash": "^0.1.4" } }, "sha512-8EyMynh679x/0gqE9fT9oilG+qEt+ibFyqjuVTsZn1+CMxH+XLlpvr2UZx4nVcCwTpx81nICr2JQFkM+HPLq4w=="], "unist-util-find-after": ["unist-util-find-after@5.0.0", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0" } }, "sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ=="], From e1f6a815860b4df864794c487a6867a6134425fc Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 3 Dec 2025 22:19:40 -0800 Subject: [PATCH 2/3] refactor: use cryptographic suffix for collision-free branch names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace random 2-digit number (100 possibilities) with a 4-character base64url-encoded random suffix (262,144 possibilities) using Node's crypto.randomBytes for better collision resistance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts index 13e72100a80..617fe1e00fc 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts @@ -1,3 +1,4 @@ +import { randomBytes } from "node:crypto"; import { mkdir } from "node:fs/promises"; import { join } from "node:path"; import simpleGit from "simple-git"; @@ -14,9 +15,9 @@ export function generateBranchName(): string { length: 2, style: "lowerCase", }); - const number = Math.floor(Math.random() * 100); + const suffix = randomBytes(3).toString("base64url"); - return `${name}-${number}`; + return `${name}-${suffix}`; } export async function createWorktree( From 3da9f7f2f79a26aa40d5cb81c80f1885b47c8b71 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Wed, 3 Dec 2025 22:24:31 -0800 Subject: [PATCH 3/3] style: use hex encoding for lowercase branch suffix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use hex encoding (0-9, a-f) instead of base64url to ensure branch names are fully lowercase. Still provides 16M+ combinations (16^6). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts index 617fe1e00fc..8e32b93405f 100644 --- a/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts +++ b/apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts @@ -15,7 +15,7 @@ export function generateBranchName(): string { length: 2, style: "lowerCase", }); - const suffix = randomBytes(3).toString("base64url"); + const suffix = randomBytes(3).toString("hex"); return `${name}-${suffix}`; }