mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-13 12:54:58 +01:00
tui: fix focus management and dialog interactions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Prompt, type PromptRef } from "@tui/component/prompt"
|
||||
import { createEffect, createMemo, Match, Show, Switch, type ParentProps } from "solid-js"
|
||||
import { Prompt } from "@tui/component/prompt"
|
||||
import { createMemo, Match, Show, Switch, type ParentProps } from "solid-js"
|
||||
import { useTheme } from "@tui/context/theme"
|
||||
import { useKeybind } from "../context/keybind"
|
||||
import type { KeybindsConfig } from "@opencode-ai/sdk"
|
||||
@@ -7,22 +7,13 @@ import { Logo } from "../component/logo"
|
||||
import { Locale } from "@/util/locale"
|
||||
import { useSync } from "../context/sync"
|
||||
import { Toast } from "../ui/toast"
|
||||
import { useDialog } from "../ui/dialog"
|
||||
|
||||
export function Home() {
|
||||
const sync = useSync()
|
||||
const { theme } = useTheme()
|
||||
const dialog = useDialog()
|
||||
const mcpError = createMemo(() => {
|
||||
return Object.values(sync.data.mcp).some((x) => x.status === "failed")
|
||||
})
|
||||
let promptRef: PromptRef | undefined = undefined
|
||||
|
||||
createEffect(() => {
|
||||
dialog.allClosedEvent.listen(() => {
|
||||
promptRef?.focus()
|
||||
})
|
||||
})
|
||||
|
||||
const Hint = (
|
||||
<Show when={Object.keys(sync.data.mcp).length > 0}>
|
||||
@@ -64,7 +55,7 @@ export function Home() {
|
||||
<HelpRow keybind="agent_cycle">Switch agent</HelpRow>
|
||||
</box>
|
||||
<box width="100%" maxWidth={75} zIndex={1000} paddingTop={1}>
|
||||
<Prompt hint={Hint} ref={(r) => (promptRef = r)} />
|
||||
<Prompt hint={Hint} />
|
||||
</box>
|
||||
<Toast />
|
||||
</box>
|
||||
|
||||
@@ -112,12 +112,6 @@ export function Session() {
|
||||
let prompt: PromptRef
|
||||
const keybind = useKeybind()
|
||||
|
||||
createEffect(() => {
|
||||
dialog.allClosedEvent.listen(() => {
|
||||
prompt.focus()
|
||||
})
|
||||
})
|
||||
|
||||
useKeyboard((evt) => {
|
||||
if (dialog.stack.length > 0) return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user