@@ -3,11 +3,13 @@ export const TUI_PTY_RECONNECT_FIXTURE = {
33 variables : `
44 const disconnectReason = process.env.OPENCLAW_TUI_PTY_DISCONNECT_REASON;
55 const reconnectOutcome = process.env.OPENCLAW_TUI_PTY_RECONNECT_OUTCOME;
6+ const replacementReconnect = reconnectOutcome === "replacement" || reconnectOutcome === "appeared";
67 let disconnectPending = disconnectReason === undefined
78 ? 0
89 : Number(process.env.OPENCLAW_TUI_PTY_DISCONNECT_COUNT ?? 1);
910 let reconnectHistoryReady = false;
1011 let reconnectRunId = "run-reconnect-fixture";
12+ let replacementReconnectHistoryLoads = 0;
1113 ` ,
1214 disconnect : `
1315 emitDisconnect() {
@@ -47,6 +49,18 @@ export const TUI_PTY_RECONNECT_FIXTURE = {
4749 ` ,
4850 loadHistory : `
4951 if (reconnectHistoryReady && reconnectOutcome) {
52+ if (replacementReconnect) {
53+ replacementReconnectHistoryLoads += 1;
54+ record("replacementReconnectHistory", {
55+ attempt: replacementReconnectHistoryLoads,
56+ });
57+ if (replacementReconnectHistoryLoads > 1) {
58+ return {
59+ sessionInfo: { ...sessionEntry(sessionKey), status: "done" },
60+ messages: [{ role: "assistant", content: "PTY_RECONNECT_RECOVERED" }],
61+ };
62+ }
63+ }
5064 const sessionInfo = {
5165 ...sessionEntry(sessionKey),
5266 ...(reconnectOutcome === "interrupted"
@@ -60,8 +74,15 @@ export const TUI_PTY_RECONNECT_FIXTURE = {
6074 messages: reconnectOutcome === "completed"
6175 ? [{ role: "assistant", content: "PTY_RECONNECT_COMPLETED" }]
6276 : [],
63- ...(reconnectOutcome === "active"
64- ? { inFlightRun: { runId: reconnectRunId, text: "PTY_RECONNECT_PARTIAL" } }
77+ ...(reconnectOutcome === "active" || replacementReconnect
78+ ? {
79+ inFlightRun: {
80+ runId: replacementReconnect ? "run-reconnect-replacement" : reconnectRunId,
81+ text: replacementReconnect
82+ ? "PTY_RECONNECT_REPLACEMENT"
83+ : "PTY_RECONNECT_PARTIAL",
84+ },
85+ }
6586 : {}),
6687 };
6788 }
0 commit comments