feat(tui): exit subagent menu with up arrow (#36951)

Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot]
2026-07-15 16:00:53 -05:00
committed by GitHub
co-authored by Aiden Cline
parent 4394b324c9
commit 888c4cb504
2 changed files with 42 additions and 0 deletions
@@ -633,6 +633,12 @@ export function RunSubagentSelectBody(props: {
return return
} }
if (event.name.toLowerCase() === "up" && menu.selected() === 0) {
event.preventDefault()
props.onClose()
return
}
handleKey({ event, menu, field: () => field, setQuery, select, close: props.onClose }) handleKey({ event, menu, field: () => field, setQuery, select, close: props.onClose })
}) })
@@ -642,6 +642,42 @@ test("direct subagent panel renders active subagents", async () => {
} }
}) })
test("direct subagent panel closes when moving up from the first item", async () => {
const [tabs] = createSignal([
subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" }),
subagent({ sessionID: "s-2", label: "General", description: "Write migration plan" }),
])
const [current] = createSignal<string | undefined>()
let closed = 0
const app = await testRender(
() => (
<box width={100} height={RUN_SUBAGENT_PANEL_ROWS}>
<RunSubagentSelectBody
theme={() => RUN_THEME_FALLBACK.footer}
tabs={tabs}
current={current}
onClose={() => closed++}
onSelect={() => {}}
/>
</box>
),
{ width: 100, height: RUN_SUBAGENT_PANEL_ROWS },
)
try {
await app.renderOnce()
app.mockInput.pressKey("ARROW_DOWN")
app.mockInput.pressKey("ARROW_UP")
expect(closed).toBe(0)
app.mockInput.pressKey("ARROW_UP")
expect(closed).toBe(1)
} finally {
app.renderer.destroy()
}
})
test("direct queued prompt panel renders pending prompt actions", async () => { test("direct queued prompt panel renders pending prompt actions", async () => {
const [prompts] = createSignal([ const [prompts] = createSignal([
{ messageID: "m-1", partID: "p-1", prompt: { text: "fix the auth test", parts: [] } }, { messageID: "m-1", partID: "p-1", prompt: { text: "fix the auth test", parts: [] } },