Skip to content

fix: use pterm open to eliminate snapshot timing gap in :Pterm command#12

Merged
ttak0422 merged 1 commit intomainfrom
fix/pterm-open-snapshot-timing
Mar 10, 2026
Merged

fix: use pterm open to eliminate snapshot timing gap in :Pterm command#12
ttak0422 merged 1 commit intomainfrom
fix/pterm-open-snapshot-timing

Conversation

@ttak0422
Copy link
Copy Markdown
Owner

Summary

  • :Pterm コマンドで作成したターミナルの表示が崩れる問題を修正
  • 原因: 2ステップフロー (pterm newwait_for_socketpterm attach) のタイミングギャップにより、bridge 接続時に flush_pty_output() が RESIZE 処理前に 80x24 サイズのスナップショットを送信し、libvterm のスクロール領域が不正になっていた
  • 修正: pterm open を jobstart で直接実行する 1 ステップフローに変更し、CLI と同一の安定したパスを使用
  • cmd_new()quiet パラメータを追加し、cmd_open 経由での JSON 出力漏れを防止

Test plan

  • :Pterm で新規セッション作成 → プロンプト表示が正常であること
  • :Pterm で Enter/文字入力 → 表示が崩れないこと
  • :Pterm session_name -- command でカスタムコマンド実行が動作すること
  • 既存セッションへの :Pterm 再接続が動作すること
  • pterm open CLI からの実行が引き続き正常であること
  • Telescope 拡張からのセッション選択が動作すること
  • cargo check がパスすること

🤖 Generated with Claude Code

When :Pterm created a session via the two-step flow (vim.fn.system for
`pterm new` → wait_for_socket → jobstart for `pterm attach`), the shell
had time to produce PTY output during the gap. On bridge connection,
server.rs flush_pty_output() triggered snapshot delivery at the old
80×24 size BEFORE the client's RESIZE was processed, leaving libvterm
with wrong scroll regions and causing progressive display corruption.

CLI `pterm open` was unaffected because it handles creation and bridge
attachment in a single process with minimal delay.

Changes:
- init.lua: M.open() now uses `pterm open` via jobstart instead of the
  two-step `pterm new` + `pterm attach`, matching the stable CLI flow
- init.lua: extract start_terminal() helper shared by M.open/M.attach
- init.lua: remove unused wait_for_socket() and attach_wait_ms/poll_ms
  config fields
- main.rs: add quiet parameter to cmd_new() to suppress JSON metadata
  output when called from cmd_open, preventing leakage into the Neovim
  terminal buffer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ttak0422 ttak0422 merged commit 94e8778 into main Mar 10, 2026
2 checks passed
@ttak0422 ttak0422 deleted the fix/pterm-open-snapshot-timing branch March 10, 2026 16:14
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