ticket: plan tui module layout cleanup

This commit is contained in:
Keisuke Hirata 2026-05-31 16:43:49 +09:00
parent d56d3951d3
commit 9b4b24c7ae
No known key found for this signature in database
9 changed files with 159 additions and 0 deletions

View File

@ -0,0 +1,45 @@
---
id: 20260531-074258-tui-extract-cli-parsing
slug: tui-extract-cli-parsing
title: TUI: extract CLI parsing from main.rs
status: open
kind: task
priority: P2
labels: [tui, cleanup]
created_at: 2026-05-31T07:42:58Z
updated_at: 2026-05-31T07:42:58Z
assignee: null
legacy_ticket: null
---
## Background
A read-only investigation of `crates/tui` found that the TUI crate's flat module list is not only cosmetic: `main.rs` has accumulated entrypoint, CLI parsing, mode dispatch, terminal setup, Pod connection, single-Pod event loop, key/mouse handling, and tests.
This ticket is the first, lowest-risk cleanup step: move command-line parsing types/functions/tests out of `main.rs` so `main.rs` starts becoming a thin entrypoint without changing runtime behavior.
## Requirements
- Extract the TUI CLI parsing code from `crates/tui/src/main.rs` into a focused module, likely `crates/tui/src/cli.rs`.
- Move the related parse tests with the parsing implementation.
- Keep external CLI behavior unchanged, including:
- `insomnia pod ...` runtime dispatch;
- `--pod`, `--session`, `-r`, `--multi`, profile/manifest-related arguments;
- memory lint and other headless subcommands.
- Keep this ticket to mechanical extraction plus names needed for clarity; do not reorganize the broader TUI module tree.
- Do not rename the `tui` crate/package.
## Non-goals
- Moving terminal runtime/event-loop code.
- Moving `ui::Mode` / view state.
- Reworking CLI UX or flag semantics.
- Introducing compatibility aliases for removed commands.
## Acceptance criteria
- `main.rs` no longer owns the core CLI parse type/function/test definitions.
- `main.rs` uses the extracted CLI module for dispatch.
- Behavior remains unchanged for normal TUI launch, Pod runtime launch, restore/attach options, multi-Pod launch, and memory lint.
- Focused CLI parser tests pass.
- `cargo fmt --check`, relevant `cargo test -p tui`, `cargo check -p tui`, `./tickets.sh doctor`, and `git diff --check` pass.

View File

@ -0,0 +1,7 @@
<!-- event: create author: tickets.sh at: 2026-05-31T07:42:58Z -->
## Created
Created by tickets.sh create.
---

View File

@ -0,0 +1,49 @@
---
id: 20260531-074258-tui-extract-single-pod-runtime
slug: tui-extract-single-pod-runtime
title: TUI: extract single-Pod runtime loop from main.rs
status: open
kind: task
priority: P2
labels: [tui, cleanup]
created_at: 2026-05-31T07:42:58Z
updated_at: 2026-05-31T07:42:58Z
assignee: null
legacy_ticket: null
---
## Background
A read-only investigation of `crates/tui` found that `main.rs` remains large even after CLI parsing because it owns terminal setup, Pod connection orchestration, single-Pod event loop, key/mouse handling, stream drain behavior, and many tests.
After CLI parsing is extracted, this ticket should move the single-Pod runtime/event-loop responsibilities out of `main.rs` so the entrypoint mostly chooses a mode and delegates execution.
## Requirements
- Extract single-Pod TUI runtime/event-loop code from `main.rs` into a focused module, likely `single_pod.rs` or `runtime.rs`.
- Include the related key/mouse handling and stream/event drain helpers only where doing so keeps behavior-preserving extraction clear.
- Keep mode dispatch in `main.rs` thin: parse CLI, choose runtime mode, delegate.
- Preserve terminal setup/restore behavior, input queueing behavior, interruption handling, task reminders, manual rewind/compact handling, and Pod socket behavior.
- Keep the change behavior-preserving; do not redesign keybindings or event handling.
- Avoid broad module reorganization in the same ticket.
## Dependencies / sequencing
- Prefer doing this after `tui-extract-cli-parsing` so `main.rs` is less entangled.
- This can be done before or after `tui-move-view-mode-state`, but implementation should avoid increasing `app <-> ui` coupling.
## Non-goals
- Moving render helpers into `render/`.
- Splitting `multi_pod.rs`.
- Reworking `App` state ownership.
- Changing Pod protocol or TUI UX.
- Renaming the `tui` crate/package.
## Acceptance criteria
- `main.rs` no longer owns the bulk of the single-Pod event loop implementation.
- Normal single-Pod TUI launch behavior is unchanged.
- Existing queueing, interrupt, compact, rewind, and stream handling tests still pass.
- `main.rs` remains the binary entrypoint and high-level dispatcher.
- `cargo fmt --check`, relevant `cargo test -p tui`, `cargo check -p tui`, `./tickets.sh doctor`, and `git diff --check` pass.

View File

@ -0,0 +1,7 @@
<!-- event: create author: tickets.sh at: 2026-05-31T07:42:58Z -->
## Created
Created by tickets.sh create.
---

View File

@ -0,0 +1,44 @@
---
id: 20260531-074258-tui-move-view-mode-state
slug: tui-move-view-mode-state
title: TUI: move view mode state out of ui module
status: open
kind: task
priority: P2
labels: [tui, cleanup]
created_at: 2026-05-31T07:42:58Z
updated_at: 2026-05-31T07:42:58Z
assignee: null
legacy_ticket: null
---
## Background
A read-only investigation of `crates/tui` found that `app.rs` imports `crate::ui::Mode` while `ui.rs` imports and renders `App`. This is not a Rust module cycle, but it makes the state/render boundary conceptually circular: application state depends on a type owned by the rendering module.
This ticket separates the single-Pod display/history mode state from the render module before larger module grouping work.
## Requirements
- Move the single-Pod display/history mode type currently owned by `ui.rs` to a state-oriented location.
- Acceptable destinations include `app.rs` or a focused module such as `view_mode.rs`.
- If renaming, prefer a clearer name such as `ViewMode` or `HistoryMode`; keep the diff small if a rename would become noisy.
- Update `app.rs`, `ui.rs`, `tool.rs`, and tests to use the new location/name.
- Remove the `app.rs -> ui.rs` dependency caused only by this mode type.
- Preserve rendering behavior and keyboard/command behavior.
- Keep visibility changes minimal; do not combine this with broad `App` field privatization.
## Non-goals
- Moving the whole render tree into `render/`.
- Splitting `app.rs` broadly.
- Reworking mode semantics or UI layout.
- Renaming the `tui` crate/package.
## Acceptance criteria
- `app.rs` no longer imports `crate::ui` solely to access display/history mode state.
- Render code still consumes the mode state from the state-oriented module/type.
- Existing mode-related behavior is unchanged.
- Focused tests covering mode/key/render behavior pass.
- `cargo fmt --check`, relevant `cargo test -p tui`, `cargo check -p tui`, `./tickets.sh doctor`, and `git diff --check` pass.

View File

@ -0,0 +1,7 @@
<!-- event: create author: tickets.sh at: 2026-05-31T07:42:58Z -->
## Created
Created by tickets.sh create.
---