Skip to content

feat(desktop): ⌘⇧L opens diff viewer in v2 workspace#3556

Merged
saddlepaddle merged 1 commit into
mainfrom
metashiftl-hotkey-open-diff-viewer-in-new-tab
Apr 18, 2026
Merged

feat(desktop): ⌘⇧L opens diff viewer in v2 workspace#3556
saddlepaddle merged 1 commit into
mainfrom
metashiftl-hotkey-open-diff-viewer-in-new-tab

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Apr 18, 2026

Summary

  • Rename TOGGLE_EXPAND_SIDEBAROPEN_DIFF_VIEWER (same ⌘⇧L / Ctrl+Shift+Alt+L binding) — the v1 action was effectively "open the diff viewer," so unifying the ID.
  • In v2, the hotkey focuses any existing diff pane (and its tab), or opens a new tab with a diff pane. It also flips the workspace sidebar to the Changes tab.
  • V1 keeps its existing expand-sidebar-to-Changes behavior under the new ID.

Test plan

  • V2 workspace: ⌘⇧L with no diff pane open → new tab with diff viewer, sidebar opens on Changes tab
  • V2 workspace: ⌘⇧L with diff pane in another tab → focuses that tab + pane
  • V2 workspace: ⌘⇧L with diff pane in current tab → focuses the pane
  • V1 workspace: ⌘⇧L still toggles Changes / Tabs sidebar modes as before
  • RightSidebar expand/collapse tooltip still shows correct hotkey

Summary by cubic

⌘⇧L (Ctrl+Shift+Alt+L) now opens or focuses the diff viewer in the v2 workspace. v1 behavior is unchanged.

  • New Features

    • In v2, focus an existing diff pane (and its tab) if present; otherwise open a new tab with a diff pane.
  • Refactors

    • Renamed hotkey ID TOGGLE_EXPAND_SIDEBAR to OPEN_DIFF_VIEWER and updated labels, registry, and tooltip.

Written for commit 6fea6da. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced a new "Open Diff Viewer" hotkey (⌘⇧L) that opens the diff viewer in a new tab or focuses an existing one
    • The diff viewer displays changes with an organized sidebar interface for easy navigation

Rename TOGGLE_EXPAND_SIDEBAR to OPEN_DIFF_VIEWER (same binding).
In v2, focus any existing diff pane or open one in a new tab, and
flip the workspace sidebar to the Changes tab. V1 keeps its existing
expand-sidebar behavior under the new ID.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

This PR replaces the TOGGLE_EXPAND_SIDEBAR hotkey with OPEN_DIFF_VIEWER. The new hotkey handler opens or focuses the diff viewer in the right sidebar, attempting to reuse existing diff panes or creating new ones as needed, instead of simply toggling sidebar expansion.

Changes

Cohort / File(s) Summary
Hotkey Registry
apps/desktop/src/renderer/hotkeys/registry.ts
Replaced TOGGLE_EXPAND_SIDEBAR entry with OPEN_DIFF_VIEWER entry. Same key bindings across platforms (mac/windows/linux), but label changed to "Open Diff Viewer" and description added explaining the new functionality.
Hotkey Handlers
apps/desktop/src/renderer/routes/.../hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts, apps/desktop/src/renderer/routes/.../page.tsx
Added new OPEN_DIFF_VIEWER handler that opens the right sidebar with the "changes" tab active, searches for existing diff panes in tabs, and creates a new diff pane if none exists. Updates hotkey references in v2 workspace route.
UI Components
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx
Updated HotkeyLabel id reference from TOGGLE_EXPAND_SIDEBAR to OPEN_DIFF_VIEWER in the sidebar expand/collapse tooltip.

Sequence Diagram

