Skip to content

The agent that grows with you

Merge remote-tracking branch 'origin/main' into bb/yolo-palette

Brooklyn Nicholson640056704c81
diff --cc apps/desktop/src/app/command-palette/index.tsx
index 970f4fb4be2,260e22db955..d62e33b6ffe
--- a/apps/desktop/src/app/command-palette/index.tsx
+++ b/apps/desktop/src/app/command-palette/index.tsx
@@@ -1,19 -1,12 +1,20 @@@
import { useStore } from '@nanostores/react'
import { useQuery } from '@tanstack/react-query'
import { Dialog as DialogPrimitive } from 'radix-ui'
- import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
+ import { memo, useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
import { useNavigate } from 'react-router-dom'
-import { HUD_HEADING, HUD_ITEM, HUD_POSITION, HUD_SURFACE, HUD_TEXT } from '@/app/floating-hud'
+import {
+ HUD_HEADING,
+ HUD_ITEM,
+ HUD_NOTE,
+ HUD_NOTE_VARIANT,
+ HUD_POSITION,
+ HUD_SURFACE,
+ HUD_TEXT
+} from '@/app/floating-hud'
import { setTerminalTakeover } from '@/app/right-sidebar/store'
+ import { codiconIcon } from '@/components/ui/codicon'
import { Command, CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/ui/command'
import { HighlightMatches } from '@/components/ui/highlight-matches'
import { KbdCombo } from '@/components/ui/kbd'
@@@ -111,10 -104,10 +112,12 @@@ interface PaletteItem
action?: string
/** Renders a trailing check: this row IS the current setting (theme, mode). */
active?: boolean
+ /** Static trailing combo hint for a modifier-variant select (e.g. `mod+enter`). */
+ comboHint?: string
- /** Muted text beside the label — state the row acts on (a version, a count). */
+ /** Short note beside the label — state the row acts on (a version, a count). */
detail?: string
+ /** `state` when the row will change what `detail` says (a toggle's on/off). */
+ detailVariant?: keyof typeof HUD_NOTE_VARIANT
icon: IconComponent
id: string
/** Keep the palette open after running (live-preview pickers like theme/mode). */
@@@ -265,15 -331,19 +341,21 @@@ const PaletteRow = memo(function Palett
value={paletteValue(item)}
>
<Icon className="size-3.5 shrink-0 text-muted-foreground" />
- <span className="truncate">
- {/* Same per-term split as scoreItem's AND matcher, so the emphasis
- shows exactly which words earned the row its rank. */}
- <HighlightMatches query={search.split(/\s+/)} text={item.label} />
+ <span className={cn('truncate', modPreview && 'text-muted-foreground/80')}>
+ {modPreview ? (
+ item.modLabel
+ ) : (
+ /* Same per-term split as scoreItem's AND matcher, so the emphasis
+ shows exactly which words earned the row its rank. */
+ <HighlightMatches query={search.split(/\s+/)} text={item.label} />
+ )}
</span>
- {item.detail && <span className="truncate text-muted-foreground/80">{item.detail}</span>}
+ {item.detail && (
+ <span className={cn(HUD_NOTE, HUD_NOTE_VARIANT[item.detailVariant ?? 'muted'])}>{item.detail}</span>
+ )}
- {combo && <KbdCombo className="ml-auto opacity-55" combo={combo} size="sm" />}
+ {combo && (
+ <KbdCombo className={cn('ml-auto', modPreview ? 'opacity-90' : 'opacity-55')} combo={combo} size="sm" />
+ )}
{item.to && <ChevronRight className={cn('size-3.5 shrink-0 text-muted-foreground/70', !combo && 'ml-auto')} />}
{item.active && <Check className={cn('size-3.5 shrink-0 text-primary', !combo && !item.to && 'ml-auto')} />}
</CommandItem>
@@@ -505,67 -652,66 +664,78 @@@ function CommandPaletteBody({ onExited
[t.settings.fieldLabels]
)
++ // Running a keepOpen row (a toggle) changes state the rows themselves report,
++ // so the groups have to rebuild without the palette closing. A counter keeps
++ // that generic — the palette never learns which stores its contributions read.
++ const [selectTick, setSelectTick] = useState(0)
++
const contributedItems = usePaletteContributions()
+ // The active repo's worktrees → "new conversation in <branch>". This is the
+ // ⌘K-typed "I want to work on <branch>" reflex: each entry seeds a fresh
+ // session anchored to that worktree's checkout (requestStartWorkSession),
+ // so git is the source of truth and edits land in the right tree.
+ const branchGroup = useMemo<PaletteGroup[]>(
+ () =>
+ worktrees.length > 0
+ ? [
+ {
+ heading: t.commandCenter.branches,
+ items: worktrees.map(wt => {
+ const name = wt.branch?.trim() || wt.path.split('/').pop() || wt.path
+
+ return {
+ icon: GitBranch,
+ id: `worktree-${wt.path}`,
+ keywords: ['branch', 'worktree', 'switch', name, wt.path],
+ label: t.commandCenter.startInBranch(name),
+ run: () => requestStartWorkSession(wt.path)
+ }
+ })
+ }
+ ]
+ : [],
+ [t, worktrees]
+ )
+
const baseGroups = useMemo<PaletteGroup[]>(() => {
const settingsTab = (tab: string) => `${SETTINGS_ROUTE}?tab=${tab}`
const cc = t.commandCenter
- // Registry-contributed rows (core features + plugins) — one group, omitted
- // while nothing contributes.
- const commandGroup: PaletteGroup[] =
- contributedItems.length > 0
- ? [
- {
- heading: cc.commands,
- items: contributedItems.map(item => ({
- action: item.action,
- // Read on open and after every select (the deps below), so a
- // row that reports state can't show the state it just left.
- detail: item.detail?.(),
- detailVariant: item.detailVariant,
- icon: item.icon ?? Zap,
- id: item.key,
- keepOpen: item.keepOpen,
- keywords: item.keywords,
- label: item.label,
- run: item.run
- }))
- }
- ]
- : []
+ // Projects are the primary way the desktop scopes work, so they're jumpable
+ // from the palette. Plain select is a pure scope switch (sidebar enters the
+ // project — never spends main); ⌘-Enter / ⌘-click also starts a new session
+ // at the project root (stacked as a tab when main holds a chat), previewed
+ // by the label swap while ⌘ is held. Rows carry the project's own codicon,
+ // matching the sidebar. The pinned "Open folder…" row is the ⌘O upsert.
+ const projectGroup: PaletteGroup = {
+ heading: cc.projects,
+ items: [
+ {
+ action: 'workspace.openFolder',
+ icon: codiconIcon('folder-opened'),
+ id: 'project-open-folder',
+ keywords: ['open', 'folder', 'directory', 'project', 'add', 'import', 'workspace'],
+ label: cc.openFolder,
+ run: () => void openFolderAsProject()
+ },
+ ...projectTree.map(project => ({
+ comboHint: 'mod+enter',
+ icon: codiconIcon(project.icon || (project.isNoProject ? 'home' : 'folder-library')),
+ id: `project-${project.id}`,
+ keywords: ['project', 'workspace', 'go to', project.label, ...(project.path ? [project.path] : [])],
+ label: project.label,
+ modLabel: cc.newSessionInProject(project.label),
+ runWithEvent: (event?: { ctrlKey?: boolean; metaKey?: boolean; shiftKey?: boolean }) =>
+ goToProject(project.id, { newSession: Boolean(event?.metaKey || event?.ctrlKey) })
+ }))
+ ]
+ }
- // The active repo's worktrees → "new conversation in <branch>". This is the
- // ⌘K-typed "I want to work on <branch>" reflex: each entry seeds a fresh
- // session anchored to that worktree's checkout (requestStartWorkSession),
- // so git is the source of truth and edits land in the right tree.
- const branchGroup: PaletteGroup[] =
- worktrees.length > 0
- ? [
- {
- heading: cc.branches,
- items: worktrees.map(wt => {
- const name = wt.branch?.trim() || wt.path.split('/').pop() || wt.path
-
- return {
- icon: GitBranch,
- id: `worktree-${wt.path}`,
- keywords: ['branch', 'worktree', 'switch', name, wt.path],
- label: cc.startInBranch(name),
- run: () => requestStartWorkSession(wt.path)
- }
- })
- }
- ]
- : []
-
+ // Group order is the tiebreaker rankGroups falls back on (stable sort), and
- // exact ties are the common case — "yolo" hits both "Toggle YOLO" and a
++ // exact ties are the common case — "yolo" hits both "Toggle yolo" and a
+ // worktree named bb/yolo-* as a whole word. So this order IS the priority:
+ // where you're going, then what you can do, then what you can configure.
return [
{
heading: cc.goTo,
@@@ -646,7 -792,8 +816,29 @@@
}
]
},
- ...commandGroup,
+ projectGroup,
- ...branchGroup,
++ // Registry-contributed rows (core features + plugins) — one group,
++ // omitted while nothing contributes.
++ ...(contributedItems.length > 0
++ ? [
++ {
++ heading: cc.commands,
++ items: contributedItems.map(item => ({
++ action: item.action,
++ // Read on mount and after every select (the deps below), so a
++ // row that reports state can't show the state it just left.
++ detail: item.detail?.(),
++ detailVariant: item.detailVariant,
++ icon: item.icon ?? Zap,
++ id: item.key,
++ keepOpen: item.keepOpen,
++ keywords: item.keywords,
++ label: item.label,
++ run: item.run
++ }))
++ }
++ ]
++ : []),
{
heading: cc.commandCenter,
items: [
@@@ -742,13 -889,26 +934,13 @@@
run: go(settingsTab(entry.tab))
}))
]
- },
- // Registry-contributed rows (core features + plugins) — one group,
- // omitted while nothing contributes.
- ...(contributedItems.length > 0
- ? [
- {
- heading: cc.commands,
- items: contributedItems.map(item => ({
- action: item.action,
- icon: item.icon ?? Zap,
- id: item.key,
- keywords: item.keywords,
- label: item.label,
- run: item.run
- }))
- }
- ]
- : [])
+ }
]
- // `open` and `selectTick` are deliberate re-read triggers, not values: rows
- // report live state through `detail()`, so the groups must rebuild when the
- // palette opens and after each select — eslint only sees unused deps.
- }, [contributedItems, go, projectTree, settingsSectionLabel, t, updateVersionLabel, worktrees])
++ // `selectTick` is a deliberate re-read trigger, not a value: rows report
++ // live state through `detail()`, so the groups must rebuild after a select
++ // that kept the palette open — eslint only sees an unused dep.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [contributedItems, go, open, selectTick, settingsSectionLabel, t, updateVersionLabel])
++ }, [contributedItems, go, projectTree, selectTick, settingsSectionLabel, t, updateVersionLabel])
// The long, granular lists (settings fields, API keys, MCP servers, archived
// chats) only surface once the user types — otherwise they'd bury the
diff --cc apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx
index a4ccc783cba,8c480dbefcd..6008ca025ff
--- a/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx
+++ b/apps/desktop/src/components/pane-shell/tree/renderer/tree-group.tsx
@@@ -45,8 -45,8 +45,8 @@@ import
restoreTreePane,
SESSION_TILE_DRAG,
setTreeGroupHeaderHidden,
-- splitTreeZone,
- setTreeGroupMinimized
- toggleTreeGroupMinimized
++ setTreeGroupMinimized,
++ splitTreeZone
} from '../store'
import { type DoubleTapContext, startPaneDrag } from './drag-session'