Skip to content

Commit abaabdc

Browse files
fix(tui): remount session view on session switch (#30129)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
1 parent 8f2afba commit abaabdc

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,9 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
10821082
<Home />
10831083
</Match>
10841084
<Match when={route.data.type === "session"}>
1085-
<Session />
1085+
<Show when={route.data.type === "session" ? route.data.sessionID : undefined} keyed>
1086+
{(_) => <Session />}
1087+
</Show>
10861088
</Match>
10871089
</Switch>
10881090
{plugin()}

packages/opencode/src/worktree/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,19 @@ export const layer: Layer.Layer<
384384

385385
function cleanDirectory(target: string) {
386386
return Effect.tryPromise({
387-
try: () =>
388-
import("fs/promises").then((fsp) =>
389-
fsp.rm(target, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 }),
390-
),
387+
try: async () => {
388+
const fsp = await import("fs/promises")
389+
const attempts = process.platform === "win32" ? 50 : 5
390+
for (const attempt of Array.from({ length: attempts }, (_, i) => i)) {
391+
try {
392+
await fsp.rm(target, { recursive: true, force: true })
393+
return
394+
} catch (error) {
395+
if (attempt === attempts - 1) throw error
396+
await new Promise((resolve) => setTimeout(resolve, 100))
397+
}
398+
}
399+
},
391400
catch: (error) =>
392401
new RemoveFailedError({ message: errorMessage(error) || "Failed to remove git worktree directory" }),
393402
})

0 commit comments

Comments
 (0)