Skip to content
26 changes: 26 additions & 0 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ export function Session() {
}
}

function toggleChildSession() {
if (session()?.parentID) {
// Currently in child, go to parent
const parentID = session()?.parentID
if (parentID) {
navigate({
type: "session",
sessionID: parentID,
})
}
} else {
// Currently in primary, go to first child
moveFirstChild()
}
}

function childSessionHandler(func: (dialog: DialogContext) => void) {
return (dialog: DialogContext) => {
if (!session()?.parentID || dialog.stack.length > 0) return
Expand Down Expand Up @@ -952,6 +968,16 @@ export function Session() {
dialog.clear()
}),
},
{
title: session()?.parentID ? "Return to parent session" : "Show child sessions",
value: "session.child.toggle",
keybind: "session_child_toggle",
category: "Session",
onSelect: (dialog) => {
toggleChildSession()
dialog.clear()
},
},
{
title: "Next child session",
value: "session.child.next",
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ export namespace Config {
session_child_cycle: z.string().optional().default("right").describe("Go to next child session"),
session_child_cycle_reverse: z.string().optional().default("left").describe("Go to previous child session"),
session_parent: z.string().optional().default("up").describe("Go to parent session"),
session_child_toggle: z.string().optional().default("none").describe("Toggle between primary and child sessions"),
terminal_suspend: z.string().optional().default("ctrl+z").describe("Suspend terminal"),
terminal_title_toggle: z.string().optional().default("none").describe("Toggle terminal title"),
tips_toggle: z.string().optional().default("<leader>h").describe("Toggle tips on home screen"),
Expand Down