@keyou007/agent-bot 0.1.27-alpha.1 → 0.1.27-alpha.3

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 (118) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +55 -5
  3. package/README.zh.md +55 -5
  4. package/SECURITY.md +14 -0
  5. package/assets/workspace-sessions.js +648 -0
  6. package/assets/workspace.css +160 -0
  7. package/assets/workspace.js +1795 -0
  8. package/config.example.yaml +3 -2
  9. package/dist/codex/CodexEventMapper.js +35 -0
  10. package/dist/codex/CodexEventMapper.js.map +1 -1
  11. package/dist/codex/CodexRuntime.js +50 -4
  12. package/dist/codex/CodexRuntime.js.map +1 -1
  13. package/dist/codex/TraeTaskNotification.js +44 -0
  14. package/dist/codex/TraeTaskNotification.js.map +1 -0
  15. package/dist/config/SettingsStore.js +1 -1
  16. package/dist/config/SettingsStore.js.map +1 -1
  17. package/dist/config/loadConfig.js +3 -2
  18. package/dist/config/loadConfig.js.map +1 -1
  19. package/dist/config/paths.js +3 -0
  20. package/dist/config/paths.js.map +1 -1
  21. package/dist/feishu/CardRenderer.js +54 -10
  22. package/dist/feishu/CardRenderer.js.map +1 -1
  23. package/dist/feishu/FeishuMessageClient.js +2 -2
  24. package/dist/feishu/FeishuMessageClient.js.map +1 -1
  25. package/dist/feishu/FeishuTurnPresenter.js +103 -16
  26. package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
  27. package/dist/index.js +61 -17
  28. package/dist/index.js.map +1 -1
  29. package/dist/local-files/DiagramPreview.js +1 -1
  30. package/dist/local-files/GitDiffPreview.js +11 -7
  31. package/dist/local-files/GitDiffPreview.js.map +1 -1
  32. package/dist/local-files/LocalFileViewerServer.js +359 -37
  33. package/dist/local-files/LocalFileViewerServer.js.map +1 -1
  34. package/dist/local-files/MarkdownFileLinks.js +5 -4
  35. package/dist/local-files/MarkdownFileLinks.js.map +1 -1
  36. package/dist/local-files/TurnPreviewPage.js +32 -10
  37. package/dist/local-files/TurnPreviewPage.js.map +1 -1
  38. package/dist/local-files/WebPageTitle.js +85 -0
  39. package/dist/local-files/WebPageTitle.js.map +1 -0
  40. package/dist/local-files/WorkspaceFiles.js +553 -0
  41. package/dist/local-files/WorkspaceFiles.js.map +1 -0
  42. package/dist/local-files/WorkspaceOrigin.js +38 -0
  43. package/dist/local-files/WorkspaceOrigin.js.map +1 -0
  44. package/dist/local-files/WorkspacePage.js +19 -0
  45. package/dist/local-files/WorkspacePage.js.map +1 -0
  46. package/dist/local-files/WorkspaceSessions.js +689 -0
  47. package/dist/local-files/WorkspaceSessions.js.map +1 -0
  48. package/dist/presentation/TurnStateReducer.js +74 -13
  49. package/dist/presentation/TurnStateReducer.js.map +1 -1
  50. package/dist/presentation/turnActivity.js +41 -0
  51. package/dist/presentation/turnActivity.js.map +1 -0
  52. package/dist/presentation/turnStatus.js +11 -0
  53. package/dist/presentation/turnStatus.js.map +1 -1
  54. package/dist/presentation/visibleTurnActivities.js +4 -2
  55. package/dist/presentation/visibleTurnActivities.js.map +1 -1
  56. package/dist/proxy/ProxySessionController.js +150 -14
  57. package/dist/proxy/ProxySessionController.js.map +1 -1
  58. package/dist/runtime/types.js +1 -1
  59. package/dist/runtime/types.js.map +1 -1
  60. package/dist/state/InboundMessageStore.js +54 -0
  61. package/dist/state/InboundMessageStore.js.map +1 -0
  62. package/dist/state/StateStore.js +71 -1
  63. package/dist/state/StateStore.js.map +1 -1
  64. package/dist/state/TurnPreviewJournal.js +4 -2
  65. package/dist/state/TurnPreviewJournal.js.map +1 -1
  66. package/dist/state/migrations.js +20 -0
  67. package/dist/state/migrations.js.map +1 -1
  68. package/dist/supervision/SafeRestartNotifier.js +1 -0
  69. package/dist/supervision/SafeRestartNotifier.js.map +1 -1
  70. package/dist/supervision/SafeRestartScheduler.js +33 -16
  71. package/dist/supervision/SafeRestartScheduler.js.map +1 -1
  72. package/dist/terminal/TerminalLinks.js +32 -0
  73. package/dist/terminal/TerminalLinks.js.map +1 -1
  74. package/dist/terminal/TerminalPage.js +44 -24
  75. package/dist/terminal/TerminalPage.js.map +1 -1
  76. package/dist/terminal/TerminalServer.js +103 -39
  77. package/dist/terminal/TerminalServer.js.map +1 -1
  78. package/docs/technical-reference.md +1 -1
  79. package/docs/technical-reference.zh.md +2 -2
  80. package/npm-shrinkwrap.json +2 -2
  81. package/package.json +1 -1
  82. package/skills/agent-bot/SKILL.md +3 -1
  83. package/src/codex/CodexEventMapper.ts +39 -1
  84. package/src/codex/CodexRuntime.ts +54 -4
  85. package/src/codex/TraeTaskNotification.ts +49 -0
  86. package/src/config/SettingsStore.ts +1 -1
  87. package/src/config/loadConfig.ts +3 -2
  88. package/src/config/paths.ts +4 -0
  89. package/src/feishu/CardRenderer.ts +45 -11
  90. package/src/feishu/FeishuMessageClient.ts +2 -2
  91. package/src/feishu/FeishuTurnPresenter.ts +110 -20
  92. package/src/index.ts +62 -17
  93. package/src/local-files/DiagramPreview.ts +1 -1
  94. package/src/local-files/GitDiffPreview.ts +10 -7
  95. package/src/local-files/LocalFileViewerServer.ts +330 -37
  96. package/src/local-files/MarkdownFileLinks.ts +5 -3
  97. package/src/local-files/TurnPreviewPage.ts +35 -9
  98. package/src/local-files/WebPageTitle.ts +59 -0
  99. package/src/local-files/WorkspaceFiles.ts +468 -0
  100. package/src/local-files/WorkspaceOrigin.ts +31 -0
  101. package/src/local-files/WorkspacePage.ts +21 -0
  102. package/src/local-files/WorkspaceSessions.ts +587 -0
  103. package/src/presentation/TurnStateReducer.ts +76 -14
  104. package/src/presentation/turnActivity.ts +43 -0
  105. package/src/presentation/turnStatus.ts +14 -0
  106. package/src/presentation/turnViewTypes.ts +10 -1
  107. package/src/presentation/visibleTurnActivities.ts +4 -2
  108. package/src/proxy/ProxySessionController.ts +149 -13
  109. package/src/runtime/types.ts +17 -0
  110. package/src/state/InboundMessageStore.ts +72 -0
  111. package/src/state/StateStore.ts +80 -1
  112. package/src/state/TurnPreviewJournal.ts +4 -2
  113. package/src/state/migrations.ts +20 -0
  114. package/src/supervision/SafeRestartNotifier.ts +1 -0
  115. package/src/supervision/SafeRestartScheduler.ts +42 -18
  116. package/src/terminal/TerminalLinks.ts +26 -0
  117. package/src/terminal/TerminalPage.ts +44 -24
  118. package/src/terminal/TerminalServer.ts +98 -36
