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

fix(tui): remount session view on session switch (#30129)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
opencode-agent[bot] 2 месяцев назад
Родитель
Сommit
abaabdcb73
2 измененных файлов с 16 добавлено и 5 удалено
  1. 3 1
      packages/opencode/src/cli/cmd/tui/app.tsx
  2. 13 4
      packages/opencode/src/worktree/index.ts

+ 3 - 1
packages/opencode/src/cli/cmd/tui/app.tsx

@@ -1082,7 +1082,9 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
               <Home />
             </Match>
             <Match when={route.data.type === "session"}>
-              <Session />
+              <Show when={route.data.type === "session" ? route.data.sessionID : undefined} keyed>
+                {(_) => <Session />}
+              </Show>
             </Match>
           </Switch>
           {plugin()}

+ 13 - 4
packages/opencode/src/worktree/index.ts

@@ -384,10 +384,19 @@ export const layer: Layer.Layer<
 
     function cleanDirectory(target: string) {
       return Effect.tryPromise({
-        try: () =>
-          import("fs/promises").then((fsp) =>
-            fsp.rm(target, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }),
-          ),
+        try: async () => {
+          const fsp = await import("fs/promises")
+          const attempts = process.platform === "win32" ? 50 : 5
+          for (const attempt of Array.from({ length: attempts }, (_, i) => i)) {
+            try {
+              await fsp.rm(target, { recursive: true, force: true })
+              return
+            } catch (error) {
+              if (attempt === attempts - 1) throw error
+              await new Promise((resolve) => setTimeout(resolve, 100))
+            }
+          }
+        },
         catch: (error) =>
           new RemoveFailedError({ message: errorMessage(error) || "Failed to remove git worktree directory" }),
       })