Repository navigation
Label canvas-layout shortcuts in Settings so the ⌘=/⌘-/⌘0 zoom duplicates read as context-scoped (#5810) - #6867
austinywang wants to merge 9 commits into
Conversation
Extract the Settings → Keyboard Shortcuts built-in scope-caption mapping out of `KeyboardShortcutsSection.scopeCaption` into a testable `builtInScopeCaption(for:)` seam (behavior-preserving) and add regression coverage for the context-scoped duplicate-default shortcuts called out in issue #5810. The ⌘= / ⌘- / ⌘0 zoom family intentionally ships the same chord across the browser, the markdown viewer, and (for ⌘0) the canvas, disambiguated only by focus/layout context. Each Settings row must state its own scope so the list does not read as a raw duplicate-default collision. This commit is the red half of the regression: canvas-scoped bindings (including `Canvas: Actual Size`, ⌘0) currently fall through to "Only while a terminal pane is focused", so the canvas caption assertions fail. The fix follows in the next commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Settings → Keyboard Shortcuts indicates context-scoped duplicate-default bindings with a per-row scope caption so they don't read as collisions (issue #5810). Canvas-layout-scoped actions — including `Canvas: Actual Size` (⌘0), which ships the same default as the browser and markdown "Actual Size" bindings — fell through to "Only while a terminal pane is focused", which is wrong. Map the built-in `workspaceCanvasLayout` clause (and the compound `canvas && !browser && !markdown` clause used by `Canvas: Actual Size`) to a new "Only while the canvas layout is active" caption, localized across all supported locales. This greens the regression added in the previous commit so the whole ⌘= / ⌘- / ⌘0 zoom-shortcut family is accurately scoped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughRefactors keyboard shortcut "when" scope caption logic by extracting it into a new centralized ChangesScope caption centralization
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (24 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Address review: the compound canvas case previously matched only `.and(.key(canvasLayoutKey), _)` (canvas key on the left). A clause that canonically placed the canvas predicate on the right side of an `&&` would fall through to the terminal caption — re-introducing the exact mislabel this change fixes. Detect the canvas-layout key as a *required* `&&` conjunct at any `.and` nesting depth via `clauseRequiresKey`, so position no longer matters. Negated (`.not`) occurrences are correctly excluded. Adds coverage for right-placed, nested, and negated canvas conjuncts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…default-shortcuts-bound-to-both # Conflicts: # Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/KeyboardShortcutsSection.swift # Resources/Localizable.xcstrings
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/ShortcutScopeCaption.swift`:
- Around line 24-73: The issue is that builtInScopeCaption(for:) is a file-scope
helper being used across files, which violates the top-level API rule. Move this
behavior onto the owning type by adding an extension method on
ShortcutWhenClause (for example, a builtInScopeCaption property or method) and
update KeyboardShortcutsSection.swift to call it through the clause instance.
Keep any remaining file-scope helper such as canvasLayoutCaption
private/fileprivate if needed, and remove the free cross-file function.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 622b6608-ef59-4178-a540-979bc21c5d39
⛔ Files ignored due to path filters (1)
.github/swift-file-length-budget.tsvis excluded by!**/*.tsv
📒 Files selected for processing (4)
Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/KeyboardShortcutsSection.swiftPackages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Sections/ShortcutScopeCaption.swiftPackages/macOS/CmuxSettingsUI/Tests/CmuxSettingsUITests/ShortcutScopeCaptionTests.swiftResources/Localizable.xcstrings
…default-shortcuts-bound-to-both
Fixes #5810
Problem
Issue #5810 reports that Zoom In/Out (⌘= / ⌘-) and Markdown Viewer: Zoom In/Out ship the same default chords, so Settings → Keyboard Shortcuts looks like it has duplicate-default collisions. The endorsed resolutions are either to re-scope the defaults or to label the context-scoped duplicates in the UI.
These zoom bindings are intentionally context-scoped —
⌘=zooms the browser when a browser pane is focused and the markdown viewer when a markdown preview is focused; they never both fire — so unbinding would regress the feature. The right fix is the UI labeling.That labeling already exists for most cases: #5196 added a per-row scope caption ("Only while a browser pane is focused" / "Only while a markdown preview is focused" / "…right sidebar…"), and #5394 fixed the browser/markdown non‑US‑layout zoom path. But there's a remaining gap in the same mechanism:
⌘0"Actual Size" trio ships on the browser, the markdown viewer, and the canvas (Canvas: Actual Size). The canvas member — like every canvas-layout-scoped shortcut — fell through to the catch-all and was mislabeled "Only while a terminal pane is focused", which is wrong and undercuts the very indication this issue asks for.Fix
KeyboardShortcutsSection.scopeCaptioninto a testablebuiltInScopeCaption(for:)seam.workspaceCanvasLayoutclause (and the compoundcanvas && !browser && !markdownclause used byCanvas: Actual Size) to a new, accurate "Only while the canvas layout is active" caption.After this, the whole
⌘=/⌘-/⌘0zoom-shortcut family is accurately scoped in Settings: browser, markdown, and canvas each read with their own context instead of looking like a raw collision.Tests (two-commit red → green)
ShortcutScopeCaptionTests(package test target, auto-discovered by SwiftPM):Canvas: Actual Size, ⌘0) assert a canvas caption while the code still returns the terminal caption → red.Coverage asserts: the clause→caption mapping for every built-in scope; each zoom action's caption (browser/markdown/canvas) including the explicit "canvas must not be the terminal caption" regression; and that the ⌘=/⌘-/⌘0 duplicate defaults share a keystroke yet are context-disjoint (
bindingsCollide == false), which is exactly why the scope caption is required.Scope notes
Localization audit
Added one new user-facing string,
shortcut.when.caption.canvasLayout, toResources/Localizable.xcstringswith translations for all 20 supported locales (verified at locale parity with the siblingshortcut.when.caption.terminalFocuskey). Noweb/or docs message catalogs are involved. No new bare English literals — all captions go throughString(localized:).Summary by cubic
Label canvas-layout shortcuts in Settings with “Only while the canvas layout is active” so the ⌘=/⌘-/⌘0 zoom defaults read as context-scoped, not duplicates. Fixes #5810; detection now handles the canvas key regardless of clause order.
Bug Fixes
workspaceCanvasLayoutand any clause that requires that key (at any&&depth) to the new caption; negated ororcases are excluded to avoid mislabels.shortcut.when.caption.canvasLayoutinLocalizable.xcstringswith translations for all supported locales.Refactors
ShortcutScopeCaptionResolverand used it inKeyboardShortcutsSection.scopeCaption.ShortcutScopeCaptionTests; covers caption mapping (incl. the combined browser-or-text-preview caption), zoom defaults’ context-disjointness, and right-placed/nested/negated canvas conjuncts.Written for commit e24bfe2. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Tests