| 742 | |
| 743 | // Emits "interrupted" final entries for all in-flight parts. Called when a turn is aborted. |
| 744 | export function flushInterrupted(data: SessionData, commits: SessionCommit[]) { |
| 745 | for (const partID of data.part.keys()) { |
| 746 | if (data.ids.has(partID)) { |
| 747 | continue |
| 748 | } |
| 749 | |
| 750 | const msg = data.msg.get(partID) |
| 751 | if (msg && data.role.get(msg) === "user" && !data.includeUserText) { |
| 752 | data.ids.add(partID) |
| 753 | drop(data, partID) |
| 754 | continue |
| 755 | } |
| 756 | |
| 757 | flushPart(data, commits, partID, true) |
| 758 | data.ids.add(partID) |
| 759 | drop(data, partID) |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | // The main reducer. Takes one SDK event and returns scrollback commits and |
| 764 | // footer updates. Called once per event from the stream transport's watch loop. |