feat(up): devbase up 後に dev コンテナ接続の VS Code を自動オープン (PLAN31_3)#69
Merged
Conversation
issues/i31.md 第3項。`devbase up` 完了後、dev コンテナへ接続した VS Code を
自動で開けるようにする (Attach to Running Container を CLI から起動)。
- 新規 lib/devbase/editor/opener.py: code CLI 委譲を一貫機構とし、ローカル/
WSL(Windows 側)/VS Code Remote-SSH 統合端末(クライアント側)を自動判別。
plain SSH では手元で叩くコマンドを提示、非TTY/code 不在はスキップ。
attach URI は {"containerName":"/<name>"} を hex 化 (vscode#242489 のネスト
authority は未サポートのため code シム/IPC hook の委譲に依拠)。
- cmd_up に [6/6] Opening editor を追加。env DEVBASE_OPEN_EDITOR(既定 OFF) /
CLI --open/--no-open/--open-index で制御。起動失敗は up の rc を変えない。
- env/keys.py に DEVBASE_OPEN_EDITOR/DEVBASE_EDITOR/DEVBASE_OPEN_INDEX。
- docs/CHANGELOG 更新、opener 単体 37 + dispatch 統合テスト追加 (748 passed)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 1 | codex | COMMENT
個別指摘のみです。
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 1 | gemini | REQUEST_CHANGES
PLAN31_3 に記載されていた実コンテナ名の動的取得(docker compose ps による確認)が実装されておらず、フォールバック側の決定的命名のみとなっています。コンテナ名の解決処理を修正してください。
レビュー指摘 (PR #69) 対応: - 指摘A (major): PLAN31_3 §3 が約束した「compose バージョン差異への保険」を実装。 opener._query_container_name で docker compose ps --format json を実行し、 NDJSON / JSON 配列の両形式から実 .Name を取得。失敗・非0・例外・空は None に 握り潰し、resolve_container_name が決定的名へフォールバックする。runner 差替で テスト可能。 - 指摘B (minor): _maybe_open_editor に scale を渡し open_index を 1..scale で 検証。0・負数・scale 超過は warning を出して既定 (1) へフォールバックする。 DEVBASE_OPEN_INDEX 経由も同じ検証を通る。 756 passed (+8 tests)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 2 | gemini | APPROVE
設計・実装ともにエッジケースが適切にカバーされており、問題は見当たりませんでした。このままマージして良いと考えます。
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 2 | codex | REQUEST_CHANGES
2件の修正必須事項があります。
cross-review round2 codex 指摘 C/D 対応。
C[正確性]: plain SSH の degrade (手元コマンド提示) は decide_action が
editor_cmd None で先頭 skip するため、リモートに code が無いと print_command
へ到達せず skip していた。提示コマンドは手元(ローカル)で実行する前提なので
リモートの code 実在に依存させない。
- resolve_editor_display() を追加 (which 非依存・必ず非None)
- decide_action(ctx, editor_available: bool) へシグネチャ変更。SSH の
print_command は editor_available に依存せず到達、launch 系経路のみ
editor 不在で skip。
- open_editor は launch=editor / print=display を使い分け。
D[正確性]: _query_container_name が docker compose ps に override compose を
渡さず base compose.yml に無い {dev}-{index} を見てほぼ常にフォールバック
していた。
- _query_container_name / resolve_container_name / open_editor /
_maybe_open_editor に compose_file を追加し起動時と同じ -f を伝播。
- cmd_up は [6/6] で override_file を渡す。
テスト追加・更新 (766 passed)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 3 | codex | APPROVE
追加の修正提案はありません。
takemi-ohama
commented
Jun 13, 2026
takemi-ohama
left a comment
Contributor
Author
There was a problem hiding this comment.
🤖 cross-review | round 3 | gemini | APPROVE
機能設計およびエッジケースへの対応が網羅的に実装されており、問題ありません。1点のマイナーな提案を行っていますが、マージのブロッカーではありません。
エディタをバックグラウンド起動する際 stdin を DEVNULL に向け、 エディタ側が stdin を要求しても親プロセス (devbase 実行ターミナル) の 入力を奪う/ハングするのを防ぐ。 Co-Authored-By: Claude Opus 4.8 (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 free
to 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.
概要
devbase upの完了後、dev コンテナへ接続した VS Code を自動で開けるようにします(VS Code の「Attach to Running Container」を CLI から起動)。/work/$GIT_REPOをワークスペースとして開きます。起動〜開発開始の導線を短縮するのが目的です。既定は OFF(暴発回避)。プロジェクトの
envか$DEVBASE_ROOT/.envにDEVBASE_OPEN_EDITOR=1を書くと常時有効化でき、devbase up --open/--no-openで都度上書きできます。関連 Issue
issues/PLAN31_3_up-open-editor.md変更点
lib/devbase/editor/opener.py: PATH 上のcodeへの委譲を一貫機構とし、実行コンテキストを自動判別して開く先を切り替える。codeラッパ経由)codeシム +VSCODE_IPC_HOOK_CLIがリモートホスト上のコンテナへ接続した窓を手元に開く)code --folder-uri ...を提示code不在 → 理由を表示してスキップ{"containerName":"/<実コンテナ名>"}を hex 化(ssh-remote+とattached-container+を 1 本に合成するネスト authority は公式未サポートのため、codeシム/IPC hook の委譲に依拠)cmd_upに[6/6] Opening editorを追加。エディタ起動の成否はupの戻り値に影響させない。up(top-level /project up/container up)に三状態の--open/--no-openと--open-index N。DEVBASE_OPEN_EDITOR(真偽・既定 OFF)/DEVBASE_EDITOR(既定code、cursor等も可)/DEVBASE_OPEN_INDEX(既定 1)。docs/user/environment-variables.mdに専用セクション、CHANGELOG.mdに追記。動作確認
devbase up --helpに--open/--no-open/--open-indexが表示されるpytest: 748 passed, 1 skipped(opener 単体 37 + dispatch 統合 5 ケース追加)python -m compileall lib bin/ モジュール import OK補足
devbase upを実行する必要があります(plain SSH ではコマンド提示に degrade)。