refactor: extract Undo dispatch into type-specific handlers #14
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
activities/undo.rscontains a 94-line match statement inreceive()that dispatches based onobject["type"]string matching:Each branch duplicates the pattern: parse object → call handler → log. Adding a new undo-able type requires editing
undo.rs. No type safety —obj_typeis a runtime string.Proposal
Option A — Registry pattern: Each activity type registers its own undo handler:
Option B — Co-locate with activity: Each activity module defines its own
undo()function, andundo.rsjust does lookup + delegation.Option C — Trait method: Add
fn undo()to the activity handler trait from #10, so undo logic lives next to receive logic.Files
src/activities/undo.rs(primary)src/activities/mod.rs(if registry-based)Trade-offs
Dependency
Best done after #10 (activity dispatcher middleware).