Skip to content

feat: PLAN31_2-tui-framework TUI 土台 (tui/ + メニューエンジン + 既存 project 操作の非回帰移送)#56

Merged
takemi-ohama merged 3 commits into
release/PLAN31_2from
feature/PLAN31_2-tui-framework
Jun 10, 2026
Merged

feat: PLAN31_2-tui-framework TUI 土台 (tui/ + メニューエンジン + 既存 project 操作の非回帰移送)#56
takemi-ohama merged 3 commits into
release/PLAN31_2from
feature/PLAN31_2-tui-framework

Conversation

@takemi-ohama

Copy link
Copy Markdown
Contributor

Summary

  • plan: issues/PLAN31_2_list-tui-unified.md
  • release PR: release: PLAN31_2 devbase list TUI の統合UI化 #55
  • 担当範囲: tui/ 新設・menu/dispatch/app・トップ階層メニュー・Esc/←/Ctrl-C 規約移送・引数収集ヘルパ・既存 project up/down/rebuild を非回帰移送・cmd_project_list を入口に置換

Test plan

  • 該当 action が plan 2.3 の契約どおり SimpleNamespace を組んで既存ハンドラを呼ぶ (monkeypatch 単体)
  • 破壊的操作は confirm を介す (該当時)
  • 非 TTY / questionary 不在のフォールバック

@takemi-ohama takemi-ohama marked this pull request as ready for review June 10, 2026 04:10
devbase list の対話 TUI を commands/project.py から lib/devbase/tui/ パッケージへ
分離し、全カテゴリを束ねるトップ階層メニューの入口を新設する (PLAN31_2 PR1)。

- tui/menu.py: questionary ラッパ・MENU_BACK 番兵・Esc/← バインド・引数収集
  ヘルパ (text/confirm/integer/path, input フォールバック)
- tui/dispatch.py: dispatch_lifecycle / dispatch_group (旧 _start_project_action
  を一般化、PR3〜5 の group 委譲も先行整備)
- tui/actions_project.py: 既存 project up/down/rebuild の非回帰移送 (一覧選択→
  running はサブメニュー→他は直接 up、番号入力フォールバック)
- tui/app.py: トップ階層メニュー (project/env/plugin/snapshot/status)。
  「プロジェクト操作」を先頭・既定ハイライトで従来フローへ Enter 連打到達 (3.2)。
  env 以降は後続 PR 用プレースホルダ (_route に1行追加で配線)
- commands/project.py: listing/整形の純粋ロジックへ縮約、cmd_project_list は
  tui.run への薄い委譲に置換

後方互換: --plain/非TTY→table、questionary 不在→従来の番号入力フォールバックへ縮退。

テスト: TUI エンジン系を tests/cli/tui/ へ移設・拡充。全 pytest 510 passed/1 skipped。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 1 | gemini | APPROVE

TUI機能の分離とトップメニュー化の土台として、既存のCLI互換性を保ちつつ綺麗に整理されています。1点だけ、堅牢性の観点から入力関数の再帰呼び出しについてインラインでコメントを残しました。

Comment thread lib/devbase/tui/menu.py Outdated

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 1 | codex | REQUEST_CHANGES

対話 TUI 経路の戻り値契約と入力ヘルパのキャンセル規約に修正が必要です。

Comment thread lib/devbase/tui/actions_project.py Outdated
Comment thread lib/devbase/tui/menu.py Outdated
cross-review round1 の 3 件を修正:

1. [major] actions_project.run() が dispatch_lifecycle の戻り値を捨てており
   project up/down/rebuild 失敗時も devbase list の終了コードが常に 0 になる問題を
   修正。run() は操作実行時に rc(int) を返すプロトコルへ拡張し、app._top_menu_loop が
   last_rc を記憶して終了コードへ伝搬する (判定は is 同一性で rc=0 を誤マッチさせない)。

2. [minor] menu.text() / menu.path() の allow_empty=False 空入力時の自己再帰呼び出しを
   while ループへ変更し RecursionError リスクを除去。

3. [minor] questionary 経路の text/confirm/path に Esc→中止 (None) バインドが無く
   docstring/select のナビ規約と不整合だったため _ask_with_escape ヘルパで
   with_escape_cancel を適用。

テスト追従: rc 伝搬・非0 rc 伝搬・Esc バインド登録・while 再入力ループの検証を追加
(510 passed → 520 passed / 1 skipped)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@takemi-ohama

Copy link
Copy Markdown
Contributor Author

cross-review round1 対応サマリ

commit: 5948c08

重要度 件数 対応
critical 0 -
major 1 対応済
minor 2 対応済
deferred 0 -
rejected 0 -

対応内容

  1. [major] actions_project.py:93dispatch_lifecycle の rc を捨てず run() の戻り値として伝搬。app._top_menu_loop が last_rc を記憶し devbase list の終了コードへ反映 (rc=0 を None/MENU_BACK と誤マッチさせないよう is 同一性判定)。
  2. [minor] menu.py:163 — text()/path() の空入力再試行を自己再帰から while ループへ変更し RecursionError リスクを除去。
  3. [minor] menu.py:157 — questionary 経路の text/confirm/path に _ask_with_escape 経由で Esc→中止バインドを適用し select のナビ規約と整合化。

テスト

uv run pytest: 520 passed / 1 skipped (510→520、rc 伝搬・非0伝搬・Esc バインド・while 再入力ループ検証を追加)。

3 thread すべて reply + resolve 済み。

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 2 | gemini | APPROVE

前回の指摘箇所(再帰呼び出しの回避)が修正されていることを確認しました。追加の修正提案はありません。

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 2 | codex | APPROVE

追加の修正必須指摘はありません。

@takemi-ohama takemi-ohama merged commit 50ab9c2 into release/PLAN31_2 Jun 10, 2026
takemi-ohama added a commit that referenced this pull request Jun 10, 2026
PR1 を cross-review approved → release へ merge (50ab9c2) 済みに更新し、
後続 PR (project/env/plugin/snapshot/status) が tui 土台へ配線する手順
(_route 1 行追加・menu 引数収集・dispatch_group・confirm/chdir) を申し送りとして追記。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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