ignore: diff stuff

This commit is contained in:
Dax Raad
2025-10-23 16:04:58 -04:00
parent 9b5fe10df6
commit f4dfae0bb0
4 changed files with 94 additions and 105 deletions

View File

@@ -406,47 +406,4 @@ export namespace Session {
await Project.setInitialized(Instance.project.id)
},
)
export const diff = fn(
z.object({
sessionID: Identifier.schema("session"),
messageID: Identifier.schema("message").optional(),
}),
async (input) => {
const all = await messages(input.sessionID)
const index = !input.messageID ? 0 : all.findIndex((x) => x.info.id === input.messageID)
if (index === -1) return []
let from: string | undefined
let to: string | undefined
// scan assistant messages to find earliest from and latest to
// snapshot
for (let i = index + 1; i < all.length; i++) {
const item = all[i]
// if messageID is provided, stop at the next user message
if (input.messageID && item.info.role === "user") break
if (!from) {
for (const part of item.parts) {
if (part.type === "step-start" && part.snapshot) {
from = part.snapshot
break
}
}
}
for (const part of item.parts) {
if (part.type === "step-finish" && part.snapshot) {
to = part.snapshot
break
}
}
}
if (from && to) return Snapshot.diffFull(from, to)
return []
},
)
}