Uh oh!
There was an error while loading. Please reload this page.
fix: 古い VSCODE_IPC_HOOK_CLI で devbase up --open が無言失敗する問題を修正 - #97
Merged
Conversation
tmux/screen のセッション再利用や VS Code ウィンドウのリロード後は VSCODE_IPC_HOOK_CLI が消えたソケットを指したまま残る。従来は変数の有無だけで VS Code 統合ターミナルと判定していたため、code が死んだソケットへ接続を試み、 _launch が stderr を捨てていたのでエラーも出ないまま何も起きなかった。 - _ipc_socket_alive() でソケットの実在を確認してから in_vscode を立てる - 古い場合は理由を warning に出し、SSH 経路では print_command へ degrade - _launch は stderr を握り潰さず親へ継承する - tmux 追随設定 (update-environment / プロンプトフック) をドキュメントに追加 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQa2WHdEqzbdCtBoQXaRNS
takemi-ohama
left a comment
ContributorAuthor
There was a problem hiding this comment.
🤖 cross-review | round 1 | codex | APPROVE
修正を求める指摘はありません。
takemi-ohama
left a comment
ContributorAuthor
There was a problem hiding this comment.
🤖 cross-review | round 1 | gemini | APPROVE
IPC ソケットの実在確認によって tmux 等での無言失敗を防ぐ堅牢な改善です。1点だけ標準ライブラリの仕様に伴う冗長な記述について提案しました。
Uh oh!
There was an error while loading. Please reload this page.
os.path.exists() は内部で OSError / ValueError を捕捉して False を返すため、 呼び出し側の try...except OSError は冗長だった。意図をコメントで残しつつ削除する。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
5 tasks
takemi-ohama added a commit
that referenced
this pull request
Aug 19, 2026
PR #97 で VSCODE_IPC_HOOK_CLI の実在確認を入れたが、ソケットの死に方には 「ファイルごと消えている」ほかに「ファイルは残っているが listen しているプロセスが 居ない」の 2 通りがある。後者は VS Code のクラッシュ・強制終了・OS 再起動で後始末 されなかった場合に $TMPDIR へ孤児として残り、os.path.exists() では弾けない。 その結果 in_vscode=True と誤判定して code を IPC 経由で起動し、 Unable to connect to VS Code server: Error in request. Error: connect ECONNREFUSED .../vscode-ipc-<uuid>.sock で失敗していた。 - _ipc_socket_alive() を connect ベースに変更 (AF_UNIX / タイムアウト 0.5 秒)。 ENOENT / ECONNREFUSED / EACCES / ENOTSOCK / パス長超過をまとめて「使えない」と扱う - AF_UNIX が無いプラットフォームでは従来どおり実在確認へフォールバック - 警告文を「存在しません」から「接続できません」に改め、ファイルが残っていても 接続を拒否する場合があることを明記 - 孤児ソケット / 通常ファイルのケースを回帰テストに追加。既存の in_vscode テストは 実際に listen する AF_UNIX ソケットを使うよう修正 - docs にソケットの死に方 2 通りを追記。tmux 追随フックの -S guard も孤児ソケットを 検出できない点を注記 Claude-Session: https://claude.ai/code/session_01622CAKyYfonYuZ6AqRJvDg Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
概要
tmux / screen のセッションを再利用している端末や、VS Code のウィンドウをリロードした後の古いシェルでは、
VSCODE_IPC_HOOK_CLIが すでに削除されたソケット ($TMPDIR/vscode-ipc-<uuid>.sock) を指したまま残ります。従来の
detect_context()は 変数の有無だけ で VS Code 統合ターミナルと判定していたため、devbase up --openはこの状態でlaunchを選び、codeが死んだソケットへ接続を試みて失敗していました。さらに_launch()が stderr をDEVNULLに捨てていたため、何も起きないがエラーも出ない という最も切り分けづらい失敗になっていました。ソケットの実在を確認したうえで判定し、古い場合は理由を warning に出して「手元で実行するコマンドの提示」へ degrade します。
関連 Issue
変更点
lib/devbase/editor/opener.py_ipc_socket_alive()を追加し、VSCODE_IPC_HOOK_CLIが実在するソケットを指す場合のみin_vscode=Trueにするdetect_context()/open_editor()にテスト用差し替え口ipc_aliveを追加_launch()の stderr を握り潰さず親へ継承する(codeは IPC 接続失敗の理由を stderr にのみ出すため)docs/user/environment-variables.mdset -ga update-environmentによる追随設定、既存ペイン向けのプロンプトフック、tmux kill-serverでの反映手順を記載tests/editor/test_opener.pyipc_alive明示のケースを追加print_commandへ degrade し、原因が分かるログが出ることを検証する回帰テストを追加CHANGELOG.mdに Fixed エントリを追加動作確認
pytest tests/editor/test_opener.pyが green(81 passed)devbase up --openを実行し、warning とコマンド提示が出ることを確認docs/user/environment-variables.md) を更新したスクリーンショット・ログ(任意)
補足
_ipc_socket_alive()はos.path.exists()で判定しています(ソケットが「存在するが応答しない」ケースまでは検出しません)。実際に問題となっていたのは ファイル自体が消えている パターンで、接続可能性まで確かめるにはcodeを実行するしかないため、ここでは安価な存在確認に留めています。_launch()は非ブロッキング起動のため、stderr のメッセージはupの出力に遅れて混ざり得ますが、無言の失敗よりは有用と判断しました。