@devries-cameron20 / t3code Mirror · read-only / commits / 4abf8b46c5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 21:30 UTC

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

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

Wout Stiens committed Jun 23, 2026 at 07:33 UTC 4abf8b46c591ae2b36aa29598c388100df651411
2 files changed +22
packages/client-runtime/src/state/shellReducer.test.ts
+20
@@ -44,6 +44,26 @@ const stubThread = {
44 } as const;
45
46 describe("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 +
67 describe("project-upserted", () => {
68 it("adds a new project", () => {
69 const event: OrchestrationShellStreamEvent = {
packages/client-runtime/src/state/shellReducer.ts
+2
@@ -13,6 +13,8 @@ export function applyShellStreamEvent(
13 snapshot: OrchestrationShellSnapshot,
14 event: OrchestrationShellStreamEvent,
15 ): OrchestrationShellSnapshot {
16 + if (event.sequence <= snapshot.snapshotSequence) return snapshot;
17 +
18 switch (event.kind) {
19 case "project-upserted": {
20 const projects = snapshot.projects.some((p) => p.id === event.project.id)