fix(app): close missing child session tabs
This commit is contained in:
parent
f9de608dea
commit
43ff2ee9cc
3 changed files with 14 additions and 2 deletions
|
|
@ -39,7 +39,9 @@ test("shows the not found fallback when the viewed session is deleted", async ({
|
|||
})
|
||||
|
||||
await expect(page.getByText("This session cannot be found")).toBeVisible()
|
||||
await expect(page.getByRole("button", { name: "Close Tab" })).toBeVisible()
|
||||
await page.getByRole("button", { name: "Close Tab" }).click()
|
||||
await expect(page).toHaveURL(/\/$/)
|
||||
await expect(page.getByText("This session cannot be found")).toHaveCount(0)
|
||||
await expect(page.getByRole("heading", { name: taskDescription })).toHaveCount(0)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -249,6 +249,16 @@ export const { use: useTabs, provider: TabsProvider } = createSimpleContext({
|
|||
removeDraftPersisted(draftID)
|
||||
},
|
||||
removeTab,
|
||||
// Child routes share their root session's tab, so the route ID cannot
|
||||
// identify the tab once a deleted child falls back to an error page.
|
||||
removeActiveTab(key: ServerConnection.Key) {
|
||||
const index = store.findIndex((tab) => tab.server === key && tabKey(tab) === recentKey())
|
||||
if (index === -1) {
|
||||
navigate("/")
|
||||
return
|
||||
}
|
||||
removeTab(index)
|
||||
},
|
||||
// User-initiated close: records the tab so it can be reopened.
|
||||
// Cleanup paths (missing sessions, archive, server removal) go through
|
||||
// removeTab and friends directly and are not recorded.
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ function SessionErrorFallback(props: { error: unknown; sessionID?: string; serve
|
|||
})
|
||||
const closeTab = () => {
|
||||
if (!props.sessionID) return
|
||||
tabs.removeSessionTab({ server: props.serverKey ?? server.key, sessionId: props.sessionID })
|
||||
tabs.removeActiveTab(props.serverKey ?? server.key)
|
||||
}
|
||||
if (isCurrentSessionNotFoundError(props.error, props.sessionID)) {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue