Skip to content

Commit 51804a4

Browse files
committed
chore: cleanup
1 parent 55739b7 commit 51804a4

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

packages/app/src/pages/layout.tsx

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -964,12 +964,29 @@ export default function Layout(props: ParentProps) {
964964
if (!current) return
965965
if (directory === current.worktree) return
966966

967-
const sessions = await globalSDK.client.session
968-
.list({ directory })
969-
.then((x) => x.data ?? [])
970-
.catch(() => [])
967+
const reset = globalSDK.client.worktree
968+
.reset({ directory: current.worktree, worktreeResetInput: { directory } })
969+
.then((x) => x.data)
970+
.catch((err) => {
971+
showToast({
972+
title: "Failed to reset workspace",
973+
description: errorMessage(err),
974+
})
975+
return false
976+
})
977+
978+
const href = `/${base64Encode(directory)}/session`
979+
navigate(href)
980+
layout.mobileSidebar.hide()
981+
982+
void (async () => {
983+
const sessions = await globalSDK.client.session
984+
.list({ directory })
985+
.then((x) => x.data ?? [])
986+
.catch(() => [])
987+
988+
if (sessions.length === 0) return
971989

972-
if (sessions.length > 0) {
973990
const archivedAt = Date.now()
974991
await Promise.all(
975992
sessions.map((session) =>
@@ -982,19 +999,9 @@ export default function Layout(props: ParentProps) {
982999
.catch(() => undefined),
9831000
),
9841001
)
985-
}
986-
987-
const result = await globalSDK.client.worktree
988-
.reset({ directory: current.worktree, worktreeResetInput: { directory } })
989-
.then((x) => x.data)
990-
.catch((err) => {
991-
showToast({
992-
title: "Failed to reset workspace",
993-
description: errorMessage(err),
994-
})
995-
return false
996-
})
1002+
})()
9971003

1004+
const result = await reset
9981005
if (!result) return
9991006

10001007
showToast({
@@ -1098,9 +1105,9 @@ export default function Layout(props: ParentProps) {
10981105
})
10991106
})
11001107

1101-
const handleReset = async () => {
1102-
await resetWorkspace(props.directory)
1108+
const handleReset = () => {
11031109
dialog.close()
1110+
void resetWorkspace(props.directory)
11041111
}
11051112

11061113
const archivedCount = () => state.sessions.length

0 commit comments

Comments
 (0)