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/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/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 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..0fec65b6150 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,21 @@ 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"), - }, }, }, + + resolve: { + // Deduplicate react/react-dom from workspace packages + dedupe: ["react", "react-dom"], + }, }, }); 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/package.json b/apps/desktop/package.json index 809450f0e7a..f8ec9dc8c82 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", @@ -66,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/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 ea0d4c5b8a1..7331e246757 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -1,19 +1,12 @@ -// 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"; -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"; @@ -50,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/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 4f44ca803f8..5a9ce15a3b2 100644 --- a/apps/desktop/src/main/lib/workspace-ipcs.ts +++ b/apps/desktop/src/main/lib/workspace-ipcs.ts @@ -7,12 +7,12 @@ import type { MosaicNode, UpdatePreviewTabInput, UpdateWorkspaceInput, -} from "shared/types"; +} 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/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-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(); 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/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 6d0c1bcf028..1362348cf9d 100644 --- a/apps/desktop/src/main/windows/main.ts +++ b/apps/desktop/src/main/windows/main.ts @@ -1,8 +1,11 @@ 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..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 = ({