@m6d/cortex-angular 1.10.0 → 1.12.0

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.
@@ -1395,6 +1395,7 @@ class CortexChatService {
1395
1395
  dispatchedToolCalls = new Set;
1396
1396
  ownsRun = false;
1397
1397
  serverAnswered = false;
1398
+ streamDropped = false;
1398
1399
  wasAborted = false;
1399
1400
  pendingThreadCreation = undefined;
1400
1401
  refreshing = Promise.resolve();
@@ -1534,6 +1535,7 @@ class CortexChatService {
1534
1535
  this.serverAnswered = true;
1535
1536
  },
1536
1537
  onError: () => {
1538
+ this.streamDropped = true;
1537
1539
  this.events.next(this.serverAnswered ? "onFinish" : "onError");
1538
1540
  }
1539
1541
  });
@@ -1541,6 +1543,7 @@ class CortexChatService {
1541
1543
  effect(() => {
1542
1544
  if (chat.isLoading()) {
1543
1545
  wasWorking = true;
1546
+ this.streamDropped = false;
1544
1547
  return;
1545
1548
  }
1546
1549
  if (!wasWorking)
@@ -1584,8 +1587,14 @@ class CortexChatService {
1584
1587
  this.wasAborted = false;
1585
1588
  return;
1586
1589
  }
1587
- if (this.ownsRun && this.dispatchPendingToolCalls(threadId))
1588
- return;
1590
+ if (this.ownsRun) {
1591
+ if (this.dispatchPendingToolCalls(threadId))
1592
+ return;
1593
+ if (this.streamDropped)
1594
+ this.threadService.reload().subscribe({ error: () => {} });
1595
+ else
1596
+ this.threadService.setRunning(threadId, false);
1597
+ }
1589
1598
  await this.refreshMessages(threadId);
1590
1599
  }
1591
1600
  refreshMessages(threadId) {
@@ -2120,8 +2129,8 @@ class ChatLandingComponent {
2120
2129
  chatService = inject(CortexChatService);
2121
2130
  threadService = inject(CortexThreadService);
2122
2131
  translateService = inject(TranslateService);
2123
- greeting = computed(() => localized(this.config().greeting, this.config().locale ?? "en"), ...ngDevMode ? [{ debugName: "greeting" }] : []);
2124
- suggestions = computed(() => localized(this.config().suggestions, this.config().locale ?? "en"), ...ngDevMode ? [{ debugName: "suggestions" }] : []);
2132
+ greeting = computed(() => localized(this.chatService.capabilities()?.greeting, this.config().locale ?? "en") || null, ...ngDevMode ? [{ debugName: "greeting" }] : []);
2133
+ suggestions = computed(() => localized(this.chatService.capabilities()?.suggestions, this.config().locale ?? "en"), ...ngDevMode ? [{ debugName: "suggestions" }] : []);
2125
2134
  ready = computed(() => this.chatService.capabilities() !== undefined, ...ngDevMode ? [{ debugName: "ready" }] : []);
2126
2135
  headless = computed(() => this.chatService.capabilities()?.messages === false, ...ngDevMode ? [{ debugName: "headless" }] : []);
2127
2136
  sendSuggestion(suggestion) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m6d/cortex-angular",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Reusable AI agent chat UI library for Angular",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -72,6 +72,10 @@ export type AgentCapabilities = {
72
72
  attachments: boolean;
73
73
  /** False when the agent's `message` trigger is off: the widget hides its composer. */
74
74
  messages: boolean;
75
+ /** Prompt chips on the blank-chat landing per locale, the runtime contract's `suggestionsSchema` shape; clicking one sends it as the first message. */
76
+ suggestions: Record<"en" | "ar", string[]>;
77
+ /** Headline of the blank-chat landing per locale; "" falls back to the widget's built-in copy. */
78
+ greeting: Record<"en" | "ar", string>;
75
79
  };
76
80
  export type MessageMetadata = {
77
81
  modelId?: string;
@@ -148,10 +152,6 @@ export type CortexConfig = {
148
152
  * or a map keyed by locale (`{ en: 'Support', ar: 'الدعم' }`).
149
153
  */
150
154
  agentName?: Localized<string>;
151
- /** Headline of the blank-chat landing; defaults to a localized greeting. */
152
- greeting?: Localized<string>;
153
- /** Prompt chips on the blank-chat landing; clicking one sends it as the first message. */
154
- suggestions?: Localized<string[]>;
155
155
  showDebugButton?: boolean;
156
156
  /**
157
157
  * Render embedded tool pages served from this page's own origin with their
@@ -274,6 +274,13 @@ declare class CortexChatService {
274
274
  * carrying; after it, those files are on the message the server stored.
275
275
  */
276
276
  private serverAnswered;
277
+ /**
278
+ * The stream ended on a transport error rather than the server's close.
279
+ * Generation runs detached from the request, so the run may still be live
280
+ * whether or not a chunk arrived first. Reset on every stream start, so a
281
+ * client-tool continuation judges its own stream.
282
+ */
283
+ private streamDropped;
277
284
  private wasAborted;
278
285
  private pendingThreadCreation;
279
286
  private refreshing;