Skip to content

The open source coding agent.

TypeScript

tweak: navigate to child session if it is asking for permissions

Aiden Cline8ab206b443f7
diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
index 7c4f51c54ae..2bffa360fa1 100644
--- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
+++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
@@ -142,9 +142,29 @@ export function Session() {
})
const toast = useToast()
-
const sdk = useSDK()
+ // Auto-navigate to whichever session currently needs permission input
+ createEffect(() => {
+ const currentSession = session()
+ const currentPermissions = permissions()
+ let targetID = currentPermissions.length > 0 ? currentSession.id : undefined
+
+ if (!targetID) {
+ const child = sync.data.session.find(
+ (x) => x.parentID === currentSession.id && (sync.data.permission[x.id]?.length ?? 0) > 0,
+ )
+ if (child) targetID = child.id
+ }
+
+ if (targetID && targetID !== currentSession.id) {
+ navigate({
+ type: "session",
+ sessionID: targetID,
+ })
+ }
+ })
+
let scroll: ScrollBoxRenderable
let prompt: PromptRef
const keybind = useKeybind()