sequenceDiagram
    actor User
    participant HotkeySystem as Hotkey System
    participant Handler as OPEN_DIFF_VIEWER Handler
    participant StateManager as Workspace State
    participant TabSystem as Tab/Pane System

    User->>HotkeySystem: Press OPEN_DIFF_VIEWER (⌘⇧L)
    HotkeySystem->>Handler: Invoke handler
    Handler->>StateManager: Open right sidebar
    Handler->>StateManager: Set activeTab to "changes"
    Handler->>TabSystem: Scan existing tabs for diff pane
    alt Diff pane exists
        TabSystem->>Handler: Return existing diff pane
        Handler->>StateManager: Set as active tab/pane
    else No diff pane found
        Handler->>TabSystem: Create new tab with diff pane
        TabSystem->>StateManager: Add to store
    end
    StateManager->>User: Diff viewer displayed/focused
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hotkey reborn, with purpose new,
From sidebar toggles to diffs in view,
Tab-hopping logic, so smooth and sleek,
When pressed, the changes you now seek! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: renaming the hotkey action and its new behavior of opening/focusing the diff viewer in v2 workspace.
Description check ✅ Passed The description includes a clear summary, testing checklist, and notes on expected behavior across v1 and v2 workspaces, though missing sections from the template like 'Type of Change'.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch metashiftl-hotkey-open-diff-viewer-in-new-tab

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts (1)

83-90: Consider deterministic tab ordering for diff-pane lookup.

Iterating state.tabs and returning the first match works, but if multiple diff panes exist across tabs, the one found depends on insertion order of state.tabs and Object.values(tab.panes). If you want to prefer the currently active tab's diff pane (so ⌘⇧L in a tab that contains a diff pane always focuses that pane — matching the "V2: ⌘⇧L with diff pane in current tab → focus the pane" test case), check the active tab first.

♻️ Suggested refinement
 		const state = store.getState();
