Skip to content

Show one context menu at a time - #447

Merged
SunkenInTime merged 4 commits into
mainfrom
t3/one-context-menu
Nov 1, 2026
Merged

SunkenInTime merged 4 commits into
mainfrom
t3/one-context-menu

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Second right-click on the canvas, before and after, web and desktop

Library background then a folder, before and after

Real frames from the web runs, stepped at 1.5 s each:

Menus stacking, then one menu

ci: test web

Right-click an agent, then right-click another agent, and both menus stay open. Add a page row and there are three. A left click on another agent left the first menu open too. #417 noted this and left it.

shadcn_ui puts every context menu and every region that opens one in a single tap group, so a press on another region doesn't count as a press outside the open menu. The group is a constant in the package, and a menu has to share it with its submenus, so it can't be split from outside.

ContextMenuRegion is a small wrapper that remembers the one open menu. A press on any region closes it, and so does opening a menu from code, like the three-dot button on a strategy. All 13 regions in the app now use it, and a test fails if a new one calls shadcn directly.

The library already had a smaller version of this, libraryContextMenuDismissalProvider, which closed strategy and folder menus on any press in the library. It didn't reach the library background menu, and one behavior shouldn't have two mechanisms, so I removed it. That's why folder_content.dart shows a re-indented block.

What I saw in a running build

Windows release driver builds against the dev deployment, and Edge at 1600 x 900 on web builds against dev. Before and after differ only by this PR.

  • one-context-menu.json, new, 96 steps: 9 failures before, clean after. It covers agent to agent, left click on another agent, agent to text to smoke, page to page, page to agent, agent to page, strategy to strategy, and strategy to background both ways. It ends by opening the Weapon submenu.
  • Strategy to strategy already worked before this PR. The library failures were all with the background menu.
  • right-click-local.json (101 steps) and right-click-cloud.json (63 steps) from Right-click a page to rename or delete it, and an agent to delete it #417: clean.
  • Web, same steps on both builds: agent to agent, left click on another agent, page to agent, background to folder. The pictures above are those runs.
  • Five new tests in test/context_menu_region_test.dart. Taking the fix out fails the three that cover it. The submenu test guards against closing too much.

I reran the new script and right-click-local.json on a rebuild of the merged head, and both were clean. CI passed on the same commit.

Not covered

  • right-click-viewer.json wasn't rerun. Viewers get no menu, and this PR doesn't change who gets one.
  • The lineup ability picker uses its own dialog with a barrier, so I left it alone.
  • The browser's own menu showing up on a second right-click on web is a different bug with a different cause. It has its own PR.

The driver gained expectText, which counts text on screen. It only compiles into driver builds.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with no actionable issues found.

Summary

Adds ContextMenuRegion to keep one context menu open across the app.

  • A press on another region replaces the open context menu.

Static review found no actionable issues. No remaining references to the removed provider were found. Tests and UI captures were not rerun because Flutter and Dart are unavailable in this environment.

SunkenInTime explicitly left the lineup ability picker unchanged because it uses a dialog with a barrier. SunkenInTime also identified the browser’s second-right-click menu as a separate bug handled by another PR.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Press another region] --> B[Hide the tracked menu]
  C[Open a menu from code] --> D[Controller listener runs]
  D --> B
  D --> E[Track the newly opened menu]
  F[Menu closes or its widget is disposed] --> G[Clear its tracked controller]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fe98bb82-aa18-4b21-8270-f595d1297c1f
Commits

Reviewing files that changed from the base of the PR and between eb888f7 and 53c85c0.

Files selected for processing: 17
  • lib/dev/drive/drive.dart
  • lib/providers/library_context_menu_provider.dart
  • lib/widgets/context_menu_region.dart
  • lib/widgets/dialogs/lineup_panel_dialog.dart
  • lib/widgets/draggable_widgets/image/placed_image_builder.dart
  • lib/widgets/draggable_widgets/text/placed_text_builder.dart
  • lib/widgets/folder_card.dart
  • lib/widgets/folder_content.dart
  • lib/widgets/folder_navigator.dart
  • lib/widgets/map_theme_settings_section.dart
  • lib/widgets/mouse_watch.dart
  • lib/widgets/pages_bar.dart
  • lib/widgets/replay/replay_library_content.dart
  • lib/widgets/sidebar_widgets/color_library.dart
  • lib/widgets/strategy_tile/strategy_tile.dart
  • test/context_menu_region_test.dart
  • tool/drive/scripts/one-context-menu.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@SunkenInTime
SunkenInTime merged commit aa4d254 into main Nov 1, 2026
15 checks passed
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