You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: code-notes.md
+17-5Lines changed: 17 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,15 @@ This "Crash-only" principle informs the design of `init.js`, `buttons-injection.
35
35
- Provides unified storage for all extension settings
36
36
- Implements reset functionality for various setting types
37
37
-**Message Handlers:**
38
+
-**Cross-Chat Prompt Sharing Module Handlers:**
39
+
-`getCrossChatModuleSettings`: Retrieves global settings for the module (enabled, autosend, etc.).
40
+
-`saveCrossChatModuleSettings`: Saves changes to the module's global settings.
41
+
-`saveStoredPrompt`: Stores the prompt text copied from a chat input.
42
+
-`getStoredPrompt`: Retrieves the currently stored prompt text.
43
+
-`clearStoredPrompt`: Clears the stored prompt text.
44
+
-**Profile Management Handlers:**
45
+
- Processes messages for loading, saving, switching, and deleting user profiles.
46
+
- Manages creation of the default profile.
38
47
- Processes messages from content scripts and popup pages
39
48
- Handles floating panel settings with message types:
40
49
- 'getFloatingPanelSettings': Retrieves settings for a specific website
@@ -145,8 +154,8 @@ This "Crash-only" principle informs the design of `init.js`, `buttons-injection.
145
154
146
155
### `init.js`
147
156
148
-
-**Purpose:** Main initialization script for the content script. It acts as the **Director** of the initial UI setup and embodies the **Crash-only** philosophy.
149
-
-**Role:** Implements a **"decide first, then create"** architecture to prevent UI flicker. It asynchronously checks if the floating panel should be visible for the current site _before_rendering any buttons. Based on this setting, it either injects the buttons into the traditional inline location (via `buttons-injection.js`) or directly into the floating panel. Its main initialization function (`publicStaticVoidMain`) is designed to be**idempotent** and is called on page load, SPA navigation, and panel closing to ensure a consistent and reliable UI state.
157
+
-**Purpose:** Main initialization script for the content script. It acts as the **Director** of the UI setup and embodies the **Crash-only** philosophy.
158
+
-**Role:** Implements a **"decide first, then create"** architecture. It asynchronously loads all necessary configurations—both the user's current profile and global module settings (like Cross-Chat Prompt Sharing)—*before*rendering any UI. It then checks if the floating panel should be visible. Based on this setting, it either injects buttons into the traditional inline location (via `buttons-injection.js`) or directly into the floating panel. Its main initialization function (`publicStaticVoidMain`) is **idempotent** and is called on page load, SPA navigation, and panel closing to ensure a consistent and reliable UI state.
150
159
151
160
### `interface.js`
152
161
@@ -156,12 +165,15 @@ This "Crash-only" principle informs the design of `init.js`, `buttons-injection.
156
165
### `buttons.js`
157
166
158
167
-**Purpose:** Manages the creation and functionality of custom send buttons.
159
-
-**Role:** Creates button elements based on configuration, assigns keyboard shortcuts, and handles click events across different supported sites. It decides which site-specific functions are called. It also contains the logic to divert clicks to the prompt queue when Queue Mode is active in the floating panel.
168
+
-**Role:** Contains the logic for creating all button types.
169
+
-`createCustomSendButton()`: Creates standard prompt buttons from the user's profile configuration. It has been updated to accept an overridden shortcut key to support unified assignment.
170
+
-`createCrossChatButton()`: Creates the new "Copy Prompt" and "Paste & Send Prompt" buttons for the cross-chat module. This function includes the logic for saving/retrieving prompts from the service worker and handling the dynamic tooltip on hover.
171
+
-`processCustomSendButtonClick()`: The central click handler that is called by all buttons to insert text and optionally trigger a send action. It decides which site-specific function to call and contains the logic to divert clicks to the prompt queue when Queue Mode is active.
160
172
161
173
### `buttons-init.js`
162
174
163
-
-**Purpose:** Acts as a **UI Factory**. It contains the logic to generate a complete set of buttons and toggles.
164
-
-**Role:**It is called by the "Director" (`init.js`)to populate a specified container, which can be either the inline injection point or the floating panel's content area. It is no longer responsible for making decisions about panel visibility.
175
+
-**Purpose:** Acts as a **UI Factory & Orchestrator**. It contains the logic to generate a complete and ordered set of all buttons and toggles.
176
+
-**Role:**Called by the "Director" (`init.js`), its `generateAndAppendAllButtons()` function is the single source of truth for UI generation. It builds a master list of all buttons to be rendered (cross-chat module buttons and standard custom buttons), places them in the correct order based on user settings (e.g., "before" or "after" for cross-chat buttons), and assigns sequential keyboard shortcuts (`Alt+1`, `Alt+2`, etc.) to the entire set. It populates a specified container, which can be either the inline injection point or the floating panel's content area.
0 commit comments