File size: 2,176 Bytes
fa35534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Card selection, selected export, draw-next, and immediate timing edits

Last updated: 2026-05-12

## Goal

The default workflow should feel like reviewing cards rather than configuring a batch pipeline:

```text
drop audio → cards appear → keep/dismiss/draw/trim → export selected
```

## Implemented

### Per-card selection

Each visible sample card now has a real checkbox. Newly produced cards are selected by default until the user changes selection manually. After the user clears or changes the selection, the UI respects that manual state.

### Selected-only export

`POST /api/jobs/{job_id}/export-selected` renders only the selected card labels into a separate `selected/` export directory:

- `selected/sample-pack.zip`,
- `selected/samples/*.wav`,
- `selected/reconstruction.mid`,
- `selected/target_reconstruction.wav`,
- `selected/reconstruction.wav`,
- `selected/manifest.json`.

The original batch export is left untouched.

### Persisted draw-next

The card “draw another” action now calls:

```text
POST /api/jobs/{job_id}/samples/{sample_label}/draw
```

The backend cycles the semantic cluster representative to the next active hit and records that as a pinned representative override. Later selected/edited exports honor this choice.

### Immediate trim/extend preview

Trim/extend actions now call:

```text
POST /api/jobs/{job_id}/samples/{sample_label}/edit
```

The backend slices from `stem.wav`, writes an edited preview under `overrides/hits/`, updates the representative hit audio path, and returns a refreshed sample card. The user hears the edited clip immediately.

## Validation

Covered by:

```bash
python3 scripts/test_selected_export_card_actions.py
```

The test verifies:

1. extraction succeeds,
2. selected-only export writes a selected pack,
3. draw-next returns a playable representative WAV,
4. trim/extend writes a playable edited override WAV.

## Remaining work

- Add true cluster relabel/merge/split from the card columns.
- Add batch restore and bulk card operations.
- Add browser-level tests for checkbox selection and selected export.
- Add visual diff between original representative and edited representative.