mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
fix(tui): open the right activity tab and make tabs clickable (#60168)
This commit is contained in:
committed by
GitHub
Unverified
parent
f352b08437
commit
433e3fb094
@@ -75,7 +75,9 @@ export function PromptFooter(props: {
|
||||
flexShrink={0}
|
||||
onMouseOver={() => setLiveHovered(true)}
|
||||
onMouseOut={() => setLiveHovered(false)}
|
||||
onMouseUp={() => props.context.keymap.dispatch("session.child.first")}
|
||||
onMouseUp={() =>
|
||||
props.context.keymap.dispatch("session.child.first", subagents() ? "subagents" : "shell")
|
||||
}
|
||||
>
|
||||
<text
|
||||
fg={liveHovered() ? props.context.theme.text.base : props.context.theme.text.muted}
|
||||
|
||||
@@ -112,6 +112,7 @@ export function Composer(props: ComposerProps) {
|
||||
<text
|
||||
fg={isActive() ? theme.text.base : theme.text.muted}
|
||||
attributes={isActive() ? TextAttributes.BOLD : undefined}
|
||||
onMouseUp={() => setStore("active", t.id)}
|
||||
>
|
||||
{t.label}
|
||||
</text>
|
||||
|
||||
@@ -1401,8 +1401,9 @@ export function Session(props: {
|
||||
title: "Toggle subagent picker",
|
||||
id: "session.child.first",
|
||||
group: "Session",
|
||||
run: () => {
|
||||
if (composer.open || session()?.parentID) setComposer("open", false)
|
||||
run: (tab?: string) => {
|
||||
if (tab === "shell" || tab === "subagents") setComposer({ open: true, tab })
|
||||
else if (composer.open || session()?.parentID) setComposer("open", false)
|
||||
else setComposer({ open: true, tab: "subagents" })
|
||||
dialog.clear()
|
||||
},
|
||||
|
||||
@@ -235,6 +235,29 @@ test("disabled shell bindings have no component fallbacks", async () => {
|
||||
}
|
||||
})
|
||||
|
||||
test("composer tabs switch by mouse and keyboard", async () => {
|
||||
const composer = await renderComposer("subagents", {})
|
||||
try {
|
||||
const lines = composer.app.captureCharFrame().split("\n")
|
||||
const row = lines.findIndex((line) => line.includes("Subagents") && line.includes("Shell"))
|
||||
await composer.app.mockMouse.click(lines[row].indexOf("Shell"), row)
|
||||
await composer.app.renderOnce()
|
||||
expect(composer.app.captureCharFrame()).toContain("bun test")
|
||||
expect(composer.app.captureCharFrame()).not.toContain("First")
|
||||
|
||||
await composer.app.mockMouse.click(lines[row].indexOf("Subagents"), row)
|
||||
await composer.app.renderOnce()
|
||||
expect(composer.app.captureCharFrame()).toContain("First")
|
||||
expect(composer.app.captureCharFrame()).not.toContain("bun test")
|
||||
|
||||
composer.app.mockInput.pressArrow("right")
|
||||
await composer.app.renderOnce()
|
||||
expect(composer.app.captureCharFrame()).toContain("bun test")
|
||||
} finally {
|
||||
composer.app.renderer.destroy()
|
||||
}
|
||||
})
|
||||
|
||||
test("shell list shows one line per command", async () => {
|
||||
const composer = await renderComposer("shell", {})
|
||||
try {
|
||||
|
||||
@@ -9,7 +9,8 @@ import { PromptFooter } from "../../src/feature-plugins/prompt/footer"
|
||||
test("prompt footer separates simultaneous subagent, shell, and usage status", async () => {
|
||||
const color = RGBA.fromInts(200, 200, 200)
|
||||
const subdued = RGBA.fromInts(100, 100, 100)
|
||||
const dispatched: string[] = []
|
||||
const dispatched: [string, string | undefined][] = []
|
||||
const [activeSubagent, setActiveSubagent] = createSignal(true)
|
||||
const context = {
|
||||
location: { directory: "/workspace" },
|
||||
theme: {
|
||||
@@ -21,14 +22,14 @@ test("prompt footer separates simultaneous subagent, shell, and usage status", a
|
||||
keymap: {
|
||||
shortcuts: (id: string) =>
|
||||
id === "session.child.first" ? ["ctrl+j"] : id === "command.palette.show" ? ["ctrl+p"] : [],
|
||||
dispatch: (id: string) => dispatched.push(id),
|
||||
dispatch: (id: string, input?: string) => dispatched.push([id, input]),
|
||||
},
|
||||
client: { rpc: () => ({ get: () => Promise.resolve(null), events: { on: () => () => {} } }) },
|
||||
data: {
|
||||
on: () => () => {},
|
||||
session: {
|
||||
family: () => ["session", "child"],
|
||||
status: (id: string) => (id === "child" ? "running" : "idle"),
|
||||
status: (id: string) => (id === "child" && activeSubagent() ? "running" : "idle"),
|
||||
get: () => ({ id: "session", location: { directory: "/workspace" } }),
|
||||
cost: () => 1,
|
||||
message: { list: () => [] },
|
||||
@@ -60,7 +61,23 @@ test("prompt footer separates simultaneous subagent, shell, and usage status", a
|
||||
expect((live as TextRenderable).fg.toInts()).toEqual(color.toInts())
|
||||
|
||||
await app.mockMouse.click(2, 0)
|
||||
expect(dispatched).toEqual(["session.child.first"])
|
||||
await app.mockMouse.click(9, 0)
|
||||
await app.mockMouse.click(23, 0)
|
||||
expect(dispatched).toEqual([
|
||||
["session.child.first", "subagents"],
|
||||
["session.child.first", "subagents"],
|
||||
["session.child.first", "subagents"],
|
||||
])
|
||||
|
||||
setActiveSubagent(false)
|
||||
await app.renderOnce()
|
||||
expect(app.captureCharFrame()).toContain("ctrl+j 1 shell · $1.00")
|
||||
await app.mockMouse.click(2, 0)
|
||||
await app.mockMouse.click(9, 0)
|
||||
expect(dispatched.slice(-2)).toEqual([
|
||||
["session.child.first", "shell"],
|
||||
["session.child.first", "shell"],
|
||||
])
|
||||
} finally {
|
||||
app.renderer.destroy()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user