chatccc 0.2.46 → 0.2.47

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatccc",
3
- "version": "0.2.46",
3
+ "version": "0.2.47",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -288,7 +288,8 @@ describe("getAllSessionsStatus", () => {
288
288
  const result = await getAllSessionsStatus();
289
289
  expect(result).toHaveLength(2);
290
290
  expect(result[0].chatId).toBe("chat1");
291
- expect(result[0].active).toBe(true);
291
+ // running=true in registry doesn't make it active — must be in activePrompts
292
+ expect(result[0].active).toBe(false);
292
293
  expect(result[0].turnCount).toBe(2);
293
294
  expect(result[0].chatName).toBe("test-chat-1");
294
295
  expect(result[1].chatId).toBe("chat2");
@@ -314,7 +315,7 @@ describe("getAllSessionsStatus", () => {
314
315
  expect(result.some((r) => r.chatId === "chat-4")).toBe(false);
315
316
  });
316
317
 
317
- it("marks disk-running sessions as active without checking chatSessionMap", async () => {
318
+ it("shows session as inactive when not in activePrompts, regardless of registry running field", async () => {
318
319
  await recordSessionRegistry({
319
320
  chatId: "chat1",
320
321
  sessionId: "s1",
@@ -323,6 +324,21 @@ describe("getAllSessionsStatus", () => {
323
324
  updatedAt: 1000,
324
325
  });
325
326
 
327
+ const result = await getAllSessionsStatus();
328
+ // After restart, activePrompts is cleared; registry running=true should not show as active
329
+ expect(result.find(r => r.chatId === "chat1")!.active).toBe(false);
330
+ });
331
+
332
+ it("shows session as active when in activePrompts", async () => {
333
+ await recordSessionRegistry({
334
+ chatId: "chat1",
335
+ sessionId: "s1",
336
+ tool: "claude",
337
+ running: false, // registry says false, but activePrompts wins
338
+ updatedAt: 1000,
339
+ });
340
+ mockActiveSession("chat1");
341
+
326
342
  const result = await getAllSessionsStatus();
327
343
  expect(result.find(r => r.chatId === "chat1")!.active).toBe(true);
328
344
  });
package/src/index.ts CHANGED
@@ -111,6 +111,7 @@ import {
111
111
  isSessionRunning,
112
112
  activePrompts,
113
113
  rebuildSessionChatsFromRegistry,
114
+ displayCards,
114
115
  } from "./session-chat-binding.ts";
115
116
  import { fixStaleStreamStates } from "./stream-state.ts";
116
117
 
@@ -528,6 +529,7 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
528
529
 
529
530
  // 让新群的默认工作目录继承当前会话的 cwd
530
531
  await setDefaultCwd(cwd, newChatId);
532
+ bindChatToSession(sessionId, newChatId);
531
533
  await recordSessionRegistry({
532
534
  chatId: newChatId,
533
535
  sessionId,
@@ -710,6 +712,7 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
710
712
  // 不 abort 旧 session,只解绑当前 chat
711
713
  // 旧 session 如果正在跑,display loop 继续服务其他群
712
714
  unbindChatFromSession(sessionId, chatId);
715
+ displayCards.delete(chatId);
713
716
 
714
717
  let newSessionId: string;
715
718
  try {
@@ -795,6 +798,7 @@ async function handleCommand(text: string, chatId: string, openId: string, msgTi
795
798
  // 不 abort 当前 chat 的旧 session,只解绑再重新绑定
796
799
  if (sessionId) {
797
800
  unbindChatFromSession(sessionId, chatId);
801
+ displayCards.delete(chatId);
798
802
  }
799
803
 
800
804
  const targetAdapter = getAdapterForTool(target.tool);
package/src/session.ts CHANGED
@@ -894,7 +894,7 @@ export async function getAllSessionsStatus(): Promise<SessionsListEntry[]> {
894
894
  chatId: info.chatId,
895
895
  sessionId: info.sessionId,
896
896
  chatName: info.chatName || "",
897
- active: info.running === true,
897
+ active: activePrompts.has(info.sessionId) && !(activePrompts.get(info.sessionId)?.stopped),
898
898
  turnCount: info.turnCount,
899
899
  startTime: info.startTime,
900
900
  model,