This commit is contained in:
flatsponge 2025-12-23 15:42:46 +08:00 committed by GitHub
commit 730acb0ece
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View file

@ -251,6 +251,22 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
setStore("vcs", { branch: event.properties.branch })
break
}
case "session.compacted": {
// Refresh messages after compaction to update sidebar context
sdk.client.session.messages({ sessionID: event.properties.sessionID, limit: 100 }).then((res) => {
if (!res.data) return
setStore(
produce((draft) => {
draft.message[event.properties.sessionID] = res.data!.map((x) => x.info)
for (const message of res.data!) {
draft.part[message.info.id] = message.parts
}
}),
)
})
break
}
}
})

View file

@ -57,9 +57,15 @@ export namespace SessionRevert {
revert.snapshot = session.revert?.snapshot ?? (await Snapshot.track())
await Snapshot.revert(patches)
if (revert.snapshot) revert.diff = await Snapshot.diff(revert.snapshot)
return Session.update(input.sessionID, (draft) => {
const result = await Session.update(input.sessionID, (draft) => {
draft.revert = revert
})
// Emit session.diff event to update sidebar's Modified Files list
Bus.publish(Session.Event.Diff, {
sessionID: input.sessionID,
diff: [],
})
return result
}
return session
}
@ -73,6 +79,12 @@ export namespace SessionRevert {
const next = await Session.update(input.sessionID, (draft) => {
draft.revert = undefined
})
// Emit session.diff event to refresh sidebar's Modified Files list
const diff = await Session.diff(input.sessionID)
Bus.publish(Session.Event.Diff, {
sessionID: input.sessionID,
diff,
})
return next
}