u-foo 2.3.7 → 2.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u-foo",
3
- "version": "2.3.7",
3
+ "version": "2.3.8",
4
4
  "description": "Multi-Agent Workspace Protocol. Just add u. claude → uclaude, codex → ucodex.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://ufoo.dev",
package/src/chat/index.js CHANGED
@@ -355,7 +355,7 @@ async function runChat(projectRoot, options = {}) {
355
355
  let preferredCol = null;
356
356
 
357
357
  function getInnerWidth() {
358
- const promptWidth = typeof promptBox.width === "number" ? promptBox.width : 2;
358
+ const promptWidth = promptBox && typeof promptBox.width === "number" ? promptBox.width : 2;
359
359
  return inputMath.getInnerWidth({ input, screen, promptWidth });
360
360
  }
361
361
 
@@ -51,24 +51,33 @@ function safeStrWidth(strWidth, value) {
51
51
  }
52
52
 
53
53
  function getInnerWidth({ input, screen, promptWidth = 2 }) {
54
- const lpos = input.lpos || input._getCoords();
54
+ const targetInput = input && typeof input === "object" ? input : {};
55
+ const targetScreen = screen && typeof screen === "object" ? screen : {};
56
+ let lpos = targetInput.lpos || null;
57
+ if (!lpos && typeof targetInput._getCoords === "function") {
58
+ try {
59
+ lpos = targetInput._getCoords();
60
+ } catch {
61
+ lpos = null;
62
+ }
63
+ }
55
64
  if (lpos && Number.isFinite(lpos.xl) && Number.isFinite(lpos.xi)) {
56
65
  return Math.max(1, lpos.xl - lpos.xi);
57
66
  }
58
- if (typeof input.width === "number") return Math.max(1, input.width);
59
- if (typeof input.width === "string") {
60
- const match = input.width.match(/^100%-([0-9]+)$/);
61
- if (match && typeof screen.width === "number") {
62
- return Math.max(1, screen.width - parseInt(match[1], 10));
67
+ if (typeof targetInput.width === "number") return Math.max(1, targetInput.width);
68
+ if (typeof targetInput.width === "string") {
69
+ const match = targetInput.width.match(/^100%-([0-9]+)$/);
70
+ if (match && typeof targetScreen.width === "number") {
71
+ return Math.max(1, targetScreen.width - parseInt(match[1], 10));
63
72
  }
64
73
  }
65
- if (typeof screen.width === "number") return Math.max(1, screen.width - promptWidth);
66
- if (typeof screen.cols === "number") return Math.max(1, screen.cols - promptWidth);
74
+ if (typeof targetScreen.width === "number") return Math.max(1, targetScreen.width - promptWidth);
75
+ if (typeof targetScreen.cols === "number") return Math.max(1, targetScreen.cols - promptWidth);
67
76
  return 1;
68
77
  }
69
78
 
70
79
  function getWrapWidth(input, fallbackWidth) {
71
- if (input._clines && typeof input._clines.width === "number") {
80
+ if (input && input._clines && typeof input._clines.width === "number") {
72
81
  return Math.max(1, input._clines.width);
73
82
  }
74
83
  return Math.max(1, fallbackWidth || 1);