@tutti-os/agent-gui 0.0.36 → 0.0.37

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 (38) hide show
  1. package/dist/{AgentMessageMarkdown-0sV8Biv3.d.ts → AgentMessageMarkdown-Fv7I0HUN.d.ts} +2 -2
  2. package/dist/agent-conversation/index.d.ts +4 -4
  3. package/dist/agent-conversation/index.js +4 -4
  4. package/dist/agent-message-center/index.d.ts +2 -2
  5. package/dist/agent-message-center/index.js +4 -4
  6. package/dist/{agentConversationVM-xuzmD5IL.d.ts → agentConversationVM-1QgRwvwZ.d.ts} +1 -1
  7. package/dist/app/renderer/agentactivity.css +25 -7
  8. package/dist/{chunk-O56P2KSZ.js → chunk-5YJPISWJ.js} +53 -16
  9. package/dist/chunk-5YJPISWJ.js.map +1 -0
  10. package/dist/{chunk-JYH2ITNL.js → chunk-BQNHPMQY.js} +4 -4
  11. package/dist/{chunk-KFMD33UD.js → chunk-JL2WNRYC.js} +7 -7
  12. package/dist/chunk-JL2WNRYC.js.map +1 -0
  13. package/dist/{chunk-U3D7YI47.js → chunk-MKSRP5XS.js} +8 -7
  14. package/dist/{chunk-U3D7YI47.js.map → chunk-MKSRP5XS.js.map} +1 -1
  15. package/dist/{chunk-UN4XGHLQ.js → chunk-SXHVKUUI.js} +9 -94
  16. package/dist/chunk-SXHVKUUI.js.map +1 -0
  17. package/dist/{chunk-CMXRLF64.js → chunk-UHQDBXGH.js} +24 -3
  18. package/dist/chunk-UHQDBXGH.js.map +1 -0
  19. package/dist/{chunk-3LEUGNCT.js → chunk-WHWZZYBV.js} +2 -2
  20. package/dist/{chunk-VPC55T7P.js → chunk-XROBPALT.js} +2 -2
  21. package/dist/context-mention-palette/index.js +5 -5
  22. package/dist/i18n/index.d.ts +6 -6
  23. package/dist/i18n/index.js +1 -1
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +337 -69
  26. package/dist/index.js.map +1 -1
  27. package/dist/plan-decision-ops.d.ts +2 -2
  28. package/dist/workspace-agent-generated-files.d.ts +1 -1
  29. package/dist/workspace-agent-generated-files.js +2 -2
  30. package/dist/{workspaceAgentActivityListViewModel-DwpbJGDx.d.ts → workspaceAgentActivityListViewModel-DLnMBMoh.d.ts} +3 -4
  31. package/package.json +12 -12
  32. package/dist/chunk-CMXRLF64.js.map +0 -1
  33. package/dist/chunk-KFMD33UD.js.map +0 -1
  34. package/dist/chunk-O56P2KSZ.js.map +0 -1
  35. package/dist/chunk-UN4XGHLQ.js.map +0 -1
  36. /package/dist/{chunk-JYH2ITNL.js.map → chunk-BQNHPMQY.js.map} +0 -0
  37. /package/dist/{chunk-3LEUGNCT.js.map → chunk-WHWZZYBV.js.map} +0 -0
  38. /package/dist/{chunk-VPC55T7P.js.map → chunk-XROBPALT.js.map} +0 -0
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  AgentInteractivePromptSurface,
15
15
  approvalOptionDisplayLabel
16
- } from "./chunk-JYH2ITNL.js";
16
+ } from "./chunk-BQNHPMQY.js";
17
17
  import {
18
18
  PLAN_IMPLEMENTATION_ACTION_FEEDBACK,
19
19
  PLAN_IMPLEMENTATION_ACTION_IMPLEMENT,
@@ -37,13 +37,13 @@ import {
37
37
  skillDescriptionForDisplay,
38
38
  skillTriggerForPrefix,
39
39
  useProjectedAgentConversation
40
- } from "./chunk-O56P2KSZ.js";
40
+ } from "./chunk-5YJPISWJ.js";
41
41
  import {
42
42
  AgentMessageMarkdown,
43
43
  ZoomableImage,
44
44
  cn,
45
45
  resolveWorkspaceLinkAction
46
- } from "./chunk-CMXRLF64.js";
46
+ } from "./chunk-UHQDBXGH.js";
47
47
  import {
48
48
  AGENT_MENTION_FILTER_TAB_ORDER,
49
49
  AgentFileMentionPalette,
@@ -51,7 +51,7 @@ import {
51
51
  DEFAULT_AGENT_MENTION_FILTER,
52
52
  agentMentionItemKey,
53
53
  preloadAgentMentionBrowse
54
- } from "./chunk-U3D7YI47.js";
54
+ } from "./chunk-MKSRP5XS.js";
55
55
  import {
56
56
  WORKSPACE_AGENT_ACTIVITY_RUNTIME_SESSION_ORIGIN,
57
57
  buildWorkspaceAgentActivityListViewModel,
@@ -60,15 +60,14 @@ import {
60
60
  isWorkspaceAgentActivityRuntimeSessionOrigin,
61
61
  isWorkspaceAgentUntitledTask,
62
62
  mergeWorkspaceAgentActivityDurableAndOverlayMessages,
63
- normalizeOptionalWorkspaceAgentStatus,
64
63
  selectWorkspaceAgentActivityOverlayMessages
65
- } from "./chunk-UN4XGHLQ.js";
64
+ } from "./chunk-SXHVKUUI.js";
66
65
  import {
67
66
  MANAGED_AGENT_ICON_FALLBACK_URL,
68
67
  MANAGED_AGENT_ICON_URLS,
69
68
  Spinner,
70
69
  normalizeManagedAgentProvider
71
- } from "./chunk-3LEUGNCT.js";
70
+ } from "./chunk-WHWZZYBV.js";
72
71
  import "./chunk-MTFSQWZ6.js";
