chatccc 0.2.116 → 0.2.117
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/package.json +1 -1
- package/src/session-chat-binding.ts +2 -0
- package/src/session.ts +8 -1
package/package.json
CHANGED
|
@@ -151,6 +151,8 @@ export interface DisplayCardState {
|
|
|
151
151
|
lastSentFinalReply?: string;
|
|
152
152
|
/** 点点点动画计数器(统一 display loop 每个卡片独立计数) */
|
|
153
153
|
dotCount: number;
|
|
154
|
+
/** stream-state 连续读取失败次数,超过阈值才删除 display entry */
|
|
155
|
+
readFailCount?: number;
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
export const displayCards = new Map<string, DisplayCardState>();
|
package/src/session.ts
CHANGED
|
@@ -1279,15 +1279,21 @@ export function startUnifiedDisplayLoop(): void {
|
|
|
1279
1279
|
const sessionId = display.sessionId;
|
|
1280
1280
|
const state = await readStreamState(sessionId);
|
|
1281
1281
|
if (!state) {
|
|
1282
|
-
|
|
1282
|
+
display.readFailCount = (display.readFailCount ?? 0) + 1;
|
|
1283
|
+
if (display.readFailCount >= 3) {
|
|
1284
|
+
console.log(`[${ts()}] [DISPLAY] readStreamState ${display.readFailCount} consecutive failures for ${sessionId}, removing display entry for chat ${chatId}`);
|
|
1285
|
+
displayCards.delete(chatId);
|
|
1286
|
+
}
|
|
1283
1287
|
continue;
|
|
1284
1288
|
}
|
|
1289
|
+
display.readFailCount = 0;
|
|
1285
1290
|
|
|
1286
1291
|
// 交叉验证:chat 当前绑定的 session 是否仍是 display 记录的 session。
|
|
1287
1292
|
// 若 chat 已被切换到其他 session(如 /newh),旧 display 必须停推。
|
|
1288
1293
|
const currentSessionForChat = sessionInfoMap.get(chatId)?.sessionId;
|
|
1289
1294
|
if (currentSessionForChat && currentSessionForChat !== sessionId) {
|
|
1290
1295
|
if (state.status !== "running") {
|
|
1296
|
+
console.log(`[${ts()}] [DISPLAY] chat ${chatId} now bound to ${currentSessionForChat}, removing stale display for ${sessionId} (terminal: ${state.status})`);
|
|
1291
1297
|
displayCards.delete(chatId);
|
|
1292
1298
|
}
|
|
1293
1299
|
continue;
|
|
@@ -1297,6 +1303,7 @@ export function startUnifiedDisplayLoop(): void {
|
|
|
1297
1303
|
const lastActive = getLastActiveChat(sessionId);
|
|
1298
1304
|
if (lastActive !== chatId) {
|
|
1299
1305
|
if (state.status !== "running") {
|
|
1306
|
+
console.log(`[${ts()}] [DISPLAY] lastActive mismatch for ${sessionId}: display chat=${chatId} lastActive=${lastActive ?? "undefined"}, removing display entry (terminal: ${state.status})`);
|
|
1300
1307
|
displayCards.delete(chatId);
|
|
1301
1308
|
}
|
|
1302
1309
|
continue;
|