Skip to content

Conversation

@addaleax
Copy link
Collaborator

@addaleax addaleax commented Oct 23, 2025

Split into two PRs (this one and #7493) for easier review and because I'm honestly quite sure that we want to do #7493, but the data-modeling specific parts add a bit of complexity that we should agree is worth it before we merge

chore: refactor and centralize app menu access (#7493)

Instead of having the logic for accessing the Electron application menu
from the collection tabs spread out through the codebase, bundle it
in a single interface that gives all Compass plugins access to
the menu as needed.

feat(data-modeling): add undo/redo application menu interactions

This requires adding some machinery to track whether undo/redo
events should apply to the current diagram (by testing whether
no element outside of the diagram is focused), as well as
accounting for the fact that the diagram also has hotkey handlers
that can be triggered by the same keyboard presses.

This requires adding some machinery to track whether undo/redo
events should apply to the current diagram (by testing whether
no element outside of the diagram is focused), as well as
accounting for the fact that the diagram also has hotkey handlers
that can be triggered by the same keyboard presses.
@addaleax addaleax marked this pull request as ready for review October 24, 2025 13:56
@addaleax addaleax requested a review from a team as a code owner October 24, 2025 13:56
@addaleax addaleax requested review from Copilot and mabaasit October 24, 2025 13:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds undo/redo functionality integration with the Electron application menu for the data modeling diagram editor. The implementation ensures that undo/redo operations triggered from the application menu only apply when the diagram editor has focus, and handles the case where the same keyboard shortcut might trigger handlers from both the hotkey listener and the application menu.

Key changes:

  • Added focus state tracking to determine when the diagram editor should respond to menu commands
  • Implemented debouncing logic to prevent duplicate handler invocations from multiple event sources
  • Integrated application menu handlers for undo/redo operations

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/compass-data-modeling/src/utils/utils.ts Adds dualSourceHandlerDebounce utility to prevent duplicate event handling
packages/compass-data-modeling/src/utils/utils.spec.tsx Adds tests for the debounce utility function
packages/compass-data-modeling/src/components/diagram-editor.tsx Adds focus state tracking to the diagram editor component
packages/compass-data-modeling/src/components/diagram-editor-toolbar.tsx Integrates application menu handlers with hotkey handlers using debouncing
packages/compass-data-modeling/package.json Adds dependency on compass-electron-menu package
packages/compass-components/src/index.ts Exports new useFocusStateIncludingUnfocused hook
packages/compass-components/src/hooks/use-focus-hover.ts Implements hook to detect when document is unfocused

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@addaleax addaleax requested a review from gribnoysup October 24, 2025 14:52
@addaleax addaleax merged commit ad6e7cd into main Oct 27, 2025
61 checks passed
@addaleax addaleax deleted the 9976-dev branch October 27, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants