Skip to content

Commit 888c4cb

Browse files
feat(tui): exit subagent menu with up arrow (anomalyco#36951)
Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
1 parent 4394b32 commit 888c4cb

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

packages/opencode/src/cli/cmd/run/footer.command.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,12 @@ export function RunSubagentSelectBody(props: {
633633
return
634634
}
635635

636+
if (event.name.toLowerCase() === "up" && menu.selected() === 0) {
637+
event.preventDefault()
638+
props.onClose()
639+
return
640+
}
641+
636642
handleKey({ event, menu, field: () => field, setQuery, select, close: props.onClose })
637643
})
638644

packages/opencode/test/cli/run/footer.view.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,42 @@ test("direct subagent panel renders active subagents", async () => {
642642
}
643643
})
644644

645+
test("direct subagent panel closes when moving up from the first item", async () => {
646+
const [tabs] = createSignal([
647+
subagent({ sessionID: "s-1", label: "Explore", description: "Inspect auth flow" }),
648+
subagent({ sessionID: "s-2", label: "General", description: "Write migration plan" }),
649+
])
650+
const [current] = createSignal<string | undefined>()
651+
let closed = 0
652+
653+
const app = await testRender(
654+
() => (
655+
<box width={100} height={RUN_SUBAGENT_PANEL_ROWS}>
656+
<RunSubagentSelectBody
657+
theme={() => RUN_THEME_FALLBACK.footer}
658+
tabs={tabs}
659+
current={current}
660+
onClose={() => closed++}
661+
onSelect={() => {}}
662+
/>
663+
</box>
664+
),
665+
{ width: 100, height: RUN_SUBAGENT_PANEL_ROWS },
666+
)
667+
668+
try {
669+
await app.renderOnce()
670+
app.mockInput.pressKey("ARROW_DOWN")
671+
app.mockInput.pressKey("ARROW_UP")
672+
expect(closed).toBe(0)
673+
674+
app.mockInput.pressKey("ARROW_UP")
675+
expect(closed).toBe(1)
676+
} finally {
677+
app.renderer.destroy()
678+
}
679+
})
680+
645681
test("direct queued prompt panel renders pending prompt actions", async () => {
646682
const [prompts] = createSignal([
647683
{ messageID: "m-1", partID: "p-1", prompt: { text: "fix the auth test", parts: [] } },

0 commit comments

Comments
 (0)