a73x

specs/005-tui-issue-creation/tasks.md

Ref:   Size: 6.1 KiB

# Tasks: TUI Issue Creation

**Input**: Design documents from `/specs/005-tui-issue-creation/`
**Prerequisites**: plan.md (required), spec.md (required for user stories)

**Tests**: Not explicitly requested — test tasks omitted.

**Organization**: Tasks are grouped by user story to enable independent implementation and testing of each story.

## Format: `[ID] [P?] [Story] Description`

- **[P]**: Can run in parallel (different files, no dependencies)
- **[Story]**: Which user story this task belongs to (e.g., US1, US2, US3)
- Include exact file paths in descriptions

## Phase 1: Setup (Shared Infrastructure)

**Purpose**: Replace `search_active: bool` with `InputMode` enum and add supporting fields

- [ ] T001 Add `InputMode` enum (`Normal`, `Search`, `CreateTitle`, `CreateBody`) and replace `search_active: bool` with `input_mode: InputMode` in App struct in `src/tui.rs`
- [ ] T002 Add `create_title: String` field to App struct for storing title while entering body in `src/tui.rs`
- [ ] T003 Update all existing `search_active` references to use `InputMode::Search` / `InputMode::Normal` checks in `src/tui.rs`

**Checkpoint**: Existing search functionality works identically using the new `InputMode` enum

---

## Phase 2: User Story 1 - Create Issue with Title (Priority: P1) 🎯 MVP

**Goal**: User presses `n` to open inline title input, types title, presses Enter to create issue

**Independent Test**: Press `n`, type a title, press Enter — new issue appears in list

### Implementation for User Story 1

- [ ] T004 [US1] Handle `n` keypress in Normal mode: set `input_mode` to `CreateTitle`, clear input buffer, switch to Issues tab if on Patches tab in `src/tui.rs`
- [ ] T005 [US1] Handle key input in `CreateTitle` mode: printable chars append to input buffer, Backspace deletes last char, Escape cancels and returns to Normal mode in `src/tui.rs`
- [ ] T006 [US1] Handle Enter in `CreateTitle` mode: reject empty/whitespace-only title (dismiss form), otherwise call `issue::open(repo, &title, "")`, reload issue list, return to Normal mode in `src/tui.rs`
- [ ] T007 [US1] Render title input form in footer area when `input_mode` is `CreateTitle` — show "New issue - Title: {input}" replacing status bar in `src/tui.rs`

**Checkpoint**: User Story 1 fully functional — user can create issues with title-only from dashboard

---

## Phase 3: User Story 2 - Create Issue with Title and Body (Priority: P2)

**Goal**: After entering title, user can optionally enter a body before creating the issue

**Independent Test**: Press `n`, enter title, press Enter, enter body, press Enter — issue has both title and body. Or press Escape at body step to create with title only.

### Implementation for User Story 2

- [ ] T008 [US2] Modify Enter handler in `CreateTitle`: instead of creating issue immediately, store title in `create_title` field and transition to `CreateBody` mode in `src/tui.rs`
- [ ] T009 [US2] Handle key input in `CreateBody` mode: printable chars append to input buffer, Backspace deletes last char in `src/tui.rs`
- [ ] T010 [US2] Handle Enter in `CreateBody` mode: call `issue::open(repo, &create_title, &body)`, reload issue list, return to Normal mode in `src/tui.rs`
- [ ] T011 [US2] Handle Escape in `CreateBody` mode: create issue with title only (`issue::open(repo, &create_title, "")`), return to Normal mode in `src/tui.rs`
- [ ] T012 [US2] Render body input form in footer area when `input_mode` is `CreateBody` — show "New issue - Body: {input}" in `src/tui.rs`

**Checkpoint**: User Stories 1 AND 2 both work — full two-step creation flow functional

---

## Phase 4: User Story 3 - Status Feedback During Creation (Priority: P3)

**Goal**: User sees clear feedback: current step label, success confirmation, error message

**Independent Test**: Create an issue and verify success message appears in status bar

### Implementation for User Story 3

- [ ] T013 [US3] On successful issue creation, set `status_msg` to "Issue created: {short-id}" in `src/tui.rs`
- [ ] T014 [US3] On failed issue creation, set `status_msg` to error description and return to Normal mode in `src/tui.rs`

**Checkpoint**: All user stories independently functional with full feedback loop

---

## Phase 5: Polish & Cross-Cutting Concerns

**Purpose**: Edge case handling and robustness

- [ ] T015 Ensure `n` keypress is ignored when `input_mode` is not `Normal` (search mode should still capture it as a character) in `src/tui.rs`
- [ ] T016 Trim whitespace from title before validation (whitespace-only titles should be rejected) in `src/tui.rs`

---

## Dependencies & Execution Order

### Phase Dependencies

- **Setup (Phase 1)**: No dependencies — T001-T003 must complete first
- **User Story 1 (Phase 2)**: Depends on Phase 1 (InputMode enum exists)
- **User Story 2 (Phase 3)**: Depends on Phase 2 (modifies title submit behavior)
- **User Story 3 (Phase 4)**: Depends on Phase 2 (needs creation flow to add feedback to)
- **Polish (Phase 5)**: Depends on all user stories being complete

### Within Each User Story

- All tasks are in `src/tui.rs` so no parallelization within phases
- Tasks within each phase should be done sequentially

### Parallel Opportunities

- User Story 3 (Phase 4) could be partially done in parallel with User Story 2 (Phase 3) since feedback is independent of the two-step flow
- Polish tasks T015 and T016 are independent of each other

---

## Implementation Strategy

### MVP First (User Story 1 Only)

1. Complete Phase 1: Setup (InputMode enum refactor)
2. Complete Phase 2: User Story 1 (title-only creation)
3. **STOP and VALIDATE**: Test title-only creation works
4. Proceed to Phase 3: User Story 2 (add body step)

### Incremental Delivery

1. Setup → InputMode enum ready
2. Add US1 → Title-only creation works (MVP!)
3. Add US2 → Two-step title+body creation works
4. Add US3 → Status feedback works
5. Polish → Edge cases handled

---

## Notes

- All changes are in a single file (`src/tui.rs`) — no parallel file editing possible
- The `issue::open()` function in `src/issue.rs` is read-only — already exists
- Total tasks: 16
- Tasks per user story: US1=4, US2=5, US3=2, Setup=3, Polish=2
- Suggested MVP scope: Phase 1 + Phase 2 (User Story 1)