ucode-agent 1.62.0 → 1.62.2

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/src/ui/screen.js CHANGED
@@ -139,6 +139,10 @@ const THOUGHT_HOLD_MS = 1100;
139
139
  /** Reasoning that is about the request rather than about the work. */
140
140
  const RESTATEMENT = /^(?:the user|they|so the user|user)|^(?:i (?:need|should|will need) to (?:understand|figure|work out|check what))|^(?:let me (?:understand|re-?read|look at the (?:request|prompt)))|^(?:the (?:request|prompt|task) (?:is|asks|says))/i;
141
141
 
142
+ /** The window size asked of macOS Terminal when it opens smaller than this. */
143
+ const MAC_COLS = 120;
144
+ const MAC_ROWS = 34;
145
+
142
146
  /** The wordmark only earns its place with room for the facts column beside it. */
143
147
  const WORDMARK_NEEDS = BANNER_WIDTH + 30;
144
148
 
@@ -241,6 +245,15 @@ export class Screen {
241
245
  };
242
246
  this.output.on('resize', this.onResize);
243
247
 
248
+ // macOS Terminal opens at 80×24, and with the header and the input box
249
+ // that leaves a letterbox for the conversation. Ask for more room — never
250
+ // less — and give the window back its own size on the way out.
251
+ if (process.env.TERM_PROGRAM === 'Apple_Terminal' && !this.grownFrom
252
+ && (this.cols < MAC_COLS || this.rows < MAC_ROWS)) {
253
+ this.grownFrom = [this.rows, this.cols];
254
+ this.output.write(`${ESC}[8;${Math.max(this.rows, MAC_ROWS)};${Math.max(this.cols, MAC_COLS)}t`);
255
+ }
256
+
244
257
  this.render();
245
258
  this.startIntro();
246
259
  }
@@ -281,6 +294,10 @@ export class Screen {
281
294
  this.input.setRawMode?.(false);
282
295
  this.input.pause();
283
296
  this.output.write(PASTE_OFF + MOUSE_OFF + ALT_OFF + SHOW);
297
+ if (this.grownFrom) {
298
+ this.output.write(`${ESC}[8;${this.grownFrom[0]};${this.grownFrom[1]}t`);
299
+ this.grownFrom = null;
300
+ }
284
301
  }
285
302
 
286
303
  close() {
@@ -789,7 +806,7 @@ export class Screen {
789
806
  ].filter(Boolean).slice(0, BANNER.length - 1);
790
807
 
791
808
  while (facts.length < BANNER.length - 1) facts.push(['', '']);
792
- facts.push(['', 'made with ❤️ by om dixit']);
809
+ facts.push(['', 'made with ❤ by om dixit']);
793
810
 
794
811
  const rows = BANNER.map((art, i) => {
795
812
  const [label, text] = facts[i] ?? ['', ''];
package/src/ui/theme.js CHANGED
@@ -230,9 +230,6 @@ export function visLen(s) {
230
230
  const cp = text.codePointAt(i);
231
231
  const ch = String.fromCodePoint(cp);
232
232
  i += ch.length;
233
- // A variation selector turns the character before it into an emoji, and
234
- // an emoji is two cells wide however narrow its text form was.
235
- if (text.codePointAt(i) === 0xfe0f) { cells += 2; i += 1; continue; }
236
233
  cells += charWidth(cp);
237
234
  }
238
235
  return cells;
@@ -252,18 +249,27 @@ export function sliceVis(s, width) {
252
249
  // in the rest.
253
250
  const cp = s.codePointAt(i);
254
251
  const ch = String.fromCodePoint(cp);
255
- const selector = s.codePointAt(i + ch.length) === 0xfe0f;
256
- const w = selector ? 2 : charWidth(cp);
252
+ const w = charWidth(cp);
257
253
  if (seen + w > width) break;
258
- out += selector ? ch + String.fromCodePoint(0xfe0f) : ch;
259
- i += (selector ? ch.length + 1 : ch.length) - 1;
254
+ out += ch;
255
+ i += ch.length - 1;
260
256
  seen += w;
261
257
  }
262
258
  return out;
263
259
  }
264
260
 
265
- /** Pad or hard-cut a possibly-coloured string to an exact visible width. */
266
- export function padVis(s, width) {
261
+ /**
262
+ * Pad or hard-cut a possibly-coloured string to an exact visible width.
263
+ *
264
+ * The emoji variation selector (U+FE0F) is dropped on the way out. Terminals
265
+ * disagree on what it does to a character like ❤ — Windows Terminal draws two
266
+ * cells, macOS Terminal draws one — so no count of it is right on both, and a
267
+ * row holding one had its right border a column off on the Mac. Without it the
268
+ * character is drawn in its plain form, one cell, everywhere. Every painted row
269
+ * passes through here, so this is the one place it needs doing.
270
+ */
271
+ export function padVis(raw, width) {
272
+ const s = String(raw).replace(/️/g, '');
267
273
  const len = visLen(s);
268
274
  if (len === width) return s;
269
275
  if (len < width) return s + ' '.repeat(width - len);