Skip to content

debug: instrument VT pipeline for ANSI display investigation#15

Closed
ttak0422 wants to merge 1 commit intomainfrom
debug/display-investigation
Closed

debug: instrument VT pipeline for ANSI display investigation#15
ttak0422 wants to merge 1 commit intomainfrom
debug/display-investigation

Conversation

@ttak0422
Copy link
Copy Markdown
Owner

Summary

  • ANSIエスケープシーケンス(色付き出力)使用時に改行位置がズレる問題の原因調査用デバッグログを追加
  • 3つの環境変数でログ出力先ファイルを制御(本番では無効)

追加したログ

環境変数 出力内容
PTERM_DEBUG_DAEMON daemon側: read_ptyのパーサ状態(n, ESC数, cursor, errors)、snapshotの統計(len, ESC数, wrapped行)、send_snapshot / flush_pty / resize
PTERM_DEBUG_FRAMES bridge側: protocol frameのdecode(type, len, ESC数)、stdoutへの書き込みバッチ(len, ESC数)
PTERM_DEBUG_OUTPUT Neovim stdoutへ書き込んだ生バイト(既存)

使い方

PTERM_DEBUG_DAEMON=/tmp/pterm_daemon.log \
PTERM_DEBUG_FRAMES=/tmp/pterm_frames.log \
PTERM_DEBUG_OUTPUT=/tmp/pterm_output.bin \
  nix run .#test-nvim

調査後はこのブランチを削除またはログコードをstrip予定。

Test plan

  • nix run .#test-nvim でNeovimが起動する
  • 色付き出力を発生させる(例: claude yes
  • PTERM_DEBUG_DAEMON ログで [snapshot] wrapped= に異常な行がないか確認
  • [read_pty] errors= でvt100パーサエラーが出ていないか確認
  • PTERM_DEBUG_FRAMES ログでOUTPUT/SCROLLBACKのESC数を比較

🤖 Generated with Claude Code

…stigation

Instrument the VT parse/snapshot/frame pipeline to diagnose the ANSI
escape sequence width misalignment that causes line-wrap corruption with
colored output (e.g. claude yes/no prompts).

Three debug log targets, each enabled by setting the env var to a file path:
- PTERM_DEBUG_DAEMON: daemon-side read_pty (n, esc count, cursor, errors),
  snapshot (len, esc count, size, wrapped rows), send_snapshot, flush_pty,
  and resize events.
- PTERM_DEBUG_FRAMES: bridge-side protocol frame decode (type, len, esc count)
  and final stdout batch writes (len, esc count).
- PTERM_DEBUG_OUTPUT: raw bytes written to Neovim stdout (pre-existing).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ttak0422 ttak0422 closed this Mar 20, 2026
@ttak0422 ttak0422 deleted the debug/display-investigation branch March 22, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant