Pass optimistic user ids to turn steer

This commit is contained in:
murashit 2026-06-03 09:21:23 +09:00
parent ae28266f5a
commit a804bca4b7
4 changed files with 17 additions and 6 deletions

View file

@ -372,11 +372,17 @@ export class AppServerClient {
return this.request("turn/start", params);
}
steerTurn(threadId: string, expectedTurnId: string, input: string | UserInput[]): Promise<TurnSteerResponse> {
steerTurn(
threadId: string,
expectedTurnId: string,
input: string | UserInput[],
clientUserMessageId?: string | null,
): Promise<TurnSteerResponse> {
return this.request("turn/steer", {
threadId,
expectedTurnId,
input: toUserInput(input),
...(clientUserMessageId !== undefined ? { clientUserMessageId } : {}),
});
}

View file

@ -112,13 +112,14 @@ export class TurnSubmissionController {
}
const codexInput = codexInputOverride ?? this.host.codexInput(text);
const localSteerId = `local-steer-${String(Date.now())}`;
this.host.setDraft("", { clearSuggestions: true });
try {
await client.steerTurn(threadId, expectedTurnId, codexInput);
await client.steerTurn(threadId, expectedTurnId, codexInput, localSteerId);
this.host.state.addLocalUserMessage(
localUserMessageItemFromInput({
id: `local-steer-${String(Date.now())}`,
id: localSteerId,
text,
turnId: expectedTurnId,
referencedThread,

View file

@ -199,13 +199,14 @@ describe("AppServerClient", () => {
getTransport().emitLine({ id: 1, result: { codexHome: "/tmp/codex" } satisfies Partial<InitializeResponse> });
await connecting;
const steering = client.steerTurn("thread-1", "turn-1", "Please adjust course.");
const steering = client.steerTurn("thread-1", "turn-1", "Please adjust course.", "local-steer-1");
expect(getTransport().sent[2]).toMatchObject({
id: 2,
method: "turn/steer",
params: {
threadId: "thread-1",
expectedTurnId: "turn-1",
clientUserMessageId: "local-steer-1",
input: [{ type: "text", text: "Please adjust course.", text_elements: [] }],
},
});

View file

@ -113,9 +113,12 @@ describe("TurnSubmissionController", () => {
await controller.sendTurnText("follow up");
expect(steerTurn).toHaveBeenCalledWith("thread", "turn", textInput("follow up"));
expect(steerTurn).toHaveBeenCalledWith("thread", "turn", textInput("follow up"), expect.stringMatching(/^local-steer-\d+$/));
expect(startTurn).not.toHaveBeenCalled();
expect(host.setStatus).toHaveBeenCalledWith("Steered current turn.");
expect(stateStore.getState().displayItems.some((item) => item.kind === "message" && item.text === "follow up")).toBe(true);
const localSteerId = steerTurn.mock.calls[0]?.[3];
expect(
stateStore.getState().displayItems.some((item) => item.kind === "message" && item.id === localSteerId && item.text === "follow up"),
).toBe(true);
});
});