-		for (const tab of state.tabs) {
+		const orderedTabs = state.activeTabId
+			? [
+					...state.tabs.filter((t) => t.id === state.activeTabId),
+					...state.tabs.filter((t) => t.id !== state.activeTabId),
+				]
+			: state.tabs;
+		for (const tab of orderedTabs) {
 			for (const pane of Object.values(tab.panes)) {
 				if (pane.kind !== "diff") continue;
 				state.setActiveTab(tab.id);
 				state.setActivePane({ tabId: tab.id, paneId: pane.id });
 				return;
 			}
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts
around lines 83 - 90, The lookup for a diff pane should prefer the currently
active tab: first inspect state.tabs to find the tab with id ===
state.activeTabId (or use state.activeTab) and, if that tab has any pane with
pane.kind === "diff", call state.setActiveTab(...) and state.setActivePane(...)
for that pane and return; only if the active tab has no diff panes, fall back to
iterating the other tabs (state.tabs) and their panes (Object.values(tab.panes))
to find the first diff pane and activate it as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx`:
- Around line 198-203: The tooltip's HotkeyLabel currently uses
id="OPEN_DIFF_VIEWER" but the hotkey now opens/focuses a diff pane (see
useWorkspaceHotkeys.ts) while the button runs handleExpandToggle/setMode to
expand/collapse; fix by either changing the HotkeyLabel id to a true toggle
hotkey (e.g., USE a new id like "TOGGLE_SIDEBAR" that maps to the
expand/collapse handler) or by updating the label text to reflect the actual
hotkey action (e.g., when collapsed show "Open diff viewer" and when expanded
show "Collapse sidebar"), or remove HotkeyLabel and use plain text if no
matching hotkey exists; update the code around HotkeyLabel
(id="OPEN_DIFF_VIEWER") and ensure consistency with useWorkspaceHotkeys.ts and
the button's handleExpandToggle/setMode behavior.

---

Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts:
- Around line 83-90: The lookup for a diff pane should prefer the currently
active tab: first inspect state.tabs to find the tab with id ===
state.activeTabId (or use state.activeTab) and, if that tab has any pane with
pane.kind === "diff", call state.setActiveTab(...) and state.setActivePane(...)
for that pane and return; only if the active tab has no diff panes, fall back to
iterating the other tabs (state.tabs) and their panes (Object.values(tab.panes))
to find the first diff pane and activate it as before.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 819a881e-87d6-4a63-945b-3eacd2b95f18

📥 Commits

Reviewing files that changed from the base of the PR and between aa23ae3 and 6fea6da.

📒 Files selected for processing (4)
  • apps/desktop/src/renderer/hotkeys/registry.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/page.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx

Comment on lines 198 to 203
<TooltipContent side="bottom" showArrow={false}>
<HotkeyLabel
label={isExpanded ? "Collapse sidebar" : "Expand sidebar"}
id="TOGGLE_EXPAND_SIDEBAR"
id="OPEN_DIFF_VIEWER"
/>
</TooltipContent>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Tooltip text no longer matches the hotkey's behavior.

The expand/collapse button's tooltip displays "Expand sidebar"/"Collapse sidebar" with the OPEN_DIFF_VIEWER hotkey (⌘⇧L). In the v2 workspace, ⌘⇧L no longer simply expands/collapses the sidebar — per the new handler in useWorkspaceHotkeys.ts it opens or focuses a diff pane and switches the sidebar to the Changes tab. Clicking the button still expands/collapses via handleExpandToggle (which calls setMode), but the displayed shortcut doesn't actually perform that action in v2. Consider either:

  • Using a different hotkey id that matches expand/collapse semantics, or
  • Updating the tooltip label so the shortcut hint is truthful (e.g. "Open diff viewer" when collapsed), or
  • Dropping the HotkeyLabel here and using plain text if no dedicated hotkey exists.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx`
around lines 198 - 203, The tooltip's HotkeyLabel currently uses
id="OPEN_DIFF_VIEWER" but the hotkey now opens/focuses a diff pane (see
useWorkspaceHotkeys.ts) while the button runs handleExpandToggle/setMode to
expand/collapse; fix by either changing the HotkeyLabel id to a true toggle
hotkey (e.g., USE a new id like "TOGGLE_SIDEBAR" that maps to the
expand/collapse handler) or by updating the label text to reflect the actual
hotkey action (e.g., when collapsed show "Open diff viewer" and when expanded
show "Collapse sidebar"), or remove HotkeyLabel and use plain text if no
matching hotkey exists; update the code around HotkeyLabel
(id="OPEN_DIFF_VIEWER") and ensure consistency with useWorkspaceHotkeys.ts and
the button's handleExpandToggle/setMode behavior.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 18, 2026

Greptile Summary

This PR renames the hotkey action TOGGLE_EXPAND_SIDEBAROPEN_DIFF_VIEWER (same ⌘⇧L / Ctrl+Shift+Alt+L binding) and wires up distinct behavior per workspace version:

  • V2 workspace: The hotkey now opens/focuses a diff viewer pane — switching the sidebar to the "changes" tab, then finding and focusing any existing diff pane or opening a new tab with one.
  • V1 workspace: Existing expand/collapse-to-Changes behavior is preserved under the new ID.
  • Registry: The label and description are updated to reflect the new intent; a description field is added.
  • RightSidebar tooltip: The HotkeyLabel id prop is updated to OPEN_DIFF_VIEWER (the label text is still hardcoded as "Expand/Collapse sidebar", so the displayed tooltip remains accurate for V1).

The rename is complete — no remaining references to TOGGLE_EXPAND_SIDEBAR exist anywhere in the codebase. The underlying store types confirm that tab.panes is Record<string, Pane<TData>> so Object.values(tab.panes) correctly yields pane objects with their .id fields. addTab automatically sets the newly created tab as active, so no explicit setActiveTab call is needed after creating the diff tab.

Key changes:

  • registry.ts: TOGGLE_EXPAND_SIDEBAROPEN_DIFF_VIEWER with updated label/description
  • useWorkspaceHotkeys.ts: New v2 handler that searches for an existing diff pane across all tabs and focuses it, or creates a new tab with a diff pane
  • page.tsx (v1): Hotkey binding updated to new ID, behavior unchanged
  • RightSidebar/index.tsx: HotkeyLabel id updated to match new hotkey ID

Confidence Score: 4/5

PR is safe to merge; the rename is complete with no stale references, v1 behavior is preserved, and the new v2 handler is logically correct.

All four changed files reviewed. Rename is complete (confirmed by grep), types verify Object.values(tab.panes) yields pane objects with valid .id fields, addTab auto-activates the new tab, and DiffPane gracefully handles path empty string. No critical or blocking issues found.

useWorkspaceHotkeys.ts is the most complex new code path but is logically correct.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/hotkeys/registry.ts Clean rename of TOGGLE_EXPAND_SIDEBAR → OPEN_DIFF_VIEWER with updated label and a new description field; no issues.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspaceHotkeys/useWorkspaceHotkeys.ts New OPEN_DIFF_VIEWER handler correctly opens/focuses diff pane in v2; sidebar guard is intentionally non-blocking (falls through to diff pane logic even without local state).
apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/page.tsx V1 hotkey re-bound to OPEN_DIFF_VIEWER with identical expand/collapse behavior; straightforward rename, no logic change.
apps/desktop/src/renderer/screens/main/components/WorkspaceView/RightSidebar/index.tsx HotkeyLabel id updated to OPEN_DIFF_VIEWER; label text stays hardcoded as Expand/Collapse sidebar so the tooltip remains accurate for v1.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    K["⌘⇧L pressed"] --> V{Which workspace?}
    V -->|V2| S1["Open sidebar, set activeTab = changes"]
    S1 --> SCAN["Scan state.tabs for pane where kind === diff"]
    SCAN --> FOUND{Found?}
    FOUND -->|Yes| FOCUS["setActiveTab + setActivePane → return"]
    FOUND -->|No| ADD["addTab with new diff pane"]
    ADD --> AUTO["Store auto-sets activeTabId to new tab"]
    V -->|V1| CHK{isSidebarOpen?}
    CHK -->|No| OPEN["setSidebarOpen + setSidebarMode = Changes"]
    CHK -->|Yes| TOGGLE{"currentMode = Changes?"}
    TOGGLE -->|Yes| TABS["setSidebarMode = Tabs"]
    TOGGLE -->|No| CHANGES["setSidebarMode = Changes"]
Loading

Reviews (1): Last reviewed commit: "feat(desktop): ⌘⇧L opens diff viewer in ..." | Re-trigger Greptile

@saddlepaddle saddlepaddle merged commit 14370d9 into main Apr 18, 2026
7 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

MocA-Love added a commit to MocA-Love/superset that referenced this pull request Apr 23, 2026
upstream PR superset-sh#3556 で追加された OPEN_DIFF_VIEWER と fork 既存の
TOGGLE_EXPAND_SIDEBAR が同じ ⌘⇧L に binding され、V1 workspace の
page.tsx で両方が useHotkey 登録されて発火順が不定になっていた。
加えて RightSidebar のサイドバー展開ボタンが誤って OPEN_DIFF_VIEWER
のラベルを表示していた。

- V1 page.tsx: OPEN_DIFF_VIEWER の useHotkey 登録を削除
  (ハンドラは SEARCH_IN_FILES と完全に同一で冗長だった)
- RightSidebar: HotkeyLabel id を TOGGLE_EXPAND_SIDEBAR に戻す
- V2 は OPEN_DIFF_VIEWER を引き続き使用 (upstream 意図を維持)

V1/V2 は別ルートなので useHotkey の enabled で自然に分岐し、
同じキーで異なる動作をしても競合しない。
@Kitenite Kitenite deleted the metashiftl-hotkey-open-diff-viewer-in-new-tab branch May 6, 2026 04:53
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