🐛 fix: add HotkeyRegistry for conversation-level hotkey management#12907
🐛 fix: add HotkeyRegistry for conversation-level hotkey management#12907sxjeru wants to merge 11 commits into
Conversation
|
@sxjeru is attempting to deploy a commit to the LobeHub OSS Team on Vercel. A member of the Team first needs to authorize it. |
Reviewer's GuideIntroduces a Conversation-level HotkeyRegistry component that wires conversation store actions into hotkey callbacks, and mounts it inside ConversationProvider so conversation-specific keyboard shortcuts work with local message state. Sequence diagram for conversation hotkey handlingsequenceDiagram
actor User
participant HotkeySystem
participant HotkeyRegistry
participant ConversationStore
participant UIChat
User->>HotkeySystem: keyDown RegenerateMessage
HotkeySystem->>HotkeyRegistry: invoke RegenerateMessage callback
HotkeyRegistry->>ConversationStore: get displayMessages
HotkeyRegistry->>HotkeyRegistry: getLastAssistantMessageId(displayMessages)
HotkeyRegistry->>ConversationStore: regenerateAssistantMessage(messageId)
ConversationStore-->>UIChat: update displayMessages
UIChat-->>User: show regenerated assistant message
Class diagram for ConversationProvider and HotkeyRegistryclassDiagram
class ConversationProvider {
+children ReactNode
+ConversationProvider(props)
}
class HotkeyRegistry {
+HotkeyRegistry()
}
class ConversationStore {
+deleteMessage(id)
+delAndRegenerateMessage(id)
+regenerateAssistantMessage(id)
+displayMessages UIChatMessage[]
}
class UIChatMessage {
+id string
+role string
}
class HotkeyEnum {
<<enumeration>>
RegenerateMessage
DeleteLastMessage
DeleteAndRegenerateMessage
}
class useHotkeyById {
+useHotkeyById(hotkeyId, callback, options, deps)
}
class useConversationStore {
+useConversationStore(selector)
}
ConversationProvider *-- HotkeyRegistry
HotkeyRegistry ..> useConversationStore
HotkeyRegistry ..> useHotkeyById
HotkeyRegistry ..> ConversationStore
HotkeyRegistry ..> HotkeyEnum
ConversationStore o-- UIChatMessage
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
HotkeyRegistry, you’re subscribing to four store values in a single selector even though each hotkey only needs a subset; consider using separateuseConversationStoreselectors per hotkey (oruseShallow) to reduce unnecessary re-renders and subscriptions. - The
getLastAssistantMessageId/getLastMessageIdhelpers embed message-selection rules directly in the component; if this logic is (or might become) shared with other features (e.g., toolbar actions, context menus), consider moving them into a small message-utils module or the store to keep the selection semantics consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `HotkeyRegistry`, you’re subscribing to four store values in a single selector even though each hotkey only needs a subset; consider using separate `useConversationStore` selectors per hotkey (or `useShallow`) to reduce unnecessary re-renders and subscriptions.
- The `getLastAssistantMessageId` / `getLastMessageId` helpers embed message-selection rules directly in the component; if this logic is (or might become) shared with other features (e.g., toolbar actions, context menus), consider moving them into a small message-utils module or the store to keep the selection semantics consistent.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #12907 +/- ##
==========================================
+ Coverage 69.18% 70.34% +1.16%
==========================================
Files 3244 3330 +86
Lines 314191 332821 +18630
Branches 32992 35164 +2172
==========================================
+ Hits 217387 234138 +16751
- Misses 96619 98498 +1879
Partials 185 185
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b870cbe3b3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR introduces conversation-scoped registration for message-control hotkeys (regenerate, delete last, delete-and-regenerate) so that shortcuts operate on the currently active conversation’s local ConversationStore, addressing broken/incorrectly-targeted shortcuts reported in #11138.
Changes:
- Added a lightweight Zustand store to track the “active” conversation key.
- Added a
ConversationHotkeyBoundaryto set/clear the active conversation based on focus/pointer interactions. - Added
HotkeyRegistry(plus tests) and wired it intoConversationProviderto register message-control hotkeys within the provider context.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/features/Conversation/hotkeyStore.ts | Adds global state for tracking the active conversation key. |
| src/features/Conversation/ConversationHotkeyBoundary.tsx | Implements focus/pointer-based activation and blur-based deactivation for conversation hotkeys. |
| src/features/Conversation/HotkeyRegistry.tsx | Registers regenerate/delete hotkeys against the per-conversation store, gated by active conversation. |
| src/features/Conversation/HotkeyRegistry.test.tsx | Adds unit tests for enabling logic and basic action selection behavior. |
| src/features/Conversation/ConversationProvider.tsx | Wraps provider contents with the boundary and mounts the hotkey registry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d6b8d68 to
9b2986c
Compare
…ionHotkeyBoundary and update HotkeyRegistry
…nd update hotkey logic
…sage control customization
…sage control customization
…sage control customization
…ntext management in tests
…roved message control
💻 Change Type
🔗 Related Issue
🔀 Description of Change
🧪 How to Test
📸 Screenshots / Videos
📝 Additional Information
Summary by Sourcery
Add a conversation-scoped hotkey registry within ConversationProvider to handle message-level keyboard shortcuts using the local conversation store.
New Features:
Bug Fixes: