Commit 7aff48c
fix(tui): 回答済みプロンプト行の消去 + リファクタリング第1〜3弾 (#62)
* fix(tui): 回答済みプロンプト行を全プロンプトで消去し残留・行ずれを解消
questionary の collapse 行 (質問+回答) が Enter/y-n 回答後も画面に残り、
TUI ループの再描画が 1 回答ごとに下へずれていた。erase_when_done を
全 ask (select/text/confirm/path) で立てる _ask_erased ヘルパを新設。
pty + pyte の実 TTY 統合テストを追加 (monkeypatch では検出不能のため)。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(tui): 中止伝搬を flow モジュールへ集約し番兵ラダー・重複ループを排除
- tui/flow.py 新設: 番兵→例外変換 (need/need_optional)、境界デコレータ
(collect_args)、共通メニューループ (menu_loop)、optional_int /
confirm_or_back を一元化
- actions_*: 約 30 回反復していた None/MENU_BACK 番兵チェック 4 行ラダーを
flow.need 1 行に、_run_operation の if-elif チェーンを dict ディスパッチに、
4 ファイル重複の run() ループを flow.menu_loop に統合
- menu.py: text/path の重複収集ループを _collect_stripped に統合、
ナビヒント文言を HINT_BACK/HINT_SEARCH 定数化
- 公開契約 (関数名・戻り値番兵・プロンプト文言・プロンプト順序) は不変。
テスト変更なしで 731 passed / ruff クリーン
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(tui): 第2弾 — 選択ヘルパの残ラダー解消とカテゴリ定義の SSoT 化
- flow.back_as_cancel 新設: 選択ヘルパに残っていた None/MENU_BACK→ARG_CANCEL
変換ラダー 4 箇所を 1 行化 (env/_select_project, project/_select_build_image,
snapshot/_select_snapshot_name×2, plugin/_select_name)
- app.py: TOP_CATEGORIES / _LABELS / _route の if-elif で三重持ちだった
カテゴリ定義を _CATEGORIES 単一 SSoT から導出。routing は module.run の
遅延解決 dict に (monkeypatch 互換)
- actions_plugin: registry 名取得 2 関数を _registry_names(lister) に統合、
空一覧の案内+中止を _select_name へ吸収し wrapper 2 関数を薄い委譲に
- actions_env / actions_project: 引数なし操作 (sync/edit/up/rebuild) を
dict 直書き lambda に統一 (plugin/snapshot と同形)
公開契約・プロンプト文言・順序は不変。731 passed / ruff クリーン
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor: 第3弾 — 100行超関数の全解消と重複ロジックの SSoT 化
可読性・Pythonic 化・関数行数適正化・メンテナンス性向上を目的とした
横断リファクタリング (動作変更なし、731 tests green / ruff clean)。
- 関数分割: migrate / _install_from_repo / install_plugin /
add_repository / refresh_repository / _add_env_parser /
generate_scaled_compose / _ensure_images / cmd_up / sync_projects
→ 100 行超の関数 8 件をゼロに
- SSoT 化: RegistryInfo.available_plugins() 新設 (AvailablePlugin 変換
4 箇所を一元化)、env パース共通化 (_parse_env_assignment)、
@ref 拒否エラー・Available plugins 表示・git 実行・[name] positional
定義の共通ヘルパ化、レコード更新を dataclasses.replace に統一
- Pythonic 化: 自前 _deep_copy → copy.deepcopy、線形探索 → next()、
内包表記 / setdefault / startswith タプル化、_dispatch の if ラダー
→ 宣言的テーブル + importlib
- 死蔵コード除去: 到達不能 except、未使用 import / 変数
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent c945459 commit 7aff48c
20 files changed
Lines changed: 1670 additions & 1503 deletions
File tree
- lib/devbase
- commands
- plugin
- tui
- volume
- tests/cli/tui
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
89 | 98 | | |
90 | 99 | | |
91 | 100 | | |
| |||
156 | 165 | | |
157 | 166 | | |
158 | 167 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 168 | + | |
| 169 | + | |
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
168 | | - | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
172 | | - | |
| 178 | + | |
173 | 179 | | |
174 | 180 | | |
175 | 181 | | |
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
179 | | - | |
| 185 | + | |
180 | 186 | | |
181 | 187 | | |
182 | 188 | | |
| |||
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
188 | | - | |
189 | | - | |
190 | | - | |
| 194 | + | |
| 195 | + | |
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
| |||
243 | 248 | | |
244 | 249 | | |
245 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
246 | 257 | | |
247 | 258 | | |
248 | 259 | | |
| |||
278 | 289 | | |
279 | 290 | | |
280 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
281 | 295 | | |
282 | 296 | | |
283 | 297 | | |
| |||
421 | 435 | | |
422 | 436 | | |
423 | 437 | | |
424 | | - | |
425 | | - | |
| 438 | + | |
426 | 439 | | |
427 | 440 | | |
428 | | - | |
| 441 | + | |
429 | 442 | | |
430 | 443 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
| 444 | + | |
| 445 | + | |
436 | 446 | | |
437 | 447 | | |
438 | 448 | | |
439 | | - | |
| 449 | + | |
440 | 450 | | |
441 | 451 | | |
442 | 452 | | |
443 | 453 | | |
444 | | - | |
445 | | - | |
446 | | - | |
| 454 | + | |
| 455 | + | |
447 | 456 | | |
448 | 457 | | |
449 | 458 | | |
| |||
569 | 578 | | |
570 | 579 | | |
571 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
572 | 592 | | |
573 | 593 | | |
574 | 594 | | |
| |||
604 | 624 | | |
605 | 625 | | |
606 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
607 | 633 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
| 634 | + | |
631 | 635 | | |
632 | 636 | | |
633 | 637 | | |
| |||
0 commit comments