authorgravatar for 71498452+StiensWout@users.noreply.github.comWout Stiens <71498452+StiensWout@users.noreply.github.com> 2026-06-23 07:33:23+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-22 22:33:23-07:00
log4abf8b46c591ae2b36aa29598c388100df651411
tree58b522667a51675ce5e7c9dd2cecc94fa49877bb
parent3083d712eefb8009f7366ba53040eb2d477bfa33
signature Signed by PGP key B5690EEEBB952194

[codex] fix: ignore stale shell reducer events (#3517)

Co-authored-by: Codex <codex@openai.com>

2 files changed, 22 insertions(+), 0 deletions(-)

packages/client-runtime/src/state/shellReducer.test.ts+20
......@@ -44,6 +44,26 @@ const stubThread = {
4444} as const;
4545
4646describe("applyShellStreamEvent", () => {
47 it("ignores stale project upserts without mutating the snapshot", () => {
48 const snapshotWithProject: OrchestrationShellSnapshot = {
49 ...baseSnapshot,
50 snapshotSequence: 4,
51 projects: [stubProject],
52 };
53
54 for (const sequence of [3, 4]) {
55 const next = applyShellStreamEvent(snapshotWithProject, {
56 kind: "project-upserted",
57 sequence,
58 project: { ...stubProject, title: "Stale Title" },
59 });
60
61 expect(next).toBe(snapshotWithProject);
62 expect(next.snapshotSequence).toBe(4);
63 expect(next.projects[0]?.title).toBe("Test Project");
64 }
65 });
66
4767 describe("project-upserted", () => {
4868 it("adds a new project", () => {
4969 const event: OrchestrationShellStreamEvent = {
packages/client-runtime/src/state/shellReducer.ts+2
......@@ -13,6 +13,8 @@ export function applyShellStreamEvent(
1313 snapshot: OrchestrationShellSnapshot,
1414 event: OrchestrationShellStreamEvent,
1515): OrchestrationShellSnapshot {
16 if (event.sequence <= snapshot.snapshotSequence) return snapshot;
17
1618 switch (event.kind) {
1719 case "project-upserted": {
1820 const projects = snapshot.projects.some((p) => p.id === event.project.id)