Просмотр исходного кода

fix scroll when no session exists

Dax Raad 3 месяцев назад
Родитель
Сommit
4463d319c9

+ 5 - 1
packages/opencode/src/cli/cmd/tui/component/dialog-session-list.tsx

@@ -2,7 +2,7 @@ import { useDialog } from "@tui/ui/dialog"
 import { DialogSelect } from "@tui/ui/dialog-select"
 import { useRoute } from "@tui/context/route"
 import { useSync } from "@tui/context/sync"
-import { createMemo, createSignal, onMount } from "solid-js"
+import { createEffect, createMemo, createSignal, onMount } from "solid-js"
 import { Locale } from "@/util/locale"
 import { Keybind } from "@/util/keybind"
 import { useTheme } from "../context/theme"
@@ -45,6 +45,10 @@ export function DialogSessionList() {
       })
   })
 
+  createEffect(() => {
+    console.log("session count", sync.data.session.length)
+  })
+
   onMount(() => {
     dialog.setSize("large")
   })

+ 11 - 7
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

@@ -107,14 +107,18 @@ export function Session() {
   const contentWidth = createMemo(() => dimensions().width - (sidebarVisible() ? 42 : 0) - 4)
 
   createEffect(async () => {
-    await sync.session.sync(route.sessionID).catch(() => {
-      toast.show({
-        message: `Session not found: ${route.sessionID}`,
-        variant: "error",
+    await sync.session
+      .sync(route.sessionID)
+      .then(() => {
+        scroll.scrollBy(100_000)
+      })
+      .catch(() => {
+        toast.show({
+          message: `Session not found: ${route.sessionID}`,
+          variant: "error",
+        })
+        return navigate({ type: "home" })
       })
-      return navigate({ type: "home" })
-    })
-    scroll.scrollBy(100_000)
   })
 
   const toast = useToast()