redo
Restore the last undone modification to your Strudel music pattern during live coding.
Instructions
Redo action
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server/tools/history.ts:129-140 (handler)The execute() handler for the 'redo' tool: pops from redoStack, pushes current pattern to undoStack, calls writePattern to restore the saved state, and returns 'Redone'.
case 'redo': { if (!ctx.isInitialized()) return 'Browser not initialized. Run init first.'; if (redoStack.length === 0) return 'Nothing to redo'; const current = await ctx.controller.getCurrentPattern(); undoStack.push(current); if (undoStack.length > maxHistory) undoStack.shift(); const next = redoStack.pop()!; await ctx.controller.writePattern(next); return 'Redone'; } - src/server/tools/history.ts:24-27 (schema)Schema definition of the 'redo' tool: name 'redo', description 'Redo action', no input properties.
{ name: 'redo', description: 'Redo action', inputSchema: { type: 'object', properties: {} }, - src/server/tools/types.ts:36-41 (schema)HistoryState type definition: contains redoStack (string[]) along with undoStack, historyStack, and maxHistory.
export interface HistoryState { undoStack: string[]; redoStack: string[]; historyStack: HistoryEntry[]; readonly maxHistory: number; } - src/server/server.ts:369-371 (registration)Registration: historyModule tools (including 'redo') are spread into the tool list at line 126, and dispatch to historyModule.execute at line 369-371.
if (historyModule.toolNames.has(name)) { return await historyModule.execute(name, args, ctx); } - src/server/server.ts:307-329 (helper)redoStack is cleared (set to []) whenever a write/append/insert/replace/clear action occurs, ensuring a clean redo history after new edits (line 329). The redoStack is initialized at line 58 and passed via ctx.history at line 351.
// Save current state for undo and history (#41) (only if initialized) if (['write', 'append', 'insert', 'replace', 'clear'].includes(name) && this.isInitialized) { try { const current = await this.controller.getCurrentPattern(); this.undoStack.push(current); // Add to history stack with metadata (#41) this.historyIdCounter++; this.historyStack.push({ id: this.historyIdCounter, pattern: current, timestamp: new Date(), action: name }); // Enforce bounds to prevent memory leaks if (this.undoStack.length > this.MAX_HISTORY) { this.undoStack.shift(); } if (this.historyStack.length > this.MAX_HISTORY) { this.historyStack.shift(); } this.redoStack = [];