Skip to content

right click menu on workspace item#159

Merged
Kitenite merged 3 commits intomainfrom
olive-cloud-73
Nov 27, 2025
Merged

right click menu on workspace item#159
Kitenite merged 3 commits intomainfrom
olive-cloud-73

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Nov 27, 2025

Summary by CodeRabbit

  • New Features

    • Right-click menu on workspace tabs adds "Rename" and "Open in Finder" to manage and locate workspaces quickly.
    • Workspace items now carry location info so actions (like opening the folder) work reliably.
  • Improvements

    • Minor light-theme color tweak for more consistent visuals.
    • Terminal launches now prefer the workspace folder when available for a smoother workflow.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 27, 2025

Walkthrough

Adds worktreePath to workspace objects (backend) and threads it through UI components; introduces a WorkspaceItemContextMenu component that can trigger "Open in Finder" via a TRPC mutation; small CSS, hotkey formatting, and IIFE-to-arrow refactorings.

Changes

Cohort / File(s) Summary
Backend: worktree path resolution
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts, apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts
Added getWorktreePath(worktreeId) utility and surfaced worktreePath: string on grouped workspace entries in getAllGrouped (uses getWorktreePath(...) ?? "").
Terminal router cwd usage
apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
Use getWorktreePath to derive cwd when no cwdOverride is provided (simplified resolution).
Frontend: workspace components
apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx, apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
Added worktreePath: string to Workspace interface and passed it down to WorkspaceItem (prop added).
Frontend: new context menu
apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
New WorkspaceItemContextMenu component implementing right-click menu with "Rename" and "Open in Finder"; calls TRPC mutation with worktreePath.
Misc frontend and assets
apps/desktop/src/renderer/globals.css, apps/desktop/src/renderer/screens/main/index.tsx, apps/desktop/src/resources/public/theme-boot.js
Minor CSS value tweak (tertiary-active), simplified useHotkeys function formatting, and converted an IIFE to an arrow function in theme-boot script.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as WorkspaceItem (UI)
    participant CM as WorkspaceItemContextMenu
    participant TRPC as TRPC Router (openInFinder)
    participant OS as Operating System / File Explorer

    User->>UI: Right-click workspace
    UI->>CM: show context menu
    User->>CM: Click "Open in Finder"
    CM->>CM: handleOpenInFinder()
    alt worktreePath exists
        CM->>TRPC: openInFinder(worktreePath)
        TRPC->>OS: open folder at path
        OS-->>TRPC: opened / error
        TRPC-->>CM: success / failure
    else missing worktreePath
        CM-->>User: no-op / early return
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review worktree lookup utility and edge-case handling in workspaces.ts and worktree.ts
  • Verify terminal cwd resolution change correctness in terminal.ts
  • Confirm TRPC mutation usage and error handling inside WorkspaceItemContextMenu.tsx
  • Ensure worktreePath is consistently passed and typed through WorkspaceGroupWorkspaceItemWorkspaceItemContextMenu

Possibly related PRs

Poem

🐰 I dug a little path in code today,
A ribbon named worktree to light the way.
Right-click for Finder, hop—open the door,
From backend burrow to desktop floor.
Hooray for tiny trails that help us explore! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely a list of commit messages rather than a structured description following the template, lacking proper sections like Description, Related Issues, Type of Change, Testing, and Screenshots. Restructure the description to follow the provided template, including a clear summary of changes, related issue links, type of change classification, and testing details.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'right click menu on workspace item' directly aligns with the main feature addition shown in the changeset: implementing a right-click context menu for workspace items.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch olive-cloud-73

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kitenite Kitenite changed the title olive cloud 73 right click menu on workspace item Nov 27, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx (2)

22-28: Add error handling for the mutation.

The openInFinder mutation can fail (e.g., if the path doesn't exist or there's a permission issue), but there's no error handling or user feedback.

Consider using the mutation's onError callback:

-	const openInFinder = trpc.external.openInFinder.useMutation();
+	const openInFinder = trpc.external.openInFinder.useMutation({
+		onError: (error) => {
+			console.error("Failed to open in Finder:", error);
+			// Consider showing a toast notification to the user
+		},
+	});

36-38: Consider disabling "Open in Finder" when worktreePath is empty.

The menu item is always visible, even when worktreePath is an empty string. While the handler guards against this, it would be better UX to disable or hide the option when it can't be used.

-				<ContextMenuItem onSelect={handleOpenInFinder}>
+				<ContextMenuItem 
+					onSelect={handleOpenInFinder}
+					disabled={!worktreePath}
+				>
 					Open in Finder
 				</ContextMenuItem>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a349f2 and cba4250.

