# Track Specification: Context Composition Slice Visualization

## Overview
Enhance slice visualization with visual editor, annotation support (tags/comments), and view presets. This is Phase 2 of the Context Composition Redesign per spec at `docs/superpowers/specs/2026-05-10-context-composition-redesign-design.md`.

## Current State Audit (as of 2026-05-10)
### Already Implemented
- [Inspect] button opens AST inspector modal showing AST tree with Def/Sig/Hide toggles
- [Slices] button opens Text Viewer with file content for slice management
- FileItem.ast_mask stores mask per AST path (Def/Sig/Hide)
- FileItem.custom_slices stores user-defined slices with line ranges

### Gaps to Fill (This Track's Scope)
- Inspect popup shows AST but doesn't show file content with highlighted slices
- Slices editor is just a list of line ranges - no visual representation
- No annotation support (tags/comments) for custom slices
- No view presets (named combinations of view settings)
- AST-derived slices not shown before user creates custom slice

## Goals
1. Slice inspector shows file content with AST-derived slices visually highlighted
2. Custom slices have visual representation (colored ranges) in slice editor
3. Each slice can have optional tag and comment annotation
4. View presets allow naming and reusing view configurations
5. User can toggle which AST elements are included in each view

## Functional Requirements
### Slice Inspector (replaces Inspect button)
- Opens as popup showing full file content with line numbers
- AST-derived slices highlighted with distinct colors:
  - Sig elements: one color
  - Def elements: another color
- User can toggle visibility of each AST element (Def/Sig/Hide)
- Changes persist to FileItem.ast_mask

### Slice Editor (extends Slices button)
- Visual file content display (not just line number list)
- Custom slices shown as colored overlays on the content
- Click-drag to select line range for new slice
- Each custom slice has:
  - Line range
  - Tag (optional, e.g., "performance", "api", "bug")
  - Comment (optional, free-text explanation)
- Remove/edit existing custom slices

### View Presets
- Named presets defining default view + default slices per file type
- Examples:
  - "Debug View" = full text + error-prone line slices
  - "API Surface" = sig + public API function slices
- Presets project-scoped, saved in project config
- User can select preset, then override for specific file

## Architecture Reference
- `src/gui_2.py:_render_ast_inspector_modal()` - needs enhancement
- `src/models.py:FileItem.ast_mask` - existing mask storage
- `src/models.py:FileItem.custom_slices` - needs tag/comment support
- `docs/superpowers/specs/2026-05-10-context-composition-redesign-design.md`

## Out of Scope
- Context preset save/load UI (Phase 3)
- Context preview before send (Phase 3)
- Changes to Files & Media panel (Phase 1)
