Add Cursor SDK orchestration replay support
- Wire Cursor adapter and provider session handling into orchestration v2 - Add replay fixtures, recording script, and coverage for Cursor turn flows - Update docs and debug timeline mapping for Cursor events
This commit is contained in:
1 parent
4fae73ee08
commit
ce64e37094
50 files changed
+7163
-201
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { removeAndRenumberTimelineItem } from "./orchestrationV2Timeline";
|
||||
|
||||
describe("removeAndRenumberTimelineItem", () => {
|
||||
it("closes the position gap before a streamed item is reinserted", () => {
|
||||
const remaining = removeAndRenumberTimelineItem(
|
||||
[
|
||||
{ position: 0, sourceItemId: "first" },
|
||||
{ position: 1, sourceItemId: "streaming" },
|
||||
{ position: 2, sourceItemId: "last" },
|
||||
],
|
||||
"streaming",
|
||||
);
|
||||
|
||||
expect(remaining).toEqual([
|
||||
{ position: 0, sourceItemId: "first" },
|
||||
{ position: 1, sourceItemId: "last" },
|
||||
]);
|
||||
expect(new Set(remaining.map((row) => row.position)).size).toBe(remaining.length);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
export function removeAndRenumberTimelineItem<
|
||||
Id,
|
||||
Row extends { readonly position: number; readonly sourceItemId: Id },
|
||||
>(rows: ReadonlyArray<Row>, sourceItemId: Id): Array<Row> {
|
||||
return rows
|
||||
.filter((row) => row.sourceItemId !== sourceItemId)
|
||||
.map((row, position) => ({ ...row, position }));
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { ProviderModelPicker } from "../components/chat/ProviderModelPicker";
|
||||
import { getPrimaryEnvironmentConnection } from "../environments/runtime";
|
||||
import { useSettings } from "../hooks/useSettings";
|
||||
import { removeAndRenumberTimelineItem } from "../lib/orchestrationV2Timeline";
|
||||
import { newCommandId, newMessageId, newProjectId, newThreadId } from "../lib/utils";
|
||||
import { type AppModelOption, getAppModelOptionsForInstance } from "../modelSelection";
|
||||
import {
|
||||
@@ -603,8 +604,9 @@ function applyStreamEventToProjection(
|
||||
};
|
||||
const withoutStaleItem = {
|
||||
...nextProjection,
|
||||
visibleTurnItems: activeVisibleTurnItems(nextProjection).filter(
|
||||
(row) => row.sourceItemId !== event.payload.id,
|
||||
visibleTurnItems: removeAndRenumberTimelineItem(
|
||||
activeVisibleTurnItems(nextProjection),
|
||||
event.payload.id,
|
||||
),
|
||||
};
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user