@@ -11,6 +11,7 @@ import type {
1111 PullRequestListState ,
1212 SourceControlProviderKind ,
1313} from "@t3tools/contracts" ;
14+ import { useAtomValue } from "@effect/atom-react" ;
1415import { createFileRoute , useNavigate } from "@tanstack/react-router" ;
1516import {
1617 ArrowDownUpIcon ,
@@ -34,6 +35,7 @@ import {
3435import {
3536 useCallback ,
3637 useEffect ,
38+ useEffectEvent ,
3739 useMemo ,
3840 useRef ,
3941 useState ,
@@ -107,7 +109,10 @@ import {
107109} from "../components/WorkspaceBreadcrumb" ;
108110import { WorkspacePageContainer } from "../components/WorkspacePageContainer" ;
109111import { WorkspacePageHeader } from "../components/WorkspacePageHeader" ;
112+ import { isCommandPaletteOpen } from "../commandPaletteBus" ;
110113import { isElectron } from "../env" ;
114+ import { resolveShortcutCommand } from "../keybindings" ;
115+ import { isTerminalFocused } from "../lib/terminalFocus" ;
111116import { PanelLayoutControls } from "../components/chat/PanelLayoutControls" ;
112117import { Button } from "../components/ui/button" ;
113118import { Menu , MenuPopup , MenuRadioGroup , MenuRadioItem , MenuTrigger } from "../components/ui/menu" ;
@@ -135,6 +140,7 @@ import {
135140} from "../state/pullRequests" ;
136141import { useAtomCommand } from "../state/use-atom-command" ;
137142import { cn } from "~/lib/utils" ;
143+ import { primaryServerKeybindingsAtom } from "~/state/server" ;
138144import { getSourceControlPresentationForKind } from "~/sourceControlPresentation" ;
139145
140146export interface PullRequestsSearch extends PullRequestListPreferences {
@@ -285,6 +291,7 @@ function PullRequestsRouteView() {
285291 const statsPolicy : PullRequestStatsPolicy =
286292 sort === "ready" || sort === "largest" || sort === "smallest" ? "eager" : "visible" ;
287293 const navigate = useNavigate ( { from : Route . fullPath } ) ;
294+ const keybindings = useAtomValue ( primaryServerKeybindingsAtom ) ;
288295 const { environments } = useEnvironments ( ) ;
289296 // Every connected environment that has said it can list pull requests. Sorted, so the query
290297 // keys, the scope key and the stored snapshot all read the same whichever order the
@@ -1888,6 +1895,26 @@ function PullRequestsRouteView() {
18881895 selectSurfaceInUrl ( null ) ;
18891896 } ;
18901897
1898+ // This page has no ChatView, so the shared panel handles `rightPanel.close`
1899+ // itself. With nothing open the event falls through to its native meaning.
1900+ const closeActiveSurfaceFromShortcut = useEffectEvent ( ( event : KeyboardEvent ) => {
1901+ if ( activePullRequestSurface === null ) return ;
1902+ event . preventDefault ( ) ;
1903+ event . stopPropagation ( ) ;
1904+ if ( ! event . repeat ) closeSurface ( activePullRequestSurface ) ;
1905+ } ) ;
1906+ useEffect ( ( ) => {
1907+ const onKeyDown = ( event : KeyboardEvent ) => {
1908+ if ( event . defaultPrevented || isCommandPaletteOpen ( ) ) return ;
1909+ const command = resolveShortcutCommand ( event , keybindings , {
1910+ context : { terminalFocus : isTerminalFocused ( ) } ,
1911+ } ) ;
1912+ if ( command === "rightPanel.close" ) closeActiveSurfaceFromShortcut ( event ) ;
1913+ } ;
1914+ window . addEventListener ( "keydown" , onKeyDown ) ;
1915+ return ( ) => window . removeEventListener ( "keydown" , onKeyDown ) ;
1916+ } , [ keybindings ] ) ;
1917+
18911918 return (
18921919 < SidebarInset className = "h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground" >
18931920 < div className = "relative flex min-h-0 flex-1" >
0 commit comments