From 9b4b24c7ae495a6cb8b5ba0747d9d89df6ba0b78 Mon Sep 17 00:00:00 2001 From: Hare Date: Sun, 31 May 2026 16:43:49 +0900 Subject: [PATCH] ticket: plan tui module layout cleanup --- .../artifacts/.gitkeep | 0 .../item.md | 45 +++++++++++++++++ .../thread.md | 7 +++ .../artifacts/.gitkeep | 0 .../item.md | 49 +++++++++++++++++++ .../thread.md | 7 +++ .../artifacts/.gitkeep | 0 .../item.md | 44 +++++++++++++++++ .../thread.md | 7 +++ 9 files changed, 159 insertions(+) create mode 100644 work-items/open/20260531-074258-tui-extract-cli-parsing/artifacts/.gitkeep create mode 100644 work-items/open/20260531-074258-tui-extract-cli-parsing/item.md create mode 100644 work-items/open/20260531-074258-tui-extract-cli-parsing/thread.md create mode 100644 work-items/open/20260531-074258-tui-extract-single-pod-runtime/artifacts/.gitkeep create mode 100644 work-items/open/20260531-074258-tui-extract-single-pod-runtime/item.md create mode 100644 work-items/open/20260531-074258-tui-extract-single-pod-runtime/thread.md create mode 100644 work-items/open/20260531-074258-tui-move-view-mode-state/artifacts/.gitkeep create mode 100644 work-items/open/20260531-074258-tui-move-view-mode-state/item.md create mode 100644 work-items/open/20260531-074258-tui-move-view-mode-state/thread.md diff --git a/work-items/open/20260531-074258-tui-extract-cli-parsing/artifacts/.gitkeep b/work-items/open/20260531-074258-tui-extract-cli-parsing/artifacts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/work-items/open/20260531-074258-tui-extract-cli-parsing/item.md b/work-items/open/20260531-074258-tui-extract-cli-parsing/item.md new file mode 100644 index 00000000..6110c019 --- /dev/null +++ b/work-items/open/20260531-074258-tui-extract-cli-parsing/item.md @@ -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. diff --git a/work-items/open/20260531-074258-tui-extract-cli-parsing/thread.md b/work-items/open/20260531-074258-tui-extract-cli-parsing/thread.md new file mode 100644 index 00000000..0a95f1aa --- /dev/null +++ b/work-items/open/20260531-074258-tui-extract-cli-parsing/thread.md @@ -0,0 +1,7 @@ + + +## Created + +Created by tickets.sh create. + +--- diff --git a/work-items/open/20260531-074258-tui-extract-single-pod-runtime/artifacts/.gitkeep b/work-items/open/20260531-074258-tui-extract-single-pod-runtime/artifacts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/work-items/open/20260531-074258-tui-extract-single-pod-runtime/item.md b/work-items/open/20260531-074258-tui-extract-single-pod-runtime/item.md new file mode 100644 index 00000000..24b1a5b3 --- /dev/null +++ b/work-items/open/20260531-074258-tui-extract-single-pod-runtime/item.md @@ -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. diff --git a/work-items/open/20260531-074258-tui-extract-single-pod-runtime/thread.md b/work-items/open/20260531-074258-tui-extract-single-pod-runtime/thread.md new file mode 100644 index 00000000..0a95f1aa --- /dev/null +++ b/work-items/open/20260531-074258-tui-extract-single-pod-runtime/thread.md @@ -0,0 +1,7 @@ + + +## Created + +Created by tickets.sh create. + +--- diff --git a/work-items/open/20260531-074258-tui-move-view-mode-state/artifacts/.gitkeep b/work-items/open/20260531-074258-tui-move-view-mode-state/artifacts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/work-items/open/20260531-074258-tui-move-view-mode-state/item.md b/work-items/open/20260531-074258-tui-move-view-mode-state/item.md new file mode 100644 index 00000000..bc5b3a3a --- /dev/null +++ b/work-items/open/20260531-074258-tui-move-view-mode-state/item.md @@ -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. diff --git a/work-items/open/20260531-074258-tui-move-view-mode-state/thread.md b/work-items/open/20260531-074258-tui-move-view-mode-state/thread.md new file mode 100644 index 00000000..0a95f1aa --- /dev/null +++ b/work-items/open/20260531-074258-tui-move-view-mode-state/thread.md @@ -0,0 +1,7 @@ + + +## Created + +Created by tickets.sh create. + +---