Skip to content

Commit 968b696

Browse files
committed
move command palette
1 parent bb68dcb commit 968b696

3 files changed

Lines changed: 25 additions & 43 deletions

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import { TuiPluginRuntime } from "@/cli/cmd/tui/plugin/runtime"
6464
import { createTuiApi } from "@/cli/cmd/tui/plugin/api"
6565
import type { RouteMap } from "@/cli/cmd/tui/plugin/api"
6666
import { FormatError, FormatUnknownError } from "@/cli/error"
67-
import { CommandPaletteProvider } from "./context/command-palette"
67+
import { COMMAND_PALETTE_DIALOG, CommandPaletteDialog } from "./component/command-palette"
6868
import {
6969
OPENCODE_BASE_MODE,
7070
OpencodeKeymapProvider,
@@ -190,17 +190,15 @@ export function tui(input: {
190190
<LocalProvider>
191191
<PromptStashProvider>
192192
<DialogProvider>
193-
<CommandPaletteProvider>
194-
<FrecencyProvider>
195-
<PromptHistoryProvider>
196-
<PromptRefProvider>
197-
<EditorContextProvider>
198-
<App onSnapshot={input.onSnapshot} />
199-
</EditorContextProvider>
200-
</PromptRefProvider>
201-
</PromptHistoryProvider>
202-
</FrecencyProvider>
203-
</CommandPaletteProvider>
193+
<FrecencyProvider>
194+
<PromptHistoryProvider>
195+
<PromptRefProvider>
196+
<EditorContextProvider>
197+
<App onSnapshot={input.onSnapshot} />
198+
</EditorContextProvider>
199+
</PromptRefProvider>
200+
</PromptHistoryProvider>
201+
</FrecencyProvider>
204202
</DialogProvider>
205203
</PromptStashProvider>
206204
</LocalProvider>
@@ -404,6 +402,14 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
404402
const connected = useConnected()
405403
const appCommands = createMemo(() =>
406404
[
405+
{
406+
name: COMMAND_PALETTE_DIALOG,
407+
title: "Show command palette",
408+
hidden: true,
409+
run: () => {
410+
dialog.replace(() => <CommandPaletteDialog />)
411+
},
412+
},
407413
{
408414
name: "session.list",
409415
title: "Switch session",

packages/opencode/src/cli/cmd/tui/context/command-palette.tsx renamed to packages/opencode/src/cli/cmd/tui/component/command-palette.tsx

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import { createMemo, type Accessor, type ParentProps } from "solid-js"
1+
import { createMemo, type Accessor } from "solid-js"
22
import { DialogSelect, type DialogSelectRef } from "@tui/ui/dialog-select"
3-
import { useDialog, type DialogContext } from "@tui/ui/dialog"
4-
import {
5-
formatKeyBindings,
6-
type OpenTuiKeymap,
7-
useBindings,
8-
useKeymapSelector,
9-
useOpencodeKeymap,
10-
} from "../keymap"
11-
import { useTuiConfig } from "./tui-config"
3+
import { type DialogContext } from "@tui/ui/dialog"
4+
import { formatKeyBindings, type OpenTuiKeymap, useKeymapSelector, useOpencodeKeymap } from "../keymap"
5+
import { useTuiConfig } from "../context/tui-config"
126

137
type SlashEntry = {
148
display: string
@@ -17,7 +11,7 @@ type SlashEntry = {
1711
onSelect: () => void
1812
}
1913

20-
const COMMAND_PALETTE_DIALOG = "command.palette.show"
14+
export const COMMAND_PALETTE_DIALOG = "command.palette.show"
2115
type PaletteCommandEntry = ReturnType<OpenTuiKeymap["getCommandEntries"]>[number]
2216

2317
function isVisiblePaletteCommand(entry: PaletteCommandEntry) {
@@ -31,25 +25,7 @@ function isSuggestedPaletteCommand(entry: PaletteCommandEntry) {
3125
return false
3226
}
3327

34-
export function CommandPaletteProvider(props: ParentProps) {
35-
const dialog = useDialog()
36-
useBindings(() => ({
37-
commands: [
38-
{
39-
name: COMMAND_PALETTE_DIALOG,
40-
title: "Show command palette",
41-
hidden: true,
42-
run() {
43-
dialog.replace(() => <CommandPaletteDialog />)
44-
},
45-
},
46-
],
47-
}))
48-
49-
return <>{props.children}</>
50-
}
51-
52-
function CommandPaletteDialog() {
28+
export function CommandPaletteDialog() {
5329
const config = useTuiConfig()
5430
const keymap = useOpencodeKeymap()
5531
const entries = useKeymapSelector((keymap: OpenTuiKeymap) => {

packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getScrollAcceleration } from "../../util/scroll"
1212
import { useTuiConfig } from "../../context/tui-config"
1313
import { useTheme, selectedForeground } from "@tui/context/theme"
1414
import { SplitBorder } from "@tui/component/border"
15-
import { useCommandSlashes } from "../../context/command-palette"
15+
import { useCommandSlashes } from "../command-palette"
1616
import { useTerminalDimensions } from "@opentui/solid"
1717
import { Locale } from "@/util/locale"
1818
import type { PromptInfo } from "./history"

0 commit comments

Comments
 (0)