chatccc 0.2.90 → 0.2.92

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/session.ts +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatccc",
3
- "version": "0.2.90",
3
+ "version": "0.2.92",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/session.ts CHANGED
@@ -813,7 +813,7 @@ export async function runAgentSession(
813
813
  const nextSeq = display.sequence + 1;
814
814
  const headerTitle = prevState.status === "stopped" ? "已停止" : "完成";
815
815
  const headerTemplate = prevState.status === "stopped" ? "red" : undefined;
816
- const cardContent = prevState.accumulatedContent || " ";
816
+ const cardContent = truncateContent(prevState.accumulatedContent + prevState.finalReply) || " ";
817
817
  const doneCard = buildProgressCard(cardContent, { showStop: false, headerTitle, headerTemplate });
818
818
  await pp.cardUpdate(display.cardId, doneCard, nextSeq).catch(() => {});
819
819
  displayCards.delete(displayChatId);
@@ -828,6 +828,8 @@ export async function runAgentSession(
828
828
  pp.setChatAvatar(displayChatId, prevState.tool, "idle").catch(() => {});
829
829
  } else if (oldLoopExisted && pp && prevState.finalReply) {
830
830
  // display loop 存在但尚未创建卡片(极快轮次),至少发送 finalReply
831
+ // 同时持久化终结旧 turn 卡片:旧 loop 的 mismatch 守卫可能已删 display entry
832
+ finalizeTurnCards(sessionId, prevState.turnCount, finalStatus).catch(() => {});
831
833
  await pp.sendText(displayChatId, prevState.finalReply).catch(() => {});
832
834
  }
833
835
  // else: display loop 已自行终结(displayCards 无记录)→ 无需处理
@@ -1105,7 +1107,7 @@ export function ensureDisplayLoop(sessionId: string): void {
1105
1107
  const nextSeq = display.sequence + 1;
1106
1108
  const headerTitle = state.status === "stopped" ? "已停止" : "完成";
1107
1109
  const headerTemplate = state.status === "stopped" ? "red" : undefined;
1108
- const cardContent = state.accumulatedContent || " ";
1110
+ const cardContent = truncateContent(state.accumulatedContent + state.finalReply) || " ";
1109
1111
  const doneCard = buildProgressCard(cardContent, { showStop: false, headerTitle, headerTemplate });
1110
1112
  await p.cardUpdate(display.cardId, doneCard, nextSeq).catch(() => {});
1111
1113
  const finalSt = state.status === "stopped" ? "stopped" : "done";
@@ -1199,6 +1201,9 @@ export function ensureDisplayLoop(sessionId: string): void {
1199
1201
  // 此处仅兜底处理异常情况(如进程重启后 display 残留)。
1200
1202
  if (display.turnCount !== state.turnCount) {
1201
1203
  console.log(`[${ts()}] [DISPLAY] turn mismatch for ${chatId}: display.turnCount=${display.turnCount} state.turnCount=${state.turnCount}, resetting`);
1204
+ // 兜底:turn mismatch 意味着旧 turn 已结束但卡片未在飞书端终结,
1205
+ // 持久化标记为 done,避免 turn-cards.json 残留 "active"
1206
+ finalizeTurnCards(sessionId, display.turnCount, "done").catch(() => {});
1202
1207
  displayCards.delete(chatId);
1203
1208
  return;
1204
1209
  }