()
| 295 | } |
| 296 | |
| 297 | const undo = async () => { |
| 298 | const sessionID = params.id |
| 299 | if (!sessionID) return |
| 300 | const owner = sessionOwnership.capture() |
| 301 | const client = sdk().client |
| 302 | const directory = sdk().directory |
| 303 | const promptSession = prompt.capture() |
| 304 | const revert = info()?.revert?.messageID |
| 305 | const messages = userMessages() |
| 306 | const message = findLast(messages, (x) => !revert || x.id < revert) |
| 307 | if (!message) return |
| 308 | const parts = sync().data.part[message.id] |
| 309 | |
| 310 | if (sync().data.session_working(sessionID)) { |
| 311 | await client.session.abort({ sessionID }).catch(() => {}) |
| 312 | } |
| 313 | |
| 314 | await runCommand({ |
| 315 | owner, |
| 316 | prompt: promptSession, |
| 317 | request: () => client.session.revert({ sessionID, messageID: message.id }), |
| 318 | updatePrompt: (promptSession) => { |
| 319 | if (parts) promptSession.set(extractPromptFromParts(parts, { directory })) |
| 320 | }, |
| 321 | updateViewport: () => setActiveMessage(findLast(messages, (x) => x.id < message.id)), |
| 322 | }) |
| 323 | } |
| 324 | |
| 325 | const redo = async () => { |
| 326 | const sessionID = params.id |
nothing calls this directly
no test coverage detected