mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Merge abbde31eac into 83397ebde2
This commit is contained in:
commit
730acb0ece
2 changed files with 29 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue