Skip to content

Centralize keyboard shortcuts following macOS HIG patterns#3

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/refactor-features-shortcuts
Closed

Centralize keyboard shortcuts following macOS HIG patterns#3
Copilot wants to merge 3 commits intomainfrom
copilot/refactor-features-shortcuts

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 23, 2025

Keyboard shortcuts were scattered across the codebase using hardcoded key codes and inline shortcut definitions, making them difficult to maintain and inconsistent with macOS conventions.

Changes

New Core/KeyboardShortcuts.swift

  • KeyboardShortcuts enum: All SwiftUI menu shortcuts in one place
  • KeyCodes enum: AppKit key codes replacing magic numbers
  • ShortcutDocumentation: Structured shortcut info for help/settings

Refactored Views

  • DataGridView, EditorTextView, ContentView, HistoryListViewController, SQLCompletionWindowController, NSViewController+SwiftUI: Replace hardcoded key codes with KeyCodes enum
  • SidebarView, QueryTabBar, QueryEditorView: Use KeyboardShortcuts for menu items

Menu Updates

  • Added Query menu with Execute (⌘↩) and Format (⌘⇧L)
  • All shortcuts now reference centralized definitions

Example

Before:

if event.keyCode == 53 { // Escape
    dismiss()
}

After:

if event.keyCode == KeyCodes.escape {
    dismiss()
}

Menu shortcuts:

Button("Execute Query") { ... }
    .keyboardShortcut(KeyboardShortcuts.executeQuery)
Original prompt

Refactoring/refactor/reavamp all feature need shortcut or not shortcode following macos pattern


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 23, 2025 01:43
- Create centralized KeyboardShortcuts.swift with all shortcut definitions
- Add KeyCodes enum for consistent key code references
- Add ShortcutDocumentation for help/settings display
- Update OpenTableApp.swift to use KeyboardShortcuts enum
- Add Query menu with Execute Query (⌘↩) and Format Query (⌘⇧L)
- Refactor DataGridView, EditorTextView, ContentView, HistoryListViewController
- Refactor SQLCompletionWindowController, NSViewController+SwiftUI
- Update SidebarView and QueryTabBar to use centralized shortcuts
- Update README.md with comprehensive keyboard shortcut documentation
- Update CLAUDE.md to reflect new keyboard shortcut organization

Co-authored-by: datlechin <56961917+datlechin@users.noreply.github.com>
Co-authored-by: datlechin <56961917+datlechin@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor feature shortcuts to follow macOS pattern Centralize keyboard shortcuts following macOS HIG patterns Dec 23, 2025
Copilot AI requested a review from datlechin December 23, 2025 01:48
@datlechin datlechin closed this Dec 23, 2025
@datlechin datlechin deleted the copilot/refactor-features-shortcuts branch December 23, 2025 16:08
datlechin added a commit that referenced this pull request Apr 28, 2026
- crates/app/src/services/structure_tracker.rs: per-tab DDL changeset
  registry. Mirrors change_tracker.rs (thread-local registry keyed
  by tab UUID, subscription channel, undo / redo stacks) but at the
  schema-operation level. StructureOp covers CreateTable, RenameTable,
  AddColumn, DropColumn, RenameColumn, AlterColumn, ReorderColumn
  (MySQL only), AddIndex, DropIndex, AddForeignKey, DropForeignKey.

  materialize() walks the op log and emits ordered DDL statements
  per driver dialect. Statement ordering avoids dependency errors:
  rename-table → drop-FK → drop-index → drop-column → rename-column
  → alter-column → add-column → reorder → add-index → add-FK. For
  New mode (single CreateTable op) the fast path delegates straight
  to build_create_table.

  MySQL alter grouping: all AlterColumn ops on the same column
  collapse into one MODIFY COLUMN reflecting the latest state, so
  multi-attribute changes don't produce three statements that each
  re-state the whole definition.

- crates/app/src/services/workspace_state.rs: extend WorkspaceTabRecord
  with Structure { schema, table } variant for Edit-mode persistence.
  New mode is intentionally not persisted (drafts for non-existent
  tables shouldn't survive disconnect). Added #[serde(other)] Unknown
  variant for forward-compat: an older binary reading newer state
  silently drops unrecognised tab kinds rather than failing the
  entire workspace load. clamp_connection retains-out Unknown
  variants up front so they don't contribute to count or active_idx.

- crates/app/src/ui/app/workspace_tabs.rs: extend restore_workspace_tabs
  with placeholder Structure / Unknown match arms (no-op for now;
  the actual append_structure_tab wiring lands in the next milestone).

8 unit tests cover push/undo round-trips, clear, materialize ordering
across all op types, MySQL alter-grouping, Postgres per-attribute
emission, and registry tab-isolation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants