feat(tui): PI_TUI_WRITE_LOG now accepts a directory path (#2508)

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
This commit is contained in:
Duncan Ogilvie
2026-03-24 00:22:24 +01:00
committed by GitHub
parent 4c7df25d03
commit 9a0be024a6
2 changed files with 20 additions and 1 deletions

View File

@@ -2,10 +2,15 @@
## [Unreleased]
### Added
- `PI_TUI_WRITE_LOG` now accepts a directory path, creating a unique log file (`tui-<timestamp>-<pid>.log`) per instance for easier debugging of multiple pi sessions
### Fixed
- Fixed blockquote text color breaking after inline links (and other inline elements) due to missing style restoration prefix
## [0.62.0] - 2026-03-23
### Fixed

View File

@@ -1,4 +1,5 @@
import * as fs from "node:fs";
import * as path from "node:path";
import { createRequire } from "node:module";
import { setKittyProtocolActive } from "./keys.js";
import { StdinBuffer } from "./stdin-buffer.js";
@@ -60,7 +61,20 @@ export class ProcessTerminal implements Terminal {
private _modifyOtherKeysActive = false;
private stdinBuffer?: StdinBuffer;
private stdinDataHandler?: (data: string) => void;
private writeLogPath = process.env.PI_TUI_WRITE_LOG || "";
private writeLogPath = (() => {
const env = process.env.PI_TUI_WRITE_LOG || "";
if (!env) return "";
try {
if (fs.statSync(env).isDirectory()) {
const now = new Date();
const ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}_${String(now.getHours()).padStart(2, "0")}-${String(now.getMinutes()).padStart(2, "0")}-${String(now.getSeconds()).padStart(2, "0")}`;
return path.join(env, `tui-${ts}-${process.pid}.log`);
}
} catch {
// Not an existing directory - use as-is (file path)
}
return env;
})();
get kittyProtocolActive(): boolean {
return this._kittyProtocolActive;