mastracode 0.20.1-alpha.3 → 0.20.1-alpha.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.20.1-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed mode switching delay — Shift+Tab now updates instantly. Fixed modal lag when opening /om and /models. Fixed duplicate messages appearing when queueing with Ctrl+F. Blocked mode switching while agent is active. ([#17008](https://github.com/mastra-ai/mastra/pull/17008))
8
+
9
+ - Fix Mastra Code TUI crash when ask_user option labels are wider than the terminal — long labels now wrap inside the bordered box, matching how question text already wraps. Reported in #17002. ([#17005](https://github.com/mastra-ai/mastra/pull/17005))
10
+
11
+ - Updated dependencies [[`6096445`](https://github.com/mastra-ai/mastra/commit/60964459733f0ab384584d95e19c36607ffdf7b0), [`91cf0e0`](https://github.com/mastra-ai/mastra/commit/91cf0e027e511b871481a8576b56b7af83b15afd)]:
12
+ - @mastra/core@1.37.0-alpha.5
13
+
14
+ ## 0.20.1-alpha.4
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [[`b7286f4`](https://github.com/mastra-ai/mastra/commit/b7286f4308267f5fd70e6bfee10dba9472640906), [`a481027`](https://github.com/mastra-ai/mastra/commit/a481027b549ba1018414990c8f045eaee7b9f413), [`801baa0`](https://github.com/mastra-ai/mastra/commit/801baa07cccdbaec1d00942a92bdc831111744a2), [`b3c3b18`](https://github.com/mastra-ai/mastra/commit/b3c3b189121489a3a51a8fd8204b569be9a89fe5)]:
19
+ - @mastra/core@1.37.0-alpha.4
20
+
3
21
  ## 0.20.1-alpha.3
4
22
 
5
23
  ### Patch Changes
@@ -205,32 +205,40 @@ var AskQuestionBorderedBox = class {
205
205
  }
206
206
  }
207
207
  addLine("", 0);
208
+ const continuationPrefix = " ";
209
+ const addWrappedOptionLine = (prefix, label, style) => {
210
+ const prefixVis = piTui.visibleWidth(prefix);
211
+ const wrapped = piTui.wrapTextWithAnsi(label, Math.max(1, innerWidth - prefixVis));
212
+ wrapped.forEach((line, index) => {
213
+ const linePrefix = index === 0 ? prefix : continuationPrefix;
214
+ const content = `${linePrefix}${style(line)}`;
215
+ addLine(content, piTui.visibleWidth(linePrefix) + piTui.visibleWidth(line));
216
+ });
217
+ };
208
218
  if (this.streaming) {
219
+ const dim = (s) => chunk5SWBONRN_cjs.theme.fg("dim", s);
209
220
  for (const item of this.items) {
210
- const line = chunk5SWBONRN_cjs.theme.fg("dim", ` ${item.label}`);
211
- addLine(line, piTui.visibleWidth(line));
221
+ addWrappedOptionLine(continuationPrefix, item.label, dim);
212
222
  }
213
223
  const waiting = chunk5SWBONRN_cjs.theme.fg("dim", "\u2026");
214
224
  addLine(waiting, piTui.visibleWidth(waiting));
215
225
  } else if (this.answered && this.items.length > 0) {
226
+ const dim = (s) => chunk5SWBONRN_cjs.theme.fg("dim", s);
216
227
  if (this.cancelled) {
217
228
  for (const item of this.items) {
218
- const line = chunk5SWBONRN_cjs.theme.fg("dim", ` ${item.label}`);
219
- addLine(line, piTui.visibleWidth(line));
229
+ addWrappedOptionLine(continuationPrefix, item.label, dim);
220
230
  }
221
231
  const cancelLine = `${chunk5SWBONRN_cjs.theme.fg("error", "\u2717")} ${chunk5SWBONRN_cjs.theme.fg("dim", "(cancelled)")}`;
222
232
  addLine(cancelLine, piTui.visibleWidth(cancelLine));
223
233
  } else {
234
+ const text = (s) => chunk5SWBONRN_cjs.theme.fg("text", s);
224
235
  for (const item of this.items) {
225
236
  const isSelected = item.label === this.selectedValue;
226
237
  if (isSelected) {
227
238
  const icon = this.answerIsNegative ? chunk5SWBONRN_cjs.theme.fg("error", "\u2717") : chunk5SWBONRN_cjs.theme.fg("success", "\u2713");
228
- const label = chunk5SWBONRN_cjs.theme.fg("text", item.label);
229
- const line = `${icon} ${label}`;
230
- addLine(line, piTui.visibleWidth(line));
239
+ addWrappedOptionLine(`${icon} `, item.label, text);
231
240
  } else {
232
- const line = chunk5SWBONRN_cjs.theme.fg("dim", ` ${item.label}`);
233
- addLine(line, piTui.visibleWidth(line));
241
+ addWrappedOptionLine(continuationPrefix, item.label, dim);
234
242
  }
235
243
  }
236
244
  }
@@ -238,10 +246,10 @@ var AskQuestionBorderedBox = class {
238
246
  } else if (this.answered && this.selectedValue != null) {
239
247
  const icon = this.answerIsNegative ? chunk5SWBONRN_cjs.theme.fg("error", "\u2717") : chunk5SWBONRN_cjs.theme.fg("success", "\u2713");
240
248
  const iconPrefix = `${icon} `;
241
- const continuationPrefix = " ";
249
+ const continuationPrefix2 = " ";
242
250
  const wrappedAnswer = piTui.wrapTextWithAnsi(this.selectedValue, Math.max(1, innerWidth - piTui.visibleWidth(iconPrefix)));
243
251
  wrappedAnswer.forEach((line, index) => {
244
- const prefix = index === 0 ? iconPrefix : continuationPrefix;
252
+ const prefix = index === 0 ? iconPrefix : continuationPrefix2;
245
253
  const content = `${prefix}${chunk5SWBONRN_cjs.theme.fg("text", line)}`;
246
254
  addLine(content, piTui.visibleWidth(prefix) + piTui.visibleWidth(line));
247
255
  });
@@ -1031,7 +1039,7 @@ function getInstallCommand(pm, version) {
1031
1039
  }
1032
1040
  function getCurrentVersion() {
1033
1041
  {
1034
- return "0.20.1-alpha.3";
1042
+ return "0.20.1-alpha.5";
1035
1043
  }
1036
1044
  }
1037
1045
  async function fetchLatestVersion() {
@@ -4227,12 +4235,10 @@ function formatMarker(data) {
4227
4235
  const msgTokens = formatTokens(data.tokensActivated);
4228
4236
  const obsTokens = formatTokens(data.observationTokens);
4229
4237
  const label2 = data.activationCount && data.activationCount > 1 ? `${data.activationCount} observations` : "observations";
4230
- return chunk5SWBONRN_cjs.theme.fg("success", ` \u2713 Activated ${label2}: -${msgTokens} msg tokens, +${obsTokens} obs tokens`);
4231
- }
4232
- case "om_activation_ttl": {
4238
+ const idleSuffix = data.activateAfterIdle !== void 0 ? ` (${formatDuration(data.activateAfterIdle)} idle timeout)` : "";
4233
4239
  return chunk5SWBONRN_cjs.theme.fg(
4234
- "muted",
4235
- ` Idle timeout (${formatDuration(data.activateAfterIdle)}) exceeded by ${formatDuration(data.ttlExpiredMs)}, activating observations`
4240
+ "success",
4241
+ ` \u2713 Activated ${label2}: -${msgTokens} msg tokens, +${obsTokens} obs tokens${idleSuffix}`
4236
4242
  );
4237
4243
  }
4238
4244
  case "om_activation_provider_change": {
@@ -8377,6 +8383,14 @@ function addUserMessage(state, message, options) {
8377
8383
  if (confirmMatchingPendingUserMessage(state, message.id, displayText)) {
8378
8384
  return;
8379
8385
  }
8386
+ const dedupKey = displayText.trim();
8387
+ const pendingEchoCounts = state.firedQueuedMessageTexts;
8388
+ const dedupCount = pendingEchoCounts?.get(dedupKey) ?? 0;
8389
+ if (dedupCount > 0) {
8390
+ if (dedupCount === 1) pendingEchoCounts.delete(dedupKey);
8391
+ else pendingEchoCounts.set(dedupKey, dedupCount - 1);
8392
+ return;
8393
+ }
8380
8394
  const legacyReminderMatch = exactDisplayText.match(
8381
8395
  /^<system-reminder(?<attrs>\s+[^>]*)?>(?<body>[\s\S]*?)<\/system-reminder>$/
8382
8396
  );
@@ -14236,6 +14250,9 @@ function drainQueuedAction(ctx) {
14236
14250
  ],
14237
14251
  createdAt: /* @__PURE__ */ new Date()
14238
14252
  });
14253
+ const key = nextMessage.content.trim();
14254
+ const counts = state.firedQueuedMessageTexts ??= /* @__PURE__ */ new Map();
14255
+ counts.set(key, (counts.get(key) ?? 0) + 1);
14239
14256
  state.ui.requestRender();
14240
14257
  ctx.fireMessage(nextMessage.content, nextMessage.images);
14241
14258
  return true;
@@ -14773,7 +14790,6 @@ function handleOMBufferingStart(ctx, operationType, tokensToBuffer) {
14773
14790
  const { state } = ctx;
14774
14791
  state.activeActivationMarker = void 0;
14775
14792
  state.activeActivationData = void 0;
14776
- state.activeActivationTTLMarker = void 0;
14777
14793
  state.activeActivationProviderChangeMarker = void 0;
14778
14794
  if (state.quietMode) {
14779
14795
  removeChatChild(ctx, state.activeBufferingMarker);
@@ -14829,19 +14845,6 @@ function handleOMBufferingFailed(ctx, operationType, error) {
14829
14845
  }
14830
14846
  function handleOMActivation(ctx, operationType, tokensActivated, observationTokens, triggeredBy, activateAfterIdle, ttlExpiredMs, previousModel, currentModel) {
14831
14847
  const { state } = ctx;
14832
- if (triggeredBy === "ttl" && activateAfterIdle !== void 0 && ttlExpiredMs !== void 0) {
14833
- const ttlData = {
14834
- type: "om_activation_ttl",
14835
- activateAfterIdle,
14836
- ttlExpiredMs
14837
- };
14838
- if (state.activeActivationTTLMarker) {
14839
- state.activeActivationTTLMarker.update(ttlData);
14840
- } else {
14841
- state.activeActivationTTLMarker = new OMMarkerComponent(ttlData);
14842
- addChildBeforeStreaming(ctx, state.activeActivationTTLMarker);
14843
- }
14844
- }
14845
14848
  if (triggeredBy === "provider_change" && previousModel && currentModel) {
14846
14849
  const providerChangeData = {
14847
14850
  type: "om_activation_provider_change",
@@ -14862,12 +14865,14 @@ function handleOMActivation(ctx, operationType, tokensActivated, observationToke
14862
14865
  operationType,
14863
14866
  tokensActivated: previousActivationData.tokensActivated + tokensActivated,
14864
14867
  observationTokens: previousActivationData.observationTokens + observationTokens,
14865
- activationCount: (previousActivationData.activationCount ?? 1) + 1
14868
+ activationCount: (previousActivationData.activationCount ?? 1) + 1,
14869
+ activateAfterIdle: previousActivationData.activateAfterIdle ?? activateAfterIdle
14866
14870
  } : {
14867
14871
  type: "om_activation",
14868
14872
  operationType,
14869
14873
  tokensActivated,
14870
- observationTokens
14874
+ observationTokens,
14875
+ ...triggeredBy === "ttl" && activateAfterIdle !== void 0 ? { activateAfterIdle } : {}
14871
14876
  };
14872
14877
  if (canCombineActivation && state.activeActivationMarker) {
14873
14878
  state.activeActivationMarker.update(activationData);
@@ -15861,6 +15866,10 @@ function setupKeyboardShortcuts(state, callbacks) {
15861
15866
  state.ui.requestRender();
15862
15867
  });
15863
15868
  state.editor.onAction("cycleMode", async () => {
15869
+ if (state.harness.isRunning()) {
15870
+ showInfo(state, "Wait for the agent to finish first");
15871
+ return;
15872
+ }
15864
15873
  if (state.activeInlinePlanApproval) {
15865
15874
  showInfo(state, "Resolve the plan approval first");
15866
15875
  return;
@@ -18030,5 +18039,5 @@ exports.createTUIState = createTUIState;
18030
18039
  exports.detectTerminalTheme = detectTerminalTheme;
18031
18040
  exports.formatOMStatus = formatOMStatus;
18032
18041
  exports.getCurrentVersion = getCurrentVersion;
18033
- //# sourceMappingURL=chunk-LFDQFOKQ.cjs.map
18034
- //# sourceMappingURL=chunk-LFDQFOKQ.cjs.map
18042
+ //# sourceMappingURL=chunk-7454RWHB.cjs.map
18043
+ //# sourceMappingURL=chunk-7454RWHB.cjs.map