chatccc 0.2.79 → 0.2.80
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.ts +19 -16
package/package.json
CHANGED
package/src/session.ts
CHANGED
|
@@ -861,6 +861,25 @@ export async function runAgentSession(
|
|
|
861
861
|
const wasStopped = prompt?.stopped ?? false;
|
|
862
862
|
activePrompts.delete(sessionId);
|
|
863
863
|
|
|
864
|
+
// 先写最终状态(done/stopped),确保 display loop 在下一轮消费前
|
|
865
|
+
// 读到新状态并终结旧卡片。否则 setImmediate 在 CHECK 阶段先于
|
|
866
|
+
// writeFile I/O(POLL 阶段)执行,display loop 会误以为旧轮仍在
|
|
867
|
+
// 运行中并更新旧卡片,而不是新建卡片。
|
|
868
|
+
const finalStatus = wasStopped ? "stopped" : "done";
|
|
869
|
+
const finalReply = pickFinalReply(state).trim();
|
|
870
|
+
await writeStreamState({
|
|
871
|
+
sessionId,
|
|
872
|
+
status: finalStatus,
|
|
873
|
+
accumulatedContent: state.accumulatedContent,
|
|
874
|
+
finalReply,
|
|
875
|
+
chunkCount: state.chunkCount,
|
|
876
|
+
turnCount: nextTurnCount,
|
|
877
|
+
contextTokens: existingInfo?.lastContextTokens ?? 0,
|
|
878
|
+
updatedAt: Date.now(),
|
|
879
|
+
cwd,
|
|
880
|
+
tool,
|
|
881
|
+
});
|
|
882
|
+
|
|
864
883
|
// 消费队列中的缓存消息(异步,不阻塞后续清理)
|
|
865
884
|
// 用户 /stop 后应丢弃队列消息,避免用户停止后又自动开始新轮
|
|
866
885
|
if (wasStopped) {
|
|
@@ -885,22 +904,6 @@ export async function runAgentSession(
|
|
|
885
904
|
}
|
|
886
905
|
}
|
|
887
906
|
|
|
888
|
-
// 写最终状态
|
|
889
|
-
const finalStatus = wasStopped ? "stopped" : "done";
|
|
890
|
-
const finalReply = pickFinalReply(state).trim();
|
|
891
|
-
await writeStreamState({
|
|
892
|
-
sessionId,
|
|
893
|
-
status: finalStatus,
|
|
894
|
-
accumulatedContent: state.accumulatedContent,
|
|
895
|
-
finalReply,
|
|
896
|
-
chunkCount: state.chunkCount,
|
|
897
|
-
turnCount: nextTurnCount,
|
|
898
|
-
contextTokens: existingInfo?.lastContextTokens ?? 0,
|
|
899
|
-
updatedAt: Date.now(),
|
|
900
|
-
cwd,
|
|
901
|
-
tool,
|
|
902
|
-
});
|
|
903
|
-
|
|
904
907
|
// display loop 下一轮会读到最终状态并发送消息
|
|
905
908
|
|
|
906
909
|
if (wasStopped) {
|