Skip to content

Commit aa2d753

Browse files
authored
feat: dialog variant menu and subagent improvements (anomalyco#19537)
1 parent 860531c commit aa2d753

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export function Session() {
334334
if (children().length === 1) return
335335

336336
const sessions = children().filter((x) => !!x.parentID)
337-
let next = sessions.findIndex((x) => x.id === session()?.id) + direction
337+
let next = sessions.findIndex((x) => x.id === session()?.id) - direction
338338

339339
if (next >= sessions.length) next = 0
340340
if (next < 0) next = sessions.length - 1
@@ -1228,7 +1228,6 @@ function UserMessage(props: {
12281228
const local = useLocal()
12291229
const text = createMemo(() => props.parts.flatMap((x) => (x.type === "text" && !x.synthetic ? [x] : []))[0])
12301230
const files = createMemo(() => props.parts.flatMap((x) => (x.type === "file" ? [x] : [])))
1231-
const sync = useSync()
12321231
const { theme } = useTheme()
12331232
const [hover, setHover] = createSignal(false)
12341233
const queued = createMemo(() => props.pending && props.message.id > props.pending)
@@ -1614,17 +1613,6 @@ function GenericTool(props: ToolProps<any>) {
16141613
)
16151614
}
16161615

1617-
function ToolTitle(props: { fallback: string; when: any; icon: string; children: JSX.Element }) {
1618-
const { theme } = useTheme()
1619-
return (
1620-
<text paddingLeft={3} fg={props.when ? theme.textMuted : theme.text}>
1621-
<Show fallback={<>~ {props.fallback}</>} when={props.when}>
1622-
<span style={{ bold: true }}>{props.icon}</span> {props.children}
1623-
</Show>
1624-
</text>
1625-
)
1626-
}
1627-
16281616
function InlineTool(props: {
16291617
icon: string
16301618
iconColor?: RGBA
@@ -1962,10 +1950,7 @@ function WebSearch(props: ToolProps<any>) {
19621950
}
19631951

19641952
function Task(props: ToolProps<typeof TaskTool>) {
1965-
const { theme } = useTheme()
1966-
const keybind = useKeybind()
19671953
const { navigate } = useRoute()
1968-
const local = useLocal()
19691954
const sync = useSync()
19701955

19711956
onMount(() => {
@@ -1996,7 +1981,7 @@ function Task(props: ToolProps<typeof TaskTool>) {
19961981

19971982
const content = createMemo(() => {
19981983
if (!props.input.description) return ""
1999-
let content = [`Task ${props.input.description}`]
1984+
let content = [`${Locale.titlecase(props.input.subagent_type ?? "General")} Task ${props.input.description}`]
20001985

20011986
if (isRunning() && tools().length > 0) {
20021987
// content[0] += ` · ${tools().length} toolcalls`

packages/opencode/src/cli/cmd/tui/routes/session/subagent-footer.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ export function SubagentFooter() {
1313
const route = useRouteData("session")
1414
const sync = useSync()
1515
const messages = createMemo(() => sync.data.message[route.sessionID] ?? [])
16+
const session = createMemo(() => sync.session.get(route.sessionID))
17+
18+
const subagentInfo = createMemo(() => {
19+
const s = session()
20+
if (!s) return { label: "Subagent", index: 0, total: 0 }
21+
const agentMatch = s.title.match(/@(\w+) subagent/)
22+
const label = agentMatch ? Locale.titlecase(agentMatch[1]) : "Subagent"
23+
24+
if (!s.parentID) return { label, index: 0, total: 0 }
25+
26+
const siblings = sync.data.session
27+
.filter((x) => x.parentID === s.parentID)
28+
.toSorted((a, b) => a.time.created - b.time.created)
29+
const index = siblings.findIndex((x) => x.id === s.id)
30+
31+
return { label, index: index + 1, total: siblings.length }
32+
})
1633

1734
const usage = createMemo(() => {
1835
const msg = messages()
@@ -58,10 +75,15 @@ export function SubagentFooter() {
5875
backgroundColor={theme.backgroundPanel}
5976
>
6077
<box flexDirection="row" justifyContent="space-between" gap={1}>
61-
<box flexDirection="row" gap={2}>
78+
<box flexDirection="row" gap={1}>
6279
<text fg={theme.text}>
63-
<b>Subagent session</b>
80+
<b>{subagentInfo().label}</b>
6481
</text>
82+
<Show when={subagentInfo().total > 0}>
83+
<text style={{ fg: theme.textMuted }}>
84+
({subagentInfo().index} of {subagentInfo().total})
85+
</text>
86+
</Show>
6587
<Show when={usage()}>
6688
{(item) => (
6789
<text fg={theme.textMuted} wrapMode="none">

0 commit comments

Comments
 (0)