From 3879f6895d37a60536bdd9ddb9a7062e72af7ca6 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 14 Nov 2025 17:15:53 -0800 Subject: [PATCH 1/7] Rebuild desktop app build system from scratch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completely rewrote the Electron build configuration using best practices: - Build outputs now go to dist/ instead of node_modules/.dev/ - Simplified package.json scripts (removed complex pre/post hooks) - Clean electron.vite.config.ts with proper workspace package handling - TypeScript electron-builder.config.ts for type safety - Fixed TSConfig path resolution (baseUrl: "./src") - Removed fragile environment variable loading - Updated turbo.jsonc to cache dist/ properly This fixes the issue where adding new packages would break the build due to build artifacts living in node_modules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/desktop/electron-builder.config.ts | 88 +++++++++++++++++++++++++ apps/desktop/electron-builder.ts | 62 ----------------- apps/desktop/electron.vite.config.ts | 65 +++++++----------- apps/desktop/package.json | 19 +++--- apps/desktop/src/main/index.ts | 7 -- apps/desktop/tsconfig.json | 8 +-- turbo.jsonc | 4 +- 7 files changed, 126 insertions(+), 127 deletions(-) create mode 100644 apps/desktop/electron-builder.config.ts delete mode 100644 apps/desktop/electron-builder.ts diff --git a/apps/desktop/electron-builder.config.ts b/apps/desktop/electron-builder.config.ts new file mode 100644 index 00000000000..0f3e94e2509 --- /dev/null +++ b/apps/desktop/electron-builder.config.ts @@ -0,0 +1,88 @@ +/** + * Electron Builder Configuration + * @see https://www.electron.build/configuration/configuration + */ + +import { join } from "node:path"; +import type { Configuration } from "electron-builder"; +import pkg from "./package.json"; + +const currentYear = new Date().getFullYear(); +const author = pkg.author?.name ?? pkg.author; +const authorInKebabCase = author.replace(/\s+/g, "-"); +const appId = `com.${authorInKebabCase}.${pkg.name}`.toLowerCase(); + +const config: Configuration = { + appId, + productName: pkg.displayName, + copyright: `Copyright © ${currentYear} — ${author}`, + + // Directories + directories: { + output: "release", + buildResources: join(pkg.resources, "build"), + }, + + files: [ + "dist/**/*", + "package.json", + { + from: pkg.resources, + to: "resources", + filter: ["**/*"], + }, + ], + + // Build optimization + npmRebuild: false, + buildDependenciesFromSource: false, + nodeGypRebuild: false, + + // macOS + mac: { + icon: join(pkg.resources, "build/icons/icon.icns"), + category: "public.app-category.utilities", + target: [ + { + target: "default", + arch: ["universal"], + }, + ], + hardenedRuntime: true, + gatekeeperAssess: false, + notarize: false, + }, + + // Deep linking protocol + protocols: { + name: pkg.displayName, + schemes: ["superset"], + }, + + // Linux + linux: { + icon: join(pkg.resources, "build/icons"), + category: "Utility", + synopsis: pkg.description, + target: ["AppImage", "deb"], + }, + + // Windows + win: { + icon: join(pkg.resources, "build/icons/icon.ico"), + target: [ + { + target: "nsis", + arch: ["x64"], + }, + ], + }, + + // NSIS installer (Windows) + nsis: { + oneClick: false, + allowToChangeInstallationDirectory: true, + }, +}; + +export default config; diff --git a/apps/desktop/electron-builder.ts b/apps/desktop/electron-builder.ts deleted file mode 100644 index ea108d93390..00000000000 --- a/apps/desktop/electron-builder.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** biome-ignore-all lint/suspicious/noTemplateCurlyInString: <> */ - -import { dirname } from "node:path"; -import type { Configuration } from "electron-builder"; - -import { - author as _author, - description, - displayName, - main, - name, - resources, - version, -} from "./package.json"; - -const author = _author?.name ?? _author; -const currentYear = new Date().getFullYear(); -const authorInKebabCase = author.replace(/\s+/g, "-"); -const appId = `com.${authorInKebabCase}.${name}`.toLowerCase(); - -const artifactName = [`${name}-v${version}`, "-${os}.${ext}"].join(""); - -export default { - appId, - productName: displayName, - copyright: `Copyright © ${currentYear} — ${author}`, - - directories: { - app: dirname(main), - output: `dist/v${version}`, - }, - - npmRebuild: false, - buildDependenciesFromSource: false, - nodeGypRebuild: false, - - mac: { - artifactName, - icon: `${resources}/build/icons/icon.icns`, - category: "public.app-category.utilities", - target: ["zip", "dmg", "dir"], - notarize: false, - }, - - protocols: { - name: displayName, - schemes: ["superset"], - }, - - linux: { - artifactName, - category: "Utilities", - synopsis: description, - target: ["AppImage", "deb", "pacman", "freebsd", "rpm"], - }, - - win: { - artifactName, - icon: `${resources}/build/icons/icon.ico`, - target: ["zip", "portable"], - }, -} satisfies Configuration; diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.ts index f45a88842bf..68cedd36c12 100644 --- a/apps/desktop/electron.vite.config.ts +++ b/apps/desktop/electron.vite.config.ts @@ -1,20 +1,9 @@ -import { dirname, normalize, resolve } from "node:path"; +import { resolve } from "node:path"; import tailwindcss from "@tailwindcss/vite"; import reactPlugin from "@vitejs/plugin-react"; import { codeInspectorPlugin } from "code-inspector-plugin"; -import { config } from "dotenv"; import { defineConfig, externalizeDepsPlugin } from "electron-vite"; -import injectProcessEnvPlugin from "rollup-plugin-inject-process-env"; import tsconfigPathsPlugin from "vite-tsconfig-paths"; -import { main, resources } from "./package.json"; -import { getPortSync } from "./src/main/lib/port-manager"; - -// Load .env from monorepo root -// Use override: true to ensure .env values take precedence over inherited env vars -config({ path: resolve(__dirname, "../../.env"), override: true }); - -const [nodeModules, devFolder] = normalize(dirname(main)).split(/\/|\\/g); -const devPath = [nodeModules, devFolder].join("/"); const tsconfigPaths = tsconfigPathsPlugin({ projects: [resolve("tsconfig.json")], @@ -23,40 +12,37 @@ const tsconfigPaths = tsconfigPathsPlugin({ export default defineConfig({ main: { plugins: [tsconfigPaths, externalizeDepsPlugin()], - build: { + outDir: "dist/main", rollupOptions: { input: { index: resolve("src/main/index.ts"), }, - - output: { - dir: resolve(devPath, "main"), - }, }, }, }, preload: { plugins: [tsconfigPaths, externalizeDepsPlugin()], - build: { - outDir: resolve(devPath, "preload"), + outDir: "dist/preload", }, }, renderer: { + // Environment variable configuration + // Load from monorepo root, only expose VITE_ prefixed vars to renderer + envDir: resolve(__dirname, "../.."), + envPrefix: ["VITE_"], + + // Define compile-time constants define: { - "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV), "process.platform": JSON.stringify(process.platform), - "import.meta.env.ENABLE_NEW_UI": JSON.stringify( - process.env.ENABLE_NEW_UI || "false", - ), - "import.meta.env.DEV_SERVER_PORT": JSON.stringify(getPortSync()), }, + // Dev server configuration server: { - port: getPortSync(), + port: 4927, strictPort: false, // Allow fallback to next available port }, @@ -64,7 +50,6 @@ export default defineConfig({ tsconfigPaths, tailwindcss(), reactPlugin(), - codeInspectorPlugin({ bundler: "vite", hotKeys: ["altKey"], @@ -72,27 +57,27 @@ export default defineConfig({ }), ], - publicDir: resolve(resources, "public"), + // Public assets directory + publicDir: resolve("src/resources/public"), build: { - outDir: resolve(devPath, "renderer"), - + outDir: "dist/renderer", rollupOptions: { - plugins: [ - injectProcessEnvPlugin({ - NODE_ENV: "production", - platform: process.platform, - }), - ], - input: { index: resolve("src/renderer/index.html"), }, - - output: { - dir: resolve(devPath, "renderer"), - }, }, }, + + // Optimize workspace package handling + optimizeDeps: { + // Include workspace packages for pre-bundling + include: ["@superset/ui", "@superset/api"], + }, + + resolve: { + // Deduplicate react/react-dom from workspace packages + dedupe: ["react", "react-dom"], + }, }, }); diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 809450f0e7a..14bba737bc0 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -3,7 +3,7 @@ "name": "Superset", "description": "The last developer tool you'll ever need", "version": "0.0.0", - "main": "./node_modules/.dev/main/index.js", + "main": "./dist/main/index.js", "resources": "src/resources", "author": { "name": "Dalton Menezes", @@ -11,17 +11,14 @@ }, "license": "MIT", "scripts": { - "start": "electron-vite preview", - "predev": "bun run clean:dev", - "dev": "cross-env NODE_ENV=development electron-vite dev --watch", - "compile:app": "electron-vite build", - "prebuild": "bun run clean:dev && bun run compile:app", - "build": "electron-builder", - "install:deps": "electron-builder install-app-deps", - "make:release": "tsx ./src/lib/electron-app/release/modules/release.ts", - "release": "electron-builder --publish always", - "clean:dev": "rimraf ./node_modules/.dev", + "dev": "electron-vite dev", + "build": "electron-vite build", + "preview": "electron-vite preview", + "package": "bun run build && electron-builder", + "package:dir": "bun run build && electron-builder --dir", + "release": "bun run build && electron-builder --publish always", "typecheck": "tsc --noEmit", + "clean": "rimraf dist", "lint": "biome check --no-errors-on-unmatched", "lint:fix": "biome check --write --no-errors-on-unmatched --assist-enabled=true", "format": "biome format --write --no-errors-on-unmatched", diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index ea0d4c5b8a1..aa39d3ea898 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -1,10 +1,3 @@ -// Load .env from monorepo root before any other imports -import { resolve } from "node:path"; -import { config } from "dotenv"; - -// Use override: true to ensure .env values take precedence over inherited env vars -config({ path: resolve(__dirname, "../../../../.env"), override: true }); - import path from "node:path"; import { app } from "electron"; import { makeAppSetup } from "lib/electron-app/factories/app/setup"; diff --git a/apps/desktop/tsconfig.json b/apps/desktop/tsconfig.json index 987d053c4e2..45bae5f89fd 100644 --- a/apps/desktop/tsconfig.json +++ b/apps/desktop/tsconfig.json @@ -16,16 +16,16 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "noEmit": true, - "baseUrl": ".", + "baseUrl": "./src", "paths": { - "*": ["src/*"], - "~/*": ["./*"] + "@/*": ["./*"], + "~/*": ["../*"] } }, "include": [ "./src", "electron.vite.config.*", - "electron-builder.ts", + "electron-builder.config.ts", "index.d.ts" ], "exclude": ["node_modules"] diff --git a/turbo.jsonc b/turbo.jsonc index 17a581ea65c..cc207ee6bf7 100644 --- a/turbo.jsonc +++ b/turbo.jsonc @@ -7,9 +7,7 @@ "outputs": [ ".next/**", "!.next/cache/**", - "dist/**", - "dist-electron/**", - "release/**" + "dist/**" ] }, "dev": { From 6259e879de3e2cf2349d9a194cd06d94e7e51c7e Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 14 Nov 2025 17:16:35 -0800 Subject: [PATCH 2/7] Fix dev mode: remove workspace packages from optimizeDeps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @superset/ui doesn't have a root "." export (only subpath exports), so Vite's optimizeDeps.include was failing. Workspace packages that export raw source files don't need to be pre-bundled - Vite handles them automatically. Dev mode now works correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/desktop/electron.vite.config.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.ts index 68cedd36c12..0fec65b6150 100644 --- a/apps/desktop/electron.vite.config.ts +++ b/apps/desktop/electron.vite.config.ts @@ -69,12 +69,6 @@ export default defineConfig({ }, }, - // Optimize workspace package handling - optimizeDeps: { - // Include workspace packages for pre-bundling - include: ["@superset/ui", "@superset/api"], - }, - resolve: { // Deduplicate react/react-dom from workspace packages dedupe: ["react", "react-dom"], From d6750cd5c1cd3a3d3d365f4cbb361ac021986342 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 14 Nov 2025 17:22:59 -0800 Subject: [PATCH 3/7] Standardize imports to use @ and ~ aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Converted all bare imports to use path aliases for consistency: - @/* for src/ imports (e.g., @/main/lib/...) - ~/* for root imports (e.g., ~/package.json) This improves IDE autocomplete and makes import paths more explicit. All 52 files updated to use the new import convention. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../src/lib/electron-app/factories/app/setup.ts | 6 +++--- .../lib/electron-app/factories/windows/create.ts | 4 ++-- apps/desktop/src/main/index.ts | 16 ++++++++-------- apps/desktop/src/main/lib/config-manager.ts | 2 +- apps/desktop/src/main/lib/workspace-ipcs.ts | 2 +- apps/desktop/src/main/lib/workspace-manager.ts | 2 +- .../src/main/lib/workspace/group-cleanup.ts | 2 +- .../src/main/lib/workspace/tab-helpers.ts | 2 +- .../src/main/lib/workspace/tab-operations.ts | 2 +- .../main/lib/workspace/workspace-operations.ts | 2 +- .../main/lib/workspace/worktree-operations.ts | 4 ++-- apps/desktop/src/main/windows/main.ts | 6 ++++-- apps/desktop/src/preload/index.ts | 2 +- .../src/renderer/components/ui/dialog.tsx | 2 +- .../desktop/src/renderer/components/ui/input.tsx | 2 +- .../desktop/src/renderer/components/ui/label.tsx | 2 +- .../src/renderer/components/ui/separator.tsx | 2 +- .../src/renderer/contexts/WorktreeContext.tsx | 2 +- apps/desktop/src/renderer/routes.tsx | 2 +- .../main/components/Layout/NewLayoutMain.tsx | 2 +- .../main/components/Layout/TaskTabs/TaskTabs.tsx | 2 +- .../main/components/Layout/TaskTabs/types.ts | 2 +- .../main/components/MainContent/TabContent.tsx | 2 +- .../main/components/MainContent/TabGroup.tsx | 2 +- .../MainContentArea/MainContentArea.tsx | 2 +- .../main/components/PlanView/KanbanColumn.tsx | 2 +- .../main/components/PlanView/PlanView.tsx | 2 +- .../main/components/PlanView/TaskCard.tsx | 2 +- .../main/components/PlanView/TaskPage.tsx | 2 +- .../screens/main/components/Sidebar/Sidebar.tsx | 2 +- .../CreateWorktreeModal/CreateWorktreeModal.tsx | 10 +++++----- .../WorkspaceCarousel/WorkspaceCarousel.tsx | 2 +- .../WorkspacePortIndicator.tsx | 2 +- .../WorkspaceSwitcher/WorkspaceSwitcher.tsx | 2 +- .../components/WorktreeList/WorktreeList.tsx | 2 +- .../components/PortIndicator/PortIndicator.tsx | 2 +- .../components/WorktreeItem/WorktreeItem.tsx | 4 ++-- .../WorktreeItem/components/GitStatusDialog.tsx | 2 +- .../WorktreeItem/components/TabItem/TabItem.tsx | 2 +- .../WorktreePortsList/WorktreePortsList.tsx | 2 +- .../components/SidebarOverlay/SidebarOverlay.tsx | 2 +- .../TabContent/components/PortTab/PortTab.tsx | 2 +- .../components/PreviewTab/PreviewTab.tsx | 2 +- .../WorkspaceSelectionModal.tsx | 4 ++-- .../src/renderer/screens/main/hooks/useTabs.ts | 2 +- .../src/renderer/screens/main/hooks/useTasks.ts | 2 +- .../renderer/screens/main/hooks/useWorkspace.ts | 2 +- .../renderer/screens/main/hooks/useWorktrees.ts | 2 +- apps/desktop/src/renderer/screens/main/utils.ts | 2 +- apps/desktop/src/shared/types.ts | 2 +- apps/desktop/src/shared/utils.ts | 5 +++-- 51 files changed, 73 insertions(+), 70 deletions(-) diff --git a/apps/desktop/src/lib/electron-app/factories/app/setup.ts b/apps/desktop/src/lib/electron-app/factories/app/setup.ts index b8fdb0321a6..f2a523eec00 100644 --- a/apps/desktop/src/lib/electron-app/factories/app/setup.ts +++ b/apps/desktop/src/lib/electron-app/factories/app/setup.ts @@ -4,9 +4,9 @@ import { installExtension, REACT_DEVELOPER_TOOLS, } from "electron-extension-installer"; -import terminalManager from "main/lib/terminal"; -import { ENVIRONMENT, PLATFORM } from "shared/constants"; -import { makeAppId } from "shared/utils"; +import terminalManager from "@/main/lib/terminal"; +import { ENVIRONMENT, PLATFORM } from "@/shared/constants"; +import { makeAppId } from "@/shared/utils"; import { ignoreConsoleWarnings } from "../../utils/ignore-console-warnings"; ignoreConsoleWarnings(["Manifest version 2 is deprecated"]); diff --git a/apps/desktop/src/lib/electron-app/factories/windows/create.ts b/apps/desktop/src/lib/electron-app/factories/windows/create.ts index bc46f7465e0..45100afe327 100644 --- a/apps/desktop/src/lib/electron-app/factories/windows/create.ts +++ b/apps/desktop/src/lib/electron-app/factories/windows/create.ts @@ -1,7 +1,7 @@ import { join } from "node:path"; import { BrowserWindow } from "electron"; -import { registerRoute } from "lib/electron-router-dom"; -import type { WindowProps } from "shared/types"; +import { registerRoute } from "@/lib/electron-router-dom"; +import type { WindowProps } from "@/shared/types"; export function createWindow({ id, ...settings }: WindowProps) { const window = new BrowserWindow(settings); diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index aa39d3ea898..7331e246757 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -1,12 +1,12 @@ import path from "node:path"; import { app } from "electron"; -import { makeAppSetup } from "lib/electron-app/factories/app/setup"; -import { registerDeepLinkIpcs } from "main/lib/deep-link-ipcs"; -import { deepLinkManager } from "main/lib/deep-link-manager"; -import { registerPortIpcs } from "main/lib/port-ipcs"; -import { getPort } from "main/lib/port-manager"; -import windowManager from "main/lib/window-manager"; -import { registerWorkspaceIPCs } from "main/lib/workspace-ipcs"; +import { makeAppSetup } from "@/lib/electron-app/factories/app/setup"; +import { registerDeepLinkIpcs } from "@/main/lib/deep-link-ipcs"; +import { deepLinkManager } from "@/main/lib/deep-link-manager"; +import { registerPortIpcs } from "@/main/lib/port-ipcs"; +import { getPort } from "@/main/lib/port-manager"; +import windowManager from "@/main/lib/window-manager"; +import { registerWorkspaceIPCs } from "@/main/lib/workspace-ipcs"; // Protocol scheme for deep linking const PROTOCOL_SCHEME = "superset"; @@ -43,7 +43,7 @@ app.on("open-url", (event, url) => { registerWorkspaceIPCs(); registerPortIpcs(); registerDeepLinkIpcs(); - const { registerWindowIPCs } = await import("main/lib/window-ipcs"); + const { registerWindowIPCs } = await import("@/main/lib/window-ipcs"); registerWindowIPCs(); await makeAppSetup( diff --git a/apps/desktop/src/main/lib/config-manager.ts b/apps/desktop/src/main/lib/config-manager.ts index 49c5c9689ea..8dc2cb9f40b 100644 --- a/apps/desktop/src/main/lib/config-manager.ts +++ b/apps/desktop/src/main/lib/config-manager.ts @@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import os from "node:os"; import path from "node:path"; -import type { WorkspaceConfig } from "shared/types"; +import type { WorkspaceConfig } from "@/shared/types"; class ConfigManager { private static instance: ConfigManager; diff --git a/apps/desktop/src/main/lib/workspace-ipcs.ts b/apps/desktop/src/main/lib/workspace-ipcs.ts index 4f44ca803f8..6db2afb0ab5 100644 --- a/apps/desktop/src/main/lib/workspace-ipcs.ts +++ b/apps/desktop/src/main/lib/workspace-ipcs.ts @@ -7,7 +7,7 @@ import type { MosaicNode, UpdatePreviewTabInput, UpdateWorkspaceInput, -} from "shared/types"; +} from "@/shared/types"; import configManager from "./config-manager"; import workspaceManager from "./workspace-manager"; diff --git a/apps/desktop/src/main/lib/workspace-manager.ts b/apps/desktop/src/main/lib/workspace-manager.ts index cbeb33631a8..a98152f4de3 100644 --- a/apps/desktop/src/main/lib/workspace-manager.ts +++ b/apps/desktop/src/main/lib/workspace-manager.ts @@ -8,7 +8,7 @@ import type { UpdateWorkspaceInput, Workspace, Worktree, -} from "shared/types"; +} from "@/shared/types"; import { proxyManager } from "./proxy-manager"; import * as tabOps from "./workspace/tab-operations"; import * as workspaceOps from "./workspace/workspace-operations"; diff --git a/apps/desktop/src/main/lib/workspace/group-cleanup.ts b/apps/desktop/src/main/lib/workspace/group-cleanup.ts index 681a2a726d4..140833d1636 100644 --- a/apps/desktop/src/main/lib/workspace/group-cleanup.ts +++ b/apps/desktop/src/main/lib/workspace/group-cleanup.ts @@ -1,4 +1,4 @@ -import type { Tab, Workspace } from "shared/types"; +import type { Tab, Workspace } from "@/shared/types"; import { findTab } from "./tab-helpers"; /** diff --git a/apps/desktop/src/main/lib/workspace/tab-helpers.ts b/apps/desktop/src/main/lib/workspace/tab-helpers.ts index bb77116f3c8..1d4ea90c432 100644 --- a/apps/desktop/src/main/lib/workspace/tab-helpers.ts +++ b/apps/desktop/src/main/lib/workspace/tab-helpers.ts @@ -1,5 +1,5 @@ import { randomUUID } from "node:crypto"; -import type { MosaicNode, Tab } from "shared/types"; +import type { MosaicNode, Tab } from "@/shared/types"; /** * Helper functions for working with tabs diff --git a/apps/desktop/src/main/lib/workspace/tab-operations.ts b/apps/desktop/src/main/lib/workspace/tab-operations.ts index 6e74dee9f0a..8173dde54c7 100644 --- a/apps/desktop/src/main/lib/workspace/tab-operations.ts +++ b/apps/desktop/src/main/lib/workspace/tab-operations.ts @@ -7,7 +7,7 @@ import type { UpdatePreviewTabInput, Workspace, Worktree, -} from "shared/types"; +} from "@/shared/types"; import configManager from "../config-manager"; import { cleanupEmptyGroupsInWorktree } from "./group-cleanup"; diff --git a/apps/desktop/src/main/lib/workspace/workspace-operations.ts b/apps/desktop/src/main/lib/workspace/workspace-operations.ts index 1218a357963..d723c4e1fcb 100644 --- a/apps/desktop/src/main/lib/workspace/workspace-operations.ts +++ b/apps/desktop/src/main/lib/workspace/workspace-operations.ts @@ -5,7 +5,7 @@ import type { Tab, UpdateWorkspaceInput, Workspace, -} from "shared/types"; +} from "@/shared/types"; import configManager from "../config-manager"; import { portDetector } from "../port-detector"; diff --git a/apps/desktop/src/main/lib/workspace/worktree-operations.ts b/apps/desktop/src/main/lib/workspace/worktree-operations.ts index 0b7428ed8f4..5deb1c3e616 100644 --- a/apps/desktop/src/main/lib/workspace/worktree-operations.ts +++ b/apps/desktop/src/main/lib/workspace/worktree-operations.ts @@ -9,8 +9,8 @@ import type { Tab, Workspace, Worktree, -} from "shared/types"; -import { generateBranchName } from "shared/utils/slug"; +} from "@/shared/types"; +import { generateBranchName } from "@/shared/utils/slug"; import configManager from "../config-manager"; import { executeSetup } from "../setup-executor"; diff --git a/apps/desktop/src/main/windows/main.ts b/apps/desktop/src/main/windows/main.ts index 6d0c1bcf028..d0ef13e2383 100644 --- a/apps/desktop/src/main/windows/main.ts +++ b/apps/desktop/src/main/windows/main.ts @@ -1,8 +1,10 @@ import { join } from "node:path"; import { screen } from "electron"; -import { createWindow } from "lib/electron-app/factories/windows/create"; -import { displayName } from "~/package.json"; +import { createWindow } from "@/lib/electron-app/factories/windows/create"; +import pkg from "~/package.json"; + +const { displayName } = pkg; import { createApplicationMenu } from "../lib/menu"; import { type PortClosedEvent, diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.ts index d5d97b92598..32b4237067a 100644 --- a/apps/desktop/src/preload/index.ts +++ b/apps/desktop/src/preload/index.ts @@ -3,7 +3,7 @@ import type { IpcChannelName, IpcRequest, IpcResponse_, -} from "shared/ipc-channels"; +} from "@/shared/ipc-channels"; declare global { interface Window { diff --git a/apps/desktop/src/renderer/components/ui/dialog.tsx b/apps/desktop/src/renderer/components/ui/dialog.tsx index 074bebcfdac..ac9cd35f835 100644 --- a/apps/desktop/src/renderer/components/ui/dialog.tsx +++ b/apps/desktop/src/renderer/components/ui/dialog.tsx @@ -2,7 +2,7 @@ import * as DialogPrimitive from "@radix-ui/react-dialog"; import { XIcon } from "lucide-react"; import type * as React from "react"; -import { cn } from "renderer/lib/utils"; +import { cn } from "@/renderer/lib/utils"; function Dialog({ ...props diff --git a/apps/desktop/src/renderer/components/ui/input.tsx b/apps/desktop/src/renderer/components/ui/input.tsx index 14413024c18..57143285835 100644 --- a/apps/desktop/src/renderer/components/ui/input.tsx +++ b/apps/desktop/src/renderer/components/ui/input.tsx @@ -1,6 +1,6 @@ import type * as React from "react"; -import { cn } from "renderer/lib/utils"; +import { cn } from "@/renderer/lib/utils"; function Input({ className, type, ...props }: React.ComponentProps<"input">) { return ( diff --git a/apps/desktop/src/renderer/components/ui/label.tsx b/apps/desktop/src/renderer/components/ui/label.tsx index 122eda2aaf2..2a40e0a3b04 100644 --- a/apps/desktop/src/renderer/components/ui/label.tsx +++ b/apps/desktop/src/renderer/components/ui/label.tsx @@ -1,7 +1,7 @@ import * as LabelPrimitive from "@radix-ui/react-label"; import type * as React from "react"; -import { cn } from "renderer/lib/utils"; +import { cn } from "@/renderer/lib/utils"; function Label({ className, diff --git a/apps/desktop/src/renderer/components/ui/separator.tsx b/apps/desktop/src/renderer/components/ui/separator.tsx index 849d6acbc2b..7d8373fad67 100644 --- a/apps/desktop/src/renderer/components/ui/separator.tsx +++ b/apps/desktop/src/renderer/components/ui/separator.tsx @@ -1,6 +1,6 @@ import type * as React from "react"; -import { cn } from "renderer/lib/utils"; +import { cn } from "@/renderer/lib/utils"; function Separator({ className, diff --git a/apps/desktop/src/renderer/contexts/WorktreeContext.tsx b/apps/desktop/src/renderer/contexts/WorktreeContext.tsx index 98ca4d621a9..1b0eecec2f8 100644 --- a/apps/desktop/src/renderer/contexts/WorktreeContext.tsx +++ b/apps/desktop/src/renderer/contexts/WorktreeContext.tsx @@ -1,6 +1,6 @@ import type React from "react"; import { createContext, useContext } from "react"; -import type { Worktree } from "shared/types"; +import type { Worktree } from "@/shared/types"; interface WorktreeContextValue { currentWorktree: Worktree | null; diff --git a/apps/desktop/src/renderer/routes.tsx b/apps/desktop/src/renderer/routes.tsx index f539e2ba0b9..16e749e952f 100644 --- a/apps/desktop/src/renderer/routes.tsx +++ b/apps/desktop/src/renderer/routes.tsx @@ -1,4 +1,4 @@ -import { Router } from "lib/electron-router-dom"; +import { Router } from "@/lib/electron-router-dom"; import { Route, useRouteError } from "react-router-dom"; import { MainScreen } from "./screens/main"; diff --git a/apps/desktop/src/renderer/screens/main/components/Layout/NewLayoutMain.tsx b/apps/desktop/src/renderer/screens/main/components/Layout/NewLayoutMain.tsx index 39fb62cfbed..77f2216607d 100644 --- a/apps/desktop/src/renderer/screens/main/components/Layout/NewLayoutMain.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Layout/NewLayoutMain.tsx @@ -6,7 +6,7 @@ import { import type React from "react"; import { useEffect, useRef, useState } from "react"; import type { ImperativePanelHandle } from "react-resizable-panels"; -import type { Tab, Workspace, Worktree } from "shared/types"; +import type { Tab, Workspace, Worktree } from "@/shared/types"; import { WorktreeProvider } from "../../../../contexts/WorktreeContext"; import { AppFrame } from "../AppFrame"; import { Background } from "../Background"; diff --git a/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/TaskTabs.tsx b/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/TaskTabs.tsx index 0b888fe44f7..c0f2504a753 100644 --- a/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/TaskTabs.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/TaskTabs.tsx @@ -8,7 +8,7 @@ import { DialogFooter, DialogHeader, DialogTitle, -} from "renderer/components/ui/dialog"; +} from "@/renderer/components/ui/dialog"; import { AddTaskButton } from "./AddTaskButton"; import { ModeToggle } from "./ModeToggle"; import { PRActions } from "./PRActions"; diff --git a/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/types.ts b/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/types.ts index bdfb847ce11..1ffa726113d 100644 --- a/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/types.ts +++ b/apps/desktop/src/renderer/screens/main/components/Layout/TaskTabs/types.ts @@ -1,4 +1,4 @@ -import type { Worktree } from "shared/types"; +import type { Worktree } from "@/shared/types"; import type { TaskStatus } from "../StatusIndicator"; export interface WorktreeWithTask extends Worktree { diff --git a/apps/desktop/src/renderer/screens/main/components/MainContent/TabContent.tsx b/apps/desktop/src/renderer/screens/main/components/MainContent/TabContent.tsx index 169bb2e489c..d1846678b14 100644 --- a/apps/desktop/src/renderer/screens/main/components/MainContent/TabContent.tsx +++ b/apps/desktop/src/renderer/screens/main/components/MainContent/TabContent.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from "react"; -import type { Tab, Worktree } from "shared/types"; +import type { Tab, Worktree } from "@/shared/types"; import { PortTab } from "../TabContent/components/PortTab"; import { PreviewTab } from "../TabContent/components/PreviewTab"; import TabGroup from "./TabGroup"; diff --git a/apps/desktop/src/renderer/screens/main/components/MainContent/TabGroup.tsx b/apps/desktop/src/renderer/screens/main/components/MainContent/TabGroup.tsx index 87cda4249b8..fa9b9598d9b 100644 --- a/apps/desktop/src/renderer/screens/main/components/MainContent/TabGroup.tsx +++ b/apps/desktop/src/renderer/screens/main/components/MainContent/TabGroup.tsx @@ -6,7 +6,7 @@ import { MosaicWindow, } from "react-mosaic-component"; import "react-mosaic-component/react-mosaic-component.css"; -import type { Tab } from "shared/types"; +import type { Tab } from "@/shared/types"; import TabContent from "./TabContent"; interface ScreenLayoutProps { diff --git a/apps/desktop/src/renderer/screens/main/components/MainContentArea/MainContentArea.tsx b/apps/desktop/src/renderer/screens/main/components/MainContentArea/MainContentArea.tsx index 7c1fa8539de..2e78501e545 100644 --- a/apps/desktop/src/renderer/screens/main/components/MainContentArea/MainContentArea.tsx +++ b/apps/desktop/src/renderer/screens/main/components/MainContentArea/MainContentArea.tsx @@ -5,7 +5,7 @@ import { } from "@superset/ui/resizable"; import { useState } from "react"; import type { ImperativePanelHandle } from "react-resizable-panels"; -import type { Tab, Workspace, Worktree } from "shared/types"; +import type { Tab, Workspace, Worktree } from "@/shared/types"; import { useDiffData } from "../../hooks"; import type { AppMode } from "../../types"; import { DiffContentArea } from "../DiffView"; diff --git a/apps/desktop/src/renderer/screens/main/components/PlanView/KanbanColumn.tsx b/apps/desktop/src/renderer/screens/main/components/PlanView/KanbanColumn.tsx index 9868a0df91c..2d3f1b91fab 100644 --- a/apps/desktop/src/renderer/screens/main/components/PlanView/KanbanColumn.tsx +++ b/apps/desktop/src/renderer/screens/main/components/PlanView/KanbanColumn.tsx @@ -1,6 +1,6 @@ import type { RouterOutputs } from "@superset/api"; import type React from "react"; -import type { Tab, Workspace } from "shared/types"; +import type { Tab, Workspace } from "@/shared/types"; import { TaskCard } from "./TaskCard"; type Task = RouterOutputs["task"]["all"][number]; diff --git a/apps/desktop/src/renderer/screens/main/components/PlanView/PlanView.tsx b/apps/desktop/src/renderer/screens/main/components/PlanView/PlanView.tsx index 69368e87a49..811397fe66c 100644 --- a/apps/desktop/src/renderer/screens/main/components/PlanView/PlanView.tsx +++ b/apps/desktop/src/renderer/screens/main/components/PlanView/PlanView.tsx @@ -2,7 +2,7 @@ import type { RouterOutputs } from "@superset/api"; import { Plus } from "lucide-react"; import type React from "react"; import { useMemo, useState } from "react"; -import type { Tab, Workspace } from "shared/types"; +import type { Tab, Workspace } from "@/shared/types"; import { mockTasks, mockUsers } from "../../../../../lib/mock-data"; import { CreateTaskModal } from "./CreateTaskModal"; import { KanbanColumn } from "./KanbanColumn"; diff --git a/apps/desktop/src/renderer/screens/main/components/PlanView/TaskCard.tsx b/apps/desktop/src/renderer/screens/main/components/PlanView/TaskCard.tsx index 3574e93d93c..85b02d97db9 100644 --- a/apps/desktop/src/renderer/screens/main/components/PlanView/TaskCard.tsx +++ b/apps/desktop/src/renderer/screens/main/components/PlanView/TaskCard.tsx @@ -2,7 +2,7 @@ import type { RouterOutputs } from "@superset/api"; import { Play } from "lucide-react"; import type React from "react"; import { useState } from "react"; -import type { Tab, Workspace } from "shared/types"; +import type { Tab, Workspace } from "@/shared/types"; type Task = RouterOutputs["task"]["all"][number]; diff --git a/apps/desktop/src/renderer/screens/main/components/PlanView/TaskPage.tsx b/apps/desktop/src/renderer/screens/main/components/PlanView/TaskPage.tsx index 49157e411f0..7928101a3f8 100644 --- a/apps/desktop/src/renderer/screens/main/components/PlanView/TaskPage.tsx +++ b/apps/desktop/src/renderer/screens/main/components/PlanView/TaskPage.tsx @@ -2,7 +2,7 @@ import type { RouterOutputs } from "@superset/api"; import { ChevronDown, ChevronLeft, Play, User as UserIcon } from "lucide-react"; import type React from "react"; import { useEffect, useRef, useState } from "react"; -import type { Tab, Workspace } from "shared/types"; +import type { Tab, Workspace } from "@/shared/types"; type Task = RouterOutputs["task"]["all"][number]; type User = RouterOutputs["user"]["all"][number]; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/Sidebar.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/Sidebar.tsx index 45857b839d5..057cd15a404 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/Sidebar.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/Sidebar.tsx @@ -1,7 +1,7 @@ import { type MotionValue, useMotionValue } from "framer-motion"; import { File, FileEdit, FilePlus, FileX } from "lucide-react"; import { useEffect, useState } from "react"; -import type { Tab, Workspace, Worktree } from "shared/types"; +import type { Tab, Workspace, Worktree } from "@/shared/types"; import { useDiffData } from "../../hooks"; import { FileTree } from "../DiffView"; import type { FileDiff } from "../DiffView/types"; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/CreateWorktreeModal/CreateWorktreeModal.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/CreateWorktreeModal/CreateWorktreeModal.tsx index 2cf7c635102..53854d41253 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/CreateWorktreeModal/CreateWorktreeModal.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/CreateWorktreeModal/CreateWorktreeModal.tsx @@ -8,11 +8,11 @@ import { DialogFooter, DialogHeader, DialogTitle, -} from "renderer/components/ui/dialog"; -import { Input } from "renderer/components/ui/input"; -import { Label } from "renderer/components/ui/label"; -import { Separator } from "renderer/components/ui/separator"; -import type { Worktree } from "shared/types"; +} from "@/renderer/components/ui/dialog"; +import { Input } from "@/renderer/components/ui/input"; +import { Label } from "@/renderer/components/ui/label"; +import { Separator } from "@/renderer/components/ui/separator"; +import type { Worktree } from "@/shared/types"; import { TerminalOutput } from "./TerminalOutput"; interface CreateWorktreeModalProps { diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceCarousel/WorkspaceCarousel.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceCarousel/WorkspaceCarousel.tsx index c2d9796ff78..6c653df8bcc 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceCarousel/WorkspaceCarousel.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceCarousel/WorkspaceCarousel.tsx @@ -6,7 +6,7 @@ import { useRef, useState, } from "react"; -import type { Workspace } from "shared/types"; +import type { Workspace } from "@/shared/types"; interface WorkspaceCarouselProps { workspaces: Workspace[]; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspacePortIndicator/WorkspacePortIndicator.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspacePortIndicator/WorkspacePortIndicator.tsx index d8cac327bcd..31934d37fe2 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspacePortIndicator/WorkspacePortIndicator.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspacePortIndicator/WorkspacePortIndicator.tsx @@ -6,7 +6,7 @@ import { } from "@superset/ui/tooltip"; import { Circle } from "lucide-react"; import { useEffect, useState } from "react"; -import type { Workspace } from "shared/types"; +import type { Workspace } from "@/shared/types"; interface WorkspacePortIndicatorProps { workspace: Workspace; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceSwitcher/WorkspaceSwitcher.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceSwitcher/WorkspaceSwitcher.tsx index a8920384e33..88f60405cd8 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceSwitcher/WorkspaceSwitcher.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorkspaceSwitcher/WorkspaceSwitcher.tsx @@ -9,7 +9,7 @@ import { ScrollArea, ScrollBar } from "@superset/ui/scroll-area"; import { Tooltip, TooltipContent, TooltipTrigger } from "@superset/ui/tooltip"; import { type MotionValue, motion, useTransform } from "framer-motion"; import { Plus } from "lucide-react"; -import type { Workspace } from "shared/types"; +import type { Workspace } from "@/shared/types"; import { getWorkspaceIcon } from "../../utils"; interface WorkspaceSwitcherProps { diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/WorktreeList.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/WorktreeList.tsx index 357de06c08e..7ddec0269e1 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/WorktreeList.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/WorktreeList.tsx @@ -1,4 +1,4 @@ -import type { Workspace, Worktree } from "shared/types"; +import type { Workspace, Worktree } from "@/shared/types"; import { WorkspacePortIndicator } from "../WorkspacePortIndicator"; import { NewTabButton } from "./components/NewTabButton"; import { WorktreeItem } from "./components/WorktreeItem"; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/PortIndicator/PortIndicator.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/PortIndicator/PortIndicator.tsx index a81644674b9..faf682571c6 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/PortIndicator/PortIndicator.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/PortIndicator/PortIndicator.tsx @@ -6,7 +6,7 @@ import { } from "@superset/ui/tooltip"; import { Circle } from "lucide-react"; import { useEffect, useState } from "react"; -import type { Worktree } from "shared/types"; +import type { Worktree } from "@/shared/types"; interface PortIndicatorProps { worktree: Worktree; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/WorktreeItem.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/WorktreeItem.tsx index adb52e83b28..3b40bdb3c4b 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/WorktreeItem.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/WorktreeItem.tsx @@ -26,8 +26,8 @@ import { DialogFooter, DialogHeader, DialogTitle, -} from "renderer/components/ui/dialog"; -import type { Tab, Worktree } from "shared/types"; +} from "@/renderer/components/ui/dialog"; +import type { Tab, Worktree } from "@/shared/types"; import { WorktreePortsList } from "../WorktreePortsList"; import { GitStatusDialog } from "./components/GitStatusDialog"; import { TabItem } from "./components/TabItem"; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/GitStatusDialog.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/GitStatusDialog.tsx index b6b00b4452c..7e4d6a3ed82 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/GitStatusDialog.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/GitStatusDialog.tsx @@ -8,7 +8,7 @@ import { DialogFooter, DialogHeader, DialogTitle, -} from "renderer/components/ui/dialog"; +} from "@/renderer/components/ui/dialog"; interface GitStatusDialogProps { open: boolean; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/TabItem/TabItem.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/TabItem/TabItem.tsx index 2c983d4f94e..07924124a32 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/TabItem/TabItem.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreeItem/components/TabItem/TabItem.tsx @@ -15,7 +15,7 @@ import { X, } from "lucide-react"; import { useEffect, useRef, useState } from "react"; -import type { Tab, Worktree } from "shared/types"; +import type { Tab, Worktree } from "@/shared/types"; interface TabItemProps { tab: Tab; diff --git a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreePortsList/WorktreePortsList.tsx b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreePortsList/WorktreePortsList.tsx index 5d8eb37f402..c46c1235648 100644 --- a/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreePortsList/WorktreePortsList.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Sidebar/components/WorktreeList/components/WorktreePortsList/WorktreePortsList.tsx @@ -1,7 +1,7 @@ import { Button } from "@superset/ui/button"; import { ExternalLink, Network } from "lucide-react"; import { useEffect, useState } from "react"; -import type { Worktree } from "shared/types"; +import type { Worktree } from "@/shared/types"; interface WorktreePortsListProps { worktree: Worktree; diff --git a/apps/desktop/src/renderer/screens/main/components/SidebarOverlay/SidebarOverlay.tsx b/apps/desktop/src/renderer/screens/main/components/SidebarOverlay/SidebarOverlay.tsx index 74545e0672a..c78cde6c882 100644 --- a/apps/desktop/src/renderer/screens/main/components/SidebarOverlay/SidebarOverlay.tsx +++ b/apps/desktop/src/renderer/screens/main/components/SidebarOverlay/SidebarOverlay.tsx @@ -1,4 +1,4 @@ -import type { Workspace } from "shared/types"; +import type { Workspace } from "@/shared/types"; import { Sidebar } from "../Sidebar"; interface SidebarOverlayProps { diff --git a/apps/desktop/src/renderer/screens/main/components/TabContent/components/PortTab/PortTab.tsx b/apps/desktop/src/renderer/screens/main/components/TabContent/components/PortTab/PortTab.tsx index b6cc5426ccb..20775fadf81 100644 --- a/apps/desktop/src/renderer/screens/main/components/TabContent/components/PortTab/PortTab.tsx +++ b/apps/desktop/src/renderer/screens/main/components/TabContent/components/PortTab/PortTab.tsx @@ -1,7 +1,7 @@ import { Button } from "@superset/ui/button"; import { ExternalLink } from "lucide-react"; import { useEffect, useState } from "react"; -import type { Tab, Worktree } from "shared/types"; +import type { Tab, Worktree } from "@/shared/types"; interface PortTabProps { tab: Tab; diff --git a/apps/desktop/src/renderer/screens/main/components/TabContent/components/PreviewTab/PreviewTab.tsx b/apps/desktop/src/renderer/screens/main/components/TabContent/components/PreviewTab/PreviewTab.tsx index 1f094feb724..f6f1b447254 100644 --- a/apps/desktop/src/renderer/screens/main/components/TabContent/components/PreviewTab/PreviewTab.tsx +++ b/apps/desktop/src/renderer/screens/main/components/TabContent/components/PreviewTab/PreviewTab.tsx @@ -9,7 +9,7 @@ import { useRef, useState, } from "react"; -import type { Tab, Worktree } from "shared/types"; +import type { Tab, Worktree } from "@/shared/types"; interface ProxyStatus { canonical: number; diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceSelectionModal/WorkspaceSelectionModal.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceSelectionModal/WorkspaceSelectionModal.tsx index 393f20ff20e..1e41676cdd1 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceSelectionModal/WorkspaceSelectionModal.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceSelectionModal/WorkspaceSelectionModal.tsx @@ -1,8 +1,8 @@ import { Button } from "@superset/ui/button"; import { ScrollArea } from "@superset/ui/scroll-area"; import { Download, FolderOpen, Settings, Terminal } from "lucide-react"; -import { Dialog, DialogContent } from "renderer/components/ui/dialog"; -import type { Workspace } from "shared/types"; +import { Dialog, DialogContent } from "@/renderer/components/ui/dialog"; +import type { Workspace } from "@/shared/types"; interface WorkspaceSelectionModalProps { isOpen: boolean; diff --git a/apps/desktop/src/renderer/screens/main/hooks/useTabs.ts b/apps/desktop/src/renderer/screens/main/hooks/useTabs.ts index bd689e5a661..b362bb5f91f 100644 --- a/apps/desktop/src/renderer/screens/main/hooks/useTabs.ts +++ b/apps/desktop/src/renderer/screens/main/hooks/useTabs.ts @@ -1,5 +1,5 @@ import type React from "react"; -import type { Tab, Workspace } from "shared/types"; +import type { Tab, Workspace } from "@/shared/types"; import { findTabRecursive } from "../utils"; interface UseTabsProps { diff --git a/apps/desktop/src/renderer/screens/main/hooks/useTasks.ts b/apps/desktop/src/renderer/screens/main/hooks/useTasks.ts index ee746626303..8d86f0ec326 100644 --- a/apps/desktop/src/renderer/screens/main/hooks/useTasks.ts +++ b/apps/desktop/src/renderer/screens/main/hooks/useTasks.ts @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from "react"; -import type { Worktree } from "shared/types"; +import type { Worktree } from "@/shared/types"; import type { TaskStatus } from "../components/Layout/StatusIndicator"; import type { UITask, PendingWorktree } from "../types"; import { transformWorktreeToTask } from "../components/Layout/AddTaskModal/utils"; diff --git a/apps/desktop/src/renderer/screens/main/hooks/useWorkspace.ts b/apps/desktop/src/renderer/screens/main/hooks/useWorkspace.ts index 26baa525db4..adc4bf4ae9e 100644 --- a/apps/desktop/src/renderer/screens/main/hooks/useWorkspace.ts +++ b/apps/desktop/src/renderer/screens/main/hooks/useWorkspace.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import type { Workspace } from "shared/types"; +import type { Workspace } from "@/shared/types"; interface UseWorkspaceProps { setSelectedWorktreeId?: (id: string | null) => void; diff --git a/apps/desktop/src/renderer/screens/main/hooks/useWorktrees.ts b/apps/desktop/src/renderer/screens/main/hooks/useWorktrees.ts index 4bd39c7d704..28e0ff3b77e 100644 --- a/apps/desktop/src/renderer/screens/main/hooks/useWorktrees.ts +++ b/apps/desktop/src/renderer/screens/main/hooks/useWorktrees.ts @@ -1,5 +1,5 @@ import type React from "react"; -import type { Workspace, Worktree } from "shared/types"; +import type { Workspace, Worktree } from "@/shared/types"; interface UseWorktreesProps { currentWorkspace: Workspace | null; diff --git a/apps/desktop/src/renderer/screens/main/utils.ts b/apps/desktop/src/renderer/screens/main/utils.ts index 908425ff56e..fb971d65905 100644 --- a/apps/desktop/src/renderer/screens/main/utils.ts +++ b/apps/desktop/src/renderer/screens/main/utils.ts @@ -1,4 +1,4 @@ -import type { Tab, Worktree } from "shared/types"; +import type { Tab, Worktree } from "@/shared/types"; import type { TaskStatus } from "./components/Layout/StatusIndicator"; import type { WorktreeWithTask } from "./components/Layout/TaskTabs"; import type { PendingWorktree } from "./types"; diff --git a/apps/desktop/src/shared/types.ts b/apps/desktop/src/shared/types.ts index 95eef46b1fb..33c68922507 100644 --- a/apps/desktop/src/shared/types.ts +++ b/apps/desktop/src/shared/types.ts @@ -1,6 +1,6 @@ import type { BrowserWindow, IpcMainInvokeEvent } from "electron"; -import type { registerRoute } from "lib/electron-router-dom"; +import type { registerRoute } from "@/lib/electron-router-dom"; export type BrowserWindowOrNull = Electron.BrowserWindow | null; diff --git a/apps/desktop/src/shared/utils.ts b/apps/desktop/src/shared/utils.ts index ca6fb1bc93e..51bc576d078 100644 --- a/apps/desktop/src/shared/utils.ts +++ b/apps/desktop/src/shared/utils.ts @@ -1,6 +1,7 @@ -import { author as _author, name } from "~/package.json"; +import pkg from "~/package.json"; -const author = _author.name ?? _author; +const author = pkg.author.name ?? pkg.author; +const name = pkg.name; const authorInKebabCase = author.replace(/\s+/g, "-"); const appId = `com.${authorInKebabCase}.${name}`.toLowerCase(); From 0671a9682a9202eb0f05c85bd7957b519cad83c7 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 14 Nov 2025 17:25:45 -0800 Subject: [PATCH 4/7] Clean up unused dependencies and files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed: - cross-env (no longer used in scripts) - dotenv (using Vite's envDir instead) - rollup-plugin-inject-process-env (removed from config) - open (not imported anywhere) - ELECTRON_INSTALL_FIX.md (outdated documentation) - src/main/lib/workspace-manager.ts.old (old backup file) Build and dev mode still work correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/desktop/ELECTRON_INSTALL_FIX.md | 66 - apps/desktop/package.json | 4 - .../src/main/lib/workspace-manager.ts.old | 1107 ----------------- 3 files changed, 1177 deletions(-) delete mode 100644 apps/desktop/ELECTRON_INSTALL_FIX.md delete mode 100644 apps/desktop/src/main/lib/workspace-manager.ts.old diff --git a/apps/desktop/ELECTRON_INSTALL_FIX.md b/apps/desktop/ELECTRON_INSTALL_FIX.md deleted file mode 100644 index 6b1ade53d27..00000000000 --- a/apps/desktop/ELECTRON_INSTALL_FIX.md +++ /dev/null @@ -1,66 +0,0 @@ -# fixing electron installation issues - -## problem - -when running `bun run dev`, you might encounter this error: - -``` -error during start dev server and electron app: -Error: Electron uninstall -``` - -this happens because electron's binary didn't download properly during installation. bun has a known issue where electron's postinstall script doesn't always run correctly. - -## quick fix - -run the electron install script manually: - -```bash -node /Users/aleks/Documents/GitHub/Kitenite/superset/node_modules/.bun/electron@*/node_modules/electron/install.js -``` - -replace the `*` with your actual electron version if needed, or just use the glob pattern - your shell should expand it. - -## verification - -check if the electron binary was downloaded: - -```bash -ls -la /Users/aleks/Documents/GitHub/Kitenite/superset/node_modules/.bun/electron@*/node_modules/electron/ -``` - -you should see a `dist/` directory. if it's there, electron is properly installed. - -## why this happens - -1. bun installs electron package -2. electron's postinstall script should download the binary -3. with bun, this script sometimes doesn't execute -4. the package exists but the actual electron binary is missing -5. electron-vite fails when trying to start the app - -## alternative fix - -if the manual script doesn't work, try: - -```bash -# remove electron completely -bun remove electron - -# reinstall and force scripts to run -bun add -D electron@^37.3.1 - -# manually run install script -node node_modules/.bun/electron@*/node_modules/electron/install.js -``` - -## prevention - -when setting up a fresh clone: - -```bash -# after initial bun install -node node_modules/.bun/electron@*/node_modules/electron/install.js -``` - -this ensures electron's binary is always downloaded, even if bun skips the postinstall hook. diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 14bba737bc0..f8ec9dc8c82 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -63,15 +63,11 @@ "@types/semver": "^7.7.1", "@vitejs/plugin-react": "^5.0.1", "code-inspector-plugin": "^1.2.2", - "cross-env": "^10.0.0", - "dotenv": "^17.2.3", "electron": "^39.1.2", "electron-builder": "^26.0.12", "electron-extension-installer": "^2.0.0", "electron-vite": "^4.0.0", - "open": "^10.2.0", "rimraf": "^6.0.1", - "rollup-plugin-inject-process-env": "^1.3.1", "tailwindcss": "^4.0.9", "tailwindcss-animate": "^1.0.7", "tsx": "^4.19.3", diff --git a/apps/desktop/src/main/lib/workspace-manager.ts.old b/apps/desktop/src/main/lib/workspace-manager.ts.old deleted file mode 100644 index 182d6da5eae..00000000000 --- a/apps/desktop/src/main/lib/workspace-manager.ts.old +++ /dev/null @@ -1,1107 +0,0 @@ -import { randomUUID } from "node:crypto"; -import { existsSync } from "node:fs"; - -import type { - CreateTabInput, - CreateWorkspaceInput, - CreateWorktreeInput, - Tab, - UpdateWorkspaceInput, - Workspace, - Worktree, -} from "shared/types"; - -import configManager from "./config-manager"; -import worktreeManager from "./worktree-manager"; - -// Function to create default tabs for a 2x2 grid layout -function createDefaultTabs(): Tab[] { - const now = new Date().toISOString(); - const cols = 2; // 2x2 grid - return [ - { - id: randomUUID(), - name: "Terminal 1", - type: "terminal", - order: 0, - row: 0, // floor(0 / 2) = 0 - col: 0, // 0 % 2 = 0 - command: null, - createdAt: now, - }, - { - id: randomUUID(), - name: "Terminal 2", - type: "terminal", - order: 1, - row: 0, // floor(1 / 2) = 0 - col: 1, // 1 % 2 = 1 - command: null, - createdAt: now, - }, - { - id: randomUUID(), - name: "Terminal 3", - type: "terminal", - order: 2, - row: 1, // floor(2 / 2) = 1 - col: 0, // 2 % 2 = 0 - command: null, - createdAt: now, - }, - { - id: randomUUID(), - name: "Terminal 4", - type: "terminal", - order: 3, - row: 1, // floor(3 / 2) = 1 - col: 1, // 3 % 2 = 1 - command: null, - createdAt: now, - }, - ]; -} - -class WorkspaceManager { - private static instance: WorkspaceManager; - - private constructor() {} - - static getInstance(): WorkspaceManager { - if (!WorkspaceManager.instance) { - WorkspaceManager.instance = new WorkspaceManager(); - } - return WorkspaceManager.instance; - } - - /** - * Get all workspaces - */ - async list(): Promise { - const config = configManager.read(); - return config.workspaces; - } - - /** - * Get a workspace by ID - */ - async get(id: string): Promise { - const config = configManager.read(); - return config.workspaces.find((ws) => ws.id === id) || null; - } - - /** - * Create a new workspace (container for worktrees) - */ - async create( - input: CreateWorkspaceInput, - ): Promise<{ success: boolean; workspace?: Workspace; error?: string }> { - try { - // Validate that repoPath is a git repository - if (!worktreeManager.isGitRepo(input.repoPath)) { - return { - success: false, - error: "The specified path is not a git repository", - }; - } - - // Create workspace object - starts with no worktrees - const now = new Date().toISOString(); - const workspace: Workspace = { - id: randomUUID(), - name: input.name, - repoPath: input.repoPath, - branch: input.branch, - worktrees: [], - activeWorktreeId: null, - activeTabId: null, - createdAt: now, - updatedAt: now, - }; - - // Save to config - const config = configManager.read(); - config.workspaces.push(workspace); - const saved = configManager.write(config); - - if (!saved) { - return { - success: false, - error: "Failed to save workspace configuration", - }; - } - - // Set as last opened workspace - configManager.setLastOpenedWorkspaceId(workspace.id); - - return { - success: true, - workspace, - }; - } catch (error) { - console.error("Failed to create workspace:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Create a new worktree with a default tab group and tab - */ - async createWorktree( - input: CreateWorktreeInput, - ): Promise<{ success: boolean; worktree?: Worktree; error?: string }> { - try { - const workspace = await this.get(input.workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - // Create git worktree - const worktreeResult = await worktreeManager.createWorktree( - workspace.repoPath, - input.branch, - input.createBranch || false, - ); - - if (!worktreeResult.success) { - return { - success: false, - error: `Failed to create worktree: ${worktreeResult.error}`, - }; - } - - // Create default tabs for 2x2 layout - const now = new Date().toISOString(); - const defaultTabs = createDefaultTabs(); - - // Create default group tab with 4 terminal tabs in 2x2 grid - const defaultGroupTab: Tab = { - id: randomUUID(), - name: "Default", - type: "group", - tabs: defaultTabs, - rows: 2, - cols: 2, - createdAt: now, - }; - - // Create worktree object - const worktree: Worktree = { - id: randomUUID(), - branch: input.branch, - path: worktreeResult.path!, - tabs: [defaultGroupTab], - createdAt: now, - }; - - // Add to workspace - workspace.worktrees.push(worktree); - workspace.updatedAt = now; - - // Save - const config = configManager.read(); - const index = config.workspaces.findIndex((ws) => ws.id === workspace.id); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true, worktree }; - } catch (error) { - console.error("Failed to create worktree:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Helper to find a tab by ID recursively - */ - private findTab(tabs: Tab[], tabId: string): Tab | null { - for (const tab of tabs) { - if (tab.id === tabId) { - return tab; - } - if (tab.type === "group" && tab.tabs) { - const found = this.findTab(tab.tabs, tabId); - if (found) return found; - } - } - return null; - } - - /** - * Helper to find parent tab of a given tab ID - */ - private findParentTab(tabs: Tab[], tabId: string): Tab | null { - for (const tab of tabs) { - if (tab.type === "group" && tab.tabs) { - if (tab.tabs.some((t) => t.id === tabId)) { - return tab; - } - const found = this.findParentTab(tab.tabs, tabId); - if (found) return found; - } - } - return null; - } - - /** - * Create a new tab in a worktree or inside a parent tab - */ - async createTab( - input: CreateTabInput, - ): Promise<{ success: boolean; tab?: Tab; error?: string }> { - try { - const workspace = await this.get(input.workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find( - (wt) => wt.id === input.worktreeId, - ); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - const tab: Tab = { - id: randomUUID(), - name: input.name, - type: input.type || "terminal", // Default to terminal if not specified - createdAt: new Date().toISOString(), - }; - - // Type-specific properties - if (tab.type === "terminal") { - tab.command = input.command; - } else if (tab.type === "group") { - tab.tabs = []; - tab.rows = input.rows || 2; - tab.cols = input.cols || 2; - } - - // Position properties (for tabs inside a group) - if (input.parentTabId) { - const parentTab = this.findTab(worktree.tabs, input.parentTabId); - if (!parentTab || parentTab.type !== "group") { - return { success: false, error: "Parent tab not found or not a group" }; - } - - if (input.row !== undefined && input.col !== undefined && parentTab.cols) { - tab.order = input.row * parentTab.cols + input.col; - tab.row = input.row; - tab.col = input.col; - } - tab.rowSpan = input.rowSpan; - tab.colSpan = input.colSpan; - - parentTab.tabs = parentTab.tabs || []; - parentTab.tabs.push(tab); - } else { - // Top-level tab in worktree - worktree.tabs.push(tab); - } - - workspace.updatedAt = new Date().toISOString(); - - // Save - const config = configManager.read(); - const index = config.workspaces.findIndex((ws) => ws.id === workspace.id); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true, tab }; - } catch (error) { - console.error("Failed to create tab:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - async deleteTab(input: { - workspaceId: string; - worktreeId: string; - tabId: string; - }): Promise<{ success: boolean; error?: string }> { - try { - const workspace = await this.get(input.workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find( - (wt) => wt.id === input.worktreeId, - ); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - // Helper function to remove tab recursively - const removeTab = (tabs: Tab[]): boolean => { - const tabIndex = tabs.findIndex((t) => t.id === input.tabId); - if (tabIndex !== -1) { - tabs.splice(tabIndex, 1); - return true; - } - - // Search in nested tabs - for (const tab of tabs) { - if (tab.type === "group" && tab.tabs) { - if (removeTab(tab.tabs)) { - // Recalculate grid positions for remaining tabs - if (tab.cols) { - tab.tabs = tab.tabs.map((childTab, index) => { - const row = Math.floor(index / (tab.cols || 2)); - const col = index % (tab.cols || 2); - return { ...childTab, order: index, row, col }; - }); - } - return true; - } - } - } - return false; - }; - - if (!removeTab(worktree.tabs)) { - return { success: false, error: "Tab not found" }; - } - - workspace.updatedAt = new Date().toISOString(); - - // Save - const config = configManager.read(); - const index = config.workspaces.findIndex((ws) => ws.id === workspace.id); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true }; - } catch (error) { - console.error("Failed to delete tab:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Get the last opened workspace - */ - async getLastOpened(): Promise { - const lastId = configManager.getLastOpenedWorkspaceId(); - if (!lastId) return null; - return await this.get(lastId); - } - - /** - * Update a workspace - */ - async update( - input: UpdateWorkspaceInput, - ): Promise<{ success: boolean; workspace?: Workspace; error?: string }> { - try { - const config = configManager.read(); - const index = config.workspaces.findIndex((ws) => ws.id === input.id); - - if (index === -1) { - return { - success: false, - error: "Workspace not found", - }; - } - - // Update workspace - const workspace = config.workspaces[index]; - if (input.name) workspace.name = input.name; - workspace.updatedAt = new Date().toISOString(); - - config.workspaces[index] = workspace; - const saved = configManager.write(config); - - if (!saved) { - return { - success: false, - error: "Failed to save workspace configuration", - }; - } - - return { - success: true, - workspace, - }; - } catch (error) { - console.error("Failed to update workspace:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Delete a workspace - */ - async delete( - id: string, - removeWorktree = false, - ): Promise<{ success: boolean; error?: string }> { - try { - const config = configManager.read(); - const workspace = config.workspaces.find((ws) => ws.id === id); - - if (!workspace) { - return { - success: false, - error: "Workspace not found", - }; - } - - // Optionally remove worktree - if (removeWorktree) { - const worktreePath = worktreeManager.getWorktreePath( - workspace.repoPath, - workspace.branch, - ); - await worktreeManager.removeWorktree(workspace.repoPath, worktreePath); - } - - // Remove from config - config.workspaces = config.workspaces.filter((ws) => ws.id !== id); - const saved = configManager.write(config); - - if (!saved) { - return { - success: false, - error: "Failed to save workspace configuration", - }; - } - - return { success: true }; - } catch (error) { - console.error("Failed to delete workspace:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Get a tab by ID - */ - getTab( - workspaceId: string, - worktreeId: string, - tabGroupId: string, - tabId: string, - ): Tab | null { - const config = configManager.read(); - const workspace = config.workspaces.find((ws) => ws.id === workspaceId); - if (!workspace) return null; - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) return null; - - const tabGroup = worktree.tabGroups.find((tg) => tg.id === tabGroupId); - if (!tabGroup) return null; - - return tabGroup.tabs.find((t) => t.id === tabId) || null; - } - - /** - * Update terminal CWD in a tab (tab now IS the terminal) - */ - updateTerminalCwd( - workspaceId: string, - worktreeId: string, - tabGroupId: string, - tabId: string, - cwd: string, - ): boolean { - try { - const config = configManager.read(); - const workspace = config.workspaces.find((ws) => ws.id === workspaceId); - if (!workspace) return false; - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) return false; - - const tabGroup = worktree.tabGroups.find((tg) => tg.id === tabGroupId); - if (!tabGroup) return false; - - const tab = tabGroup.tabs.find((t) => t.id === tabId); - if (!tab) return false; - - // Update CWD on the tab itself (tab is the terminal) - tab.cwd = cwd; - workspace.updatedAt = new Date().toISOString(); - - // Save to config - const index = config.workspaces.findIndex((ws) => ws.id === workspaceId); - if (index !== -1) { - config.workspaces[index] = workspace; - return configManager.write(config); - } - - return false; - } catch (error) { - console.error("Failed to update terminal CWD:", error); - return false; - } - } - - /** - * Scan and import existing git worktrees for a workspace - */ - async scanAndImportWorktrees( - workspaceId: string, - ): Promise<{ success: boolean; imported?: number; error?: string }> { - try { - const workspace = await this.get(workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - // Get all git worktrees from the repository - const gitWorktrees = worktreeManager.listWorktrees(workspace.repoPath); - - // Include all worktrees (including main repo) that actually exist on filesystem - const allWorktrees = gitWorktrees.filter( - (wt) => !wt.bare && existsSync(wt.path), - ); - - // Create a set of valid worktree paths for quick lookup - const validWorktreePaths = new Set(allWorktrees.map((wt) => wt.path)); - - let importedCount = 0; - let configChanged = false; - const now = new Date().toISOString(); - - // Remove worktrees that no longer exist (either not in git or not on filesystem) - const initialWorktreeCount = workspace.worktrees.length; - workspace.worktrees = workspace.worktrees.filter((wt) => { - // Remove if not in git's worktree list OR if path doesn't exist on filesystem - if (!validWorktreePaths.has(wt.path) || !existsSync(wt.path)) { - configChanged = true; - return false; - } - return true; - }); - const removedCount = initialWorktreeCount - workspace.worktrees.length; - - for (const gitWorktree of allWorktrees) { - // Get the actual current branch for this worktree path - const currentBranch = - worktreeManager.getCurrentBranch(gitWorktree.path) || - gitWorktree.branch; - - // Check if this worktree is already in our workspace - const existingWorktree = workspace.worktrees.find( - (wt) => wt.path === gitWorktree.path, - ); - - if (existingWorktree) { - // Update the branch if it has changed - if (existingWorktree.branch !== currentBranch) { - existingWorktree.branch = currentBranch; - importedCount++; - configChanged = true; - } - } else { - // Create default tabs for 2x2 layout - const defaultTabs = createDefaultTabs(); - - // Create default tab group with 4 tabs in 2x2 grid - const defaultTabGroup: TabGroup = { - id: randomUUID(), - name: "Default", - tabs: defaultTabs, - rows: 2, - cols: 2, - createdAt: now, - }; - - // Create worktree object - const worktree: Worktree = { - id: randomUUID(), - branch: currentBranch, - path: gitWorktree.path, - tabGroups: [defaultTabGroup], - createdAt: now, - }; - - workspace.worktrees.push(worktree); - importedCount++; - configChanged = true; - } - } - - if (configChanged) { - workspace.updatedAt = now; - - // Save to config - const config = configManager.read(); - const index = config.workspaces.findIndex( - (ws) => ws.id === workspace.id, - ); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - } - - if (removedCount > 0) { - console.log(`Removed ${removedCount} deleted worktree(s) from config`); - } - - return { success: true, imported: importedCount }; - } catch (error) { - console.error("Failed to scan and import worktrees:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Reorder tabs within a tab group - */ - async reorderTabs( - workspaceId: string, - worktreeId: string, - tabGroupId: string, - tabIds: string[], - ): Promise<{ success: boolean; error?: string }> { - try { - const config = configManager.read(); - const workspace = config.workspaces.find((ws) => ws.id === workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - const tabGroup = worktree.tabGroups.find((tg) => tg.id === tabGroupId); - if (!tabGroup) { - return { success: false, error: "Tab group not found" }; - } - - // Reorder tabs based on tabIds array - const reorderedTabs = tabIds - .map((id) => tabGroup.tabs.find((t) => t.id === id)) - .filter((t): t is Tab => t !== undefined); - - // Verify all tabs are accounted for - if (reorderedTabs.length !== tabGroup.tabs.length) { - return { success: false, error: "Invalid tab order" }; - } - - // Recalculate grid positions based on new order - const tabsWithUpdatedPositions = reorderedTabs.map((tab, index) => { - const row = Math.floor(index / tabGroup.cols); - const col = index % tabGroup.cols; - return { ...tab, row, col }; - }); - - tabGroup.tabs = tabsWithUpdatedPositions; - workspace.updatedAt = new Date().toISOString(); - - // Save to config - const index = config.workspaces.findIndex((ws) => ws.id === workspaceId); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true }; - } catch (error) { - console.error("Failed to reorder tabs:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Reorder tab groups within a worktree - */ - async reorderTabGroups( - workspaceId: string, - worktreeId: string, - tabGroupIds: string[], - ): Promise<{ success: boolean; error?: string }> { - try { - const config = configManager.read(); - const workspace = config.workspaces.find((ws) => ws.id === workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - // Reorder tab groups based on tabGroupIds array - const reorderedTabGroups = tabGroupIds - .map((id) => worktree.tabGroups.find((tg) => tg.id === id)) - .filter((tg): tg is TabGroup => tg !== undefined); - - // Verify all tab groups are accounted for - if (reorderedTabGroups.length !== worktree.tabGroups.length) { - return { success: false, error: "Invalid tab group order" }; - } - - worktree.tabGroups = reorderedTabGroups; - workspace.updatedAt = new Date().toISOString(); - - // Save to config - const index = config.workspaces.findIndex((ws) => ws.id === workspaceId); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true }; - } catch (error) { - console.error("Failed to reorder tab groups:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Update tab group grid sizes (row and column sizes) - */ - async updateTabGroupGridSizes( - workspaceId: string, - worktreeId: string, - tabGroupId: string, - rowSizes?: number[], - colSizes?: number[], - ): Promise<{ success: boolean; error?: string }> { - try { - const config = configManager.read(); - const workspace = config.workspaces.find((ws) => ws.id === workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - const tabGroup = worktree.tabGroups.find((tg) => tg.id === tabGroupId); - if (!tabGroup) { - return { success: false, error: "Tab group not found" }; - } - - // Update grid sizes - if (rowSizes !== undefined) { - tabGroup.rowSizes = rowSizes; - } - if (colSizes !== undefined) { - tabGroup.colSizes = colSizes; - } - - workspace.updatedAt = new Date().toISOString(); - - // Save to config - const index = config.workspaces.findIndex((ws) => ws.id === workspaceId); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true }; - } catch (error) { - console.error("Failed to update tab group grid sizes:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Move a tab from one tab group to another - */ - async moveTabToGroup( - workspaceId: string, - worktreeId: string, - tabId: string, - sourceTabGroupId: string, - targetTabGroupId: string, - targetIndex: number, - ): Promise<{ success: boolean; error?: string }> { - try { - const config = configManager.read(); - const workspace = config.workspaces.find((ws) => ws.id === workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - const sourceTabGroup = worktree.tabGroups.find( - (tg) => tg.id === sourceTabGroupId, - ); - const targetTabGroup = worktree.tabGroups.find( - (tg) => tg.id === targetTabGroupId, - ); - - if (!sourceTabGroup || !targetTabGroup) { - return { success: false, error: "Tab group not found" }; - } - - // Find and remove tab from source group - const tabIndex = sourceTabGroup.tabs.findIndex((t) => t.id === tabId); - if (tabIndex === -1) { - return { success: false, error: "Tab not found in source group" }; - } - - const [tab] = sourceTabGroup.tabs.splice(tabIndex, 1); - - // Insert tab into target group at specified index - targetTabGroup.tabs.splice(targetIndex, 0, tab); - - // Recalculate grid positions for both groups - sourceTabGroup.tabs = sourceTabGroup.tabs.map((t, index) => { - const row = Math.floor(index / sourceTabGroup.cols); - const col = index % sourceTabGroup.cols; - return { ...t, row, col }; - }); - - targetTabGroup.tabs = targetTabGroup.tabs.map((t, index) => { - const row = Math.floor(index / targetTabGroup.cols); - const col = index % targetTabGroup.cols; - return { ...t, row, col }; - }); - - workspace.updatedAt = new Date().toISOString(); - - // Save to config - const index = config.workspaces.findIndex((ws) => ws.id === workspaceId); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true }; - } catch (error) { - console.error("Failed to move tab to group:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Remove a worktree - */ - async removeWorktree( - workspaceId: string, - worktreeId: string, - ): Promise<{ success: boolean; error?: string }> { - try { - const workspace = await this.get(workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - // Remove git worktree - await worktreeManager.removeWorktree(workspace.repoPath, worktree.path); - - // Remove from workspace - workspace.worktrees = workspace.worktrees.filter( - (wt) => wt.id !== worktreeId, - ); - workspace.updatedAt = new Date().toISOString(); - - // Save to config - const config = configManager.read(); - const index = config.workspaces.findIndex((ws) => ws.id === workspace.id); - if (index !== -1) { - config.workspaces[index] = workspace; - configManager.write(config); - } - - return { success: true }; - } catch (error) { - console.error("Failed to remove worktree:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Check if a worktree can be merged into the active worktree - */ - async canMergeWorktree( - workspaceId: string, - worktreeId: string, - ): Promise<{ - success: boolean; - canMerge?: boolean; - reason?: string; - error?: string; - isActiveWorktree?: boolean; - hasUncommittedChanges?: boolean; - }> { - try { - const workspace = await this.get(workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - // Check if this is the active worktree - if (workspace.activeWorktreeId === worktreeId) { - return { - success: true, - canMerge: false, - reason: "Cannot merge the active worktree into itself", - isActiveWorktree: true, - }; - } - - // Find the active worktree - const activeWorktree = workspace.worktrees.find( - (wt) => wt.id === workspace.activeWorktreeId, - ); - if (!activeWorktree) { - return { - success: true, - canMerge: false, - reason: "No active worktree found", - }; - } - - // Check if the source branch can be merged into the active worktree - const canMerge = await worktreeManager.canMerge( - activeWorktree.path, - worktree.branch, - ); - - return { - success: true, - canMerge: canMerge.canMerge, - reason: canMerge.reason, - hasUncommittedChanges: canMerge.hasUncommittedChanges, - isActiveWorktree: false, - }; - } catch (error) { - console.error("Failed to check if worktree can be merged:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Merge a worktree into the active worktree - */ - async mergeWorktree( - workspaceId: string, - worktreeId: string, - ): Promise<{ success: boolean; error?: string }> { - try { - const workspace = await this.get(workspaceId); - if (!workspace) { - return { success: false, error: "Workspace not found" }; - } - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - if (!worktree) { - return { success: false, error: "Worktree not found" }; - } - - // Check if this is the active worktree - if (workspace.activeWorktreeId === worktreeId) { - return { - success: false, - error: "Cannot merge the active worktree into itself", - }; - } - - // Find the active worktree - const activeWorktree = workspace.worktrees.find( - (wt) => wt.id === workspace.activeWorktreeId, - ); - if (!activeWorktree) { - return { success: false, error: "No active worktree found" }; - } - - // Merge the source branch into the active worktree - const result = await worktreeManager.merge( - activeWorktree.path, - worktree.branch, - ); - - if (!result.success) { - return { success: false, error: result.error }; - } - - return { success: true }; - } catch (error) { - console.error("Failed to merge worktree:", error); - return { - success: false, - error: error instanceof Error ? error.message : String(error), - }; - } - } - - /** - * Get the path of a worktree - */ - async getWorktreePath( - workspaceId: string, - worktreeId: string, - ): Promise { - const workspace = await this.get(workspaceId); - if (!workspace) return null; - - const worktree = workspace.worktrees.find((wt) => wt.id === worktreeId); - return worktree?.path || null; - } -} - -export default WorkspaceManager.getInstance(); From 0533ffa29d15d65f03ee57f8d8888fe29b86f750 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 14 Nov 2025 17:32:21 -0800 Subject: [PATCH 5/7] Remove app-specific config files from desktop app Removed files that should be at monorepo root or aren't needed: - .editorconfig, .npmrc (not used with Bun) - .vscode/, .github/ (root handles these) - components.json (belongs in packages/ui) - docs/ (TYPE_SAFE_IPC.md, DEEP_LINKING.md) - .gitignore (root has this) Kept only essential app-specific files: - electron.vite.config.ts - electron-builder.config.ts - tsconfig.json - index.d.ts (webview types) - package.json - trusted-dependencies-scripts.json Build verified working after cleanup. --- apps/desktop/.editorconfig | 12 - apps/desktop/.github/FUNDING.yml | 3 - apps/desktop/.gitignore | 25 --- apps/desktop/.npmrc | 3 - apps/desktop/.vscode/extensions.json | 7 - apps/desktop/.vscode/settings.json | 35 --- apps/desktop/components.json | 21 -- apps/desktop/docs/DEEP_LINKING.md | 190 ---------------- apps/desktop/docs/TYPE_SAFE_IPC.md | 318 --------------------------- 9 files changed, 614 deletions(-) delete mode 100644 apps/desktop/.editorconfig delete mode 100644 apps/desktop/.github/FUNDING.yml delete mode 100644 apps/desktop/.gitignore delete mode 100644 apps/desktop/.npmrc delete mode 100644 apps/desktop/.vscode/extensions.json delete mode 100644 apps/desktop/.vscode/settings.json delete mode 100644 apps/desktop/components.json delete mode 100644 apps/desktop/docs/DEEP_LINKING.md delete mode 100644 apps/desktop/docs/TYPE_SAFE_IPC.md diff --git a/apps/desktop/.editorconfig b/apps/desktop/.editorconfig deleted file mode 100644 index fac40a5f52c..00000000000 --- a/apps/desktop/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false \ No newline at end of file diff --git a/apps/desktop/.github/FUNDING.yml b/apps/desktop/.github/FUNDING.yml deleted file mode 100644 index 53e49767f47..00000000000 --- a/apps/desktop/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -github: daltonmenezes -patreon: daltonmenezes - diff --git a/apps/desktop/.gitignore b/apps/desktop/.gitignore deleted file mode 100644 index 43ffb2d1436..00000000000 --- a/apps/desktop/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build -/dist - -# misc -.DS_Store -.env -.env.local -.env.development.local -.env.test.local -.env.production.local -.eslintcache - -npm-debug.log* -yarn-debug.log* -yarn-error.log* -electron.vite.config.*.mjs \ No newline at end of file diff --git a/apps/desktop/.npmrc b/apps/desktop/.npmrc deleted file mode 100644 index 92177f47f01..00000000000 --- a/apps/desktop/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -auto-install-peers=true -shamefully-hoist=true -strict-peer-dependencies=false diff --git a/apps/desktop/.vscode/extensions.json b/apps/desktop/.vscode/extensions.json deleted file mode 100644 index ca1d0b1f7c4..00000000000 --- a/apps/desktop/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "recommendations": ["biomejs.biome", "bradlc.vscode-tailwindcss"], - "unwantedRecommendations": [ - "dbaeumer.vscode-eslint", - "esbenp.prettier-vscode" - ] -} diff --git a/apps/desktop/.vscode/settings.json b/apps/desktop/.vscode/settings.json deleted file mode 100644 index 2426450377c..00000000000 --- a/apps/desktop/.vscode/settings.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "[javascript]": { - "editor.formatOnSave": true - }, - - "[json]": { - "editor.formatOnSave": true - }, - - "[typescript]": { - "editor.formatOnSave": true - }, - - "[typescriptreact]": { - "editor.formatOnSave": true - }, - - "biome.enabled": true, - - "editor.codeActionsOnSave": { - "source.fixAll.biome": "explicit" - }, - - "editor.defaultFormatter": "biomejs.biome", - - "editor.quickSuggestions": { - "strings": "on" - }, - - "files.associations": { - "*.css": "tailwindcss" - }, - - "tailwindCSS.experimental.configFile": "src/renderer/globals.css" -} diff --git a/apps/desktop/components.json b/apps/desktop/components.json deleted file mode 100644 index 5881eaaf6fe..00000000000 --- a/apps/desktop/components.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "new-york", - "rsc": false, - "tsx": true, - "tailwind": { - "config": "", - "css": "src/renderer/globals.css", - "baseColor": "neutral", - "cssVariables": true, - "prefix": "" - }, - "aliases": { - "components": "renderer/components", - "utils": "renderer/utils", - "ui": "renderer/components/ui", - "lib": "renderer/lib", - "hooks": "renderer/hooks" - }, - "iconLibrary": "lucide" -} diff --git a/apps/desktop/docs/DEEP_LINKING.md b/apps/desktop/docs/DEEP_LINKING.md deleted file mode 100644 index f67b886accf..00000000000 --- a/apps/desktop/docs/DEEP_LINKING.md +++ /dev/null @@ -1,190 +0,0 @@ -# Deep Linking in Superset Desktop - -This guide explains how deep linking works in the Superset desktop app and how to use it. - -## Overview - -Deep linking allows you to open the Superset desktop app from a website or external application using custom URLs with the `superset://` protocol scheme. - -## How It Works - -### Protocol Registration - -The app registers the `superset://` protocol scheme during startup: - -- **macOS**: Uses `app.setAsDefaultProtocolClient()` to register the protocol handler -- **Windows/Linux**: Same registration mechanism, OS handles the protocol - -### Development vs Production - -In **development mode**, the protocol handler includes the executable path and arguments: - -```typescript -app.setAsDefaultProtocolClient('superset', process.execPath, [path.resolve(process.argv[1])]); -``` - -In **production mode**, it's simpler: - -```typescript -app.setAsDefaultProtocolClient('superset'); -``` - -### URL Handling Flow - -1. **Website/external app** triggers a deep link: `superset://action/something` -2. **OS** routes the URL to the Superset desktop app -3. **Main process** receives the URL via: - - `open-url` event (macOS) - app already running - - Command line args (Windows/Linux) - app launch -4. **Deep link manager** stores the URL -5. **Renderer process** polls for the URL via IPC -6. **Your handler** receives and processes the URL - -## Using Deep Links - -### From a Website - -```html - -Open Workspace - - - -``` - -### In the Renderer Process - -Use the `useDeepLink` hook to handle deep links in your React components: - -```tsx -import { useDeepLink } from '@/renderer/hooks/useDeepLink'; - -function MyComponent() { - useDeepLink((url) => { - console.log('Deep link received:', url); - - // Parse the URL - const urlObj = new URL(url); - - // Handle different deep link types - if (urlObj.hostname === 'workspace') { - const workspaceId = urlObj.pathname.slice(1); - // Load the workspace... - } else if (urlObj.hostname === 'worktree') { - // Handle worktree deep link... - } - }); - - return
My Component
; -} -``` - -### URL Format Examples - -``` -superset://workspace/abc123 # Open workspace by ID -superset://worktree/abc123/def456 # Open workspace + worktree -superset://action/create-workspace # Trigger an action -superset://import?url=https://... # Import with query params -``` - -## Implementation Details - -### Files - -- **Main process**: `apps/desktop/src/main/index.ts` - Protocol registration -- **Deep link manager**: `apps/desktop/src/main/lib/deep-link-manager.ts` - URL storage -- **IPC handlers**: `apps/desktop/src/main/lib/deep-link-ipcs.ts` - IPC communication -- **IPC types**: `apps/desktop/src/shared/ipc-channels.ts` - Type definitions -- **React hook**: `apps/desktop/src/renderer/hooks/useDeepLink.ts` - Renderer API - -### IPC Channel - -The deep link system uses a single IPC channel: - -```typescript -"deep-link-get-url": { - request: void; - response: string | null; -} -``` - -Calling this channel returns and clears the current deep link URL (one-time retrieval). - -### Development Workflow - -1. Start the dev server: `bun dev` -2. In your browser/terminal, trigger a deep link: `open superset://test/hello` -3. The app should receive and log the URL - -### Fallback Handling - -When using deep links from a website, consider that users might not have the app installed: - -```javascript -function openApp() { - const deepLink = 'superset://workspace/abc123'; - const timeout = setTimeout(() => { - // App didn't open, redirect to download page - window.location.href = '/download'; - }, 2000); - - window.addEventListener('blur', () => { - // App likely opened - clearTimeout(timeout); - }); - - window.location.href = deepLink; -} -``` - -## Testing - -### macOS - -```bash -# Open a deep link from terminal -open superset://test/hello - -# Or use a direct protocol handler -open -a Superset superset://workspace/abc123 -``` - -### Windows - -```powershell -# Run from PowerShell -start superset://test/hello -``` - -### Linux - -```bash -# Run from terminal -xdg-open superset://test/hello -``` - -## Security Considerations - -- Always validate and sanitize deep link URLs before processing -- Never execute arbitrary code from deep link parameters -- Treat deep link data as untrusted user input -- Validate workspace/worktree IDs exist before navigation - -## Troubleshooting - -**Deep links not working in development:** -- Make sure the app is running (`bun dev`) -- Check console logs for protocol registration messages -- On macOS, try `open superset://test` to verify protocol is registered - -**URL not being received in renderer:** -- Check the polling interval in `useDeepLink` hook -- Verify IPC handler is registered in `main/windows/main.ts` -- Check browser console for errors - -**Multiple instances opening:** -- This is expected behavior - the app allows multiple instances -- Each instance will independently handle deep links diff --git a/apps/desktop/docs/TYPE_SAFE_IPC.md b/apps/desktop/docs/TYPE_SAFE_IPC.md deleted file mode 100644 index 2d1b0bfd393..00000000000 --- a/apps/desktop/docs/TYPE_SAFE_IPC.md +++ /dev/null @@ -1,318 +0,0 @@ -# Type-Safe IPC in Electron - -This guide explains how to use type-safe IPC (Inter-Process Communication) in the Superset desktop application. - -## Overview - -The type-safe IPC system ensures that: -- ✅ **Compile-time type checking** - TypeScript catches incorrect channel names and payloads -- ✅ **Autocomplete** - Your IDE suggests available channels and their parameters -- ✅ **Refactor-safe** - Renaming types updates all usages automatically -- ✅ **Self-documenting** - Types serve as inline documentation - -## Architecture - -``` -┌─────────────────────────────────────────────────────────────┐ -│ shared/ipc-channels.ts │ -│ (Single source of truth) │ -│ • Define all IPC channels │ -│ • Define request/response types │ -└─────────────────────────────────────────────────────────────┘ - ▲ ▲ - │ │ - ┌───────────┴──────────┐ ┌─────────┴──────────┐ - │ preload/index.ts │ │ main/lib/*.ts │ - │ (Type-safe wrapper) │ │ (IPC handlers) │ - └───────────┬──────────┘ └────────────────────┘ - │ - ┌───────────▼──────────┐ - │ renderer/**/*.tsx │ - │ (React components) │ - └──────────────────────┘ -``` - -## How to Use - -### 1. Define Your IPC Channel - -Add your channel definition to `src/shared/ipc-channels.ts`: - -```typescript -export interface IpcChannels { - // Add your channel here - "my-channel-name": { - request: { userId: string; data: string }; // Input type - response: { success: boolean; result: any }; // Output type - }; - - // For channels with no input, use void - "get-all-users": { - request: void; - response: User[]; - }; -} -``` - -### 2. Implement the Handler (Main Process) - -In your IPC handler file (e.g., `src/main/lib/workspace-ipcs.ts`): - -```typescript -import type { CreateWorktreeInput } from "shared/types"; - -// ✅ CORRECT: Accept object parameter -ipcMain.handle("worktree-create", async (_event, input: CreateWorktreeInput) => { - return await workspaceManager.createWorktree(input); -}); - -// ❌ WRONG: Don't use positional parameters -ipcMain.handle("worktree-create", async (_event, workspaceId, branch, createBranch) => { - // This won't match the typed renderer calls! -}); -``` - -**Important:** Always accept **object parameters** (not positional), matching your type definition. - -### 3. Call from Renderer (Type-Safe!) - -In your React component: - -```typescript -// ✅ Type-safe - TypeScript knows the input and output types -const result = await window.ipcRenderer.invoke("worktree-create", { - workspaceId: currentWorkspace.id, - branch: branchName.trim(), - createBranch: true, -}); - -// TypeScript knows `result` has type: IpcResponse -if (result.success) { - console.log("Created worktree:", result.data); -} - -// ❌ TypeScript error - wrong parameter name -const result = await window.ipcRenderer.invoke("worktree-create", { - wrongId: "123", // Type error: workspaceId is required -}); - -// ❌ TypeScript error - channel name typo -const result = await window.ipcRenderer.invoke("worktree-crate", { ... }); -// ^^^^^^^^^^ Type error! -``` - -## Examples - -### Example 1: Creating a Worktree (with request payload) - -```typescript -// Renderer side -const result = await window.ipcRenderer.invoke("worktree-create", { - workspaceId: workspace.id, - branch: "feature-branch", - createBranch: true, -}); - -// TypeScript knows: -// - result.success is boolean -// - result.data is Worktree | undefined -// - result.error is string | undefined -``` - -### Example 2: Listing Workspaces (no request payload) - -```typescript -// Renderer side -const workspaces = await window.ipcRenderer.invoke("workspace-list"); - -// TypeScript knows: workspaces is Workspace[] -``` - -### Example 3: Getting a Workspace by ID (primitive request) - -```typescript -// Renderer side -const workspace = await window.ipcRenderer.invoke("workspace-get", workspaceId); - -// TypeScript knows: workspace is Workspace | null -``` - -## Migration Guide - -### Before (Untyped) - -```typescript -const result = (await window.ipcRenderer.invoke("worktree-create", { - currentWorkspaceId: currentWorkspace.id, // ❌ Typo: should be workspaceId - branch: branchName.trim(), - createBranch: true, -})) as { success: boolean; error?: string }; // ❌ Manual type assertion -``` - -**Problems:** -- Typo in `currentWorkspaceId` (should be `workspaceId`) - no error until runtime! -- Manual type assertion required -- No autocomplete -- Easy to break when refactoring - -### After (Type-Safe) - -```typescript -const result = await window.ipcRenderer.invoke("worktree-create", { - workspaceId: currentWorkspace.id, // ✅ Correct - TypeScript enforces this - branch: branchName.trim(), - createBranch: true, -}); -``` - -**Benefits:** -- TypeScript error if you use `currentWorkspaceId` instead of `workspaceId` -- No manual type assertion needed -- Full autocomplete -- Refactor-safe - -## Available Channels - -See `src/shared/ipc-channels.ts` for the complete list of available channels. - -### Workspace Operations -- `workspace-list` - Get all workspaces -- `workspace-get` - Get workspace by ID -- `workspace-create` - Create new workspace -- `workspace-update` - Update workspace -- `workspace-delete` - Delete workspace -- `workspace-get-last-opened` - Get last opened workspace -- `workspace-scan-worktrees` - Scan and import git worktrees -- `workspace-get-active-selection` - Get active selection -- `workspace-set-active-selection` - Set active selection - -### Worktree Operations -- `worktree-create` - Create new worktree - -### Tab Group Operations -- `tab-group-create` - Create new tab group -- `tab-group-reorder` - Reorder tab groups - -### Tab Operations -- `tab-create` - Create new tab -- `tab-reorder` - Reorder tabs -- `tab-move-to-group` - Move tab to another group - -## Adding New Channels - -To add a new IPC channel: - -1. **Define the channel** in `src/shared/ipc-channels.ts` -2. **Implement the handler** in `src/main/lib/workspace-ipcs.ts` (or relevant file) -3. **Use it** in your renderer components with full type safety - -### Example: Adding a new channel - -```typescript -// 1. Define in src/shared/ipc-channels.ts -export interface IpcChannels { - "user-get-profile": { - request: string; // user ID - response: { name: string; email: string } | null; - }; -} - -// 2. Implement handler in main process -ipcMain.handle("user-get-profile", async (_event, userId: string) => { - return await userService.getProfile(userId); -}); - -// 3. Use in renderer -const profile = await window.ipcRenderer.invoke("user-get-profile", userId); -// TypeScript knows: profile is { name: string; email: string } | null -``` - -## Benefits Over Untyped IPC - -| Feature | Untyped IPC | Type-Safe IPC | -|---------|-------------|---------------| -| Type checking | ❌ Runtime only | ✅ Compile-time | -| Autocomplete | ❌ No | ✅ Yes | -| Refactoring | ❌ Manual search | ✅ Automatic | -| Documentation | ❌ External docs | ✅ Types are docs | -| Error detection | ❌ At runtime | ✅ Before build | -| Parameter validation | ❌ Manual | ✅ TypeScript | - -## Troubleshooting - -### Error: "Argument of type 'X' is not assignable to parameter of type 'keyof IpcChannels'" - -**Solution:** Add the channel to `src/shared/ipc-channels.ts`. - -### Error: "Property 'X' is missing in type..." - -**Solution:** Ensure your request object includes all required fields defined in the channel's request type. - -### Error: "Expected 1 arguments, but got 2" - -**Solution:** For channels with `request: void`, don't pass any arguments: - -```typescript -// ❌ Wrong -await window.ipcRenderer.invoke("workspace-list", undefined); - -// ✅ Correct -await window.ipcRenderer.invoke("workspace-list"); -``` - -### Error: IPC calls work but functionality fails silently - -**Symptom:** Type checking passes, but operations like reordering don't work. - -**Cause:** Handler expects object parameters but receives positional parameters (or vice versa). - -**Solution:** Ensure handlers accept **object parameters** matching the type definition: - -```typescript -// ❌ WRONG: Positional parameters -ipcMain.handle("tab-reorder", async (_event, workspaceId, worktreeId, tabGroupId, tabIds) => { - // Renderer sends: { workspaceId, worktreeId, tabGroupId, tabIds } - // Handler receives: workspaceId = { workspaceId, worktreeId, ... } - // Result: worktreeId, tabGroupId, tabIds are undefined! -}); - -// ✅ CORRECT: Object parameter -ipcMain.handle("tab-reorder", async (_event, input: { workspaceId, worktreeId, tabGroupId, tabIds }) => { - return await workspaceManager.reorderTabs( - input.workspaceId, - input.worktreeId, - input.tabGroupId, - input.tabIds, - ); -}); -``` - -## Best Practices - -1. **Always define types in shared/ipc-channels.ts first** before implementing handlers -2. **Use object parameters, not positional** - Handlers must accept a single object parameter that matches the request type -3. **Use descriptive channel names** with kebab-case (e.g., `workspace-create`, not `ws-c`) -4. **Keep request/response types simple** - use types from `shared/types.ts` -5. **Document complex channels** with JSDoc comments in the interface -6. **Use IpcResponse wrapper** for operations that can fail: - ```typescript - response: IpcResponse; // { success, data?, error? } - ``` -7. **Test after adding channels** - Verify the handler receives the correct parameters - -## Future Improvements - -Potential enhancements to the type-safe IPC system: - -- [ ] Add runtime validation using Zod schemas -- [ ] Generate API documentation from types -- [ ] Add typed events (not just invoke/handle) -- [ ] Create code generation tool for boilerplate -- [ ] Add request/response logging in dev mode - ---- - -**Questions?** Check the implementation in: -- `src/shared/ipc-channels.ts` - Type definitions -- `src/preload/index.ts` - Type-safe wrapper -- `src/renderer/screens/main/components/Sidebar/Sidebar.tsx` - Usage example From 678544a295aff7d62e611c0017c1448bdec99d08 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 14 Nov 2025 17:39:04 -0800 Subject: [PATCH 6/7] Sync lockfile after rebase --- bun.lock | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/bun.lock b/bun.lock index 0078f7c349d..f28b409a779 100644 --- a/bun.lock +++ b/bun.lock @@ -81,15 +81,11 @@ "@types/semver": "^7.7.1", "@vitejs/plugin-react": "^5.0.1", "code-inspector-plugin": "^1.2.2", - "cross-env": "^10.0.0", - "dotenv": "^17.2.3", "electron": "^39.1.2", "electron-builder": "^26.0.12", "electron-extension-installer": "^2.0.0", "electron-vite": "^4.0.0", - "open": "^10.2.0", "rimraf": "^6.0.1", - "rollup-plugin-inject-process-env": "^1.3.1", "tailwindcss": "^4.0.9", "tailwindcss-animate": "^1.0.7", "tsx": "^4.19.3", @@ -455,8 +451,6 @@ "@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.1.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ=="], - "@epic-web/invariant": ["@epic-web/invariant@1.0.0", "", {}, "sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA=="], - "@esbuild-kit/core-utils": ["@esbuild-kit/core-utils@3.3.2", "", { "dependencies": { "esbuild": "~0.18.20", "source-map-support": "^0.5.21" } }, "sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ=="], "@esbuild-kit/esm-loader": ["@esbuild-kit/esm-loader@2.6.5", "", { "dependencies": { "@esbuild-kit/core-utils": "^3.3.2", "get-tsconfig": "^4.7.0" } }, "sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA=="], @@ -1295,8 +1289,6 @@ "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="], - "bundle-name": ["bundle-name@4.1.0", "", { "dependencies": { "run-applescript": "^7.0.0" } }, "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q=="], - "cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="], "cacache": ["cacache@16.1.3", "", { "dependencies": { "@npmcli/fs": "^2.1.0", "@npmcli/move-file": "^2.0.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "glob": "^8.0.1", "infer-owner": "^1.0.4", "lru-cache": "^7.7.1", "minipass": "^3.1.6", "minipass-collect": "^1.0.2", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", "mkdirp": "^1.0.4", "p-map": "^4.0.0", "promise-inflight": "^1.0.1", "rimraf": "^3.0.2", "ssri": "^9.0.0", "tar": "^6.1.11", "unique-filename": "^2.0.0" } }, "sha512-/+Emcj9DAXxX4cwlLmRI9c166RuL3w30zp4R7Joiv2cQTtTtA+jeuCAjH3ZlGnYS3tKENSrKhAzVVP9GVyzeYQ=="], @@ -1409,7 +1401,7 @@ "cross-dirname": ["cross-dirname@0.1.0", "", {}, "sha512-+R08/oI0nl3vfPcqftZRpytksBXDzOUveBq/NBVx0sUp1axwzPQrKinNx5yd5sxPu8j1wIy8AfnVQ+5eFdha6Q=="], - "cross-env": ["cross-env@10.1.0", "", { "dependencies": { "@epic-web/invariant": "^1.0.0", "cross-spawn": "^7.0.6" }, "bin": { "cross-env": "dist/bin/cross-env.js", "cross-env-shell": "dist/bin/cross-env-shell.js" } }, "sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw=="], + "cross-env": ["cross-env@7.0.3", "", { "dependencies": { "cross-spawn": "^7.0.1" }, "bin": { "cross-env": "src/bin/cross-env.js", "cross-env-shell": "src/bin/cross-env-shell.js" } }, "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw=="], "cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="], @@ -1499,18 +1491,12 @@ "deepmerge": ["deepmerge@4.3.1", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="], - "default-browser": ["default-browser@5.2.1", "", { "dependencies": { "bundle-name": "^4.1.0", "default-browser-id": "^5.0.0" } }, "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg=="], - - "default-browser-id": ["default-browser-id@5.0.0", "", {}, "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA=="], - "defaults": ["defaults@1.0.4", "", { "dependencies": { "clone": "^1.0.2" } }, "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A=="], "defer-to-connect": ["defer-to-connect@2.0.1", "", {}, "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg=="], "define-data-property": ["define-data-property@1.1.4", "", { "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "gopd": "^1.0.1" } }, "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A=="], - "define-lazy-prop": ["define-lazy-prop@3.0.0", "", {}, "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg=="], - "define-properties": ["define-properties@1.2.1", "", { "dependencies": { "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", "object-keys": "^1.1.1" } }, "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg=="], "delaunator": ["delaunator@5.0.1", "", { "dependencies": { "robust-predicates": "^3.0.2" } }, "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw=="], @@ -2295,8 +2281,6 @@ "oniguruma-to-es": ["oniguruma-to-es@4.3.3", "", { "dependencies": { "oniguruma-parser": "^0.12.1", "regex": "^6.0.1", "regex-recursion": "^6.0.2" } }, "sha512-rPiZhzC3wXwE59YQMRDodUwwT9FZ9nNBwQQfsd1wfdtlKEyCdRV0avrTcSZ5xlIvGRVPd/cx6ZN45ECmS39xvg=="], - "open": ["open@10.2.0", "", { "dependencies": { "default-browser": "^5.2.1", "define-lazy-prop": "^3.0.0", "is-inside-container": "^1.0.0", "wsl-utils": "^0.1.0" } }, "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA=="], - "ora": ["ora@9.0.0", "", { "dependencies": { "chalk": "^5.6.2", "cli-cursor": "^5.0.0", "cli-spinners": "^3.2.0", "is-interactive": "^2.0.0", "is-unicode-supported": "^2.1.0", "log-symbols": "^7.0.1", "stdin-discarder": "^0.2.2", "string-width": "^8.1.0", "strip-ansi": "^7.1.2" } }, "sha512-m0pg2zscbYgWbqRR6ABga5c3sZdEon7bSgjnlXC64kxtxLOyjRcbbUkLj7HFyy/FTD+P2xdBWu8snGhYI0jc4A=="], "p-cancelable": ["p-cancelable@2.1.1", "", {}, "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg=="], @@ -2555,12 +2539,8 @@ "rollup": ["rollup@4.53.1", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.53.1", "@rollup/rollup-android-arm64": "4.53.1", "@rollup/rollup-darwin-arm64": "4.53.1", "@rollup/rollup-darwin-x64": "4.53.1", "@rollup/rollup-freebsd-arm64": "4.53.1", "@rollup/rollup-freebsd-x64": "4.53.1", "@rollup/rollup-linux-arm-gnueabihf": "4.53.1", "@rollup/rollup-linux-arm-musleabihf": "4.53.1", "@rollup/rollup-linux-arm64-gnu": "4.53.1", "@rollup/rollup-linux-arm64-musl": "4.53.1", "@rollup/rollup-linux-loong64-gnu": "4.53.1", "@rollup/rollup-linux-ppc64-gnu": "4.53.1", "@rollup/rollup-linux-riscv64-gnu": "4.53.1", "@rollup/rollup-linux-riscv64-musl": "4.53.1", "@rollup/rollup-linux-s390x-gnu": "4.53.1", "@rollup/rollup-linux-x64-gnu": "4.53.1", "@rollup/rollup-linux-x64-musl": "4.53.1", "@rollup/rollup-openharmony-arm64": "4.53.1", "@rollup/rollup-win32-arm64-msvc": "4.53.1", "@rollup/rollup-win32-ia32-msvc": "4.53.1", "@rollup/rollup-win32-x64-gnu": "4.53.1", "@rollup/rollup-win32-x64-msvc": "4.53.1", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-n2I0V0lN3E9cxxMqBCT3opWOiQBzRN7UG60z/WDKqdX2zHUS/39lezBcsckZFsV6fUTSnfqI7kHf60jDAPGKug=="], - "rollup-plugin-inject-process-env": ["rollup-plugin-inject-process-env@1.3.1", "", { "dependencies": { "magic-string": "^0.25.7" } }, "sha512-kKDoL30IZr0wxbNVJjq+OS92RJSKRbKV6B5eNW4q3mZTFqoWDh6lHy+mPDYuuGuERFNKXkG+AKxvYqC9+DRpKQ=="], - "roughjs": ["roughjs@4.6.6", "", { "dependencies": { "hachure-fill": "^0.5.2", "path-data-parser": "^0.1.0", "points-on-curve": "^0.2.0", "points-on-path": "^0.2.1" } }, "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ=="], - "run-applescript": ["run-applescript@7.1.0", "", {}, "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q=="], - "run-parallel": ["run-parallel@1.2.0", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="], "rw": ["rw@1.3.3", "", {}, "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ=="], @@ -2637,8 +2617,6 @@ "source-map-support": ["source-map-support@0.5.21", "", { "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w=="], - "sourcemap-codec": ["sourcemap-codec@1.4.8", "", {}, "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA=="], - "space-separated-tokens": ["space-separated-tokens@2.0.2", "", {}, "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="], "speech-rule-engine": ["speech-rule-engine@4.1.2", "", { "dependencies": { "@xmldom/xmldom": "0.9.8", "commander": "13.1.0", "wicked-good-xpath": "1.3.0" }, "bin": { "sre": "bin/sre" } }, "sha512-S6ji+flMEga+1QU79NDbwZ8Ivf0S/MpupQQiIC0rTpU/ZTKgcajijJJb1OcByBQDjrXCN1/DJtGz4ZJeBMPGJw=="], @@ -2887,8 +2865,6 @@ "write-file-atomic": ["write-file-atomic@5.0.1", "", { "dependencies": { "imurmurhash": "^0.1.4", "signal-exit": "^4.0.1" } }, "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw=="], - "wsl-utils": ["wsl-utils@0.1.0", "", { "dependencies": { "is-wsl": "^3.1.0" } }, "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw=="], - "xmlbuilder": ["xmlbuilder@15.1.1", "", {}, "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg=="], "y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="], @@ -3007,8 +2983,6 @@ "@radix-ui/react-tooltip/@radix-ui/react-slot": ["@radix-ui/react-slot@1.2.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="], - "@react-three/drei/cross-env": ["cross-env@7.0.3", "", { "dependencies": { "cross-spawn": "^7.0.1" }, "bin": { "cross-env": "src/bin/cross-env.js", "cross-env-shell": "src/bin/cross-env-shell.js" } }, "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw=="], - "@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.7.0", "", { "dependencies": { "@emnapi/wasi-threads": "1.1.0", "tslib": "^2.4.0" }, "bundled": true }, "sha512-pJdKGq/1iquWYtv1RRSljZklxHCOCAJFJrImO5ZLKPJVJlVUcs8yFwNQlqS0Lo8xT1VAXXTCZocF9n26FWEKsw=="], "@tailwindcss/oxide-wasm32-wasi/@emnapi/runtime": ["@emnapi/runtime@1.7.0", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-oAYoQnCYaQZKVS53Fq23ceWMRxq5EhQsE0x0RdQ55jT7wagMu5k+fS39v1fiSLrtrLQlXwVINenqhLMtTrV/1Q=="], @@ -3213,8 +3187,6 @@ "remark-reading-time/unist-util-visit": ["unist-util-visit@3.1.0", "", { "dependencies": { "@types/unist": "^2.0.0", "unist-util-is": "^5.0.0", "unist-util-visit-parents": "^4.0.0" } }, "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA=="], - "rollup-plugin-inject-process-env/magic-string": ["magic-string@0.25.9", "", { "dependencies": { "sourcemap-codec": "^1.4.8" } }, "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ=="], - "serialize-error/type-fest": ["type-fest@0.13.1", "", {}, "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg=="], "slice-ansi/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="], From cfd652c5cfd91ff19a17385a43748e8e009e0e33 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 14 Nov 2025 17:42:58 -0800 Subject: [PATCH 7/7] Auto-fix lint errors from biome - Prefix unused variables/parameters with underscore - Fix module augmentation false positive for ImportMeta - Auto-fixed 70+ files with biome check --write Note: Remaining lint/typecheck errors are pre-existing from main branch --- apps/desktop/index.d.ts | 1 + apps/desktop/src/main/lib/window-manager.ts | 19 +- .../src/main/lib/window-state-manager.ts | 6 +- apps/desktop/src/main/lib/workspace-ipcs.ts | 6 +- apps/desktop/src/main/lib/worktree-manager.ts | 5 +- apps/desktop/src/main/windows/main.ts | 1 + apps/desktop/src/renderer/routes.tsx | 2 +- .../main/components/AppFrame/AppFrame.tsx | 6 +- .../main/components/DiffView/DiffContent.tsx | 17 +- .../components/DiffView/DiffContentArea.tsx | 17 +- .../main/components/Layout/AddTaskModal.tsx | 18 +- .../Layout/AddTaskModal/CreatingView.tsx | 5 +- .../Layout/AddTaskModal/TaskForm.tsx | 20 +- .../Layout/AddTaskModal/TaskList.tsx | 17 +- .../components/Layout/AddTaskModal/index.ts | 3 +- .../components/Layout/AddTaskModal/types.ts | 3 +- .../Layout/AddTaskModal/useTaskData.ts | 1 - .../Layout/AddTaskModal/useTaskForm.ts | 7 +- .../components/Layout/AddTaskModal/utils.ts | 13 +- .../main/components/Layout/NewLayoutMain.tsx | 46 +- .../Layout/TaskTabs/AddTaskButton.tsx | 7 +- .../components/Layout/TaskTabs/ModeToggle.tsx | 10 +- .../components/Layout/TaskTabs/TaskTabs.tsx | 12 +- .../Layout/TaskTabs/WorktreeTabButton.tsx | 18 +- .../MainContentArea/MainContentArea.tsx | 394 +++++++++--------- .../main/components/MainContentArea/index.ts | 1 - .../main/components/Sidebar/Sidebar.tsx | 5 +- .../components/ModeCarousel/ModeCarousel.tsx | 5 +- .../AnimatedBackground/AnimatedBackground.tsx | 3 +- .../components/AnimatedBackground/index.ts | 1 - .../components/ModeContent/index.ts | 1 - .../components/ModeHeader/ModeHeader.tsx | 1 - .../components/ModeHeader/index.ts | 1 - .../ModeNavigation/ModeNavigation.tsx | 9 +- .../components/ModeNavigation/index.ts | 1 - .../components/ModeCarousel/constants.ts | 1 - .../ModeCarousel/hooks/useModeDetection.ts | 7 +- .../ModeCarousel/hooks/useScrollProgress.ts | 1 - .../ModeCarousel/hooks/useScrollSnap.ts | 1 - .../Sidebar/components/ModeCarousel/index.ts | 2 +- .../Sidebar/components/ModeCarousel/types.ts | 1 - .../components/ModeSwitcher/ModeSwitcher.tsx | 1 - .../Sidebar/components/ModeSwitcher/index.ts | 1 - .../components/WorktreeList/WorktreeList.tsx | 1 - .../components/NewTabButton/index.ts | 1 - .../components/WorktreeItem/WorktreeItem.tsx | 28 +- .../components/TabItem/TabItem.tsx | 5 +- .../SidebarOverlay/SidebarOverlay.tsx | 6 +- .../main/components/SidebarOverlay/index.ts | 1 - .../WorkspaceSelectionModal.tsx | 6 +- .../WorkspaceSelectionModal/index.ts | 1 - .../src/renderer/screens/main/constants.ts | 347 ++++++++------- .../screens/main/hooks/useDiffData.ts | 10 +- .../renderer/screens/main/hooks/useSidebar.ts | 1 - .../renderer/screens/main/hooks/useTabs.ts | 2 - .../renderer/screens/main/hooks/useTasks.ts | 41 +- .../screens/main/hooks/useWorkspace.ts | 6 +- .../screens/main/hooks/useWorktrees.ts | 10 +- .../src/renderer/screens/main/types.ts | 39 +- .../src/renderer/screens/main/utils.ts | 120 +++--- apps/desktop/src/shared/ipc-channels.ts | 1 - .../src/shared/ipc-channels/deep-link.ts | 1 - .../src/shared/ipc-channels/external.ts | 1 - apps/desktop/src/shared/ipc-channels/index.ts | 3 +- apps/desktop/src/shared/ipc-channels/proxy.ts | 1 - apps/desktop/src/shared/ipc-channels/tab.ts | 8 +- .../src/shared/ipc-channels/terminal.ts | 1 - apps/desktop/src/shared/ipc-channels/types.ts | 1 - .../desktop/src/shared/ipc-channels/window.ts | 1 - .../src/shared/ipc-channels/workspace.ts | 1 - .../src/shared/ipc-channels/worktree.ts | 1 - 71 files changed, 697 insertions(+), 645 deletions(-) diff --git a/apps/desktop/index.d.ts b/apps/desktop/index.d.ts index 59390fdba02..b68a09acbae 100644 --- a/apps/desktop/index.d.ts +++ b/apps/desktop/index.d.ts @@ -8,6 +8,7 @@ interface ImportMetaEnv { readonly ENABLE_NEW_UI?: string; } +// biome-ignore lint/correctness/noUnusedVariables: Module augmentation for ImportMeta interface ImportMeta { readonly env: ImportMetaEnv; } diff --git a/apps/desktop/src/main/lib/window-manager.ts b/apps/desktop/src/main/lib/window-manager.ts index 736cabd2991..1bdac755dad 100644 --- a/apps/desktop/src/main/lib/window-manager.ts +++ b/apps/desktop/src/main/lib/window-manager.ts @@ -7,9 +7,10 @@ class WindowManager { private windowWorkspaces: Map = new Map(); private restoredWindowIds: Set = new Set(); - async createWindow( - restoreState?: { workspaceId: string | null; bounds?: Electron.Rectangle }, - ): Promise { + async createWindow(restoreState?: { + workspaceId: string | null; + bounds?: Electron.Rectangle; + }): Promise { const window = await MainWindow(); // Restore window bounds if provided @@ -55,7 +56,7 @@ class WindowManager { // Save final state before closing (window is still valid here) // Get workspace ID from our map before window might be destroyed const workspaceId = this.windowWorkspaces.get(window) ?? null; - + try { if (!window.isDestroyed()) { const bounds = window.getBounds(); @@ -77,7 +78,10 @@ class WindowManager { } catch (error) { // Silently fail if window is destroyed - we'll clean up in closed handler if (!(error instanceof Error && error.message.includes("destroyed"))) { - console.error("[WindowManager] Failed to save window state on close:", error); + console.error( + "[WindowManager] Failed to save window state on close:", + error, + ); } } }); @@ -109,7 +113,10 @@ class WindowManager { return this.windowWorkspaces.get(window) ?? null; } - setWorkspaceForWindow(window: BrowserWindow, workspaceId: string | null): void { + setWorkspaceForWindow( + window: BrowserWindow, + workspaceId: string | null, + ): void { this.windowWorkspaces.set(window, workspaceId); // Persist the workspace association windowStateManager.saveWindowState(window, workspaceId); diff --git a/apps/desktop/src/main/lib/window-state-manager.ts b/apps/desktop/src/main/lib/window-state-manager.ts index bea74137411..e254ffacae8 100644 --- a/apps/desktop/src/main/lib/window-state-manager.ts +++ b/apps/desktop/src/main/lib/window-state-manager.ts @@ -132,7 +132,10 @@ class WindowStateManager { this.write(state); } catch (error) { - console.error("[WindowStateManager] Failed to save window state by ID:", error); + console.error( + "[WindowStateManager] Failed to save window state by ID:", + error, + ); } } @@ -157,4 +160,3 @@ class WindowStateManager { } export default WindowStateManager.getInstance(); - diff --git a/apps/desktop/src/main/lib/workspace-ipcs.ts b/apps/desktop/src/main/lib/workspace-ipcs.ts index 6db2afb0ab5..5a9ce15a3b2 100644 --- a/apps/desktop/src/main/lib/workspace-ipcs.ts +++ b/apps/desktop/src/main/lib/workspace-ipcs.ts @@ -10,9 +10,9 @@ import type { } from "@/shared/types"; import configManager from "./config-manager"; +import windowManager from "./window-manager"; import workspaceManager from "./workspace-manager"; import worktreeManager from "./worktree-manager"; -import windowManager from "./window-manager"; export function registerWorkspaceIPCs() { // Open repository dialog @@ -627,7 +627,9 @@ export function registerWorkspaceIPCs() { // Detect main branch instead of using workspace.branch // This ensures we compare against main/master, not a feature branch - const mainBranch = await worktreeManager.detectMainBranch(workspace.repoPath); + const mainBranch = await worktreeManager.detectMainBranch( + workspace.repoPath, + ); return await worktreeManager.getGitDiffFile( worktree.path, diff --git a/apps/desktop/src/main/lib/worktree-manager.ts b/apps/desktop/src/main/lib/worktree-manager.ts index 1df6166e1a3..9fcdb203cd9 100644 --- a/apps/desktop/src/main/lib/worktree-manager.ts +++ b/apps/desktop/src/main/lib/worktree-manager.ts @@ -854,7 +854,10 @@ class WorktreeManager { const oldPath = parts[2]; // For renamed files // Check if file should be excluded - if (this.shouldExcludeFile(filePath) || (oldPath && this.shouldExcludeFile(oldPath))) { + if ( + this.shouldExcludeFile(filePath) || + (oldPath && this.shouldExcludeFile(oldPath)) + ) { continue; } diff --git a/apps/desktop/src/main/windows/main.ts b/apps/desktop/src/main/windows/main.ts index d0ef13e2383..1362348cf9d 100644 --- a/apps/desktop/src/main/windows/main.ts +++ b/apps/desktop/src/main/windows/main.ts @@ -5,6 +5,7 @@ import { createWindow } from "@/lib/electron-app/factories/windows/create"; import pkg from "~/package.json"; const { displayName } = pkg; + import { createApplicationMenu } from "../lib/menu"; import { type PortClosedEvent, diff --git a/apps/desktop/src/renderer/routes.tsx b/apps/desktop/src/renderer/routes.tsx index 16e749e952f..1c5d34a5207 100644 --- a/apps/desktop/src/renderer/routes.tsx +++ b/apps/desktop/src/renderer/routes.tsx @@ -1,5 +1,5 @@ -import { Router } from "@/lib/electron-router-dom"; import { Route, useRouteError } from "react-router-dom"; +import { Router } from "@/lib/electron-router-dom"; import { MainScreen } from "./screens/main"; diff --git a/apps/desktop/src/renderer/screens/main/components/AppFrame/AppFrame.tsx b/apps/desktop/src/renderer/screens/main/components/AppFrame/AppFrame.tsx index b31079f13bb..5bce819bb7c 100644 --- a/apps/desktop/src/renderer/screens/main/components/AppFrame/AppFrame.tsx +++ b/apps/desktop/src/renderer/screens/main/components/AppFrame/AppFrame.tsx @@ -3,9 +3,5 @@ interface AppFrameProps { } export function AppFrame({ children }: AppFrameProps) { - return ( -
- {children} -
- ); + return
{children}
; } diff --git a/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContent.tsx b/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContent.tsx index 83efbc0a4e9..16e81d0186e 100644 --- a/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContent.tsx +++ b/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContent.tsx @@ -155,14 +155,15 @@ export const DiffContent = memo(function DiffContent({ )} {file.status} diff --git a/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContentArea.tsx b/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContentArea.tsx index 56c41c6749f..678bba98b74 100644 --- a/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContentArea.tsx +++ b/apps/desktop/src/renderer/screens/main/components/DiffView/DiffContentArea.tsx @@ -49,21 +49,31 @@ export function DiffContentArea({ // Load selected file immediately useEffect(() => { - if (selectedFile && loadFileContent && !loadedFiles.has(selectedFile) && !loadingFiles.has(selectedFile)) { + if ( + selectedFile && + loadFileContent && + !loadedFiles.has(selectedFile) && + !loadingFiles.has(selectedFile) + ) { loadFileContent(selectedFile); } }, [selectedFile, loadFileContent, loadedFiles, loadingFiles]); // Use intersection observer to load files when they come into view useEffect(() => { - if (viewMode !== "files" || !scrollContainerRef.current || !loadFileContent) return; + if (viewMode !== "files" || !scrollContainerRef.current || !loadFileContent) + return; const observer = new IntersectionObserver( (entries) => { for (const entry of entries) { if (entry.isIntersecting) { const fileId = entry.target.id.replace("file-diff-", ""); - if (fileId && !loadedFilesRef.current.has(fileId) && !loadingFilesRef.current.has(fileId)) { + if ( + fileId && + !loadedFilesRef.current.has(fileId) && + !loadingFilesRef.current.has(fileId) + ) { loadFileContentRef.current?.(fileId); } } @@ -361,4 +371,3 @@ export function DiffContentArea({ ); } - diff --git a/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal.tsx b/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal.tsx index bf3b1a4b5a1..09505c8dc0e 100644 --- a/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal.tsx @@ -34,12 +34,12 @@ export const AddTaskModal: React.FC = ({ const [searchQuery, setSearchQuery] = useState(""); const [selectedTaskId, setSelectedTaskId] = useState(null); - const { tasks, isLoadingTasks, tasksError, refetch: refetchTasks } = useTaskData( - isOpen, - mode, - currentWorkspaceId ?? null, - worktrees, - ); + const { + tasks, + isLoadingTasks, + tasksError, + refetch: refetchTasks, + } = useTaskData(isOpen, mode, currentWorkspaceId ?? null, worktrees); const formState = useTaskForm(isOpen, mode, branches, worktrees); @@ -231,7 +231,7 @@ export const AddTaskModal: React.FC = ({ ) : ( <> {/* Show creating view when creating or when there's a status */} - {(isCreating || setupStatus) ? ( + {isCreating || setupStatus ? ( = ({ sourceBranch={formState.sourceBranch} onSourceBranchChange={formState.setSourceBranch} cloneTabsFromWorktreeId={formState.cloneTabsFromWorktreeId} - onCloneTabsFromWorktreeIdChange={formState.setCloneTabsFromWorktreeId} + onCloneTabsFromWorktreeIdChange={ + formState.setCloneTabsFromWorktreeId + } branches={branches} worktrees={worktrees} onSubmit={handleCreateTask} diff --git a/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/CreatingView.tsx b/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/CreatingView.tsx index 84d9f5a44a4..4f6e995b77a 100644 --- a/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/CreatingView.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/CreatingView.tsx @@ -1,7 +1,7 @@ import { Button } from "@superset/ui/button"; +import { ScrollArea } from "@superset/ui/scroll-area"; import { Loader2 } from "lucide-react"; import type React from "react"; -import { ScrollArea } from "@superset/ui/scroll-area"; import { TerminalOutput } from "../../Sidebar/components/CreateWorktreeModal/TerminalOutput"; interface CreatingViewProps { @@ -13,7 +13,7 @@ interface CreatingViewProps { function getStatusType(status?: string): "error" | "success" | "creating" { if (!status) return "creating"; - + const lowerStatus = status.toLowerCase(); if (lowerStatus.includes("failed") || lowerStatus.includes("error")) { return "error"; @@ -103,4 +103,3 @@ export const CreatingView: React.FC = ({ ); }; - diff --git a/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/TaskForm.tsx b/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/TaskForm.tsx index 07e46b6d640..845f469e5c5 100644 --- a/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/TaskForm.tsx +++ b/apps/desktop/src/renderer/screens/main/components/Layout/AddTaskModal/TaskForm.tsx @@ -80,7 +80,9 @@ export const TaskForm: React.FC = ({