throughline 0.3.8 → 0.3.9

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": "throughline",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "type": "module",
5
5
  "description": "Claude Code hooks plugin for structured context compression (/clear-safe persistent memory)",
6
6
  "keywords": [
@@ -33,6 +33,12 @@ let lastTimeAgoRefresh = Date.now();
33
33
  const ANSI = {
34
34
  hideCursor: '\x1b[?25l',
35
35
  showCursor: '\x1b[?25h',
36
+ // オルタネートスクリーンバッファ (htop / vim / less が使うやつ)。
37
+ // プライマリバッファでの `\x1b[2J` は xterm.js だと「描画済み行をスクロール履歴に
38
+ // 押し上げる」挙動になり、狭い VSCode task terminal で描画が永遠に積み上がる
39
+ // 症状を引き起こす。alt バッファならスクロール履歴に残らず真にクリアできる。
40
+ enterAltScreen: '\x1b[?1049h',
41
+ leaveAltScreen: '\x1b[?1049l',
36
42
  clearLine: '\x1b[2K',
37
43
  clearScreen: '\x1b[2J\x1b[H',
38
44
  clearBelow: '\x1b[0J', // 現在位置から画面末尾までをクリア
@@ -441,12 +447,18 @@ function renderFrame(args) {
441
447
  }
442
448
 
443
449
  // --- 起動 ---
444
- let cursorRestored = false;
450
+ let terminalRestored = false;
451
+ /**
452
+ * 終了時に端末状態を元に戻す:
453
+ * - オルタネートスクリーンバッファから抜ける (起動前の画面に戻る)
454
+ * - カーソル表示を復活
455
+ * 2 回以上呼ばれても安全 (冪等)。
456
+ */
445
457
  function restoreCursor() {
446
- if (cursorRestored) return;
447
- cursorRestored = true;
458
+ if (terminalRestored) return;
459
+ terminalRestored = true;
448
460
  try {
449
- process.stdout.write(ANSI.showCursor);
461
+ process.stdout.write(ANSI.leaveAltScreen + ANSI.showCursor);
450
462
  } catch {
451
463
  // stdout がすでに閉じていても無視
452
464
  }
@@ -472,7 +484,9 @@ export function main() {
472
484
  process.exit(2);
473
485
  }
474
486
 
475
- process.stdout.write(ANSI.hideCursor);
487
+ // オルタネートスクリーンバッファに入る → プライマリ画面を保存、クリア時に履歴に残らない。
488
+ // これにより「1 セッション」ヘッダが再描画のたびに積み上がる不具合を根絶できる。
489
+ process.stdout.write(ANSI.enterAltScreen + ANSI.hideCursor);
476
490
  process.stdout.write(color(ANSI.dim, `[Throughline] モニター起動 (state: ${getStateDir()}, Ctrl+C で終了)\n`));
477
491
 
478
492
  safeRenderFrame(args);