xiaohongshu
xiaohongshu
dev-undo-redo
FIX conflicting undo/redo implementations with VueUse + Pinia and DESIGN robust patterns for complex applications. Use for both stabilizing existing systems and implementing advanced undo/redo architecture.
Full skill instructions
ALWAYS use this exact pattern for FlowState undo/redo:
import { useManualRefHistory } from '@vueuse/core'
const {
history,
undo,
redo,
canUndo,
canRedo,
commit
} = useManualRefHistory(unifiedState, {
capacity: 50,
deep: true,
clone: true
})
// Pattern: Save state before and after every change
const saveState = (description: string) => {
commit() // VueUse handles everything
}
saveState() before and after state changesuseUnifiedUndoRedo()actions: {
createTask(taskData: Partial<Task>) {
const undoRedo = useUnifiedUndoRedo()
undoRedo.saveState('Before task creation')
// Your logic here
this.tasks.push(newTask)
undoRedo.saveState('After task creation')
return newTask
}
}
<script setup>
const { canUndo, canRedo, undo, redo } = useUnifiedUndoRedo()
// Keyboard shortcuts handled automatically
// UI shows correct button states
</script>
<template>
<button @click="undo" :disabled="!canUndo">↶ Undo</button>
<button @click="redo" :disabled="!canRedo">↷ Redo</button>
</template>
This skill ensures ONE consistent undo/redo system across FlowState, eliminating all conflicts and providing reliable functionality.
For complex applications requiring enhanced undo/redo capabilities, consider these advanced patterns:
Use the Command Pattern for complex operations requiring granular control:
interface Command {
execute(): void | Promise<void>
undo(): void | Promise<void>
getDescription(): string
canExecute(): boolean
}
class OptimizedHistory {
private undoStack: HistoryEntry[] = []
private redoStack: HistoryEntry[] = []
async execute(command: Command): Promise<void> {
await command.execute()
this.undoStack.push({ command, timestamp: Date.now() })
this.redoStack = []
this.optimizeMemory()
}
}
Create domain-specific commands for all mutable operations:
// Task Management Commands
class CreateTaskCommand extends BaseCommand {
constructor(private taskStore: any, private taskData: any) {
super(`Create task: ${taskData.title}`)
}
async execute(): Promise<void> {
this.generatedId = await this.taskStore.createTask(this.taskData)
}
async undo(): Promise<void> {
if (this.generatedId) {
await this.taskStore.deleteTask(this.generatedId)
}
}
}
// Canvas Interaction Commands
class MoveNodeCommand extends BaseCommand {
constructor(
private canvasStore: any,
private nodeId: string,
private fromPos: Position,
private toPos: Position
) {
super(`Move node ${nodeId}`)
}
async execute(): Promise<void> {
await this.canvasStore.updateNodePosition(this.nodeId, this.toPos)
}
async undo(): Promise<void> {
await this.canvasStore.updateNodePosition(this.nodeId, this.fromPos)
}
}
For large-scale applications, implement these optimizations:
execute() and undo() methodsUse Command Pattern and advanced architecture when:
Use the VueUse approach (from primary section above) when:
This comprehensive approach ensures robust, scalable undo/redo systems that maintain consistency across complex applications while optimizing performance and memory usage.
CRITICAL: Before claiming ANY issue, bug, or problem is "fixed", "resolved", "working", or "complete", the following verification protocol is MANDATORY:
REQUIRED: Use the AskUserQuestion tool to explicitly ask the user to verify the fix:
"I've implemented [description of fix]. Before I mark this as complete, please verify:
1. [Specific thing to check #1]
2. [Specific thing to check #2]
3. Does this fix the issue you were experiencing?
Please confirm the fix works as expected, or let me know what's still not working."
Remember: The user is the final authority on whether something is fixed. No exceptions.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience