mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
fix(app): keep a running rewind's echo through a commit (#61920)
This commit is contained in:
committed by
GitHub
Unverified
parent
e1296da9b4
commit
4fcad7365f
@@ -165,6 +165,21 @@ describe("transitionSessionRevert", () => {
|
||||
expect(echoed.effects).toEqual([])
|
||||
})
|
||||
|
||||
test("a commit while a rewind is still interrupting keeps that rewind's own echo", () => {
|
||||
const steps = replay([
|
||||
undo(),
|
||||
// A prompt sent while an earlier boundary was staged commits it before this rewind's stage goes out.
|
||||
{ type: "revert.committed" },
|
||||
rewound(1, "unsent draft"),
|
||||
{ type: "revert.staged", messageID: "msg_3" },
|
||||
])
|
||||
|
||||
expect(steps[1].state).toMatchObject({ status: "running", echoes: ["msg_3"] })
|
||||
expect(steps[3].state).toEqual({ ...steps[2].state, echoes: [] })
|
||||
expect(steps[3].state.status).toBe("restored")
|
||||
expect(steps[3].effects).toEqual([])
|
||||
})
|
||||
|
||||
test("a late stage echo after a redo keeps the cleared boundary until the clear echo arrives", () => {
|
||||
const steps = replay([
|
||||
undo(),
|
||||
|
||||
@@ -235,8 +235,14 @@ export function transitionSessionRevert(state: SessionRevertState, event: Sessio
|
||||
}
|
||||
|
||||
// A stage or clear from elsewhere, or a sent prompt committing the revert: the stream is the source of truth again.
|
||||
// A commit lands after every request sent before it.
|
||||
const echoes = event.type === "revert.committed" ? [] : state.echoes
|
||||
// A commit lands after every request already sent, but a running operation may still be interrupting or waiting,
|
||||
// so its own echo stays due. Echoes drain in order, so a pending one at the end is always the running operation's.
|
||||
const echoes =
|
||||
event.type !== "revert.committed"
|
||||
? state.echoes
|
||||
: state.status === "running" && state.operation.type !== "withdraw"
|
||||
? state.echoes.slice(-1)
|
||||
: []
|
||||
|
||||
// A newer boundary replaced this rewind, so its Undo would restore a stale draft.
|
||||
if (state.status === "restored") return changed(idle(state.attempt, echoes), [{ type: "toast.dismiss" }])
|
||||
|
||||
Reference in New Issue
Block a user