73
72
  import {
74
73
  resolveWorkspaceAgentSessionSortTimeUnixMs
@@ -79,7 +78,7 @@ import {
79
78
  mentionItemToAttrs,
80
79
  normalizeAgentSessionMentionTitle,
81
80
  parseMentionItemFromHref
82
- } from "./chunk-VPC55T7P.js";
81
+ } from "./chunk-XROBPALT.js";
83
82
  import "./chunk-Y35GDLP2.js";
84
83
  import {
85
84
  AgentActivityHostProvider,
@@ -108,12 +107,13 @@ import {
108
107
  getActiveUiLanguage,
109
108
  translate,
110
109
  useTranslation
111
- } from "./chunk-KFMD33UD.js";
110
+ } from "./chunk-JL2WNRYC.js";
112
111
  import "./chunk-LUGELG5V.js";
113
112
  import "./chunk-PJP5BUU6.js";
114
113
 
115
114
  // shared/agentActivitySnapshotProjection.ts
116
115
  import {
116
+ normalizeAgentActivityDisplayStatus,
117
117
  selectNeedsAttentionCount,
118
118
  selectNeedsAttentionItems
119
119
  } from "@tutti-os/agent-activity-core";
@@ -170,22 +170,23 @@ function agentHostPresenceFromCore(presence, index) {
170
170
  };
171
171
  }
