fix(tasks): rename NewWorkspacePage to TaskPage and give it a proper titlebar (#921)
* fix(tasks): rename NewWorkspacePage to TaskPage and unblock Close on collapsed sidebar Rename the full-page work-item view to TaskPage (file, component, store actions, and the `activeView` literal) so the name matches the surface the user sees. Also fix a regression where the page's Close button was unreachable in workspace view with the sidebar collapsed — the floating titlebar-left strip (traffic lights + sidebar toggle + agent badge) overlapped the Close button, leaving the user stuck. Mirror the TabGroupPanel fix by reserving `var(--collapsed-sidebar-header-width)` of left padding on the Close row, which App.tsx already keeps in sync with the live measured width of that floating header. * fix(tasks): give TaskPage its own 42px titlebar and drop Close below it Rather than cramming the Close button into the same horizontal band that App.tsx uses for the floating traffic-lights/sidebar-toggle strip, give TaskPage its own 42px "Tasks" titlebar (matching the sidebar header and tab rows) and move the Close (X) button into a dedicated row below it. The titlebar is drag-region so the window stays movable from this band. Skipped in non-workspace mode where App.tsx already owns the full-width titlebar, to avoid a duplicate band. * fix(tasks): keep sidebar-expand toggle visible over TaskPage titlebar When the left sidebar is collapsed, App.tsx floats the titlebar-left strip (traffic lights, sidebar-expand toggle, agent badge) over the top-left of the page at z-10. TaskPage's own 42px strip sat at the same stacking level and painted later in DOM, so its solid background hid the expand toggle. Split the strip: keep the reserved region transparent so the floating controls show through, and only paint bg/border on the remainder. The floating titlebar-left already carries the matching bg + border-bottom, so the two segments still read as one continuous band. * fix(tasks): let clicks reach sidebar toggle under TaskPage titlebar The reserved spacer in TaskPage's titlebar strip sits on top of App.tsx's floating titlebar-left (which hosts the sidebar-expand toggle and agent badge). Two things were swallowing clicks meant for the toggle: 1. The outer strip carried WebkitAppRegion='drag', so Electron treated the whole 42px row as window-drag — even the transparent reserved region. 2. The transparent div itself absorbed pointer events before they reached the underlying toggle. Scope the drag region to just the painted "Tasks" segment, and mark the reserved spacer pointer-events-none with an explicit no-drag override. * fix(tasks): stop TaskPage wrapper from blocking sidebar-expand toggle The TaskPage's inner column had z-10, the same z-index as App.tsx's floating titlebar-left cluster (traffic lights, sidebar toggle, agent badge) that hovers in the top-left when the sidebar is collapsed. Tie on z-index + later in DOM meant TaskPage painted over titlebar-left, so clicks on the reserved spacer region fell through pointer-events-none into the wrapper behind the spacer rather than reaching the toggle. Dropping z-10 from the inner column lets titlebar-left paint above the page content and receive clicks cleanly, without changing the visual layout.
This commit is contained in:
+13
-13
@@ -15,7 +15,7 @@ import Sidebar from './components/Sidebar'
|
||||
import Terminal from './components/Terminal'
|
||||
import { shutdownBufferCaptures } from './components/terminal-pane/TerminalPane'
|
||||
import Landing from './components/Landing'
|
||||
import NewWorkspacePage from './components/NewWorkspacePage'
|
||||
import TaskPage from './components/TaskPage'
|
||||
import Settings from './components/settings/Settings'
|
||||
import RightSidebar from './components/right-sidebar'
|
||||
import QuickOpen from './components/QuickOpen'
|
||||
@@ -447,9 +447,9 @@ function App(): React.JSX.Element {
|
||||
// full-width titlebar is replaced by a sidebar-width left header so the
|
||||
// terminal + tab groups extend to the very top of the window.
|
||||
const workspaceActive = activeView !== 'settings' && activeWorktreeId !== null
|
||||
// Why: suppress right sidebar controls on new-workspace page since that
|
||||
// surface is intentionally distraction-free (no right sidebar).
|
||||
const showRightSidebarControls = activeView !== 'settings' && activeView !== 'new-workspace'
|
||||
// Why: suppress right sidebar controls on the tasks page since that surface
|
||||
// is intentionally distraction-free (no right sidebar).
|
||||
const showRightSidebarControls = activeView !== 'settings' && activeView !== 'tasks'
|
||||
|
||||
const handleToggleExpand = (): void => {
|
||||
if (!effectiveActiveTabId) {
|
||||
@@ -509,9 +509,9 @@ function App(): React.JSX.Element {
|
||||
// (contentEditable) or a browser guest webContents, both of which bypass
|
||||
// this renderer-side window keydown listener.
|
||||
|
||||
// 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') {
|
||||
// Why: the tasks page should not be able to reveal the right sidebar at
|
||||
// all, because that surface is intentionally distraction-free.
|
||||
if (activeView === 'tasks') {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -739,9 +739,9 @@ function App(): React.JSX.Element {
|
||||
) : null
|
||||
|
||||
useEffect(() => {
|
||||
if (activeView === 'new-workspace' && rightSidebarOpen) {
|
||||
// Why: hide the right sidebar immediately when entering the composer so
|
||||
// a previous open state can't bleed into the dedicated workspace flow.
|
||||
if (activeView === 'tasks' && rightSidebarOpen) {
|
||||
// Why: hide the right sidebar immediately when entering the tasks page
|
||||
// so a previous open state can't bleed into that distraction-free view.
|
||||
actions.setRightSidebarOpen(false)
|
||||
}
|
||||
}, [activeView, rightSidebarOpen, actions])
|
||||
@@ -759,7 +759,7 @@ function App(): React.JSX.Element {
|
||||
{/* Why: in workspace view (split groups always enabled), the full-width
|
||||
titlebar is removed so tab groups + terminal extend to the top of
|
||||
the window. Left titlebar controls move to a header above the sidebar.
|
||||
Settings, landing, and new-workspace views keep the full-width titlebar. */}
|
||||
Settings, landing, and the tasks page keep the full-width titlebar. */}
|
||||
{!workspaceActive ? (
|
||||
<div className="titlebar">
|
||||
<div
|
||||
@@ -853,14 +853,14 @@ function App(): React.JSX.Element {
|
||||
<Terminal />
|
||||
</div>
|
||||
{activeView === 'settings' ? <Settings /> : null}
|
||||
{activeView === 'new-workspace' ? <NewWorkspacePage /> : null}
|
||||
{activeView === 'tasks' ? <TaskPage /> : null}
|
||||
{activeView === 'terminal' && !activeWorktreeId ? <Landing /> : null}
|
||||
</div>
|
||||
</div>
|
||||
{/* Why: keep RightSidebar mounted even when closed so that its
|
||||
child components (FileExplorer, SourceControl, etc.) and their
|
||||
filesystem watchers + cached directory trees survive across
|
||||
open/close toggles. Unmount on new-workspace view since that
|
||||
open/close toggles. Unmount on the tasks view since that
|
||||
surface is intentionally distraction-free. */}
|
||||
{showRightSidebarControls ? <RightSidebar /> : null}
|
||||
</div>
|
||||
|
||||
+76
-12
@@ -139,10 +139,10 @@ function getTaskStatusTone(item: GitHubWorkItem): string {
|
||||
return 'border-cyan-500/30 bg-cyan-500/10 text-cyan-700 dark:text-cyan-200'
|
||||
}
|
||||
|
||||
export default function NewWorkspacePage(): React.JSX.Element {
|
||||
export default function TaskPage(): React.JSX.Element {
|
||||
const settings = useAppStore((s) => s.settings)
|
||||
const pageData = useAppStore((s) => s.newWorkspacePageData)
|
||||
const closeNewWorkspacePage = useAppStore((s) => s.closeNewWorkspacePage)
|
||||
const pageData = useAppStore((s) => s.taskPageData)
|
||||
const closeTaskPage = useAppStore((s) => s.closeTaskPage)
|
||||
const activeModal = useAppStore((s) => s.activeModal)
|
||||
const repos = useAppStore((s) => s.repos)
|
||||
const activeRepoId = useAppStore((s) => s.activeRepoId)
|
||||
@@ -150,6 +150,18 @@ export default function NewWorkspacePage(): React.JSX.Element {
|
||||
const updateSettings = useAppStore((s) => s.updateSettings)
|
||||
const fetchWorkItems = useAppStore((s) => s.fetchWorkItems)
|
||||
const getCachedWorkItems = useAppStore((s) => s.getCachedWorkItems)
|
||||
// Why: in workspace view (a worktree is active) App.tsx hides its
|
||||
// full-width titlebar, so this page renders its own 42px titlebar strip to
|
||||
// keep the top band continuous with the sidebar header and tab rows. When
|
||||
// the sidebar is also collapsed, App.tsx floats its titlebar-left controls
|
||||
// (traffic lights, sidebar toggle, agent badge) over our strip — reserve
|
||||
// the measured width of those controls on the left so our "Tasks" label
|
||||
// never sits behind them. In non-workspace mode App.tsx already owns the
|
||||
// top titlebar, so skip our strip to avoid a duplicate band.
|
||||
const sidebarOpen = useAppStore((s) => s.sidebarOpen)
|
||||
const activeWorktreeId = useAppStore((s) => s.activeWorktreeId)
|
||||
const workspaceActive = activeWorktreeId !== null
|
||||
const reserveCollapsedHeaderSpace = workspaceActive && !sidebarOpen
|
||||
|
||||
const eligibleRepos = useMemo(() => repos.filter((repo) => isGitRepoKind(repo)), [repos])
|
||||
|
||||
@@ -489,27 +501,79 @@ export default function NewWorkspacePage(): React.JSX.Element {
|
||||
}
|
||||
|
||||
event.preventDefault()
|
||||
closeNewWorkspacePage()
|
||||
closeTaskPage()
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', onKeyDown, { capture: true })
|
||||
return () => window.removeEventListener('keydown', onKeyDown, { capture: true })
|
||||
}, [activeModal, closeNewWorkspacePage, drawerWorkItem, newIssueOpen])
|
||||
}, [activeModal, closeTaskPage, drawerWorkItem, newIssueOpen])
|
||||
|
||||
return (
|
||||
<div className="relative flex h-full min-h-0 flex-1 overflow-hidden bg-background text-foreground">
|
||||
<div className="relative z-10 flex min-h-0 flex-1 flex-col">
|
||||
{/* Why: left-aligned so it doesn't collide with the app sidebar on the
|
||||
right edge. The GitHub preview is a modal sheet that overlays the
|
||||
whole surface, so this button is hidden behind it while it's open. */}
|
||||
<div className="flex-none flex items-center justify-start px-5 py-3 md:px-8 md:py-4">
|
||||
{/* Why: no z-index here. App.tsx's floating titlebar-left (traffic lights
|
||||
+ sidebar-expand toggle + agent badge) is absolutely positioned at
|
||||
z-10 in the root stacking context when the sidebar is collapsed. If
|
||||
this wrapper also sits at z-10 it ties with titlebar-left on
|
||||
z-index and wins on DOM order (later sibling), so even though our
|
||||
top-left spacer is pointer-events-none, the click still lands on
|
||||
this wrapper behind the spacer instead of falling through to the
|
||||
sidebar toggle. Keeping this at z-auto lets titlebar-left's z-10
|
||||
paint above our content and receive the click cleanly. */}
|
||||
<div className="relative flex min-h-0 flex-1 flex-col">
|
||||
{/* Why: in workspace view App.tsx suppresses its full-width titlebar,
|
||||
so render a matching 42px strip here to keep the top band
|
||||
continuous with the sidebar header and tab rows. When the sidebar
|
||||
is collapsed, App.tsx floats its titlebar-left controls (traffic
|
||||
lights, sidebar toggle, agent badge) over the top-left of this
|
||||
page at z-10, and the page wrapper stays at z-auto so that float
|
||||
always paints above our content. Keep the reserved region
|
||||
transparent so the floating titlebar-left's own bg + border-bottom
|
||||
is what the user sees on the left — the two segments then read as
|
||||
one continuous band. The painted remainder is a drag-region so the
|
||||
window stays movable here, matching other top chrome. Skipped in
|
||||
non-workspace mode because App.tsx already owns the top titlebar
|
||||
and a second strip would produce a duplicate band. */}
|
||||
{workspaceActive ? (
|
||||
<div className="flex-none flex h-[42px]">
|
||||
{reserveCollapsedHeaderSpace ? (
|
||||
// Why: the floating titlebar-left hosts real interactive chrome
|
||||
// (sidebar-expand toggle, agent badge) under this segment. Both
|
||||
// pointer-events-none AND WebkitAppRegion='no-drag' are needed:
|
||||
// without pointer-events-none, this transparent div absorbs
|
||||
// clicks before they reach the toggle; without no-drag, Electron
|
||||
// marks the area as window-drag and still consumes clicks even
|
||||
// when the element itself is click-through.
|
||||
<div
|
||||
aria-hidden
|
||||
className="h-full shrink-0 pointer-events-none"
|
||||
style={
|
||||
{
|
||||
width: 'var(--collapsed-sidebar-header-width)',
|
||||
WebkitAppRegion: 'no-drag'
|
||||
} as React.CSSProperties
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
<div
|
||||
className="flex h-full flex-1 items-center border-b border-border bg-card px-4 text-sm font-medium text-muted-foreground"
|
||||
style={{ WebkitAppRegion: 'drag' } as React.CSSProperties}
|
||||
>
|
||||
<span>Tasks</span>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{/* Why: Close sits in its own row below the titlebar strip so it can
|
||||
never overlap the floating macOS traffic lights. Kept left-aligned
|
||||
to stay out of the app sidebar on the right edge. */}
|
||||
<div className="flex-none flex items-center justify-start px-5 pt-3 pb-1 md:px-8 md:pt-4">
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-8 rounded-full z-10"
|
||||
onClick={closeNewWorkspacePage}
|
||||
className="size-8 rounded-full"
|
||||
onClick={closeTaskPage}
|
||||
aria-label="Close tasks"
|
||||
>
|
||||
<X className="size-4" />
|
||||
@@ -1010,7 +1010,7 @@ function Terminal(): React.JSX.Element | null {
|
||||
return null
|
||||
}
|
||||
// Why: use strict equality with 'terminal' instead of !== 'settings'
|
||||
// so the terminal/browser surface hides on the new-workspace page too.
|
||||
// so the terminal/browser surface hides on the tasks page too.
|
||||
const isVisible = activeView === 'terminal' && worktree.id === activeWorktreeId
|
||||
return (
|
||||
<div
|
||||
@@ -1068,7 +1068,7 @@ function Terminal(): React.JSX.Element | null {
|
||||
.filter((wt) => mountedWorktreeIdsRef.current.has(wt.id))
|
||||
.map((worktree) => {
|
||||
// Why: use strict equality with 'terminal' instead of !== 'settings'
|
||||
// so the terminal/browser surface hides on the new-workspace page too.
|
||||
// so the terminal/browser surface hides on the tasks page too.
|
||||
const isVisible = activeView === 'terminal' && worktree.id === activeWorktreeId
|
||||
return (
|
||||
<div
|
||||
@@ -1114,7 +1114,7 @@ function Terminal(): React.JSX.Element | null {
|
||||
{allWorktrees.map((worktree) => {
|
||||
const browserTabs = browserTabsByWorktree[worktree.id] ?? []
|
||||
// Why: use strict equality with 'terminal' instead of !== 'settings'
|
||||
// so browser panes also hide on the new-workspace page.
|
||||
// so browser panes also hide on the tasks page.
|
||||
const isVisibleWorktree =
|
||||
activeView === 'terminal' && worktree.id === activeWorktreeId
|
||||
if (browserTabs.length === 0) {
|
||||
|
||||
@@ -14,7 +14,7 @@ function LinearIcon({ className }: { className?: string }): React.JSX.Element {
|
||||
}
|
||||
|
||||
const SidebarNav = React.memo(function SidebarNav() {
|
||||
const openNewWorkspacePage = useAppStore((s) => s.openNewWorkspacePage)
|
||||
const openTaskPage = useAppStore((s) => s.openTaskPage)
|
||||
const activeView = useAppStore((s) => s.activeView)
|
||||
const repos = useAppStore((s) => s.repos)
|
||||
const canBrowseTasks = repos.some((repo) => isGitRepoKind(repo))
|
||||
@@ -33,14 +33,14 @@ const SidebarNav = React.memo(function SidebarNav() {
|
||||
const firstGitRepo = activeRepo ?? repos.find((r) => isGitRepoKind(r))
|
||||
if (firstGitRepo?.path) {
|
||||
// Why: warm the exact cache key the page will read on mount — must
|
||||
// match NewWorkspacePage's `initialTaskQuery` derived from the same
|
||||
// default preset, otherwise the prefetch lands in a key the page
|
||||
// never reads and we pay the full round-trip after click.
|
||||
// match TaskPage's `initialTaskQuery` derived from the same default
|
||||
// preset, otherwise the prefetch lands in a key the page never reads
|
||||
// and we pay the full round-trip after click.
|
||||
prefetchWorkItems(firstGitRepo.path, 36, getTaskPresetQuery(defaultTaskViewPreset))
|
||||
}
|
||||
}, [activeRepoId, canBrowseTasks, defaultTaskViewPreset, prefetchWorkItems, repos])
|
||||
|
||||
const tasksActive = activeView === 'new-workspace'
|
||||
const tasksActive = activeView === 'tasks'
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-0.5 px-2 pt-2 pb-1">
|
||||
@@ -50,7 +50,7 @@ const SidebarNav = React.memo(function SidebarNav() {
|
||||
if (!canBrowseTasks) {
|
||||
return
|
||||
}
|
||||
openNewWorkspacePage()
|
||||
openTaskPage()
|
||||
}}
|
||||
onPointerEnter={handlePrefetch}
|
||||
onFocus={handlePrefetch}
|
||||
|
||||
@@ -182,9 +182,9 @@ const WorktreeCard = React.memo(function WorktreeCard({
|
||||
}
|
||||
}
|
||||
if (useAppStore.getState().activeView !== 'terminal') {
|
||||
// Why: the sidebar remains visible during the new-workspace flow, so
|
||||
// clicking a real worktree should switch the main pane back to that
|
||||
// worktree instead of leaving the create surface visible.
|
||||
// Why: the sidebar remains visible on the tasks page, so clicking a
|
||||
// real worktree should switch the main pane back to that worktree
|
||||
// instead of leaving the tasks surface visible.
|
||||
setActiveView('terminal')
|
||||
}
|
||||
// Why: always activate the worktree so the user can see terminal history,
|
||||
|
||||
@@ -622,9 +622,9 @@ const WorktreeList = React.memo(function WorktreeList() {
|
||||
.map((r) => r.worktree),
|
||||
[rows]
|
||||
)
|
||||
// Why: when the new-workspace page is active, no sidebar card should appear
|
||||
// selected — the user hasn't picked a worktree yet.
|
||||
const selectedSidebarWorktreeId = activeView === 'new-workspace' ? null : activeWorktreeId
|
||||
// Why: when the tasks page is active, no sidebar card should appear selected
|
||||
// — the user hasn't picked a worktree yet.
|
||||
const selectedSidebarWorktreeId = activeView === 'tasks' ? null : activeWorktreeId
|
||||
|
||||
// Why layout effect instead of effect: the global Cmd/Ctrl+1–9 key handler
|
||||
// can fire immediately after React commits the new grouped/collapsed order.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* based on current view, tab type, and focused element.
|
||||
*/
|
||||
export function resolveZoomTarget(args: {
|
||||
activeView: 'terminal' | 'settings' | 'new-workspace'
|
||||
activeView: 'terminal' | 'settings' | 'tasks'
|
||||
activeTabType: 'terminal' | 'editor' | 'browser'
|
||||
activeElement: unknown
|
||||
}): 'terminal' | 'editor' | 'ui' {
|
||||
|
||||
@@ -47,8 +47,8 @@ export type UseComposerStateOptions = {
|
||||
/** Invoked after a successful createWorktree. The caller usually closes its
|
||||
* surface here (palette modal, full page, etc.). */
|
||||
onCreated?: () => void
|
||||
/** Optional external repoId override — used by NewWorkspacePage's task list
|
||||
* which wants to drive repo selection from the page header, not the card. */
|
||||
/** Optional external repoId override — used by TaskPage's work-item list
|
||||
* which drives repo selection from the page header, not the card. */
|
||||
repoIdOverride?: string
|
||||
onRepoIdOverrideChange?: (value: string) => void
|
||||
}
|
||||
@@ -114,8 +114,8 @@ export type UseComposerStateResult = {
|
||||
createDisabled: boolean
|
||||
}
|
||||
|
||||
// Why: both the full-page NewWorkspacePage composer and the Cmd+J modal can
|
||||
// be mounted simultaneously. Without instance scoping, a single native file
|
||||
// Why: both the full-page TaskPage composer and the Cmd+J modal can be
|
||||
// mounted simultaneously. Without instance scoping, a single native file
|
||||
// drop fires every subscriber and duplicates attachments/prompt edits across
|
||||
// the background draft and the visible modal. Route drops to the
|
||||
// most-recently-mounted composer only — the modal stacks on top, so the
|
||||
|
||||
@@ -4,10 +4,10 @@ import { isShellProcess } from '@/lib/tui-agent-startup'
|
||||
import type { GitHubWorkItem, OrcaHooks, TaskViewPresetId } from '../../../shared/types'
|
||||
|
||||
/**
|
||||
* Why: the NewWorkspacePage's preset buttons and the openNewWorkspacePage
|
||||
* prefetcher both need to compute the same GitHub query string for a given
|
||||
* preset id. Keep the mapping here so the prefetch warms exactly the cache
|
||||
* key the page will look up on mount.
|
||||
* Why: the TaskPage's preset buttons and the openTaskPage prefetcher both need
|
||||
* to compute the same GitHub query string for a given preset id. Keep the
|
||||
* mapping here so the prefetch warms exactly the cache key the page will look
|
||||
* up on mount.
|
||||
*/
|
||||
export function getTaskPresetQuery(presetId: TaskViewPresetId | null): string {
|
||||
switch (presetId) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { findWorktreeById } from '@/store/slices/worktree-helpers'
|
||||
|
||||
// Why: issue commands can originate from two sources with different shapes —
|
||||
// (1) a repo-level runner script generated by main (WorktreeSetupLaunch), or
|
||||
// (2) a user-typed command template substituted in the NewWorkspacePage flow.
|
||||
// (2) a user-typed command template substituted in the TaskPage flow.
|
||||
// We accept either so callers don't need to synthesize a runner script file
|
||||
// just to queue a direct command string.
|
||||
export type IssueCommandLaunch =
|
||||
@@ -170,8 +170,8 @@ export function ensureWorktreeHasInitialTerminal(
|
||||
// concerns, so Orca should not invent a dependency between them.
|
||||
if (issueCommand) {
|
||||
// Why: WorktreeSetupLaunch carries a runner-script file (from main) and we
|
||||
// shell out to bash; the NewWorkspacePage variant is already an expanded
|
||||
// command string, so pass it through directly.
|
||||
// shell out to bash; the TaskPage variant is already an expanded command
|
||||
// string, so pass it through directly.
|
||||
const queuedIssueCommand =
|
||||
'runnerScriptPath' in issueCommand
|
||||
? {
|
||||
|
||||
@@ -97,31 +97,31 @@ describe('createUISlice hydratePersistedUI', () => {
|
||||
})
|
||||
|
||||
describe('createUISlice settings navigation', () => {
|
||||
it('returns to the new workspace page after visiting settings from an in-progress draft', () => {
|
||||
it('returns to the tasks page after visiting settings from an in-progress draft', () => {
|
||||
const store = createUIStore()
|
||||
|
||||
store.getState().openNewWorkspacePage({ preselectedRepoId: 'repo-1' })
|
||||
store.getState().openTaskPage({ preselectedRepoId: 'repo-1' })
|
||||
store.getState().openSettingsPage()
|
||||
|
||||
expect(store.getState().activeView).toBe('settings')
|
||||
expect(store.getState().previousViewBeforeSettings).toBe('new-workspace')
|
||||
expect(store.getState().previousViewBeforeSettings).toBe('tasks')
|
||||
|
||||
store.getState().closeSettingsPage()
|
||||
|
||||
expect(store.getState().activeView).toBe('new-workspace')
|
||||
expect(store.getState().activeView).toBe('tasks')
|
||||
})
|
||||
|
||||
it('keeps the original return target when settings is reopened while already visible', () => {
|
||||
const store = createUIStore()
|
||||
|
||||
store.getState().openNewWorkspacePage()
|
||||
store.getState().openTaskPage()
|
||||
store.getState().openSettingsPage()
|
||||
store.getState().openSettingsPage()
|
||||
|
||||
expect(store.getState().previousViewBeforeSettings).toBe('new-workspace')
|
||||
expect(store.getState().previousViewBeforeSettings).toBe('tasks')
|
||||
|
||||
store.getState().closeSettingsPage()
|
||||
|
||||
expect(store.getState().activeView).toBe('new-workspace')
|
||||
expect(store.getState().activeView).toBe('tasks')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -11,10 +11,9 @@ import type {
|
||||
WorktreeCardProperty
|
||||
} from '../../../../shared/types'
|
||||
|
||||
// Why: mirrors the preset→query mapping used by NewWorkspacePage's preset
|
||||
// buttons. Keeping a local copy here avoids a store ↔ lib circular import
|
||||
// while letting openNewWorkspacePage warm exactly the cache key the page will
|
||||
// read on mount.
|
||||
// Why: mirrors the preset→query mapping used by TaskPage's preset buttons.
|
||||
// Keeping a local copy here avoids a store ↔ lib circular import while letting
|
||||
// openTaskPage warm exactly the cache key the page will read on mount.
|
||||
function presetToQuery(presetId: TaskViewPresetId | null): string {
|
||||
switch (presetId) {
|
||||
case 'my-issues':
|
||||
@@ -53,11 +52,11 @@ export type UISlice = {
|
||||
toggleSidebar: () => void
|
||||
setSidebarOpen: (open: boolean) => void
|
||||
setSidebarWidth: (width: number) => void
|
||||
activeView: 'terminal' | 'settings' | 'new-workspace'
|
||||
previousViewBeforeNewWorkspace: 'terminal' | 'settings'
|
||||
previousViewBeforeSettings: 'terminal' | 'new-workspace'
|
||||
activeView: 'terminal' | 'settings' | 'tasks'
|
||||
previousViewBeforeTasks: 'terminal' | 'settings'
|
||||
previousViewBeforeSettings: 'terminal' | 'tasks'
|
||||
setActiveView: (view: UISlice['activeView']) => void
|
||||
newWorkspacePageData: {
|
||||
taskPageData: {
|
||||
preselectedRepoId?: string
|
||||
prefilledName?: string
|
||||
}
|
||||
@@ -77,8 +76,8 @@ export type UISlice = {
|
||||
linkedIssue: string
|
||||
linkedPR: number | null
|
||||
} | null
|
||||
openNewWorkspacePage: (data?: UISlice['newWorkspacePageData']) => void
|
||||
closeNewWorkspacePage: () => void
|
||||
openTaskPage: (data?: UISlice['taskPageData']) => void
|
||||
closeTaskPage: () => void
|
||||
setNewWorkspaceDraft: (draft: NonNullable<UISlice['newWorkspaceDraft']>) => void
|
||||
clearNewWorkspaceDraft: () => void
|
||||
openSettingsPage: () => void
|
||||
@@ -167,25 +166,23 @@ export const createUISlice: StateCreator<AppState, [], [], UISlice> = (set, get)
|
||||
setSidebarWidth: (width) => set({ sidebarWidth: width }),
|
||||
|
||||
activeView: 'terminal',
|
||||
previousViewBeforeNewWorkspace: 'terminal',
|
||||
previousViewBeforeTasks: 'terminal',
|
||||
previousViewBeforeSettings: 'terminal',
|
||||
setActiveView: (view) => set({ activeView: view }),
|
||||
newWorkspacePageData: {},
|
||||
taskPageData: {},
|
||||
newWorkspaceDraft: null,
|
||||
openNewWorkspacePage: (data = {}) => {
|
||||
openTaskPage: (data = {}) => {
|
||||
set((state) => ({
|
||||
activeView: 'new-workspace',
|
||||
previousViewBeforeNewWorkspace:
|
||||
state.activeView === 'new-workspace'
|
||||
? state.previousViewBeforeNewWorkspace
|
||||
: state.activeView,
|
||||
newWorkspacePageData: data
|
||||
activeView: 'tasks',
|
||||
previousViewBeforeTasks:
|
||||
state.activeView === 'tasks' ? state.previousViewBeforeTasks : state.activeView,
|
||||
taskPageData: data
|
||||
}))
|
||||
// Why: prefetch the GitHub work-item list in parallel with React's first
|
||||
// render of the NewWorkspacePage — by the time the page's own effect runs,
|
||||
// the SWR cache is either already populated or the request is in-flight
|
||||
// and will be deduped. This removes ~300–800ms of perceived latency on
|
||||
// initial page load.
|
||||
// render of the TaskPage — by the time the page's own effect runs, the SWR
|
||||
// cache is either already populated or the request is in-flight and will
|
||||
// be deduped. This removes ~300–800ms of perceived latency on initial
|
||||
// page load.
|
||||
const state = get()
|
||||
const targetRepoId =
|
||||
data.preselectedRepoId ?? state.activeRepoId ?? state.repos.find((r) => r.path)?.id ?? null
|
||||
@@ -195,10 +192,10 @@ export const createUISlice: StateCreator<AppState, [], [], UISlice> = (set, get)
|
||||
state.prefetchWorkItems(repo.path, 36, presetToQuery(preset))
|
||||
}
|
||||
},
|
||||
closeNewWorkspacePage: () =>
|
||||
closeTaskPage: () =>
|
||||
set((state) => ({
|
||||
activeView: state.previousViewBeforeNewWorkspace,
|
||||
newWorkspacePageData: {}
|
||||
activeView: state.previousViewBeforeTasks,
|
||||
taskPageData: {}
|
||||
})),
|
||||
setNewWorkspaceDraft: (draft) => set({ newWorkspaceDraft: draft }),
|
||||
clearNewWorkspaceDraft: () => set({ newWorkspaceDraft: null }),
|
||||
@@ -206,9 +203,9 @@ export const createUISlice: StateCreator<AppState, [], [], UISlice> = (set, get)
|
||||
set((state) => ({
|
||||
activeView: 'settings',
|
||||
// Why: Settings is a temporary detour from either terminal or the
|
||||
// full-page new-workspace composer. Preserve the originating view so the
|
||||
// Settings back action restores an in-progress workspace draft instead of
|
||||
// always dumping the user into terminal.
|
||||
// full-page tasks view. Preserve the originating view so the Settings
|
||||
// back action restores an in-progress workspace draft instead of always
|
||||
// dumping the user into terminal.
|
||||
previousViewBeforeSettings:
|
||||
state.activeView === 'settings' ? state.previousViewBeforeSettings : state.activeView
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user