# T3-2.3: Task Picker and Active Task

## Priority
Medium

## Status
Completed

## Description
Implement task picker and active task tracking for the CLI. This allows users to "pick" a task they're working on, save it locally, and quickly reference it.

## Objectives
- Implement `anyt task pick` command with interactive selection
- Implement `anyt active` command to show current active task
- Store active task in `.anyt/active_task.json`
- Support quick operations on active task without specifying ID
- Interactive task picker when no ID provided

## Commands

### anyt task pick
```bash
# Pick a specific task
$ anyt task pick DEV-42
✓ Picked DEV-42 (Implement OAuth callback)
  Saved to .anyt/active_task.json

# Interactive picker (no args)
$ anyt task pick
? Select task to work on:
  [Active]
    DEV-42  Implement OAuth callback     you    2h ago

  [Runnable] (no blocking dependencies)
>   DEV-45  Integration tests            —      30m ago
    DEV-46  Add logging                  —      1d ago

  [Blocked]
    DEV-43  Add tests                    agent  ← DEV-42

Use ↑↓ to navigate, Enter to select, q to quit

✓ Picked DEV-45 (Integration tests)
```

### anyt active
```bash
# Show active task
$ anyt active

DEV-42: Implement OAuth callback
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Status: in progress    Priority: ●●○○○ (2)
Owner: you             Labels: auth, backend

Dependencies: All satisfied ✓

Last updated: 2 hours ago
Time tracked: 3h 45m (estimated: 5h)

# If no active task
$ anyt active
No active task. Pick one with: anyt task pick
```

### Shorthand operations on active task
```bash
# After picking a task
$ anyt task pick DEV-42

# These commands work without specifying ID
$ anyt task done          # Mark DEV-42 as done
$ anyt task edit --status in progress
$ anyt task show          # Show DEV-42 details
$ anyt dep list           # Show DEV-42 dependencies
```

## Interactive Picker Features

### Grouping
Tasks are grouped by status:
- **Active**: Currently in-progress tasks
- **Runnable**: Tasks with no blocking dependencies
- **Blocked**: Tasks waiting on dependencies

### Filtering
```bash
# Pick from specific status
$ anyt task pick --status backlog

# Pick from specific project
$ anyt task pick --project 5

# Pick assigned to me
$ anyt task pick --mine
```

### Display Information
Each task in picker shows:
- Identifier (DEV-42)
- Title (truncated if needed)
- Owner (you, agent name, or —)
- Last updated (relative time)
- Blocking status (if applicable)

## Active Task Storage

`.anyt/active_task.json`:
```json
{
  "identifier": "DEV-42",
  "title": "Implement OAuth callback",
  "picked_at": "2025-10-15T14:30:00Z",
  "workspace_id": 1,
  "project_id": 3
}
```

## Acceptance Criteria
- [x] `anyt task pick <id>` sets active task and saves to `.anyt/active_task.json`
- [ ] `anyt task pick` (no args) shows interactive picker with ↑↓ navigation (marked as TODO for future implementation)
- [x] `anyt active` displays current active task details
- [x] `anyt active` shows helpful message when no task is active
- [ ] Interactive picker groups tasks by runnable/blocked status (marked as TODO for future implementation)
- [ ] Interactive picker supports filtering (--status, --project, --mine) (filter options added, interactive picker pending)
- [x] Commands without ID use active task as default
- [x] Active task persists across CLI sessions
- [x] Picking a new task replaces the previous active task
- [x] Rich formatted output with colors and navigation hints

## Dependencies
- T3-2.1: CLI Task Commands - Core (core commands needed for context)

## Estimated Effort
4-5 hours

## Technical Notes
- Use `rich.prompt.Prompt` or `inquirer` library for interactive selection
- Store active task in `.anyt/active_task.json` (gitignored)
- Check for active task in commands using helper function: `get_active_task_id()`
- Keyboard navigation: ↑/↓ to move, Enter to select, q/Esc to quit
- Display relative timestamps using `humanize` or custom formatter
- Limit picker to 20 most recent tasks (with option to see more)
- Auto-clear active task when it's marked as done
- Consider adding `anyt task unpick` to clear active task

## Out of Scope
- Time tracking/timer features
- Multiple active tasks
- Active task history/switching between recent tasks
- Pomodoro timer integration

## Events

### 2025-10-15 21:10 - Started work
- Moved task from backlog to active
- Created new branch T3-2.3-task-picker-active-task based on main
- Beginning implementation of task picker and active task tracking
- Will implement: `anyt task pick`, `anyt active`, and active task integration

### 2025-10-15 22:30 - Implementation completed
- Created `ActiveTaskConfig` model in `src/cli/config.py` for managing active task state
- Implemented `anyt task pick <id>` command to set active task and save to `.anyt/active_task.json`
- Implemented `anyt active` top-level command to display current active task details
- Updated all task commands to support optional identifier (uses active task as default):
  - `anyt task show` - shows active task if no ID provided
  - `anyt task edit` - edits active task if no ID provided
  - `anyt task done` - marks active task as done and clears it
  - `anyt task rm` - deletes active task and clears it
  - `anyt dep add`, `anyt dep rm`, `anyt dep list` - all support active task as default
- Added `.anyt/active_task.json` to .gitignore
- Auto-clear active task when marked as done or deleted
- All code passes linting, formatting, and type checking
- Interactive picker (`anyt task pick` without args) marked as TODO for future implementation
- Ready for PR creation

### 2025-10-15 22:35 - PR created
- Committed changes to branch T3-2.3-task-picker-active-task
- Pushed to remote origin
- Created PR #23: https://github.com/supercarl87/AnyTaskBackend/pull/23
- Task moved to done/
