throughline 0.3.7 → 0.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 +1 -1
- package/src/token-monitor.mjs +14 -7
package/package.json
CHANGED
package/src/token-monitor.mjs
CHANGED
|
@@ -420,13 +420,20 @@ function renderFrame(args) {
|
|
|
420
420
|
const columns = resolveColumns();
|
|
421
421
|
const clipped = lines.map((l) => truncateToCells(l, columns));
|
|
422
422
|
|
|
423
|
-
//
|
|
424
|
-
//
|
|
425
|
-
//
|
|
426
|
-
//
|
|
427
|
-
//
|
|
428
|
-
|
|
429
|
-
|
|
423
|
+
// 再描画戦略:
|
|
424
|
+
// - TTY: 真の columns が分かるので CUU + clearBelow で部分再描画(省フリッカ)
|
|
425
|
+
// - 非 TTY (VSCode の type:process タスク等): columns を信用できないので 200 で
|
|
426
|
+
// truncate しているが、実ターミナル幅が 200 未満なら自動改行が起き、論理行数と
|
|
427
|
+
// 物理行数がズレて CUU が誤作動する(「1 セッション」行が毎フレーム積み上がる
|
|
428
|
+
// バグを実機で確認)。非 TTY では画面全クリアで愚直に描き直す方が確実。
|
|
429
|
+
// どちらも差分検知 (needsRerender) を通過したフレームのみ書き込むので、
|
|
430
|
+
// フリッカ量はデータ変化頻度に比例するだけで爆発しない。
|
|
431
|
+
if (process.stdout.isTTY) {
|
|
432
|
+
if (lastRenderedLines > 0) {
|
|
433
|
+
process.stdout.write(ANSI.up(lastRenderedLines) + '\r' + ANSI.clearBelow);
|
|
434
|
+
}
|
|
435
|
+
} else {
|
|
436
|
+
process.stdout.write(ANSI.clearScreen);
|
|
430
437
|
}
|
|
431
438
|
|
|
432
439
|
process.stdout.write(clipped.join('\n') + '\n');
|