[codex] fix: ignore stale shell reducer events (#3517)
Co-authored-by: Codex <[email protected]>
This commit is contained in:
1 parent
3083d712ee
commit
4abf8b46c5
2 files changed
+22
No files matched your search
@@ -44,6 +44,26 @@ const stubThread = {
|
||||
} as const;
|
||||
|
||||
describe("applyShellStreamEvent", () => {
|
||||
it("ignores stale project upserts without mutating the snapshot", () => {
|
||||
const snapshotWithProject: OrchestrationShellSnapshot = {
|
||||
...baseSnapshot,
|
||||
snapshotSequence: 4,
|
||||
projects: [stubProject],
|
||||
};
|
||||
|
||||
for (const sequence of [3, 4]) {
|
||||
const next = applyShellStreamEvent(snapshotWithProject, {
|
||||
kind: "project-upserted",
|
||||
sequence,
|
||||
project: { ...stubProject, title: "Stale Title" },
|
||||
});
|
||||
|
||||
expect(next).toBe(snapshotWithProject);
|
||||
expect(next.snapshotSequence).toBe(4);
|
||||
expect(next.projects[0]?.title).toBe("Test Project");
|
||||
}
|
||||
});
|
||||
|
||||
describe("project-upserted", () => {
|
||||
it("adds a new project", () => {
|
||||
const event: OrchestrationShellStreamEvent = {
|
||||
|
||||
@@ -13,6 +13,8 @@ export function applyShellStreamEvent(
|
||||
snapshot: OrchestrationShellSnapshot,
|
||||
event: OrchestrationShellStreamEvent,
|
||||
): OrchestrationShellSnapshot {
|
||||
if (event.sequence <= snapshot.snapshotSequence) return snapshot;
|
||||
|
||||
switch (event.kind) {
|
||||
case "project-upserted": {
|
||||
const projects = snapshot.projects.some((p) => p.id === event.project.id)
|
||||
|
||||
Reference in new issue
Block a user