Feature Request: Add PostRewind hook event for plugins
Summary
Add a new PostRewind (or Rewind) hook event that fires after the user executes /rewind, allowing plugins to react to conversation rollbacks.
Use Case
Plugins like claude-mem track session activity (observations, prompts, tool usage) in a timeline. When users rewind a conversation, the plugin's recorded history becomes inconsistent with the actual conversation state.
Current behavior:
- User submits prompt →
UserPromptSubmithook fires → plugin records the prompt - Claude responds with tool calls →
PostToolUsehooks fire → plugin records observations - User runs
/rewind→ no hook fires → plugin still shows the now-undone activity
Desired behavior:
- User runs
/rewind PostRewindhook fires with context about what was undone- Plugin can soft-delete or mark as "rewound" the corresponding records
Proposed Hook Input
export type PostRewindHookInput = BaseHookInput & {
hook_event_name: 'PostRewind';
user_message_id: string; // The message ID that was rewound to
rewound_message_ids: string[]; // IDs of messages that were undone
files_changed?: string[]; // Files affected by the rewind
};
Why This Matters
- Data consistency: Plugins maintaining state need to know when that state becomes invalid
- User experience: Timeline/history views showing "ghost" activity that was undone is confusing
- Ecosystem growth: As more plugins emerge, this becomes increasingly important
Existing Infrastructure
The SDK already has SDKControlRewindFilesRequest internally. This request is asking to expose a corresponding hook event so plugins can observe when rewind happens.
Alternatives Considered
- Polling transcript file - Hacky, race-prone, inefficient
- Manual API call by user - Poor UX, users won't remember to do it
- Detecting via missing tool_result - Unreliable, doesn't capture all rewind scenarios
A proper hook event is the clean solution that aligns with the existing hook architecture.
---
Happy to discuss implementation details or provide more context. Thanks for considering!
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