@oh-my-pi/pi-tui 14.0.5 → 14.1.1

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
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [14.1.1] - 2026-04-14
6
+
7
+ ### Breaking Changes
8
+
9
+ - Removed the `searchDb` constructor argument from `CombinedAutocompleteProvider`, requiring callers to use the built-in search behavior
10
+
11
+ ### Changed
12
+
13
+ - Changed truncation debug logging to run only when `debugRedraw` is enabled
14
+
5
15
  ## [14.0.5] - 2026-04-11
6
16
 
7
17
  ### Changed
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-tui",
4
- "version": "14.0.5",
4
+ "version": "14.1.1",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
@@ -37,8 +37,8 @@
37
37
  "fmt": "biome format --write ."
38
38
  },
39
39
  "dependencies": {
40
- "@oh-my-pi/pi-natives": "14.0.5",
41
- "@oh-my-pi/pi-utils": "14.0.5",
40
+ "@oh-my-pi/pi-natives": "workspace:*",
41
+ "@oh-my-pi/pi-utils": "workspace:*",
42
42
  "marked": "^17.0"
43
43
  },
44
44
  "devDependencies": {
@@ -1,7 +1,6 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as os from "node:os";
3
3
  import * as path from "node:path";
4
- import type { SearchDb } from "@oh-my-pi/pi-natives";
5
4
  import { fuzzyFind } from "@oh-my-pi/pi-natives";
6
5
  import { getProjectDir } from "@oh-my-pi/pi-utils";
7
6
 
@@ -204,17 +203,11 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
204
203
  // per-directory readdir fast-path for prefix completions. Global fuzzy
205
204
  // discovery continues to use native fuzzyFind + shared scan cache.
206
205
  #dirCache: Map<string, { entries: fs.Dirent[]; timestamp: number }> = new Map();
207
- #searchDb?: SearchDb;
208
206
  readonly #DIR_CACHE_TTL = 2000; // 2 seconds
209
207
 
210
- constructor(
211
- commands: (SlashCommand | AutocompleteItem)[] = [],
212
- basePath: string = getProjectDir(),
213
- searchDb?: SearchDb,
214
- ) {
208
+ constructor(commands: (SlashCommand | AutocompleteItem)[] = [], basePath: string = getProjectDir()) {
215
209
  this.#commands = commands;
216
210
  this.#basePath = basePath;
217
- this.#searchDb = searchDb;
218
211
  }
219
212
 
220
213
  async getSuggestions(
@@ -682,7 +675,7 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
682
675
  const scopedQuery = await this.#resolveScopedFuzzyQuery(query);
683
676
  const searchPath = scopedQuery?.baseDir ?? this.#basePath;
684
677
  const fuzzyQuery = scopedQuery?.query ?? query;
685
- const result = await fuzzyFind(buildAutocompleteFuzzyDiscoveryProfile(fuzzyQuery, searchPath), this.#searchDb);
678
+ const result = await fuzzyFind(buildAutocompleteFuzzyDiscoveryProfile(fuzzyQuery, searchPath));
686
679
  const lowerQuery = fuzzyQuery.toLowerCase();
687
680
  const filteredMatches = result.matches.filter(entry => {
688
681
  const p = entry.path.endsWith("/") ? entry.path.slice(0, -1) : entry.path;
package/src/tui.ts CHANGED
@@ -3,11 +3,11 @@
3
3
  */
4
4
  import * as fs from "node:fs";
5
5
  import * as path from "node:path";
6
- import { $flag, getCrashLogPath, getDebugLogPath } from "@oh-my-pi/pi-utils";
6
+ import { $flag, getDebugLogPath } from "@oh-my-pi/pi-utils";
7
7
  import { isKeyRelease, matchesKey } from "./keys";
8
8
  import type { Terminal } from "./terminal";
9
9
  import { ImageProtocol, setCellDimensions, setTerminalImageProtocol, TERMINAL } from "./terminal-capabilities";
10
- import { extractSegments, sliceByColumn, sliceWithWidth, visibleWidth } from "./utils";
10
+ import { Ellipsis, extractSegments, sliceByColumn, sliceWithWidth, truncateToWidth, visibleWidth } from "./utils";
11
11
 
12
12
  const SEGMENT_RESET = "\x1b[0m";
13
13
 
@@ -1193,36 +1193,25 @@ export class TUI extends Container {
1193
1193
  if (i > firstChanged) buffer += "\r\n";
1194
1194
  buffer += "\x1b[2K"; // Clear current line
1195
1195
  const line = newLines[i];
1196
+ let truncatedLine = line;
1196
1197
  const isImage = TERMINAL.isImageLine(line);
1197
1198
  if (!isImage && visibleWidth(line) > width) {
1198
- // Log all lines to crash file for debugging
1199
- const crashLogPath = getCrashLogPath();
1200
- const crashData = [
1201
- `Crash at ${new Date().toISOString()}`,
1202
- `Terminal width: ${width}`,
1203
- `Line ${i} visible width: ${visibleWidth(line)}`,
1204
- "",
1205
- "=== All rendered lines ===",
1206
- ...newLines.map((l, idx) => `[${idx}] (w=${visibleWidth(l)}) ${l}`),
1207
- "",
1208
- ].join("\n");
1209
- fs.mkdirSync(path.dirname(crashLogPath), { recursive: true });
1210
- fs.writeFileSync(crashLogPath, crashData);
1211
-
1212
- // Clean up terminal state before throwing
1213
- this.stop();
1214
-
1215
- const errorMsg = [
1216
- `Rendered line ${i} exceeds terminal width (${visibleWidth(line)} > ${width}).`,
1217
- "",
1218
- "This is likely caused by a custom TUI component not truncating its output.",
1219
- "Use visibleWidth() to measure and truncateToWidth() to truncate lines.",
1220
- "",
1221
- `Debug log written to: ${crashLogPath}`,
1222
- ].join("\n");
1223
- throw new Error(errorMsg);
1199
+ if (debugRedraw) {
1200
+ const debugData = [
1201
+ `[TUI Truncate] ${new Date().toISOString()}`,
1202
+ `Line ${i} truncated: ${visibleWidth(line)} > ${width}`,
1203
+ `Content preview: ${line.slice(0, 100)}...`,
1204
+ "",
1205
+ ].join("\n");
1206
+ try {
1207
+ fs.appendFileSync(getDebugLogPath(), debugData);
1208
+ } catch {
1209
+ // Ignore write errors - truncation should still work
1210
+ }
1211
+ }
1212
+ truncatedLine = truncateToWidth(line, width, Ellipsis.Omit);
1224
1213
  }
1225
- buffer += isImage ? line : line + SEGMENT_RESET;
1214
+ buffer += isImage ? truncatedLine : truncatedLine + SEGMENT_RESET;
1226
1215
  }
1227
1216
 
1228
1217
  // Track where cursor ended up after rendering