mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-18 15:28:48 +03:00
fix(app): focus search input when opening /model dialog (#53707)
This commit is contained in:
committed by
GitHub
Unverified
parent
fcad1319bf
commit
98d57d0dd2
@@ -213,7 +213,18 @@ test("keeps a narrow session composer contained when invoking a built-in", async
|
||||
await page.getByRole("menuitem", { name: "Commands" }).click()
|
||||
await page.locator('[data-suggestion-id="model.choose"]').click()
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Select model", exact: true })
|
||||
const search = dialog.getByRole("searchbox", { name: "Search models", exact: true })
|
||||
await expect(search).toBeFocused()
|
||||
await expect(editor).toHaveText("keep me")
|
||||
await page.keyboard.press("Escape")
|
||||
await expect(dialog).toBeHidden()
|
||||
|
||||
await editor.fill("/model")
|
||||
await expect(page.locator('[data-suggestion-id="model.choose"]')).toHaveAttribute("data-active", "")
|
||||
await editor.press("Enter")
|
||||
await expect(search).toBeFocused()
|
||||
await expect(editor).toBeEmpty()
|
||||
})
|
||||
|
||||
test("lists slash commands in their built-in order", async ({ page }) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCommand, type CommandOption } from "@/shell/commands/command"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { DialogSelectModel } from "@/providers/models/select-dialog"
|
||||
import { useLocal, type ModelSelection } from "@/providers/models/selection"
|
||||
import { useDialog } from "@opencode/ui/context/dialog"
|
||||
import { getCursorPosition, setCursorPosition } from "./editor/dom"
|
||||
@@ -33,7 +34,7 @@ export const useComposerCommands = (input: { model?: ModelSelection } = {}) => {
|
||||
void dialog.show(() => <DialogConnectProvider directory={workspace().directory} />)
|
||||
}
|
||||
|
||||
const chooseModel = async () => {
|
||||
const chooseModel = () => {
|
||||
const owner = sessionOwnership.capture()
|
||||
const editor = document.querySelector<HTMLElement>('[data-component="composer-editor"]')
|
||||
const selection = window.getSelection()
|
||||
@@ -54,7 +55,6 @@ export const useComposerCommands = (input: { model?: ModelSelection } = {}) => {
|
||||
})
|
||||
}
|
||||
|
||||
const { DialogSelectModel } = await import("@/providers/models/select-dialog")
|
||||
owner.run(() => {
|
||||
void dialog.show(() => <DialogSelectModel model={model} />, restoreComposer)
|
||||
})
|
||||
|
||||
@@ -204,7 +204,7 @@ export function createComposerEditor(input: {
|
||||
const action = event.type === "popover.select" ? input.onSuggestionSelect?.(event.item) : undefined
|
||||
|
||||
if (event.type === "popover.select") {
|
||||
if (!action || state.popover.type !== "command-menu") result.commands.forEach(execute)
|
||||
if (!action) result.commands.forEach(execute)
|
||||
|
||||
if (action && event.item.kind === "command" && state.popover.type !== "command-menu") {
|
||||
draft.setPrompt(draft.state.prompt.filter(isAttachment), 0)
|
||||
|
||||
Reference in New Issue
Block a user