Problem
The Design Mode has an Apply button and a Reset button, but no Undo/Redo functionality. If a user applies a change and then regrets it, they must manually revert the CSS/Tailwind classes. There is no history of changes.
Goal
Implement a proper Command-History system for the Design Mode that supports:
- Undo last change (⌘Z / Ctrl+Z)
- Redo previously undone change (⌘ShiftZ / Ctrl+ShiftZ)
- Persistent history across sessions (stored in
.sin-webui/)
- History items show description (e.g., "Changed div class to 'p-4'")
Acceptance Criteria
Files to modify / create
New files
lib/workspace/design-history.ts # Command pattern: history stack, undo/redo
app/api/workspace/design-history/route.ts # GET/POST/DELETE history entries
Files to modify
components/workspace/design-panel.tsx # Wire Undo/Redo buttons to history API
components/workspace/workspace-header.tsx # Add keyboard shortcut listener (⌘Z)
public/design-mode-agent.js # Report actions to parent for history tracking
app/api/workspace/design-edit/route.ts # Push to history stack after successful apply
Technical Notes
- Use the Command Pattern: each action is an object with
execute() and undo() methods
- Store history in
.sin-webui/design-history.jsonl (append-only, bounded)
- History entry format:
{
"id": "uuid",
"timestamp": "ISO-8601",
"type": "class-change",
"file": "app/page.tsx",
"line": 12,
"oldValue": "p-2 m-4",
"newValue": "p-4 m-6",
"description": "Changed padding and margin on div"
}
- Undo: read last entry, apply
oldValue to the file, pop from stack
- Redo: push undone entry back to stack, apply
newValue
- The design-mode-agent.js should report all user actions (clicks, drags, class changes) to the parent so they can be recorded
Related
- components/workspace/design-panel.tsx: Current Undo/Redo buttons (currently no-op)
- app/api/workspace/design-edit/route.ts: Where changes are applied to files
Problem
The Design Mode has an Apply button and a Reset button, but no Undo/Redo functionality. If a user applies a change and then regrets it, they must manually revert the CSS/Tailwind classes. There is no history of changes.
Goal
Implement a proper Command-History system for the Design Mode that supports:
.sin-webui/)Acceptance Criteria
Files to modify / create
New files
Files to modify
Technical Notes
execute()andundo()methods.sin-webui/design-history.jsonl(append-only, bounded){ "id": "uuid", "timestamp": "ISO-8601", "type": "class-change", "file": "app/page.tsx", "line": 12, "oldValue": "p-2 m-4", "newValue": "p-4 m-6", "description": "Changed padding and margin on div" }oldValueto the file, pop from stacknewValueRelated