mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-21 18:26:09 +00:00
tui: prevent crash when opening session switcher from an active session
This commit is contained in:
@@ -155,11 +155,10 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
|
||||
.filter((item) => item.label),
|
||||
...(props.footerHints ?? []),
|
||||
])
|
||||
const actionItems = createMemo(() =>
|
||||
const actionItems = () =>
|
||||
visibleActions()
|
||||
.filter(isActionItem)
|
||||
.filter((item) => !isActionDisabled(item)),
|
||||
)
|
||||
.filter((item) => !isActionDisabled(item))
|
||||
|
||||
createEffect(() => {
|
||||
const index = focusedAction()
|
||||
|
||||
@@ -16,6 +16,7 @@ async function renderSelect(
|
||||
options: DialogSelectOption<string>[],
|
||||
onGlobal: () => void,
|
||||
onRow: (option: DialogSelectOption<string>) => void,
|
||||
current?: string,
|
||||
) {
|
||||
const state = path.join(root, "state")
|
||||
await mkdir(state, { recursive: true })
|
||||
@@ -52,6 +53,7 @@ async function renderSelect(
|
||||
<DialogSelect
|
||||
title="Items"
|
||||
options={options}
|
||||
current={current}
|
||||
actions={[
|
||||
{
|
||||
command: "dialog.move_session.delete",
|
||||
@@ -153,6 +155,23 @@ async function mountSelect(root: string, initial: DialogSelectOption<string>[])
|
||||
return { app, moved, replaceOptions, selected }
|
||||
}
|
||||
|
||||
test("renders actions with a current selection", async () => {
|
||||
await using tmp = await tmpdir()
|
||||
const app = await renderSelect(
|
||||
tmp.path,
|
||||
[{ title: "Alpha", value: "alpha" }],
|
||||
() => {},
|
||||
() => {},
|
||||
"alpha",
|
||||
)
|
||||
|
||||
try {
|
||||
await app.waitForFrame((frame) => frame.includes("delete"))
|
||||
} finally {
|
||||
app.renderer.destroy()
|
||||
}
|
||||
})
|
||||
|
||||
test("dialog actions run without options while row actions still require a selection", async () => {
|
||||
await using tmp = await tmpdir()
|
||||
let global = 0
|
||||
|
||||
Reference in New Issue
Block a user