Quick Replies Management
Relevant source files
The following files were used as context for generating this wiki page:
Quick Replies Management is a power-user feature within Messenger Unleashed that allows users to define, store, and trigger templated text responses using keyboard shortcuts. This system bypasses standard manual typing by programmatically inserting text into the Messenger message input field and simulating the submission process.
The system is architected across the Electron main process for persistence and shortcut registration, and the renderer process for DOM manipulation. It supports dynamic configuration through a dedicated settings UI and global hotkeys for rapid communication.
Sources: src/main/index.ts:1-30, CLAUDE.md:1-50
Architecture and Data Flow
The Quick Replies system follows a tri-partite architecture involving the electron-store for persistence, the Main process for event handling/menus, and JavaScript injection for interaction with the Messenger web DOM.
Data Model
Quick replies are stored as an array of objects within the application state. Each object consists of a unique trigger key and the corresponding message text.
| Field | Type | Description |
|---|---|---|
key | String | A single alphanumeric character used as the shortcut trigger (e.g., "1", "A"). |
text | String | The templated message content to be inserted into the chat. |
Sources: src/main/index.ts:742-766, src/preload/settings-modal.ts:515-530
Logic Flow Diagram
The following diagram illustrates the flow from user input to message transmission in the Messenger interface.
Component Implementation
1. Persistence and State Management
The system utilizes electron-store to maintain quick replies across application restarts. The default state is initialized in src/main/state.ts (referenced as store in the main process).
- Store Key:
quickReplies - Format: Array of
{key: string, text: string}objects.
Sources: src/main/index.ts:1210-1215, CLAUDE.md:120-130
2. Main Process Logic
The main process handles the registration of global shortcuts and the orchestration of the injection process.
sendQuickReply(text): The core execution function. It usesmainWindow.webContents.executeJavaScriptto run an IIFE in the renderer context. It utilizes the modernInputEventAPI to ensure compatibility with Messenger's React-based state management.refreshGlobalShortcuts(): This function is called whenever the settings change. It unregisters existing shortcuts and iterates through thequickRepliesarray to register newCmdOrCtrl+Shift+[KEY]combinations.
Sources: src/main/index.ts:717-740, src/main/index.ts:1608-1625
3. User Interface and Configuration
Users manage quick replies through the Settings Modal or the Application Menu.
- Application Menu: Dynamically builds a "Quick Replies" submenu under "Power Tools" containing all defined templates.
- Input Parsing: The function
parseQuickRepliesInput(value)processes multi-line text input from the user, identifying the trigger key and message text using regex (e.g.,KEY: message).
Key Implementation Details
DOM Manipulation Strategy
Because Messenger uses a complex contenteditable container, the injection logic specifically targets elements with role="textbox" and contenteditable="true". To trigger Messenger's internal React state updates, the system dispatches a manual InputEvent.
// src/main/index.ts:725-738
const input = document.querySelector('[contenteditable="true"][role="textbox"]');
// ... selection and range logic ...
input.dispatchEvent(new InputEvent('input', {
bubbles: true,
inputType: 'insertText',
data: text
}));
const enterEvent = new KeyboardEvent('keydown', {
key: 'Enter',
code: 'Enter',
keyCode: 13,
bubbles: true
});
input.dispatchEvent(enterEvent);
Sources: src/main/index.ts:717-740
Interaction Summary
| Component | Responsibility | Relevant File |
|---|---|---|
| Global Shortcuts | Maps hardware keys to sendQuickReply | src/main/index.ts |
| Menu Builder | Reflects current replies in the UI menu | src/main/index.ts |
| Settings Modal | Provides visual editor for replies | src/preload/settings-modal.ts |
| Input Parser | Converts raw text string into structured objects | src/main/index.ts |
| Input Interceptor | Injects text and events into the webview | src/main/index.ts |
Sources: src/main/index.ts:1210-1350, src/preload/settings-modal.ts:515-530
Conclusion
Quick Replies Management provides a robust automation layer for the Messenger desktop experience. By combining Electron's global shortcut capabilities with precise JavaScript injection into the Messenger web container, the system enables high-velocity communication while maintaining state synchronization with the underlying web application.