Browse Source

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

Aiden Cline 3 months ago
parent
commit
8ab206b443
1 changed files with 21 additions and 1 deletions
  1. 21 1
      packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

+ 21 - 1
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()