@ccpocket/bridge 1.81.4 → 1.81.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/websocket.js CHANGED
@@ -1015,7 +1015,7 @@ export class BridgeWebSocketServer {
1015
1015
  }
1016
1016
  const codexProcess = session.process;
1017
1017
  if (session.provider !== "codex" ||
1018
- typeof codexProcess.rollbackThread !== "function") {
1018
+ typeof codexProcess.forkThreadAtUserTurn !== "function") {
1019
1019
  this.send(ws, {
1020
1020
  type: "rewind_result",
1021
1021
  sessionId,
@@ -1088,16 +1088,18 @@ export class BridgeWebSocketServer {
1088
1088
  worktreeBranch: session.worktreeBranch,
1089
1089
  }
1090
1090
  : undefined;
1091
- const rolledBackThread = await codexProcess.rollbackThread(numTurns);
1091
+ const forked = targetOrdinal > 1
1092
+ ? await codexProcess.forkThreadAtUserTurn(targetOrdinal - 1)
1093
+ : undefined;
1092
1094
  const pastMessages = this.codexHistoryFromThreadOrFallback({
1093
- thread: rolledBackThread,
1095
+ thread: forked?.thread,
1094
1096
  expectedUserTurns: targetOrdinal - 1,
1095
1097
  fallback: buildCodexHistoryPrefix(session, targetOrdinal - 1),
1096
1098
  });
1097
1099
  this.destroySession(sessionId);
1098
1100
  const newSessionId = this.sessionManager.create(projectPath, undefined, pastMessages, worktreeOpts, "codex", this.withCodexAutoReviewPolicy({
1099
1101
  ...(codexSettings ?? {}),
1100
- threadId,
1102
+ threadId: forked?.threadId,
1101
1103
  }));
1102
1104
  this.attachWorkspaceToRuntimeSession(newSessionId, workspace);
1103
1105
  const newSession = this.sessionManager.get(newSessionId);
@@ -1130,7 +1132,7 @@ export class BridgeWebSocketServer {
1130
1132
  }
1131
1133
  const codexProcess = session.process;
1132
1134
  if (session.provider !== "codex" ||
1133
- typeof codexProcess.forkThread !== "function") {
1135
+ typeof codexProcess.forkThreadAtUserTurn !== "function") {
1134
1136
  this.send(ws, {
1135
1137
  type: "error",
1136
1138
  message: "Fork is only supported for Codex sessions",
@@ -1173,13 +1175,9 @@ export class BridgeWebSocketServer {
1173
1175
  worktreeBranch: session.worktreeBranch,
1174
1176
  }
1175
1177
  : undefined;
1176
- const forked = await codexProcess.forkThread();
1178
+ const forked = await codexProcess.forkThreadAtUserTurn(targetOrdinal);
1177
1179
  const forkedThreadId = forked.threadId;
1178
- const turnsToDrop = totalUserTurns - targetOrdinal;
1179
- let forkedThread = forked.thread;
1180
- if (turnsToDrop > 0) {
1181
- forkedThread = await codexProcess.rollbackThreadById(forkedThreadId, turnsToDrop);
1182
- }
1180
+ const forkedThread = forked.thread;
1183
1181
  const pastMessages = this.codexHistoryFromThreadOrFallback({
1184
1182
  thread: forkedThread,
1185
1183
  expectedUserTurns: targetOrdinal,