diff --git a/packages/app/e2e/regression/command-palette.spec.ts b/packages/app/e2e/regression/command-palette.spec.ts
index b7ccba66a37..afe1d25b471 100644
--- a/packages/app/e2e/regression/command-palette.spec.ts
+++ b/packages/app/e2e/regression/command-palette.spec.ts
@@ -129,6 +129,43 @@ test("titlebar search lists recent sessions and opens the typed match", async ({
await expect(page.getByRole("heading", { name: paletteSession.title, exact: true })).toBeVisible()
})
+test("Search commands lists only commands and runs the chosen one", async ({ page }) => {
+ const { dialog, input } = await openCommandPalette(page, true)
+ await input.fill("search commands")
+ await dialog.getByRole("option", { name: /^Search commands/ }).click()
+ const search = page.getByRole("dialog").getByRole("combobox")
+ await expect(search).toHaveAttribute("placeholder", "Search commands")
+ await expect(search).toBeFocused()
+ await expect(page.getByRole("dialog").getByRole("option", { name: /^Open settings/ })).toBeVisible()
+ await search.fill("Palette fixture")
+ await expect(page.getByRole("dialog").getByText("No results found", { exact: true })).toBeVisible()
+ await search.fill("open settings")
+ await expect(page.getByRole("dialog").getByRole("option")).toHaveCount(1)
+ await search.press("Enter")
+ await expect(page).toHaveURL("/settings")
+})
+
+test("Search projects opens a new session's project picker from a session and from Home", async ({ page }) => {
+ const editor = page.locator('[data-component="composer-editor"]')
+ const picker = page.getByRole("combobox", { name: "Search projects", exact: true })
+ const { dialog, input } = await openCommandPalette(page)
+ await input.fill("search projects")
+ await dialog.getByRole("option", { name: /^Search projects/ }).click()
+ await expect(page).toHaveURL(/\/new-session\?draftId=.+$/)
+ await expect(picker).toBeFocused()
+ await picker.press("Escape")
+ await expect(picker).toHaveCount(0)
+ await expect(editor).toBeFocused()
+
+ await page.goto("/")
+ await expect(
+ page.getByRole("region", { name: "Recent sessions" }).getByRole("button", { name: /Palette fixture session/ }),
+ ).toBeEnabled()
+ await page.keyboard.press("ControlOrMeta+Shift+O")
+ await expect(page).toHaveURL(/\/new-session\?draftId=.+$/)
+ await expect(picker).toBeFocused()
+})
+
test("reopens from its shortcut as soon as it closes", async ({ page }) => {
const { dialog, input } = await openCommandPalette(page)
await input.press("Escape")
diff --git a/packages/app/e2e/regression/settings-search.spec.ts b/packages/app/e2e/regression/settings-search.spec.ts
index 8ca44ac0bcd..fabceae84b8 100644
--- a/packages/app/e2e/regression/settings-search.spec.ts
+++ b/packages/app/e2e/regression/settings-search.spec.ts
@@ -210,11 +210,11 @@ test("Models and Shortcuts leave focus on navigation until the user types", asyn
}
const search = view.settings.getByRole("searchbox", { name: "Search shortcuts", exact: true })
- await page.keyboard.press("p")
+ await page.keyboard.press("e")
await expect(search).toBeFocused()
- await page.keyboard.type("alette")
- await expect(search).toHaveValue("palette")
- await expect(view.settings.getByText("Command palette", { exact: true })).toBeVisible()
+ await page.keyboard.type("verything")
+ await expect(search).toHaveValue("everything")
+ await expect(view.settings.getByText("Search everything", { exact: true })).toBeVisible()
})
test("section search takes typed input, clears in place, and escapes in steps", async ({ page }) => {
diff --git a/packages/app/e2e/regression/settings.spec.ts b/packages/app/e2e/regression/settings.spec.ts
index 22fc573008f..3b016ce6dee 100644
--- a/packages/app/e2e/regression/settings.spec.ts
+++ b/packages/app/e2e/regression/settings.spec.ts
@@ -564,6 +564,28 @@ test("clearing project fields sends explicit removal values", async ({ page }) =
}
})
+test("shortcuts list Search sessions once and unbind a shortcut while recording it", async ({ page }) => {
+ // Opening Settings from Home registers Home's Find, which must not add a second Search sessions.
+ const { settings } = await open(page)
+ await settings.getByRole("tab", { name: "Shortcuts", exact: true }).click()
+ await expect(settings.locator('[data-keybind-id="sessions.search"]')).toBeVisible()
+ await expect(settings.getByText("Search sessions", { exact: true })).toHaveCount(1)
+
+ const binding = settings.locator('[data-keybind-id="settings.open"]')
+ const unbind = settings.getByRole("button", { name: "Unbind", exact: true })
+ await expect(binding).toHaveText("Ctrl+,")
+ await expect(unbind).toHaveCount(0)
+ await binding.click()
+ await expect(binding).toHaveText("Press keys")
+ await unbind.click()
+ await expect(binding).toHaveText("Unassigned")
+ await expect(unbind).toHaveCount(0)
+ // An unassigned shortcut has nothing to unbind.
+ await binding.click()
+ await expect(binding).toHaveText("Press keys")
+ await expect(unbind).toHaveCount(0)
+})
+
test("the new session shortcut waits for a shortcut recording, then leaves settings", async ({ page }) => {
const { settings } = await open(page)
await settings.getByRole("tab", { name: "Shortcuts", exact: true }).click()
diff --git a/packages/app/src/home/sessions/search.ts b/packages/app/src/home/sessions/search.ts
index 0d4f1b43ce5..bade5e332ad 100644
--- a/packages/app/src/home/sessions/search.ts
+++ b/packages/app/src/home/sessions/search.ts
@@ -91,10 +91,11 @@ export function createHomeSessionSearchController(home: HomeController, sessions
if (layout.home.searchFocus.take()) focus()
})
+ // Home's Find focuses its session search, so Settings > Shortcuts lists one Find and one Search sessions.
command.register("home.search", () => [
{
- id: "home.sessions.search.focus",
- title: placeholder(),
+ id: "session.search",
+ title: language.t("session.search.placeholder"),
keybind: "mod+f",
hidden: true,
onSelect: focus,
diff --git a/packages/app/src/new-session/commands.tsx b/packages/app/src/new-session/commands.tsx
index 868174b60eb..5bd5de1bf58 100644
--- a/packages/app/src/new-session/commands.tsx
+++ b/packages/app/src/new-session/commands.tsx
@@ -2,6 +2,7 @@ import { useDialog } from "@opencode/ui/context/dialog"
import { useSettingsCommand } from "@/settings/command"
import { useCommand } from "@/shell/commands/command"
import { useLanguage } from "@/runtime/i18n/language"
+import { projectSearchCommand } from "@/shell/titlebar/titlebar"
export function useNewSessionCommands(input: {
restoreFocus: () => void
@@ -39,10 +40,9 @@ export function useNewSessionCommands(input: {
onSelect: input.restoreFocus,
},
{
- id: "project.select",
+ ...projectSearchCommand,
title: language.t("session.new.project.search"),
category: language.t("command.category.project"),
- keybind: "mod+shift+o",
disabled: input.project.empty(),
onSelect: input.project.open,
},
diff --git a/packages/app/src/new-session/screen.tsx b/packages/app/src/new-session/screen.tsx
index 12288c66e56..1e5a170886b 100644
--- a/packages/app/src/new-session/screen.tsx
+++ b/packages/app/src/new-session/screen.tsx
@@ -1,6 +1,7 @@
import { createPromptProjectController } from "@/new-session/project/selector"
import { useNewSessionLocationDialog } from "@/new-session/location/dialog"
import { useTabs, type DraftTab } from "@/shell/tabs/tabs"
+import { useLayout } from "@/shell/state/layout"
import { useSearchParams } from "@solidjs/router"
import { createEffect, createMemo, createResource, on, untrack } from "solid-js"
import { createComposerModel } from "@/composer/model"
@@ -15,6 +16,7 @@ import { createDraftMcpControls } from "./mcp"
export default function NewSessionPage(props: { draftId: string }) {
const [search, setSearch] = useSearchParams<{ draftId?: string; prompt?: string }>()
const tabs = useTabs()
+ const layout = useLayout()
const draftTab = createMemo(() =>
tabs.store.find((tab): tab is DraftTab => tab.type === "draft" && tab.draftID === search.draftId),
@@ -62,7 +64,11 @@ export default function NewSessionPage(props: { draftId: string }) {
// a stale cursor a frame after every key-up and yank the caret from a key pressed in that frame.
createEffect(
on(composer.ready, (ready) => {
- if (ready) model.restoreFocus()
+ if (!ready) return
+
+ // Search projects opened this draft; the picker returns focus to the composer when it closes.
+ if (layout.draft.projectSearch.take()) location()
+ else model.restoreFocus()
}),
)
createEffect(() => {
diff --git a/packages/app/src/runtime/i18n/en.ts b/packages/app/src/runtime/i18n/en.ts
index 997a0195332..61f2c45a020 100644
--- a/packages/app/src/runtime/i18n/en.ts
+++ b/packages/app/src/runtime/i18n/en.ts
@@ -66,7 +66,8 @@ export const dict = {
"command.usage.view.description": "See your OpenCode Go allowance and Console budgets",
"command.session.location.cycle": "Cycle session location",
- "command.palette": "Command palette",
+ "command.palette": "Search everything",
+ "command.commands.search": "Search commands",
"command.session.new": "New session",
"command.session.search": "Search sessions",
@@ -1078,6 +1079,7 @@ export const dict = {
"settings.shortcuts.conflict.description": "{{keybind}} is already assigned to {{titles}}.",
"settings.shortcuts.unassigned": "Unassigned",
"settings.shortcuts.pressKeys": "Press keys",
+ "settings.shortcuts.unbind": "Unbind",
"settings.shortcuts.search.placeholder": "Search shortcuts",
"settings.shortcuts.group.general": "General",
diff --git a/packages/app/src/settings/keybinds/keybinds.tsx b/packages/app/src/settings/keybinds/keybinds.tsx
index 740bb7258fa..68e067c1c55 100644
--- a/packages/app/src/settings/keybinds/keybinds.tsx
+++ b/packages/app/src/settings/keybinds/keybinds.tsx
@@ -308,6 +308,11 @@ export function createKeybindSettingsController(
input.command.keybinds(false)
}
+ const unbind = (id: string) => {
+ input.settings.keybinds.set(id, "none")
+ stop()
+ }
+
const notify = input.notify ?? ((toast: { title: string; description: string }) => showToast(toast))
const handle = (event: KeyboardEvent) => {
@@ -333,8 +338,7 @@ export function createKeybindSettingsController(
!event.shiftKey
if (clear) {
- input.settings.keybinds.set(id, "none")
- stop()
+ unbind(id)
return
}
@@ -387,6 +391,7 @@ export function createKeybindSettingsController(
capture: {
active: () => store.active,
toggle,
+ unbind,
},
settings: {
hasOverrides: () => Object.values(overrides()).some((value) => typeof value === "string"),
@@ -420,6 +425,7 @@ export function SettingsKeybinds(props: { active?: boolean }) {
keybind={controller.catalog.keybind}
active={controller.capture.active()}
onCapture={controller.capture.toggle}
+ onUnbind={controller.capture.unbind}
hasOverrides={controller.settings.hasOverrides()}
onReset={controller.settings.reset}
/>
@@ -434,6 +440,7 @@ function SettingsKeybindsView(props: {
keybind: (id: string) => string
active: string | null
onCapture: (id: string) => void
+ onUnbind: (id: string) => void
hasOverrides: boolean
onReset: () => void
}) {
@@ -476,21 +483,33 @@ function SettingsKeybindsView(props: {
return (
{props.title(id)}
-
)
}}
diff --git a/packages/app/src/settings/keybinds/migration.ts b/packages/app/src/settings/keybinds/migration.ts
index f93082b2595..f4d664cf2f4 100644
--- a/packages/app/src/settings/keybinds/migration.ts
+++ b/packages/app/src/settings/keybinds/migration.ts
@@ -3,10 +3,12 @@ import { Predicate } from "effect"
import type { useSettings } from "@/settings/model"
/**
- * Stored custom keybinds of commands that built-in GUI extensions now publish under another id. Each old id maps to
+ * Stored custom keybinds of commands now published under another id, mostly by built-in GUI extensions. Each old id maps to
* the current one, and a newer old id comes first, so its override wins over an older one.
*/
export const keybindRenames = {
+ // Home's session search focus now follows Find; a custom binding of it keeps searching sessions.
+ "home.sessions.search.focus": "sessions.search",
"app.checkForUpdates": "updater.check",
"server.pair": "pairing.open",
"server.ssh.add": "ssh.add",
diff --git a/packages/app/src/shell/commands/command-search.tsx b/packages/app/src/shell/commands/command-search.tsx
new file mode 100644
index 00000000000..7bb3166b923
--- /dev/null
+++ b/packages/app/src/shell/commands/command-search.tsx
@@ -0,0 +1,51 @@
+import { useDialog } from "@opencode/ui/context/dialog"
+import { createMemo, onCleanup } from "solid-js"
+import { useLanguage } from "@/runtime/i18n/language"
+import { COMMAND_SEARCH_ID, commandPaletteOptions, useCommand } from "./command"
+import { CommandPaletteView, matchesCommandPaletteEntry } from "./dialog"
+import { createCommandPaletteCommandEntry, type CommandPaletteEntry, type PaletteHighlight } from "./palette"
+
+/** Search everything, limited to commands. */
+export function DialogCommandSearch() {
+ const command = useCommand()
+ const dialog = useDialog()
+ const language = useLanguage()
+ const state: PaletteHighlight = { cleanup: undefined, committed: false }
+
+ const entries = createMemo(() => {
+ const category = language.t("palette.group.commands")
+
+ return commandPaletteOptions(command.options)
+ .filter((option) => option.id !== COMMAND_SEARCH_ID)
+ .map((option) => createCommandPaletteCommandEntry(option, category))
+ })
+
+ const highlight = (item: CommandPaletteEntry | undefined) => {
+ state.cleanup?.()
+ state.cleanup = item?.option?.onHighlight?.()
+ }
+
+ const select = (item: CommandPaletteEntry | undefined) => {
+ if (!item) return
+ state.committed = true
+ state.cleanup = undefined
+ dialog.close()
+ void item.option?.onSelect?.("palette")
+ }
+
+ onCleanup(() => {
+ if (state.committed) return
+ state.cleanup?.()
+ })
+
+ return (
+ entries().filter((entry) => matchesCommandPaletteEntry(entry, query))}
+ sources={[]}
+ highlight={highlight}
+ select={select}
+ close={() => dialog.close()}
+ />
+ )
+}
diff --git a/packages/app/src/shell/commands/command.tsx b/packages/app/src/shell/commands/command.tsx
index f3d8c3f75f6..18323d8b869 100644
--- a/packages/app/src/shell/commands/command.tsx
+++ b/packages/app/src/shell/commands/command.tsx
@@ -15,6 +15,9 @@ const IS_MAC = /(Mac|iPod|iPhone|iPad)/.test(globalThis.navigator?.platform ?? "
const PALETTE_ID = "command.palette"
+/** Search commands: Search everything (the palette) limited to commands. */
+export const COMMAND_SEARCH_ID = "commands.search"
+
export const DEFAULT_PALETTE_KEYBIND = "mod+k,mod+shift+p"
const SUGGESTED_PREFIX = "suggested."
diff --git a/packages/app/src/shell/shell.tsx b/packages/app/src/shell/shell.tsx
index 7a114c7b288..255090dd9a8 100644
--- a/packages/app/src/shell/shell.tsx
+++ b/packages/app/src/shell/shell.tsx
@@ -12,7 +12,7 @@ import { useSettingsSurface } from "@/settings/surface"
import { useSettings } from "@/settings/model"
import { ExtensionServerCover } from "@/runtime/extension/server-shell"
import { ExtensionSlot } from "@/runtime/extension/render"
-import { useCommand } from "@/shell/commands/command"
+import { COMMAND_SEARCH_ID, useCommand } from "@/shell/commands/command"
import { useLanguage } from "@/runtime/i18n/language"
import { useGlobal } from "@/runtime/server/runtime"
import { useServers } from "@/runtime/server/registry"
@@ -193,6 +193,17 @@ export default function Layout(props: ParentProps) {
},
},
])
+ command.register("commands", () => [
+ {
+ id: COMMAND_SEARCH_ID,
+ title: language.t("command.commands.search"),
+ category: language.t("command.category.view"),
+ onSelect: async () => {
+ const { DialogCommandSearch } = await import("@/shell/commands/command-search")
+ void dialog.show(() => )
+ },
+ },
+ ])
const bottomTitlebar = () => mobile() && preferences.general.mobileTitlebarPosition() === "bottom"
const dragInset = () => windowDragEnabled(platform) && !mobile()
diff --git a/packages/app/src/shell/state/layout.tsx b/packages/app/src/shell/state/layout.tsx
index 1ac5905a476..445ea140113 100644
--- a/packages/app/src/shell/state/layout.tsx
+++ b/packages/app/src/shell/state/layout.tsx
@@ -300,6 +300,9 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
// Opening Home with its shortcut focuses session search, so typing filters immediately.
let homeSearchFocus = false
+ // Search projects outside a draft opens a new draft, which then opens its project picker.
+ let draftProjectSearch = false
+
// Names of other session-scoped stores, e.g. extension storage, so pruning drops them with the layout state.
const [scoped, setScoped, , scopedReady] = persisted(
Persist.global("layout.scoped"),
@@ -453,6 +456,19 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
},
},
},
+ draft: {
+ projectSearch: {
+ request() {
+ draftProjectSearch = true
+ },
+ take() {
+ const requested = draftProjectSearch
+ draftProjectSearch = false
+
+ return requested
+ },
+ },
+ },
sessionState: {
/** Records a session-scoped store, so pruning a session's layout state drops it too. */
track(name: string) {
diff --git a/packages/app/src/shell/titlebar/titlebar.tsx b/packages/app/src/shell/titlebar/titlebar.tsx
index 0e8b6541180..93a594a8653 100644
--- a/packages/app/src/shell/titlebar/titlebar.tsx
+++ b/packages/app/src/shell/titlebar/titlebar.tsx
@@ -37,6 +37,9 @@ import { TitlebarItems, useTitlebarItems } from "@/runtime/extension/titlebar-it
export const newTabCommand = { id: "tab.new", keybind: "mod+t,mod+n" }
+/** A draft registers its own Search projects; everywhere else it opens a new draft with the project picker open. */
+export const projectSearchCommand = { id: "project.select", keybind: "mod+shift+o" }
+
export const goBackCommand = { id: "common.goBack", keybind: "mod+[" }
export const goForwardCommand = { id: "common.goForward", keybind: "mod+]" }
@@ -338,6 +341,7 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
tabsStoreActions.removeSessions(detail)
})
+ /** Opens a new session draft for the current context. Returns false when there is nothing to open it in. */
const openNewTab = () => {
const route = layout.route()
@@ -349,12 +353,12 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
const model = tabs.stateValue(pending.draft, "prompt")?.model.current()
void tabs.newDraft({ server: route.server, directory: pending.draft.directory }, "", model)
- return
+ return true
}
const activeSession = session()
- if (!activeSession) return
+ if (!activeSession) return false
const sessionTab = {
type: "session" as const,
@@ -369,18 +373,18 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
model,
)
- return
+ return true
}
case "draft": {
const activeTab = currentTab()
- if (activeTab?.type !== "draft") return
+ if (activeTab?.type !== "draft") return false
const model = tabs.stateValue(activeTab, "prompt")?.model.current()
void tabs.newDraft({ server: activeTab.server, directory: activeTab.directory }, "", model)
- return
+ return true
}
case "settings":
@@ -403,8 +407,10 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
if (conn && project) {
void tabs.newDraft({ server: ServerConnection.key(conn), directory: project.worktree }, "")
- return
+ return true
}
+
+ return false
}
}
}
@@ -550,6 +556,16 @@ export function Titlebar(props: { verticalTabs?: { mount?: HTMLElement } }) {
tabsStoreActions.closeTab(tabsStore.findIndex((tab) => current === tab))
},
},
+ {
+ ...projectSearchCommand,
+ title: language.t("session.new.project.search"),
+ category: language.t("command.category.project"),
+ onSelect: () => {
+ layout.draft.projectSearch.request()
+
+ if (!openNewTab()) layout.draft.projectSearch.take()
+ },
+ },
{
id: "tab.reopenClosed",
category: language.t("command.category.file"),
diff --git a/packages/ui/src/actions/button/button.css b/packages/ui/src/actions/button/button.css
index 329f6e57cae..83fdf0ccdc9 100644
--- a/packages/ui/src/actions/button/button.css
+++ b/packages/ui/src/actions/button/button.css
@@ -282,6 +282,25 @@
cursor: not-allowed;
}
+ /* Ghost danger: a destructive action that sits beside other ghost buttons */
+ [data-component="button-v2"][data-variant="ghost-danger"] {
+ background-color: transparent;
+ color: var(--v2-state-fg-danger);
+ }
+
+ [data-component="button-v2"][data-variant="ghost-danger"]:is(:hover, [data-state="hover"]):not(:disabled) {
+ background-color: var(--v2-overlay-simple-overlay-hover);
+ }
+
+ [data-component="button-v2"][data-variant="ghost-danger"]:is(:active, [data-state="pressed"]):not(:disabled) {
+ background-color: var(--v2-overlay-simple-overlay-pressed);
+ }
+
+ [data-component="button-v2"][data-variant="ghost-danger"]:is(:disabled, [data-state="disabled"]) {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+
/* Ghost faint */
[data-component="button-v2"][data-variant="ghost-faint"] {
background-color: transparent;
diff --git a/packages/ui/src/actions/button/button.stories.tsx b/packages/ui/src/actions/button/button.stories.tsx
index 2c895ff5d6f..c04677205fc 100644
--- a/packages/ui/src/actions/button/button.stories.tsx
+++ b/packages/ui/src/actions/button/button.stories.tsx
@@ -5,7 +5,7 @@ const docs = `### Overview
Button v2 with visual variants and three sizes.
### API
-- \`variant\`: "neutral" | "danger" | "warning" | "contrast" | "submit" | "ghost" | "ghost-muted" | "ghost-faint" | "loading".
+- \`variant\`: "neutral" | "danger" | "warning" | "contrast" | "submit" | "ghost" | "ghost-muted" | "ghost-faint" | "ghost-danger" | "loading".
- \`submit\` shares the brighter contrast icon-button styling for Composer submission actions.
- \`size\`: "small" | "normal" | "large".
- \`icon\`: Optional icon name.
@@ -41,7 +41,18 @@ export default {
},
variant: {
control: "select",
- options: ["neutral", "danger", "warning", "contrast", "submit", "ghost", "ghost-muted", "ghost-faint", "loading"],
+ options: [
+ "neutral",
+ "danger",
+ "warning",
+ "contrast",
+ "submit",
+ "ghost",
+ "ghost-muted",
+ "ghost-faint",
+ "ghost-danger",
+ "loading",
+ ],
},
size: {
control: "select",
@@ -74,6 +85,7 @@ export const Variants = {
Ghost faint
+ Ghost danger
Loading
),
diff --git a/packages/ui/src/actions/button/button.tsx b/packages/ui/src/actions/button/button.tsx
index 50ce2a49f8c..ea9321bbb29 100644
--- a/packages/ui/src/actions/button/button.tsx
+++ b/packages/ui/src/actions/button/button.tsx
@@ -17,6 +17,7 @@ export interface ButtonProps
| "ghost"
| "ghost-muted"
| "ghost-faint"
+ | "ghost-danger"
| "loading"
icon?: IconProps["name"]
}