|
|
@@ -65,6 +65,7 @@ import { usePlatform } from "@/context/platform"
|
|
|
import { useSettings } from "@/context/settings"
|
|
|
import { useSDK } from "@/context/sdk"
|
|
|
import { useSync } from "@/context/sync"
|
|
|
+import { notifySessionTabsRemoved } from "@/components/titlebar-session-events"
|
|
|
import { messageAgentColor } from "@/utils/agent"
|
|
|
import { sessionTitle } from "@/utils/session-title"
|
|
|
import { makeTimer } from "@solid-primitives/timer"
|
|
|
@@ -861,7 +862,9 @@ export function MessageTimeline(props: {
|
|
|
if (index !== -1) draft.session.splice(index, 1)
|
|
|
}),
|
|
|
)
|
|
|
+ sync.session.evict(sessionID)
|
|
|
navigateAfterSessionRemoval(sessionID, session.parentID, nextSession?.id)
|
|
|
+ notifySessionTabsRemoved({ directory: sdk.directory, sessionIDs: [sessionID] })
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
showToast({
|
|
|
@@ -892,42 +895,46 @@ export function MessageTimeline(props: {
|
|
|
|
|
|
if (!result) return false
|
|
|
|
|
|
- sync.set(
|
|
|
- produce((draft) => {
|
|
|
- const removed = new Set<string>([sessionID])
|
|
|
-
|
|
|
- const byParent = new Map<string, string[]>()
|
|
|
- for (const item of draft.session) {
|
|
|
- const parentID = item.parentID
|
|
|
- if (!parentID) continue
|
|
|
- const existing = byParent.get(parentID)
|
|
|
- if (existing) {
|
|
|
- existing.push(item.id)
|
|
|
- continue
|
|
|
- }
|
|
|
- byParent.set(parentID, [item.id])
|
|
|
- }
|
|
|
+ const removed = new Set<string>([sessionID])
|
|
|
+ const byParent = new Map<string, string[]>()
|
|
|
+ for (const item of sync.data.session) {
|
|
|
+ const parentID = item.parentID
|
|
|
+ if (!parentID) continue
|
|
|
+ const existing = byParent.get(parentID)
|
|
|
+ if (existing) {
|
|
|
+ existing.push(item.id)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ byParent.set(parentID, [item.id])
|
|
|
+ }
|
|
|
|
|
|
- const stack = [sessionID]
|
|
|
- while (stack.length) {
|
|
|
- const parentID = stack.pop()
|
|
|
- if (!parentID) continue
|
|
|
+ const stack = [sessionID]
|
|
|
+ while (stack.length) {
|
|
|
+ const parentID = stack.pop()
|
|
|
+ if (!parentID) continue
|
|
|
|
|
|
- const children = byParent.get(parentID)
|
|
|
- if (!children) continue
|
|
|
+ const children = byParent.get(parentID)
|
|
|
+ if (!children) continue
|
|
|
|
|
|
- for (const child of children) {
|
|
|
- if (removed.has(child)) continue
|
|
|
- removed.add(child)
|
|
|
- stack.push(child)
|
|
|
- }
|
|
|
- }
|
|
|
+ for (const child of children) {
|
|
|
+ if (removed.has(child)) continue
|
|
|
+ removed.add(child)
|
|
|
+ stack.push(child)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ navigateAfterSessionRemoval(sessionID, session.parentID, nextSession?.id)
|
|
|
|
|
|
+ sync.set(
|
|
|
+ produce((draft) => {
|
|
|
draft.session = draft.session.filter((s) => !removed.has(s.id))
|
|
|
}),
|
|
|
)
|
|
|
|
|
|
- navigateAfterSessionRemoval(sessionID, session.parentID, nextSession?.id)
|
|
|
+ for (const id of removed) {
|
|
|
+ sync.session.evict(id)
|
|
|
+ }
|
|
|
+ notifySessionTabsRemoved({ directory: sdk.directory, sessionIDs: [...removed] })
|
|
|
return true
|
|
|
}
|
|
|
|