fix: support Cmd+N and Esc on the tasks page (#868)

Move the Cmd+N handler above the new-workspace early-return so the
shortcut opens the composer modal from the tasks page. Add an
activeModal guard to the page-level Esc handler so it yields to the
composer modal's own Esc dismissal.
This commit is contained in:
Jinjing 2026-04-20 12:49:45 -07:00 committed by GitHub
parent 781bc9fd62
commit a4bfeef8a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 17 deletions

View file

@ -516,6 +516,17 @@ function App(): React.JSX.Element {
return
}
// Cmd/Ctrl+N — new workspace (opens the lightweight composer modal)
if (!e.altKey && !e.shiftKey && e.key.toLowerCase() === 'n') {
if (!repos.some((repo) => isGitRepoKind(repo))) {
return
}
dispatchClearModifierHints()
e.preventDefault()
actions.openModal('new-workspace-composer')
return
}
// Why: the new-workspace composer should not be able to reveal the right
// sidebar at all, because that surface is intentionally distraction-free.
if (activeView === 'new-workspace') {
@ -530,17 +541,6 @@ function App(): React.JSX.Element {
return
}
// Cmd/Ctrl+N — new workspace (opens the lightweight composer modal)
if (!e.altKey && !e.shiftKey && e.key.toLowerCase() === 'n') {
if (!repos.some((repo) => isGitRepoKind(repo))) {
return
}
dispatchClearModifierHints()
e.preventDefault()
actions.openModal('new-workspace-composer')
return
}
// Cmd/Ctrl+Shift+E — toggle right sidebar / explorer tab
if (e.shiftKey && !e.altKey && e.key.toLowerCase() === 'e') {
dispatchClearModifierHints()

View file

@ -142,6 +142,7 @@ export default function NewWorkspacePage(): React.JSX.Element {
const settings = useAppStore((s) => s.settings)
const pageData = useAppStore((s) => s.newWorkspacePageData)
const closeNewWorkspacePage = useAppStore((s) => s.closeNewWorkspacePage)
const activeModal = useAppStore((s) => s.activeModal)
const repos = useAppStore((s) => s.repos)
const activeRepoId = useAppStore((s) => s.activeRepoId)
const openModal = useAppStore((s) => s.openModal)
@ -443,11 +444,8 @@ export default function NewWorkspacePage(): React.JSX.Element {
}, [newIssueBody, newIssueSubmitting, newIssueTitle, selectedRepo])
useEffect(() => {
// Why: when the GitHub preview sheet is open, Radix's Dialog owns Esc —
// it closes the sheet on its own. Page-level capture would otherwise fire
// first and pop the tasks page while the user just meant to dismiss the
// preview.
if (drawerWorkItem || newIssueOpen) {
// Why: when a modal is open, let it own Esc dismissal.
if (drawerWorkItem || newIssueOpen || activeModal !== 'none') {
return
}
@ -481,7 +479,7 @@ export default function NewWorkspacePage(): React.JSX.Element {
window.addEventListener('keydown', onKeyDown, { capture: true })
return () => window.removeEventListener('keydown', onKeyDown, { capture: true })
}, [closeNewWorkspacePage, drawerWorkItem, newIssueOpen])
}, [activeModal, closeNewWorkspacePage, drawerWorkItem, newIssueOpen])
return (
<div className="relative flex h-full min-h-0 flex-1 overflow-hidden bg-background text-foreground">