172
172
  function agentHostSessionFromCore(session, id, presenceId) {
173
+ const displayStatus = agentActivityDisplayStatusFromSession(session);
173
174
  return {
174
175
  agentSessionId: session.agentSessionId,
175
176
  endedAtUnixMs: session.endedAtUnixMs,
176
177
  startedAtUnixMs: session.startedAtUnixMs,
177
178
  createdAtUnixMs: session.createdAtUnixMs,
178
179
  cwd: session.cwd,
179
- effectiveStatus: agentHostEffectiveStatusFromCore(session.status),
180
+ effectiveStatus: agentHostEffectiveStatusFromDisplay(displayStatus),
180
181
  id,
181
- lifecycleStatus: agentHostLifecycleStatusFromCore(session.status),
182
+ lifecycleStatus: agentHostLifecycleStatusFromDisplay(displayStatus),
182
183
  presenceId,
183
184
  pinnedAtUnixMs: session.pinnedAtUnixMs,
184
185
  provider: session.provider,
185
186
  providerSessionId: session.providerSessionId ?? session.agentSessionId,
186
187
  resumable: session.resumable ?? false,
187
188
  sessionOrigin: "WORKSPACE_AGENT_SESSION_ORIGIN_RUNTIME",
188
- status: agentHostSessionStatusFromCore(session.status),
189
+ status: agentHostSessionStatusFromDisplay(displayStatus),
189
190
  syncState: session.lastError ? {
190
191
  agentSessionId: session.agentSessionId,
191
192
  lastError: session.lastError,
@@ -194,7 +195,7 @@ function agentHostSessionFromCore(session, id, presenceId) {
194
195
  workspaceId: session.workspaceId
195
196
  } : void 0,
196
197
  title: session.title || void 0,
197
- turnPhase: agentHostTurnPhaseFromCore(session.status),
198
+ turnPhase: agentHostTurnPhaseFromDisplay(displayStatus),
198
199
  updatedAtUnixMs: session.updatedAtUnixMs ?? session.lastEventUnixMs,
199
200
  userId: session.userId?.trim() || "local",
200
201
  workspaceId: session.workspaceId
@@ -212,7 +213,7 @@ function agentHostMessageFromCore(message) {
212
213
  role: message.role,
213
214
  startedAtUnixMs: message.startedAtUnixMs,
214
215
  status: message.status ?? void 0,
215
- turnId: message.turnId ?? void 0,
216
+ turnId: message.turnId,
216
217
  version: message.version,
217
218
  workspaceId: message.workspaceId ?? ""
218
219
  };
@@ -222,6 +223,7 @@ function projectCoreSessionStatus(status) {
222
223
  }
223
224
  function agentHostSessionStatusFromCore(status) {
224
225
  switch (status) {
226
+ case "active":
225
227
  case "created":
226
228
  case "queued":
227
229
  return "ready";
@@ -233,21 +235,20 @@ function agentHostSessionStatusFromCore(status) {
233
235
  return status;
234
236
  }
235
237
  }
236
- function agentHostEffectiveStatusFromCore(status) {
237
- switch (status) {
238
- case "created":
239
- case "queued":
240
- return "ready";
241
- case "running":
242
- return "working";
243
- case "waiting":
244
- case "failed":
245
- return status;
246
- default:
247
- return "idle";
248
- }
238
+ function agentActivityDisplayStatusFromSession(session) {
239
+ return normalizeAgentActivityDisplayStatus(session.status, {
240
+ currentPhase: session.currentPhase,
241
+ turnLifecycleOutcome: session.turnLifecycle?.outcome,
242
+ turnLifecyclePhase: session.turnLifecycle?.phase
243
+ });
249
244
  }
250
- function agentHostLifecycleStatusFromCore(status) {
245
+ function agentHostSessionStatusFromDisplay(status) {
246
+ return status === "idle" ? "ready" : status;
247
+ }
248
+ function agentHostEffectiveStatusFromDisplay(status) {
249
+ return status === "idle" ? "ready" : status;
250
+ }
251
+ function agentHostLifecycleStatusFromDisplay(status) {
251
252
  switch (status) {
252
253
  case "failed":
253
254
  return "failed";
@@ -258,15 +259,12 @@ function agentHostLifecycleStatusFromCore(status) {
258
259
  return "active";
259
260
  }
260
261
  }
261
- function agentHostTurnPhaseFromCore(status) {
262
+ function agentHostTurnPhaseFromDisplay(status) {
262
263
  switch (status) {
263
- case "running":
264
264
  case "working":
265
- return "working";
266
265
  case "waiting":
267
- return "waiting";
268
266
  case "failed":
269
- return "failed";
267
+ return status;
270
268
  default:
271
269
  return "idle";
272
270
  }
@@ -2925,28 +2923,32 @@ function firstUserMessageTitleFromMessages(messages) {
2925
2923
  return userMessage ? messageText(userMessage) : "";
2926
2924
  }
2927
2925
  function workspaceAgentMessagesFromTimelineItems(timelineItems) {
2928
- return timelineItems.map((item, index) => ({
2929
- id: item.id,
2930
- workspaceId: item.workspaceId,
2931
- agentSessionId: item.agentSessionId,
2932
- messageId: item.eventId || `${item.agentSessionId}:${item.id}:${index}`,
2933
- version: item.seq ?? item.id,
2934
- ...item.turnId ? { turnId: item.turnId } : {},
2935
- role: item.role ?? timelineItemRole(item) ?? item.actorType,
2936
- kind: item.itemType === "call" ? "tool_call" : item.itemType,
2937
- ...item.status ? { status: item.status } : {},
2938
- payload: {
2939
- ...item.payload,
2940
- content: item.payload?.content ?? item.content,
2941
- text: item.payload?.text ?? item.content,
2942
- callType: item.callType,
2943
- callId: item.callId,
2944
- name: item.name
2945
- },
2946
- occurredAtUnixMs: item.occurredAtUnixMs ?? item.createdAtUnixMs,
2947
- startedAtUnixMs: item.createdAtUnixMs,
2948
- completedAtUnixMs: item.occurredAtUnixMs
2949
- }));
2926
+ return timelineItems.map((item, index) => {
2927
+ const messageId = item.eventId || `${item.agentSessionId}:${item.id}:${index}`;
2928
+ const version = item.seq ?? item.id;
2929
+ return {
2930
+ id: item.id,
2931
+ workspaceId: item.workspaceId,
2932
+ agentSessionId: item.agentSessionId,
2933
+ messageId,
2934
+ version,
2935
+ turnId: item.turnId || `timeline:${messageId}`,
2936
+ role: item.role ?? timelineItemRole(item) ?? item.actorType,
2937
+ kind: item.itemType === "call" ? "tool_call" : item.itemType,
2938
+ ...item.status ? { status: item.status } : {},
2939
+ payload: {
2940
+ ...item.payload,
2941
+ content: item.payload?.content ?? item.content,
2942
+ text: item.payload?.text ?? item.content,
2943
+ callType: item.callType,
2944
+ callId: item.callId,
2945
+ name: item.name
2946
+ },
2947
+ occurredAtUnixMs: item.occurredAtUnixMs ?? item.createdAtUnixMs ?? version,
2948
+ startedAtUnixMs: item.createdAtUnixMs,
2949
+ completedAtUnixMs: item.occurredAtUnixMs
2950
+ };
2951
+ });
2950
2952
  }
2951
2953
  function messageRole(message) {
2952
2954
  const role = message.role?.trim().toLowerCase();
@@ -3354,6 +3356,120 @@ function agentPromptFileBlockToDraftFile(file, idPrefix, index) {
3354
3356
  };
3355
3357
  }
3356
3358
 
3359
+ // shared/workspaceAgentStatusNormalizer.ts
3360
+ var FAILED_STATUS_TOKENS = /* @__PURE__ */ new Set(["failed", "error"]);
3361
+ var CANCELED_STATUS_TOKENS = /* @__PURE__ */ new Set([
3362
+ "canceled",
3363
+ "cancelled",
3364
+ "interrupted"
3365
+ ]);
3366
+ var COMPLETED_STATUS_TOKENS = /* @__PURE__ */ new Set(["completed", "ended", "end"]);
3367
+ var WAITING_APPROVAL_TOKENS = /* @__PURE__ */ new Set([
3368
+ "waiting_approval",
3369
+ "awaiting_approval"
3370
+ ]);
3371
+ var WAITING_INPUT_TOKENS = /* @__PURE__ */ new Set(["waiting_input"]);
3372
+ var WAITING_STATUS_TOKENS = /* @__PURE__ */ new Set(["waiting"]);
3373
+ var WORKING_STATUS_TOKENS = /* @__PURE__ */ new Set([
3374
+ "submitted",
3375
+ "working",
3376
+ "running",
3377
+ "streaming"
3378
+ ]);
3379
+ var READY_STATUS_TOKENS = /* @__PURE__ */ new Set(["ready", "idle"]);
3380
+ function normalizeOptionalWorkspaceAgentStatus(input) {
3381
+ const lifecycleStatus = normalizeStatusToken(input.lifecycleStatus);
3382
+ const effectiveStatus = normalizeStatusToken(input.effectiveStatus);
3383
+ const sessionStatus = normalizeStatusToken(input.status);
3384
+ const turnLifecycleOutcome = normalizeStatusToken(
3385
+ input.turnLifecycle?.outcome
3386
+ );
3387
+ const turnPhase = normalizeStatusToken(
3388
+ input.turnLifecycle?.phase ?? input.turnPhase
3389
+ );
3390
+ const currentPhase = normalizeStatusToken(input.currentPhase);
3391
+ const tokens = [
3392
+ lifecycleStatus,
3393
+ effectiveStatus,
3394
+ sessionStatus,
3395
+ turnPhase,
3396
+ currentPhase
3397
+ ].filter(Boolean);
3398
+ if (tokens.length === 0) {
3399
+ return null;
3400
+ }
3401
+ if (turnPhase === "settled") {
3402
+ if (FAILED_STATUS_TOKENS.has(turnLifecycleOutcome)) {
3403
+ return { kind: "failed" };
3404
+ }
3405
+ if (CANCELED_STATUS_TOKENS.has(turnLifecycleOutcome)) {
3406
+ return { kind: "canceled" };
3407
+ }
3408
+ if (COMPLETED_STATUS_TOKENS.has(turnLifecycleOutcome)) {
3409
+ return { kind: "completed" };
3410
+ }
3411
+ if (FAILED_STATUS_TOKENS.has(sessionStatus) || FAILED_STATUS_TOKENS.has(currentPhase)) {
3412
+ return { kind: "failed" };
3413
+ }
3414
+ if (CANCELED_STATUS_TOKENS.has(sessionStatus) || CANCELED_STATUS_TOKENS.has(currentPhase)) {
3415
+ return { kind: "canceled" };
3416
+ }
3417
+ return { kind: "completed" };
3418
+ }
3419
+ if ([lifecycleStatus, effectiveStatus, sessionStatus, currentPhase].some(
3420
+ (token) => FAILED_STATUS_TOKENS.has(token)
3421
+ )) {
3422
+ return { kind: "failed" };
3423
+ }
3424
+ if ([lifecycleStatus, effectiveStatus, sessionStatus].some(
3425
+ (token) => CANCELED_STATUS_TOKENS.has(token)
3426
+ )) {
3427
+ return { kind: "canceled" };
3428
+ }
3429
+ if ([lifecycleStatus, effectiveStatus, sessionStatus].some(
3430
+ (token) => COMPLETED_STATUS_TOKENS.has(token)
3431
+ )) {
3432
+ return { kind: "completed" };
3433
+ }
3434
+ const waitKind = waitingKindFromTokens([
3435
+ currentPhase,
3436
+ turnPhase,
3437
+ effectiveStatus,
3438
+ sessionStatus
3439
+ ]);
3440
+ if (waitKind) {
3441
+ return { kind: "waiting", waitKind };
3442
+ }
3443
+ if ([currentPhase, turnPhase, effectiveStatus, sessionStatus].some(
3444
+ (token) => WAITING_STATUS_TOKENS.has(token)
3445
+ )) {
3446
+ return { kind: "waiting" };
3447
+ }
3448
+ if ([currentPhase, turnPhase, effectiveStatus, sessionStatus].some(
3449
+ (token) => WORKING_STATUS_TOKENS.has(token)
3450
+ )) {
3451
+ return { kind: "working" };
3452
+ }
3453
+ if (lifecycleStatus === "active" || lifecycleStatus === "ready" || [currentPhase, turnPhase, effectiveStatus, sessionStatus].some(
3454
+ (token) => READY_STATUS_TOKENS.has(token)
3455
+ )) {
3456
+ return { kind: "ready" };
3457
+ }
3458
+ return null;
3459
+ }
3460
+ function waitingKindFromTokens(tokens) {
3461
+ if (tokens.some((token) => WAITING_APPROVAL_TOKENS.has(token))) {
3462
+ return "approval";
3463
+ }
3464
+ if (tokens.some((token) => WAITING_INPUT_TOKENS.has(token))) {
3465
+ return "input";
3466
+ }
3467
+ return void 0;
3468
+ }
3469
+ function normalizeStatusToken(status) {
3470
+ return status?.trim().toLowerCase() ?? "";
3471
+ }
3472
+
3357
3473
  // shared/agentConversation/projection/workspaceAgentMessageProjection.ts
3358
3474
  function projectWorkspaceAgentMessagesToTimelineItems(messages) {
3359
3475
  const sortedMessages = latestMessageSnapshots(messages).sort(
@@ -6459,6 +6575,7 @@ var EMPTY_AGENT_GUI_MESSAGES = [];
6459
6575
  var EMPTY_AGENT_GUI_AVAILABLE_COMMANDS = [];
6460
6576
  var ACTIVITY_STREAM_STATE_RELOAD_DEBOUNCE_MS = 150;
6461
6577
  var AGENT_GUI_DETAIL_MESSAGES_PAGE_SIZE = 100;
6578
+ var AGENT_GUI_SUBMIT_RETARGET_EARLY_MESSAGE_TOLERANCE_MS = 5e3;
6462
6579
  function mergeAgentModelCatalogInvalidationEvents(events) {
6463
6580
  const providers = /* @__PURE__ */ new Set();
6464
6581
  let occurredAtUnixMs = 0;
@@ -7052,8 +7169,18 @@ function filterMessagesForDetailWindowOverlay(input) {
7052
7169
  return newestDurableVersion !== null && Number.isFinite(message.version) && message.version >= newestDurableVersion;
7053
7170
  });
7054
7171
  }
7055
- const oldestDetailVersion = minFiniteMessageVersion(input.detailMessages);
7056
- const newestDetailVersion = maxFiniteMessageVersion(input.detailMessages);
7172
+ const boundedDetailMessages = input.detailMessages.filter(
7173
+ (message) => !isWorkspaceAgentActivityOptimisticMessage(message)
7174
+ );
7175
+ const oldestDetailVersion = minFiniteMessageVersion(boundedDetailMessages);
7176
+ const newestDetailVersion = maxFiniteMessageVersion(boundedDetailMessages);
7177
+ if (oldestDetailVersion === null && newestDetailVersion === null) {
7178
+ const optimisticWindowMessages = filterMessagesForOptimisticDetailWindow({
7179
+ detailMessages: input.detailMessages,
7180
+ localMessages: input.localMessages
7181
+ });
7182
+ return optimisticWindowMessages.length > 0 || input.detailMessages.some(isWorkspaceAgentActivityOptimisticMessage) ? optimisticWindowMessages : [...input.localMessages];
7183
+ }
7057
7184
  return input.localMessages.filter((message) => {
7058
7185
  if (isWorkspaceAgentActivityOptimisticMessage(message)) {
7059
7186
  return true;
@@ -7067,6 +7194,69 @@ function filterMessagesForDetailWindowOverlay(input) {
7067
7194
  return oldestDetailVersion !== null && message.version >= oldestDetailVersion;
7068
7195
  });
7069
7196
  }
7197
+ function filterMessagesForOptimisticDetailWindow(input) {
7198
+ const optimisticTurnIds = new Set(
7199
+ input.detailMessages.filter(isWorkspaceAgentActivityOptimisticMessage).map((message) => message.turnId?.trim() ?? "").filter(Boolean)
7200
+ );
7201
+ if (optimisticTurnIds.size === 0) {
7202
+ return [];
7203
+ }
7204
+ return input.localMessages.filter((message) => {
7205
+ if (isWorkspaceAgentActivityOptimisticMessage(message)) {
7206
+ return true;
7207
+ }
7208
+ const turnId = message.turnId?.trim() ?? "";
7209
+ return turnId !== "" && optimisticTurnIds.has(turnId);
7210
+ });
7211
+ }
7212
+ function retargetOptimisticPromptMessages(messages, input) {
7213
+ const clientSubmitId = input.clientSubmitId.trim();
7214
+ const turnId = input.turnId.trim();
7215
+ if (!clientSubmitId || !turnId || messages.length === 0) {
7216
+ return { changed: false, messages: [...messages] };
7217
+ }
7218
+ const pendingTurnId = createPendingOptimisticTurnId(clientSubmitId);
7219
+ let changed = false;
7220
+ const retargeted = messages.map((message) => {
7221
+ if (!isWorkspaceAgentActivityOptimisticMessage(message) || message.turnId?.trim() !== pendingTurnId) {
7222
+ return message;
7223
+ }
7224
+ const messageClientSubmitId = message.payload?.clientSubmitId;
7225
+ if (typeof messageClientSubmitId === "string" && messageClientSubmitId.trim() && messageClientSubmitId.trim() !== clientSubmitId) {
7226
+ return message;
7227
+ }
7228
+ changed = true;
7229
+ return { ...message, turnId };
7230
+ });
7231
+ return { changed, messages: retargeted };
7232
+ }
7233
+ function shouldRetargetOptimisticPromptFromMessage(message, trace) {
7234
+ const turnId = message.turnId?.trim() ?? "";
7235
+ if (!turnId || trace.turnId) {
7236
+ return false;
7237
+ }
7238
+ const clientSubmitId = stringPayloadValue2(message.payload, "clientSubmitId");
7239
+ if (clientSubmitId?.trim()) {
7240
+ return clientSubmitId.trim() === trace.clientSubmitId;
7241
+ }
7242
+ if (message.role.trim().toLowerCase() === "user") {
7243
+ return false;
7244
+ }
7245
+ const messageTimeUnixMs = messageActivityTimeUnixMs(message);
7246
+ return messageTimeUnixMs === null || messageTimeUnixMs >= trace.startedAtUnixMs - AGENT_GUI_SUBMIT_RETARGET_EARLY_MESSAGE_TOLERANCE_MS;
7247
+ }
7248
+ function messageActivityTimeUnixMs(message) {
7249
+ for (const value of [
7250
+ message.occurredAtUnixMs,
7251
+ message.startedAtUnixMs,
7252
+ message.completedAtUnixMs
7253
+ ]) {
7254
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) {
7255
+ return value;
7256
+ }
7257
+ }
7258
+ return null;
7259
+ }
7070
7260
  function minFiniteMessageVersion(messages) {
7071
7261
  let result = null;
7072
7262
  for (const message of messages) {
@@ -7924,7 +8114,7 @@ function messageFromMessageUpdate(update) {
7924
8114
  agentSessionId: update.agentSessionId,
7925
8115
  messageId: update.messageId.trim() || `message:${id}`,
7926
8116
  version: id,
7927
- ...update.turnId?.trim() ? { turnId: update.turnId.trim() } : {},
8117
+ turnId: update.turnId.trim(),
7928
8118
  role,
7929
8119
  kind,
7930
8120
  status: update.status,
@@ -7933,7 +8123,7 @@ function messageFromMessageUpdate(update) {
7933
8123
  ...isToolCall && update.callId?.trim() ? { callId: update.callId.trim() } : {},
7934
8124
  ...isToolCall && update.title?.trim() ? { title: update.title.trim() } : {}
7935
8125
  },
7936
- ...update.occurredAtUnixMs !== void 0 ? { occurredAtUnixMs: update.occurredAtUnixMs } : {},
8126
+ occurredAtUnixMs: update.occurredAtUnixMs,
7937
8127
  ...update.startedAtUnixMs !== void 0 ? { startedAtUnixMs: update.startedAtUnixMs } : {},
7938
8128
  ...update.completedAtUnixMs !== void 0 ? { completedAtUnixMs: update.completedAtUnixMs } : {}
7939
8129
  };
@@ -8487,10 +8677,22 @@ function useAgentGUINodeController({
8487
8677
  useEffect4(() => {
8488
8678
  const externalId = data.lastActiveAgentSessionId?.trim() ?? "";
8489
8679
  if (externalId === (activeConversationIdRef.current ?? "")) return;
8490
- setIntent((current) => {
8491
- if (!externalId) {
8492
- return current.tag !== "home" ? { tag: "home" } : current;
8680
+ if (!externalId) {
8681
+ const previous = activeConversationIdRef.current;
8682
+ if (previous) {
8683
+ void activation.unactivate(previous);
8493
8684
  }
8685
+ setIntent({ tag: "home" });
8686
+ isComposerHomeRef.current = true;
8687
+ setIsComposerHome(true);
8688
+ activeConversationIdRef.current = null;
8689
+ setActiveConversationId(null);
8690
+ setIsLoadingMessages(false);
8691
+ setDetailError(null);
8692
+ loadDraftComposerOptions();
8693
+ return;
8694
+ }
8695
+ setIntent((current) => {
8494
8696
  if ((current.tag === "active" || current.tag === "requested") && current.id === externalId) {
8495
8697
  return current;
8496
8698
  }
@@ -9825,6 +10027,42 @@ function useAgentGUINodeController({
9825
10027
  sessionViewRef
9826
10028
  ]
9827
10029
  );
10030
+ const retargetOptimisticPromptTurn = useCallback4(
10031
+ (agentSessionId, clientSubmitId, turnId) => {
10032
+ const normalizedAgentSessionId = agentSessionId.trim();
10033
+ const normalizedTurnId = turnId.trim();
10034
+ if (!normalizedAgentSessionId || !clientSubmitId.trim() || !normalizedTurnId) {
10035
+ return;
10036
+ }
10037
+ const sessionView = getAgentSessionView(
10038
+ sessionViewRef(normalizedAgentSessionId)
10039
+ );
10040
+ if (!sessionView) {
10041
+ return;
10042
+ }
10043
+ const detail = retargetOptimisticPromptMessages(
10044
+ sessionView.detailMessages,
10045
+ { clientSubmitId, turnId: normalizedTurnId }
10046
+ );
10047
+ if (detail.changed) {
10048
+ setAgentSessionViewDetailMessages(
10049
+ sessionViewRef(normalizedAgentSessionId),
10050
+ detail.messages
10051
+ );
10052
+ }
10053
+ const overlay = retargetOptimisticPromptMessages(
10054
+ sessionView.overlayMessages,
10055
+ { clientSubmitId, turnId: normalizedTurnId }
10056
+ );
10057
+ if (overlay.changed) {
10058
+ setAgentSessionViewOverlayMessages(
10059
+ sessionViewRef(normalizedAgentSessionId),
10060
+ overlay.messages
10061
+ );
10062
+ }
10063
+ },
10064
+ [sessionViewRef]
10065
+ );
9828
10066
  const applyStatePatch = useCallback4(
9829
10067
  (patch) => {
9830
10068
  const agentSessionId = patch.agentSessionId.trim();
@@ -9842,11 +10080,8 @@ function useAgentGUINodeController({
9842
10080
  const structuredTurnPhase = patch.turn?.phase?.trim() ?? "";
9843
10081
  const submitTrace = submitTraceBySessionIdRef.current[agentSessionId];
9844
10082
  if (submitTrace && structuredTurnPhase) {
9845
- const matchesTraceTurn = !submitTrace.turnId || patchTurnId === submitTrace.turnId || patchActiveTurnId === submitTrace.turnId;
10083
+ const matchesTraceTurn = Boolean(submitTrace.turnId) && (patchTurnId === submitTrace.turnId || patchActiveTurnId === submitTrace.turnId);
9846
10084
  if (matchesTraceTurn) {
9847
- if (!submitTrace.turnId && (patchTurnId || patchActiveTurnId)) {
9848
- submitTrace.turnId = patchTurnId || patchActiveTurnId;
9849
- }
9850
10085
  reportAgentSubmitTraceDiagnostic({
9851
10086
  event: `lifecycle.${structuredTurnPhase}`,
9852
10087
  runtime: agentActivityRuntime,
@@ -9959,6 +10194,7 @@ function useAgentGUINodeController({
9959
10194
  [
9960
10195
  patchConversation,
9961
10196
  resolveSessionMessages,
10197
+ retargetOptimisticPromptTurn,
9962
10198
  sessionViewRef,
9963
10199
  setTransientConversation,
9964
10200
  statePatchErrorBySessionId,
@@ -10001,6 +10237,16 @@ function useAgentGUINodeController({
10001
10237
  if (!agentSessionId) {
10002
10238
  continue;
10003
10239
  }
10240
+ const submitTrace = submitTraceBySessionIdRef.current[agentSessionId];
10241
+ const messageTurnId = message.turnId?.trim() ?? "";
10242
+ if (submitTrace && messageTurnId && shouldRetargetOptimisticPromptFromMessage(message, submitTrace)) {
10243
+ submitTrace.turnId = messageTurnId;
10244
+ retargetOptimisticPromptTurn(
10245
+ agentSessionId,
10246
+ submitTrace.clientSubmitId,
10247
+ messageTurnId
10248
+ );
10249
+ }
10004
10250
  const completionKey = completionKeyFromMessage(message);
10005
10251
  if (completionKey) {
10006
10252
  pendingCompletionKeysBySessionId.set(agentSessionId, completionKey);
@@ -10024,7 +10270,8 @@ function useAgentGUINodeController({
10024
10270
  applyStatePatch,
10025
10271
  applyBackgroundTimelineStatusUpdate,
10026
10272
  conversationListQuery,
10027
- recordLocalMessages
10273
+ recordLocalMessages,
10274
+ retargetOptimisticPromptTurn
10028
10275
  ]
10029
10276
  );
10030
10277
  const handleBackgroundActivityStreamEvents = useCallback4(
@@ -18652,6 +18899,22 @@ function AgentComposer({
18652
18899
  setFileMentionSuggestion(null);
18653
18900
  setIsPaletteOpen(false);
18654
18901
  }, [fileMentionSuggestion]);
18902
+ const clearActiveFileMentionTrigger = useCallback9(() => {
18903
+ if (!fileMentionSuggestion) {
18904
+ return;
18905
+ }
18906
+ const triggerLength = Math.max(
18907
+ fileMentionSuggestion.range.to - fileMentionSuggestion.range.from,
18908
+ fileMentionSuggestion.text.length
18909
+ );
18910
+ const nextDraft = triggerLength > 0 ? editorHandleRef.current?.replaceTextBeforeSelection(triggerLength, "") : null;
18911
+ if (nextDraft === null || nextDraft === void 0) {
18912
+ return;
18913
+ }
18914
+ draftPromptRef.current = nextDraft;
18915
+ setPaletteDraftPrompt(nextDraft);
18916
+ onDraftContentChange({ ...draftContent, prompt: nextDraft });
18917
+ }, [draftContent, fileMentionSuggestion, onDraftContentChange]);
18655
18918
  const closeOpenPalette = useCallback9(() => {
18656
18919
  if (showFileMentionPalette) {
18657
18920
  closeFileMentionPalette();
@@ -19063,6 +19326,7 @@ function AgentComposer({
19063
19326
  }, [applyReferencePickResult, onRequestWorkspaceReferences]);
19064
19327
  const handleOpenReferencesForEntity = useCallback9(
19065
19328
  (entity) => {
19329
+ clearActiveFileMentionTrigger();
19066
19330
  closeFileMentionPalette();
19067
19331
  if (!onRequestWorkspaceReferences) {
19068
19332
  return;
@@ -19072,6 +19336,7 @@ function AgentComposer({
19072
19336
  );
19073
19337
  },
19074
19338
  [
19339
+ clearActiveFileMentionTrigger,
19075
19340
  closeFileMentionPalette,
19076
19341
  applyReferencePickResult,
19077
19342
  onRequestWorkspaceReferences
@@ -20371,6 +20636,9 @@ function resolveAgentGUIHeroIconUrl(provider) {
20371
20636
  const normalizedProvider = normalizeManagedAgentProvider(provider);
20372
20637
  return MANAGED_AGENT_ICON_URLS[normalizedProvider] ?? MANAGED_AGENT_ICON_FALLBACK_URL;
20373
20638
  }
20639
+ function shouldEmphasizeEmptyHeroProvider(label) {
20640
+ return !/[\u3400-\u9fff]/u.test(label);
20641
+ }
20374
20642
  var fallbackWorkspaceFileReferenceCopy = {
20375
20643
  t(key, values) {
20376
20644
  return values ? `${key}:${JSON.stringify(values)}` : key;
@@ -22148,7 +22416,7 @@ function EmptyHeroTitle({
22148
22416
  providerLabel
22149
22417
  }) {
22150
22418
  const providerStart = providerLabel ? label.indexOf(providerLabel) : -1;
22151
- if (providerStart < 0) {
22419
+ if (!shouldEmphasizeEmptyHeroProvider(label) || providerStart < 0) {
22152
22420
  return /* @__PURE__ */ jsx29(Fragment8, { children: label });
22153
22421
  }
22154
22422
  const providerEnd = providerStart + providerLabel.length;
@@ -22805,7 +23073,7 @@ var AgentGUIConversationRailSection = memo(
22805
23073
  /* @__PURE__ */ jsx29(
22806
23074
  TooltipContent3,
22807
23075
  {
22808
- side: "right",
23076
+ side: "top",
22809
23077
  sideOffset: 6,
22810
23078
  className: AgentGUINode_styles_default.conversationSectionActionTooltip,
22811
23079
  children: createConversationLabel