# Playlist Queue Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Add a Settings-based playlist queue that can advance through footage, GIFs, and images with shuffle and repeat.

**Architecture:** Add a `src/playlist.js` module that stores a lightweight queue in localStorage and reuses History media items for loading. History exposes a shared loader so normal History clicks still close Settings while playlist advancement stays in place.

**Tech Stack:** Adobe CEP panel, vanilla JavaScript modules, IndexedDB media history, localStorage, CSS.

---

### Task 1: UI

**Files:**
- Modify: `index.html`
- Modify: `style.css`

- [x] Add a Playlist settings tab.
- [x] Add playlist controls for Add Current, Add From History, Play/Pause, Previous, Next, Shuffle, Repeat, Clear, and image duration.
- [x] Add queue and history-pick containers.
- [x] Style playlist rows, controls, active item, and empty states.

### Task 2: Shared Loading

**Files:**
- Modify: `src/history.js`

- [x] Split History loading into a shared media item loader.
- [x] Keep existing History click behavior closing Settings.
- [x] Export the shared loader for playlist playback.

### Task 3: Playlist Logic

**Files:**
- Create: `src/playlist.js`
- Modify: `src/storage-keys.js`
- Modify: `src/controls.js`

- [x] Add storage keys for queue, active index, shuffle, repeat, image duration, and playing state.
- [x] Build queue add/remove/clear/play/pause/previous/next behavior.
- [x] Add current media from History metadata.
- [x] Add items from History into the queue.
- [x] Auto-advance on video ended.
- [x] Auto-advance images/GIFs after the selected duration.

### Task 4: Verify And Install

**Files:**
- Modify: `CHANGELOG-CODEX.md`

- [x] Add changelog entry.
- [x] Run JS syntax checks and build.
- [x] Copy to CEP with backup.
- [x] Verify installed bundle, manifest, and feature strings.
