Skip to content
TypeScript

fix(web): use the configured panel shortcut on the PR page (#11292)

Bilal Bakr15c6167bc489
diff --git a/apps/web/src/routes/_chat.pull-requests.tsx b/apps/web/src/routes/_chat.pull-requests.tsx
index 5a21a2cc37f..2b5586a6e8e 100644
--- a/apps/web/src/routes/_chat.pull-requests.tsx
+++ b/apps/web/src/routes/_chat.pull-requests.tsx
@@ -114,7 +114,7 @@ import { WorkspacePageContainer } from "../components/WorkspacePageContainer";
import { WorkspacePageHeader } from "../components/WorkspacePageHeader";
import { isCommandPaletteOpen } from "../commandPaletteBus";
import { isElectron } from "../env";
-import { resolveShortcutCommand } from "../keybindings";
+import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
import { isTerminalFocused } from "../lib/terminalFocus";
import { PanelLayoutControls } from "../components/chat/PanelLayoutControls";
import { Button } from "../components/ui/button";
@@ -1577,7 +1577,7 @@ function PullRequestsRouteView() {
terminalShortcutLabel={null}
rightPanelAvailable={rightPanelAvailable}
rightPanelOpen={rightPanelState.isOpen}
- rightPanelShortcutLabel={null}
+ rightPanelShortcutLabel={shortcutLabelForCommand(keybindings, "rightPanel.toggle")}
rightPanelUnavailableLabel="Select a pull request first"
liveAgentCount={0}
onToggleTerminal={() => undefined}
@@ -1914,6 +1914,12 @@ function PullRequestsRouteView() {
event.stopPropagation();
if (!event.repeat) closeSurface(activePullRequestSurface);
});
+ const toggleRightPanelFromShortcut = useEffectEvent((event: KeyboardEvent) => {
+ if (!rightPanelAvailable) return;
+ event.preventDefault();
+ event.stopPropagation();
+ if (!event.repeat) toggleRightPanel();
+ });
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
if (event.defaultPrevented || isCommandPaletteOpen()) return;
@@ -1921,6 +1927,7 @@ function PullRequestsRouteView() {
context: { terminalFocus: isTerminalFocused() },
});
if (command === "rightPanel.close") closeActiveSurfaceFromShortcut(event);
+ if (command === "rightPanel.toggle") toggleRightPanelFromShortcut(event);
if (command === "thread.copyReference") copyPullRequestFromShortcut(event);
};
window.addEventListener("keydown", onKeyDown);