diff --git a/.factory/library/architecture.md b/.factory/library/architecture.md
index b1c7691..00d322f 100644
--- a/.factory/library/architecture.md
+++ b/.factory/library/architecture.md
@@ -59,6 +59,7 @@ Unified event system replacing EventBus + CustomEvents. Topics with `equals: fal
- `addExample()` — adds current I/O as training example, updates reactive count
- `clearAll()` — clears examples, loss history, resets noise to default
- `getLossHistory()` — returns copy of loss history array
+- Undo stack: ring buffer (max 20 entries) of weight snapshots with noise level. `pushUndoSnapshot()` called before `thumbsDown()` and `randomise()`. `undo()` pops snapshot, restores weights and noise. `undoDepthSignal` — reactive depth for UI button state.
- `dispose()` destroys both IML instances (called in App.tsx onCleanup)
- Bus topics created: `ml.outputs`, `ml.outputCount`, `mode.output`
- Debug probe (`probe/debug-probe.ts`) now wraps MLStore instead of raw WasmIML
@@ -117,6 +118,16 @@ Unified event system replacing EventBus + CustomEvents. Topics with `equals: fal
- Format: "N examples · loss X.XXXXX · noise X.XXX" or "N examples · untrained · noise X.XXX"
- Reactively watches exampleCountSignal, lastLossSignal, noiseLevel signals
+### RLButtons Component (`components/rl/RLButtons.tsx`) — IMPLEMENTED
+- Three floating circular buttons: thumbs-down (−, key 1), undo (↶, key Z), thumbs-up (+, key 2)
+- Positioned bottom-center above status line
+- Thumbs-down: push undo snapshot, add noise to weights
+- Thumbs-up: add example + async training + decay noise
+- Undo: pop undo stack, restore weights + noise level
+- Undo button shows muted state when stack empty, cyan accent (`has-undo` class) when entries exist
+- Glass morphism styling with per-button accent colors
+- Exposed as `#btn-thumbsdown`, `#btn-undo`, `#btn-thumbsup` for e2e tests
+
### Dual IML System
- `imlJoy`: 2 inputs (joystick), dynamic outputs — warm-started on resize
- `imlHand`: 14 inputs (hand tracking), dynamic outputs — fresh on resize
diff --git a/src/components/rl/RLButtons.tsx b/src/components/rl/RLButtons.tsx
index ccae980..3736041 100644
--- a/src/components/rl/RLButtons.tsx
+++ b/src/components/rl/RLButtons.tsx
@@ -4,6 +4,7 @@
* Matches the old app's rl-buttons div:
* - Thumbs-down (−): explore more (adds noise to weights)
* - Thumbs-up (+): keep this (adds example + async training + decays noise)
+ * - Undo (↶): restore previous weight state from undo stack
*
* Positioned at bottom-center of viewport, above the status line.
* Glass morphism circular buttons with keyboard shortcut hints.
@@ -20,6 +21,15 @@ export interface RLButtonsProps {
export default function RLButtons(props: RLButtonsProps) {
let thumbsUpBtn: HTMLButtonElement | undefined;
let thumbsDownBtn: HTMLButtonElement | undefined;
+ let undoBtn: HTMLButtonElement | undefined;
+
+ // Track undo depth for has-undo class (reactive signal)
+ createEffect(() => {
+ const depth = props.mlStore.undoDepthSignal();
+ if (undoBtn) {
+ undoBtn.classList.toggle('has-undo', depth > 0);
+ }
+ });
function onThumbsUp(): void {
flashButton(thumbsUpBtn);
@@ -33,6 +43,11 @@ export default function RLButtons(props: RLButtonsProps) {
props.mlStore.thumbsDown();
}
+ function onUndo(): void {
+ flashButton(undoBtn);
+ props.mlStore.undo();
+ }
+
function flashButton(btn: HTMLButtonElement | undefined): void {
if (!btn) return;
btn.classList.add('flash');
@@ -51,6 +66,16 @@ export default function RLButtons(props: RLButtonsProps) {
−
1
+