@oh-my-pi/pi-tui 10.2.2 → 10.3.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/tui.ts +35 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-tui",
3
- "version": "10.2.2",
3
+ "version": "10.3.0",
4
4
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -47,7 +47,7 @@
47
47
  "bun": ">=1.3.7"
48
48
  },
49
49
  "dependencies": {
50
- "@oh-my-pi/pi-natives": "10.2.2",
50
+ "@oh-my-pi/pi-natives": "10.3.0",
51
51
  "@types/mime-types": "^3.0.1",
52
52
  "chalk": "^5.6.2",
53
53
  "marked": "^17.0.1",
package/src/tui.ts CHANGED
@@ -1080,39 +1080,44 @@ export class TUI extends Container {
1080
1080
  for (let i = firstChanged; i <= renderEnd; i++) {
1081
1081
  if (i > firstChanged) buffer += "\r\n";
1082
1082
  buffer += "\x1b[2K"; // Clear current line
1083
- const line = newLines[i];
1083
+ let line = newLines[i];
1084
1084
  const isImageLine = TERMINAL_INFO.isImageLine(line);
1085
1085
  if (!isImageLine && visibleWidth(line) > width) {
1086
- // Log all lines to crash file for debugging
1087
- const crashLogPath = path.join(os.homedir(), ".omp", "agent", "omp-crash.log");
1088
- const crashData = [
1089
- `Crash at ${new Date().toISOString()}`,
1090
- `Terminal width: ${width}`,
1091
- `Line ${i} visible width: ${visibleWidth(line)}`,
1092
- "",
1093
- "=== All rendered lines ===",
1094
- ...newLines.map((l, idx) => `[${idx}] (w=${visibleWidth(l)}) ${l}`),
1095
- "",
1096
- ].join("\n");
1097
- try {
1098
- fs.mkdirSync(path.dirname(crashLogPath), { recursive: true });
1099
- fs.writeFileSync(crashLogPath, crashData);
1100
- } catch {
1101
- // Ignore - crash log is best-effort
1102
- }
1086
+ if (process.platform === "win32") {
1087
+ line = sliceByColumn(line, 0, width, true);
1088
+ newLines[i] = line;
1089
+ } else {
1090
+ // Log all lines to crash file for debugging
1091
+ const crashLogPath = path.join(os.homedir(), ".omp", "agent", "omp-crash.log");
1092
+ const crashData = [
1093
+ `Crash at ${new Date().toISOString()}`,
1094
+ `Terminal width: ${width}`,
1095
+ `Line ${i} visible width: ${visibleWidth(line)}`,
1096
+ "",
1097
+ "=== All rendered lines ===",
1098
+ ...newLines.map((l, idx) => `[${idx}] (w=${visibleWidth(l)}) ${l}`),
1099
+ "",
1100
+ ].join("\n");
1101
+ try {
1102
+ fs.mkdirSync(path.dirname(crashLogPath), { recursive: true });
1103
+ fs.writeFileSync(crashLogPath, crashData);
1104
+ } catch {
1105
+ // Ignore - crash log is best-effort
1106
+ }
1103
1107
 
1104
- // Clean up terminal state before throwing
1105
- this.stop();
1106
-
1107
- const errorMsg = [
1108
- `Rendered line ${i} exceeds terminal width (${visibleWidth(line)} > ${width}).`,
1109
- "",
1110
- "This is likely caused by a custom TUI component not truncating its output.",
1111
- "Use visibleWidth() to measure and truncateToWidth() to truncate lines.",
1112
- "",
1113
- `Debug log written to: ${crashLogPath}`,
1114
- ].join("\n");
1115
- throw new Error(errorMsg);
1108
+ // Clean up terminal state before throwing
1109
+ this.stop();
1110
+
1111
+ const errorMsg = [
1112
+ `Rendered line ${i} exceeds terminal width (${visibleWidth(line)} > ${width}).`,
1113
+ "",
1114
+ "This is likely caused by a custom TUI component not truncating its output.",
1115
+ "Use visibleWidth() to measure and truncateToWidth() to truncate lines.",
1116
+ "",
1117
+ `Debug log written to: ${crashLogPath}`,
1118
+ ].join("\n");
1119
+ throw new Error(errorMsg);
1120
+ }
1116
1121
  }
1117
1122
  buffer += line;
1118
1123
  }