Skip to content

feat: add unified right-click context menus across all components#240

Open
Mr54233 wants to merge 1 commit into
hanshuaikang:mainfrom
Mr54233:refactor/context-menu
Open

feat: add unified right-click context menus across all components#240
Mr54233 wants to merge 1 commit into
hanshuaikang:mainfrom
Mr54233:refactor/context-menu

Conversation

@Mr54233

@Mr54233 Mr54233 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Extracts a shared ContextMenu component (Radix UI) and adds right-click context menus to all major interactive areas of the app.

Closes #234

What's included

Shared component

  • src/components/ContextMenu.tsx — generic context menu with typed MenuItem array, async onSelect with error catching, variant support (default/success/destructive)

Context menus added (8 components)

Component Menu items
TaskListItem Star, Rename, Resume, Mark done, Cancel, Reconnect, Merge worktree, Discard worktree, Delete (conditional on task status)
ProjectRail (vertical) Open in file manager, Copy path, Hide/show, Delete
ProjectRail (expanded) Same as above
FileExplorer / TreeItem Replaces dedicated component with shared ContextMenu
FileViewer tab Close, Close others, Close all, Copy path
GitChanges Discard, Open file, Copy path
GitHistory Copy commit hash
RunningView terminal Copy, Paste, Clear, Select all + Cancel/Reconnect (status-dependent)
SessionView Copy message

Bug fixes / refactors along the way

  • Fix ProjectDrawer closing when clicking context menu items (Radix portal renders outside drawer ref)
  • Remove fake MouseEvent hack in GitChanges onDiscard
  • Async onSelect error catching in ContextMenu

Test plan

  • Right-click each component listed above and verify menu appears
  • Verify status-conditional items (e.g., detached tasks show "Reconnect", active tasks show "Cancel")
  • Verify ProjectDrawer doesn't close when clicking context menu items inside it
  • Verify GitChanges discard works without console errors

@
feat: add unified right-click context menus across all components

Extract a shared ContextMenu component (Radix UI) and add context menus
to TaskListItem, ProjectRail, FileExplorer, FileViewer, GitChanges,
GitHistory, RunningView terminal, and SessionView.

Menu items per component:
- TaskListItem: star, rename, resume, mark done, cancel, reconnect,
  merge/discard worktree, delete (conditional on task status)
- ProjectRail: open in file manager, copy path, hide/show, delete
- FileExplorer/TreeItem: replace dedicated component with shared one
- FileViewer tab: close, close others, close all, copy path
- GitChanges: discard, open file, copy path
- GitHistory: copy commit hash
- RunningView terminal: copy, paste, clear, select all + cancel/reconnect
- SessionView: copy message

Also includes:
- Async onSelect with error catching
- Fix ProjectDrawer closing when clicking context menu items
- Remove fake MouseEvent hack in GitChanges onDiscard
- Hide/show project option in ProjectRail
@
@Mr54233
Mr54233 force-pushed the refactor/context-menu branch from f765009 to 3a7ea9e Compare June 7, 2026 05:15
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