@@ -283,6 +283,9 @@ export class ProxySessionController {
283
283
  recoveryActivityHeartbeat;
284
284
  startupRecovery;
285
285
  queuedPromptsRestored = false;
286
+ inboundPaused = false;
287
+ inboundInFlight = new Set();
288
+ inboundActionsInFlight = 0;
286
289
  constructor(config, store, runtimes, outbound, logger, lifecycle, shellCommandExecutor = executeShellCommand, windowsDriveLister = listWindowsDriveRoots, shellCommandJobs = new ShellCommandJobManager(path.join(path.dirname(config.storage.sqlitePath), "command-jobs")), threadWriterProcesses = new SystemThreadWriterProcessController(), referenceInstructionWindowMs = REFERENCE_INSTRUCTION_WINDOW_MS) {
287
290
  this.config = config;
288
291
  this.store = store;
@@ -310,9 +313,6 @@ export class ProxySessionController {
310
313
  this.recoveryActivityHeartbeat.unref?.();
311
314
  }
312
315
  async onMessage(message) {
313
- let forwardedImages = [];
314
- let forwardedFiles = [];
315
- let coalescedForwardAttachment = false;
316
316
  if (!message.contextKey.startsWith("console:") && !allowsFeishuUser(this.config, message.userId)) {
317
317
  this.logger.debug({ messageId: message.messageId }, "Ignored a Feishu message from a non-owner before acknowledgement.");
318
318
  return;
@@ -323,10 +323,37 @@ export class ProxySessionController {
323
323
  this.logger.debug({ messageId: message.messageId, contextKey: message.contextKey }, "Ignored an unmentioned message from a muted Lark group.");
324
324
  return;
325
325
  }
326
- // For accepted messages, claim durable deduplication before acknowledgement so event
327
- // retries cannot add duplicate reactions.
328
- if (!this.store.claimInboundEvent(message.messageId, "message"))
326
+ const currentId = this.store.getUserContext(message.contextKey)?.currentSessionId;
327
+ if (!this.store.inboundMessages.claim(message, currentId, currentId ? this.store.executionGeneration(currentId) : 0))
328
+ return;
329
+ if (this.inboundPaused || this.recoveryClosed)
329
330
  return;
331
+ await this.processAcceptedMessage(message);
332
+ }
333
+ get pendingInboundMessages() {
334
+ return this.inboundInFlight.size + this.inboundActionsInFlight;
335
+ }
336
+ pauseInboundMessages() {
337
+ this.inboundPaused = true;
338
+ }
339
+ resumeInboundMessages() {
340
+ this.inboundPaused = false;
341
+ }
342
+ async processAcceptedMessage(message, recoveryGuard) {
343
+ this.inboundInFlight.add(message.messageId);
344
+ try {
345
+ await this.handleAcceptedMessage(message, recoveryGuard);
346
+ }
347
+ finally {
348
+ this.inboundInFlight.delete(message.messageId);
349
+ if (!this.recoveryClosed)
350
+ this.store.inboundMessages.finish(message.messageId);
351
+ }
352
+ }
353
+ async handleAcceptedMessage(message, recoveryGuard) {
354
+ let forwardedImages = [];
355
+ let forwardedFiles = [];
356
+ let coalescedForwardAttachment = false;
330
357
  if (!message.text.trim().startsWith("/")) {
331
358
  const currentId = this.store.getUserContext(message.contextKey)?.currentSessionId;
332
359
  if (currentId)
@@ -355,6 +382,8 @@ export class ProxySessionController {
355
382
  : undefined;
356
383
  try {
357
384
  const reactionId = await this.outbound.addReaction(message.contextKey, message.messageId, MESSAGE_RECEIVED_REACTION);
385
+ if (this.recoveryClosed)
386
+ return;
358
387
  if (reactionId) {
359
388
  this.store.saveMessageReaction(message.messageId, message.contextKey, reactionId, MESSAGE_RECEIVED_REACTION);
360
389
  }
@@ -365,6 +394,11 @@ export class ProxySessionController {
365
394
  await this.waitForCurrentSessionReset(message.contextKey);
366
395
  if (this.recoveryClosed)
367
396
  return;
397
+ if (recoveryGuard && !recoveryGuard()) {
398
+ await this.reportUnprocessedMessage(message, "已有后续指令或任务状态发生变化");
399
+ return;
400
+ }
401
+ this.store.inboundMessages.beginDispatch(message.messageId);
368
402
  if (attachmentReservation && this.completeReferenceInstruction(message, attachmentReservation)) {
369
403
  this.store.audit(message.contextKey, "referenced_message_coalesced", {
370
404
  messageId: message.messageId,
@@ -575,6 +609,10 @@ export class ProxySessionController {
575
609
  await this.outbound.withReplyTarget(message.contextKey, replyTarget, async () => {
576
610
  try {
577
611
  await this.waitForCurrentSessionReset(message.contextKey);
612
+ if (recoveryGuard && !recoveryGuard()) {
613
+ await this.reportUnprocessedMessage(message, "已有后续指令或任务状态发生变化");
614
+ return;
615
+ }
578
616
  if (command.type === "prompt")
579
617
  await this.ensureThreadFork(message);
580
618
  await this.execute(message.contextKey, command, message.messageId, replyTarget, localImagePaths, message.userId, message);
@@ -599,6 +637,10 @@ export class ProxySessionController {
599
637
  await this.waitForCurrentSessionReset(message.contextKey);
600
638
  return this.outbound.withReplyTarget(message.contextKey, replyTarget, async () => {
601
639
  try {
640
+ if (recoveryGuard && !recoveryGuard()) {
641
+ await this.reportUnprocessedMessage(message, "已有后续指令或任务状态发生变化");
642
+ return;
643
+ }
602
644
  let executableCommand = command;
603
645
  let executableImagePaths = localImagePaths;
604
646
  let executableMessage = message;
@@ -658,10 +700,23 @@ export class ProxySessionController {
658
700
  this.messageQueues.delete(message.contextKey);
659
701
  }
660
702
  async onCardAction(action) {
703
+ this.inboundActionsInFlight += 1;
704
+ try {
705
+ await this.handleCardAction(action);
706
+ }
707
+ finally {
708
+ this.inboundActionsInFlight -= 1;
709
+ }
710
+ }
711
+ async handleCardAction(action) {
661
712
  if (!allowsFeishuUser(this.config, action.userId)) {
662
713
  this.logger.debug({ actionId: action.actionId }, "Ignored a Feishu card action from a non-owner.");
663
714
  return;
664
715
  }
716
+ if (this.inboundPaused || this.recoveryClosed) {
717
+ await this.outbound.sendText(action.contextKey, "Agent Bot 正在重启,请恢复在线后重新操作。");
718
+ return;
719
+ }
665
720
  if (!this.store.claimInboundEvent(action.actionId, "card_action"))
666
721
  return;
667
722
  let resolvedAction;
@@ -1083,10 +1138,24 @@ export class ProxySessionController {
1083
1138
  this.stopShellCommandJobMonitor(jobId);
1084
1139
  clearInterval(this.recoveryActivityHeartbeat);
1085
1140
  }
1086
- async controlStopTask(localSessionId) {
1141
+ async controlStopTask(localSessionId, expectedTurnId) {
1087
1142
  const record = this.store.getSession(localSessionId);
1088
1143
  if (!record || record.status === "closed")
1089
1144
  throw new Error(`Task not found: ${localSessionId}`);
1145
+ if (expectedTurnId) {
1146
+ const runtime = this.runtimes.forAgent(record.agentName);
1147
+ if (!record.remoteSessionId || !runtime.interruptRemoteTurn
1148
+ || runtime.getSession(localSessionId)?.activeTurnId !== expectedTurnId)
1149
+ return "stale";
1150
+ // The App Server interrupt targets this exact turn, not whichever turn is current later.
1151
+ this.store.requestSessionExecutionStop(localSessionId);
1152
+ this.responseContinuations.get(localSessionId)?.abort.abort();
1153
+ this.responseContinuations.delete(localSessionId);
1154
+ this.planHandoffs.delete(localSessionId);
1155
+ await runtime.interruptRemoteTurn(record.remoteSessionId, expectedTurnId);
1156
+ this.store.audit(record.contextKey, "turn_interrupt_sent", { localSessionId, turnId: expectedTurnId, source: "workspace" });
1157
+ return "accepted";
1158
+ }
1090
1159
  await this.cancelSession(record);
1091
1160
  return `Task stop requested: ${record.title ?? record.remoteSessionId ?? record.localSessionId}`;
1092
1161
  }
@@ -1160,7 +1229,7 @@ export class ProxySessionController {
1160
1229
  });
1161
1230
  return `Task title changed to: ${normalizedTitle}`;
1162
1231
  }
1163
- async controlSendTaskPrompt(localSessionId, text) {
1232
+ async controlSendTaskPrompt(localSessionId, text, workspace) {
1164
1233
  const promptText = text.trim();
1165
1234
  if (!promptText)
1166
1235
  throw new Error("The Prompt cannot be empty.");
@@ -1193,7 +1262,11 @@ export class ProxySessionController {
1193
1262
  const previous = this.messageQueues.get(responseContextKey) ?? Promise.resolve();
1194
1263
  const next = previous.catch(() => undefined).then(async () => {
1195
1264
  this.outbound.registerSession(scopedRecord.localSessionId, responseContextKey, scopedRecord.title, scopedRecord.cwd, this.agentLabel(scopedRecord.agentName), scopedRecord.model, scopedRecord.modelProvider);
1265
+ if (workspace && this.store.getSession(localSessionId)?.status === "closed")
1266
+ throw new Error("任务已归档。");
1267
+ workspace?.onPosting();
1196
1268
  const promptMessageId = await this.outbound.withReplyTarget(responseContextKey, existingReplyTarget, () => this.outbound.sendText(responseContextKey, promptText));
1269
+ workspace?.onPosted();
1197
1270
  const turnReplyTarget = isThreadContextKey(responseContextKey)
1198
1271
  ? promptMessageId
1199
1272
  ? { messageId: promptMessageId, replyInThread: true }
@@ -1202,7 +1275,8 @@ export class ProxySessionController {
1202
1275
  await this.promptSession(scopedRecord, responseContextKey, promptText, undefined, turnReplyTarget);
1203
1276
  this.store.audit(responseContextKey, "task_prompt_sent", {
1204
1277
  localSessionId,
1205
- source: "cli",
1278
+ source: workspace ? "workspace" : "cli",
1279
+ requestId: workspace?.requestId,
1206
1280
  });
1207
1281
  });
1208
1282
  this.messageQueues.set(responseContextKey, next);
@@ -1895,7 +1969,7 @@ export class ProxySessionController {
1895
1969
  await this.prompt(contextKey, command.text, messageId, replyTarget, localImagePaths, incomingMessage?.displayText);
1896
1970
  return;
1897
1971
  case "nosteer":
1898
- await this.enqueueNoSteerPrompt(contextKey, command.text, messageId, replyTarget);
1972
+ await this.enqueueNoSteerPrompt(contextKey, command.text, messageId, replyTarget, localImagePaths);
1899
1973
  return;
1900
1974
  case "sessions":
1901
1975
  await this.outbound.sendText(contextKey, LIST_SESSIONS_STARTED_MESSAGE);
@@ -2026,6 +2100,7 @@ export class ProxySessionController {
2026
2100
  return recovery;
2027
2101
  }
2028
2102
  async runStartupRecovery() {
2103
+ await this.recoverUnprocessedMessages();
2029
2104
  await this.finishPersistedCancellationRequests();
2030
2105
  await this.recoverShellCommandJobs();
2031
2106
  const recoveryCutoff = Date.now() - RECOVERY_ACTIVITY_WINDOW_MS;
@@ -2068,6 +2143,61 @@ export class ProxySessionController {
2068
2143
  }
2069
2144
  this.restorePersistedQueuedPrompts();
2070
2145
  }
2146
+ async recoverUnprocessedMessages() {
2147
+ for (const pending of this.store.inboundMessages.listPending()) {
2148
+ if (this.recoveryClosed || this.inboundPaused)
2149
+ return;
2150
+ const message = pending.message;
2151
+ if (this.inboundInFlight.has(message.messageId) || !this.outbound.canRoute(message.contextKey))
2152
+ continue;
2153
+ if (!this.store.inboundMessages.isPending(message.messageId))
2154
+ continue;
2155
+ if (this.store.inboundMessages.hasDurableWork(message.messageId)) {
2156
+ this.store.inboundMessages.finish(message.messageId);
2157
+ continue;
2158
+ }
2159
+ const currentId = this.store.getUserContext(message.contextKey)?.currentSessionId;
2160
+ const superseded = currentId !== pending.localSessionId
2161
+ || (currentId && this.store.executionGeneration(currentId) !== pending.executionGeneration)
2162
+ || this.store.inboundMessages.hasNewerMessage(message.messageId, message.contextKey, pending.localSessionId);
2163
+ const messageAt = Math.min(Date.parse(pending.createdAt), message.createdAt ?? Infinity);
2164
+ const recent = messageAt >= Date.now() - RECOVERY_ACTIVITY_WINDOW_MS;
2165
+ const allowed = message.contextKey.startsWith("console:") || allowsFeishuUser(this.config, message.userId);
2166
+ const muted = message.chatType === "group" && this.store.chatRequiresMention(baseChatContextKey(message.contextKey))
2167
+ && message.mentionedBot !== true;
2168
+ if (!allowed || muted) {
2169
+ this.store.inboundMessages.finish(message.messageId);
2170
+ continue;
2171
+ }
2172
+ const isStop = /^\/stop\s*$/iu.test(message.text.trim());
2173
+ if (pending.status === "received" && recent && !superseded && (!message.text.trimStart().startsWith("/") || isStop)) {
2174
+ this.logger.warn({ messageId: message.messageId, contextKey: message.contextKey }, "Recovering a received but unprocessed message.");
2175
+ await this.processAcceptedMessage(message, () => {
2176
+ const current = this.store.getUserContext(message.contextKey)?.currentSessionId;
2177
+ return current === pending.localSessionId
2178
+ && (!current || this.store.executionGeneration(current) === pending.executionGeneration)
2179
+ && !this.store.inboundMessages.hasNewerMessage(message.messageId, message.contextKey, pending.localSessionId)
2180
+ && messageAt >= Date.now() - RECOVERY_ACTIVITY_WINDOW_MS;
2181
+ }).catch((error) => {
2182
+ this.logger.warn({ error, messageId: message.messageId }, "Failed to recover an unprocessed message.");
2183
+ });
2184
+ continue;
2185
+ }
2186
+ if (isStop && pending.localSessionId && recent && !superseded)
2187
+ this.recoverySupersededSessions.add(pending.localSessionId);
2188
+ const reason = superseded ? "已有后续指令或任务绑定发生变化" : !recent ? "已超过 20 分钟" : "处理结果无法确认";
2189
+ await this.reportUnprocessedMessage(message, reason).then(() => {
2190
+ this.store.inboundMessages.finish(message.messageId);
2191
+ }).catch((error) => {
2192
+ this.logger.warn({ error, messageId: message.messageId }, "Failed to notify about an interrupted inbound message.");
2193
+ });
2194
+ }
2195
+ }
2196
+ async reportUnprocessedMessage(message, reason) {
2197
+ const replyTarget = message.replyInThread ? { messageId: message.messageId, replyInThread: true } : undefined;
2198
+ await this.finalizeStandaloneMessageReaction(message.messageId, "failed");
2199
+ await this.outbound.withReplyTarget(message.contextKey, replyTarget, () => this.outbound.sendText(message.contextKey, `重启前有一条消息未确认提交(${reason}),未自动重发。需要继续时请重新发送该消息。`));
2200
+ }
2071
2201
  async finishPersistedCancellationRequests() {
2072
2202
  for (const attempt of this.store.listCancellationRequestedTurnAttempts()) {
2073
2203
  if (attempt.executionGeneration === this.store.executionGeneration(attempt.localSessionId)) {
@@ -2721,13 +2851,16 @@ export class ProxySessionController {
2721
2851
  const activeTurnId = loaded.session.activeTurnId;
2722
2852
  if (activeTurnId) {
2723
2853
  const activeContextKey = this.store.getTurnContextKey(activeTurnId);
2724
- if (activeContextKey && activeContextKey !== contextKey) {
2854
+ const notificationTurn = Boolean(turnViewSnapshot(this.store.getTurnSnapshot(activeTurnId))?.taskNotificationCard);
2855
+ if ((activeContextKey && activeContextKey !== contextKey) || notificationTurn) {
2725
2856
  this.persistQueuedPrompt(record.localSessionId, contextKey, text, {
2726
2857
  localImagePaths,
2727
2858
  messageId,
2728
2859
  replyTarget,
2729
2860
  displayPrompt,
2730
2861
  });
2862
+ if (notificationTurn)
2863
+ await this.presentPromptQueueCard(record.localSessionId, contextKey);
2731
2864
  return;
2732
2865
  }
2733
2866
  try {
@@ -2755,7 +2888,8 @@ export class ProxySessionController {
2755
2888
  await this.bindMessageReactionToTurn(messageId, record.localSessionId, turnId);
2756
2889
  return;
2757
2890
  }
2758
- if (current.activeTurnId !== activeTurnId) {
2891
+ const notificationTurn = Boolean(turnViewSnapshot(this.store.getTurnSnapshot(current.activeTurnId))?.taskNotificationCard);
2892
+ if (current.activeTurnId !== activeTurnId && !notificationTurn) {
2759
2893
  try {
2760
2894
  this.assertExecutionGeneration(record.localSessionId, executionGeneration);
2761
2895
  await loaded.runtime.steerTurn(record.localSessionId, current.activeTurnId, runtimePrompt(text, localImagePaths));
@@ -2777,6 +2911,8 @@ export class ProxySessionController {
2777
2911
  replyTarget,
2778
2912
  displayPrompt,
2779
2913
  });
2914
+ if (notificationTurn)
2915
+ await this.presentPromptQueueCard(record.localSessionId, contextKey);
2780
2916
  return;
2781
2917
  }
2782
2918
  }
@@ -2793,9 +2929,9 @@ export class ProxySessionController {
2793
2929
  this.logger.warn({ error, sessionId: localSessionId, turnId, messageId }, "Failed to insert a steer message into the thinking card.");
2794
2930
  }
2795
2931
  }
2796
- async enqueueNoSteerPrompt(contextKey, text, messageId, replyTarget) {
2932
+ async enqueueNoSteerPrompt(contextKey, text, messageId, replyTarget, localImagePaths) {
2797
2933
  const record = this.requireCurrentSession(contextKey);
2798
- const queued = this.persistQueuedPrompt(record.localSessionId, contextKey, text, { messageId, replyTarget });
2934
+ const queued = this.persistQueuedPrompt(record.localSessionId, contextKey, text, { messageId, replyTarget, localImagePaths });
2799
2935
  this.store.audit(contextKey, "queued_prompt_added", {
2800
2936
  promptId: queued.promptId,
2801
2937
  localSessionId: record.localSessionId,