codex-to-im 1.0.44 → 1.0.46

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.
@@ -5446,6 +5446,18 @@ function recordBindingChange(store, input) {
5446
5446
  });
5447
5447
  }
5448
5448
 
5449
+ // src/lib/bridge/turns/turn-classifier.ts
5450
+ function normalizeThreadId(value) {
5451
+ const normalized = value?.trim();
5452
+ return normalized || void 0;
5453
+ }
5454
+ function getCodexThreadId(session, binding) {
5455
+ return normalizeThreadId(session?.codex_thread_id) || normalizeThreadId(binding?.sdkSessionId) || normalizeThreadId(session?.sdk_session_id);
5456
+ }
5457
+ function getExplicitDesktopThreadId(session) {
5458
+ return normalizeThreadId(session?.desktop_thread_id) || (session?.thread_origin === "desktop" ? normalizeThreadId(session.sdk_session_id) : void 0);
5459
+ }
5460
+
5449
5461
  // src/session-bindings.ts
5450
5462
  function asChannelProvider(value) {
5451
5463
  return value === "feishu" || value === "weixin" ? value : void 0;
@@ -5497,15 +5509,31 @@ function getSessionName(session) {
5497
5509
  function getSessionMode(store, session) {
5498
5510
  return session.preferred_mode || store.getSetting("bridge_default_mode") || "code";
5499
5511
  }
5512
+ function getBindingResumeThreadId(session) {
5513
+ return getCodexThreadId(session) || "";
5514
+ }
5515
+ function markSessionAsDesktopBacked(store, sessionId, desktopThreadId) {
5516
+ store.updateSdkSessionId(sessionId, desktopThreadId);
5517
+ store.updateSession(sessionId, {
5518
+ sdk_session_id: desktopThreadId,
5519
+ codex_thread_id: desktopThreadId,
5520
+ desktop_thread_id: desktopThreadId,
5521
+ thread_origin: "desktop"
5522
+ });
5523
+ }
5500
5524
  function bindStoreToSession(store, channelType, chatId, sessionId, chatMeta) {
5501
5525
  const session = store.getSession(sessionId);
5502
5526
  if (!session) return null;
5503
5527
  assertBindingTargetAvailable(
5504
5528
  store,
5505
5529
  { channelType, chatId },
5506
- { sessionId: session.id, sdkSessionId: session.sdk_session_id || void 0 }
5530
+ {
5531
+ sessionId: session.id,
5532
+ sdkSessionId: getCodexThreadId(session) || getExplicitDesktopThreadId(session)
5533
+ }
5507
5534
  );
5508
5535
  const meta = resolveChannelMeta(channelType);
5536
+ const sdkSessionId = getBindingResumeThreadId(session);
5509
5537
  return store.upsertChannelBinding({
5510
5538
  channelType,
5511
5539
  channelProvider: meta.provider,
@@ -5514,7 +5542,7 @@ function bindStoreToSession(store, channelType, chatId, sessionId, chatMeta) {
5514
5542
  chatUserId: chatMeta?.chatUserId,
5515
5543
  chatDisplayName: chatMeta?.chatDisplayName,
5516
5544
  codepilotSessionId: session.id,
5517
- sdkSessionId: session.sdk_session_id || "",
5545
+ sdkSessionId,
5518
5546
  workingDirectory: session.working_directory,
5519
5547
  model: session.model,
5520
5548
  mode: getSessionMode(store, session)
@@ -5529,6 +5557,7 @@ function bindStoreToSdkSession(store, channelType, chatId, sdkSessionId, opts) {
5529
5557
  const meta = resolveChannelMeta(channelType);
5530
5558
  const existing = store.findSessionBySdkSessionId(sdkSessionId);
5531
5559
  if (existing) {
5560
+ markSessionAsDesktopBacked(store, existing.id, sdkSessionId);
5532
5561
  return store.upsertChannelBinding({
5533
5562
  channelType,
5534
5563
  channelProvider: meta.provider,
@@ -5553,7 +5582,7 @@ function bindStoreToSdkSession(store, channelType, chatId, sdkSessionId, opts) {
5553
5582
  workingDirectory,
5554
5583
  "code"
5555
5584
  );
5556
- store.updateSdkSessionId(session.id, sdkSessionId);
5585
+ markSessionAsDesktopBacked(store, session.id, sdkSessionId);
5557
5586
  return store.upsertChannelBinding({
5558
5587
  channelType,
5559
5588
  channelProvider: meta.provider,
@@ -5582,11 +5611,11 @@ function listBindingTargetOptions(_store, desktopLimit = 12) {
5582
5611
  function listBindingSummaries(store) {
5583
5612
  return store.listChannelBindings().map((binding) => {
5584
5613
  const session = store.getSession(binding.codepilotSessionId);
5585
- const currentThreadId = binding.sdkSessionId || session?.sdk_session_id || void 0;
5586
- const desktop = currentThreadId ? getDesktopSessionByThreadId(currentThreadId) : null;
5587
- const archived = currentThreadId ? isArchivedDesktopThread(currentThreadId) : false;
5588
- const currentTargetKey = currentThreadId ? `desktop:${currentThreadId}` : `session:${binding.codepilotSessionId}`;
5589
- const currentTargetLabel = currentThreadId ? desktop?.title || (archived ? `\u5DF2\u5F52\u6863\u684C\u9762\u7EBF\u7A0B ${currentThreadId.slice(0, 8)}...` : `Desktop thread ${currentThreadId.slice(0, 8)}...`) : getSessionName(session || {
5614
+ const currentDesktopThreadId = session ? getExplicitDesktopThreadId(session) : void 0;
5615
+ const desktop = currentDesktopThreadId ? getDesktopSessionByThreadId(currentDesktopThreadId) : null;
5616
+ const archived = currentDesktopThreadId ? isArchivedDesktopThread(currentDesktopThreadId) : false;
5617
+ const currentTargetKey = currentDesktopThreadId ? `desktop:${currentDesktopThreadId}` : `session:${binding.codepilotSessionId}`;
5618
+ const currentTargetLabel = currentDesktopThreadId ? desktop?.title || (archived ? `\u5DF2\u5F52\u6863\u684C\u9762\u7EBF\u7A0B ${currentDesktopThreadId.slice(0, 8)}...` : `Desktop thread ${currentDesktopThreadId.slice(0, 8)}...`) : getSessionName(session || {
5590
5619
  id: binding.codepilotSessionId,
5591
5620
  working_directory: binding.workingDirectory,
5592
5621
  model: binding.model
@@ -5606,7 +5635,7 @@ function listBindingSummaries(store) {
5606
5635
  currentTargetLabel,
5607
5636
  currentSessionId: binding.codepilotSessionId,
5608
5637
  currentSessionName: session ? getSessionName(session) : binding.codepilotSessionId.slice(0, 8),
5609
- currentThreadId,
5638
+ currentThreadId: currentDesktopThreadId || getCodexThreadId(session, binding),
5610
5639
  runtimeStatus: session?.runtime_status,
5611
5640
  queuedCount: session?.queued_count,
5612
5641
  mirrorStatus: session?.mirror_status,
@@ -6495,7 +6524,7 @@ var JsonFileStore = class {
6495
6524
  findSessionBySdkSessionId(sdkSessionId) {
6496
6525
  this.reloadSessions();
6497
6526
  for (const session of this.sessions.values()) {
6498
- if (session.sdk_session_id === sdkSessionId) {
6527
+ if (session.sdk_session_id === sdkSessionId || session.codex_thread_id === sdkSessionId || session.desktop_thread_id === sdkSessionId) {
6499
6528
  return session;
6500
6529
  }
6501
6530
  }
@@ -6629,6 +6658,15 @@ var JsonFileStore = class {
6629
6658
  const s = this.sessions.get(sessionId);
6630
6659
  if (s) {
6631
6660
  s.sdk_session_id = sdkSessionId;
6661
+ if (sdkSessionId) {
6662
+ s.codex_thread_id = sdkSessionId;
6663
+ s.thread_origin = s.thread_origin || "bridge";
6664
+ } else {
6665
+ delete s.codex_thread_id;
6666
+ if (s.thread_origin !== "desktop") {
6667
+ delete s.thread_origin;
6668
+ }
6669
+ }
6632
6670
  s.updated_at = now();
6633
6671
  this.persistSessions();
6634
6672
  }