📒 Files selected for processing (7)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (2 hunks)
  • apps/desktop/src/renderer/globals.css (1 hunks)
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx (2 hunks)
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx (3 hunks)
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx (1 hunks)
  • apps/desktop/src/renderer/screens/main/index.tsx (1 hunks)
  • apps/desktop/src/resources/public/theme-boot.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/resources/public/theme-boot.js
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
apps/**/*.{tsx,ts}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
apps/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Use one component per file; do not create multi-component files

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
apps/desktop/src/renderer/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Define keyboard shortcuts using the centralized system in apps/desktop/src/renderer/lib/shortcuts.ts with Arc Browser-inspired shortcut definitions

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
apps/desktop/**/*.{ts,tsx,js,jsx}

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

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

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/resources/public/theme-boot.js
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
apps/desktop/**/*.{ts,tsx}

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

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
🧠 Learnings (5)
📚 Learning: 2025-11-24T21:32:46.559Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T21:32:46.559Z
Learning: Applies to apps/desktop/src/renderer/**/*.tsx : Define keyboard shortcuts using the centralized system in apps/desktop/src/renderer/lib/shortcuts.ts with Arc Browser-inspired shortcut definitions

Applied to files:

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

Applied to files:

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

Applied to files:

  • apps/desktop/src/renderer/screens/main/index.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx
📚 Learning: 2025-11-24T21:32:46.559Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T21:32:46.559Z
Learning: Applies to apps/**/*.tsx : Use one component per file; do not create multi-component files

Applied to files:

  • apps/desktop/src/renderer/screens/main/index.tsx
📚 Learning: 2025-11-24T21:32:46.559Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T21:32:46.559Z
Learning: Applies to apps/**/*.{tsx,ts} : Co-locate component dependencies (hooks, utils, constants, tests, stories) next to the file using them

Applied to files:

  • apps/desktop/src/renderer/screens/main/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (7)
apps/desktop/src/renderer/globals.css (1)

74-74: LGTM—trivial formatting change.

The change from 0.90 to 0.9 is mathematically equivalent and has no functional impact.

apps/desktop/src/resources/public/theme-boot.js (1)

3-12: LGTM—modern syntax.

Converting the IIFE from a traditional function to an arrow function is a reasonable modernization with no functional change.

apps/desktop/src/renderer/screens/main/index.tsx (1)

32-47: LGTM—formatting refactor preserves behavior.

The refactoring to single-line arrow functions maintains the same logic, guards, and dependency arrays.

apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceGroup.tsx (1)

9-9: LGTM—correct propagation of new field.

The worktreePath field is properly added to the interface and passed through to WorkspaceItem.

Also applies to: 75-75

apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItem.tsx (1)

13-13: LGTM—clean integration of context menu.

The WorkspaceItemContextMenu wrapper is correctly integrated, preserving all existing functionality (drag/drop, rename, active styling, hover behavior) while adding the new context menu.

Also applies to: 20-20, 32-32, 78-151

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

156-156: LGTM—safe implementation with proper fallback.

The worktree lookup uses optional chaining and provides a sensible fallback ("") when the worktree is not found. The spread operator correctly preserves all existing workspace fields.

Also applies to: 184-190

apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceItemContextMenu.tsx (1)

22-22: The tRPC route external.openInFinder is properly defined.

The route exists in apps/desktop/src/lib/trpc/routers/external/index.ts (lines 42-45) as a public procedure that accepts a string input and calls shell.showItemInFolder(). The usage in the component is correct.

@Kitenite Kitenite merged commit c6d674f into main Nov 27, 2025
1 of 5 checks passed
@Kitenite Kitenite deleted the olive-cloud-73 branch November 27, 2025 16:56
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src/lib/trpc/routers/terminal/terminal.ts (1)

140-152: Eliminate code duplication by using getWorktreePath.

The getWorkspaceCwd query duplicates the logic now available in getWorktreePath. Refactor to use the utility function for consistency and maintainability.

Apply this diff:

 getWorkspaceCwd: publicProcedure
 	.input(z.string())
 	.query(async ({ input: workspaceId }) => {
 		const workspace = db.data.workspaces.find((w) => w.id === workspaceId);
 		if (!workspace) {
 			return undefined;
 		}
-
-		const worktree = db.data.worktrees.find(
-			(wt) => wt.id === workspace.worktreeId,
-		);
-		return worktree?.path;
+		return getWorktreePath(workspace.worktreeId);
 	}),
🧹 Nitpick comments (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts (1)

6-8: Consider caching or indexing if worktrees grow large.

The linear search through db.data.worktrees is acceptable for small datasets. However, if this function is called frequently and the worktrees array grows, consider adding a Map-based index for O(1) lookups.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cba4250 and 13d9fa4.

📒 Files selected for processing (3)
  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts (2 hunks)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts (1 hunks)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts
  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts
  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
apps/**/*.{tsx,ts}

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

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

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

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

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts
  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
apps/desktop/**/*.{ts,tsx}

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

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

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

Applied to files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts
  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
🧬 Code graph analysis (1)
apps/desktop/src/lib/trpc/routers/terminal/terminal.ts (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/worktree.ts (1)
  • getWorktreePath (6-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (1)
apps/desktop/src/lib/trpc/routers/terminal/terminal.ts (1)

6-6: LGTM! Good refactoring to use the utility function.

The import and usage of getWorktreePath correctly centralizes the worktree path lookup logic, improving maintainability.

Also applies to: 49-51

@Kitenite Kitenite restored the olive-cloud-73 branch November 29, 2025 18:00
@coderabbitai coderabbitai Bot mentioned this pull request Nov 29, 2025
5 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Dec 1, 2025
@Kitenite Kitenite deleted the olive-cloud-73 branch December 1, 2025 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant