feat(desktop): list a workspace's pages in the sidebar strip, with New page

Merged
KI
2mo ago
+1141-86

Links

Summary

  • The strip above Files / Changes / Review now has a pages menu next to Run: pages published from this workspace, your pinned pages, and "All pages".
  • "New page" in the menu takes a one-line request and hands it to an agent, using the same agent picker as design mode and diff comments.
  • When a publish lands, the button turns blue with "New" and the row is marked, until the menu is closed.

Screenshots

Captured over CDP from this branch's dev app (dark theme). Page titles are demo names set in the worktree's own dev database for the capture.

Populated: workspace pages, then pinnedFresh publish: blue "New" button, row marked
New page composer with the agent pickerNo pages in this workspace yet

Why / Context

A page an agent publishes from a workspace was only reachable by leaving for the org-wide Pages view. The sidebar's top strip had been empty since the PR badge and Open-in moved out (#7167), so it had room. Gated on the existing PAGES flag.

How It Works

  • WorkspacePagesMenu (Popover) is rendered by the workspace page and passed into PRActionHeader beside runButton, the same way the Run button is.
  • Workspace pages come from the existing page.list({ workspaceId }). Pinned pages come from page.list({}) filtered by usePageFavorites, fetched only while the menu is open. No API or schema change.
  • selectMenuPages sorts by latest publish, drops pinned pages already listed under the workspace, and flags pages published after the last-seen time.
  • Last-seen is a session-only zustand store keyed by workspace. It records the newest publish the menu has displayed, not the wall clock, so a slow refetch cannot clear a badge for a page that was never shown. Nothing is persisted.
  • The list refetches on open and on the workspace's page-watch:changed event.
  • useAgentSessionLauncher is extracted from usePaneRegistry unchanged, so the sidebar can start agent sessions. buildPageAgentPrompt(request?) replaces PAGE_AGENT_PROMPT; with no request it returns the same text (checked byte for byte).
  • usePageFavorites moves to _dashboard/hooks/ now that two routes use it.

Manual QA Checklist

Driven over CDP with real input against this worktree's dev app, console.error hooked and empty throughout. Run twice: once before committing and again on the committed build for the screenshots above.

  • No pages: bare icon, menu shows New page and All pages
  • With pages: count on the button, newest first, relative times
  • Clicking a row opens the page in a pane in this workspace and closes the menu
  • New page: composer opens with the default request focused and selected, agent picker populated, send enabled
  • Escape in the composer steps back to the list; Escape again closes; outside click closes
  • Fresh publish: button turns blue with "New", row marked, both clear after closing, stay clear on reopen
  • Pinned section appears after pinning a page in the Pages view; private page shows the lock
  • Sending the New page request to an agent (not submitted, it spawns a real agent)
  • page-watch:changed firing on a real publish (the publish was simulated by bumping a version timestamp in the dev DB branch)
  • Light theme and Windows/Linux window-controls inset

Testing

  • bun run typecheck (desktop): 0 errors
  • bunx biome check on the touched tree: clean
  • bun test for selectMenuPages and buildPageAgentPrompt: 7 pass
  • bun run check:i18n: passes; 7 new strings translated in all 16 locales

Design Decisions

  • Popover, not DropdownMenu: the composer has a textarea and a select, and menu typeahead would eat keystrokes.
  • Escape handled in onEscapeKeyDown: Radix dismisses at the document level, so a React keydown handler with stopPropagation runs too late.
  • Reuse the agent picker rather than always starting a new session, so there is one way to hand a prompt to an agent across the app.

Known Limitations

  • Placement is still under discussion on the design page (strip icon vs a fourth tab vs a labeled button vs a footer bar). The list, composer, pinned and fresh-publish pieces are placement-independent, so moving them is a change of mount point.
  • page.list mints a ticket per row and took about 5s against the dev API, so the count can lag a publish by that much.
  • NewPageComposer imports AgentPickerSelect from under usePaneRegistry/components/, as PullRequestCommentComposer already does. Promoting that folder is left for a separate move-only PR.