tui: prevent crash when opening session switcher from an active session

This commit is contained in:
Dax Raad 2026-07-13 21:04:36 -04:00
parent c15e3487b2
commit 5cf24bf185
2 changed files with 21 additions and 3 deletions

View file

@ -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()

View file

@ -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