Merge pull request #2595 from openchamber/feat/ctrl-l-add-selection-to-chat-58c2

feat(ui): Ctrl/Cmd+L adds selected text to chat
This commit is contained in:
Serhii Dziupin
2026-08-04 11:33:51 +03:00
committed by GitHub
30 changed files with 528 additions and 3 deletions
+11 -2
View File
@@ -2255,6 +2255,13 @@ const dispatchMenuAction = (action) => {
dispatchDomEventToWindow(target, 'openchamber:menu-action', action);
};
// Append-style menu actions must reach the renderer exactly once. Dual IPC+DOM
// delivery (dispatchMenuAction) would insert the selection twice.
const dispatchAddSelectionToChat = () => {
const target = getMenuTargetWindow();
if (target) emitToWindow(target, 'openchamber:menu-action', 'add-selection-to-chat');
};
// Mini-chat draft windows are not deduplicated, so this must reach the renderer
// exactly once — emitToWindow alone (no DOM-event double dispatch). The renderer
// resolves the active directory/project and opens the window.
@@ -4564,6 +4571,7 @@ const buildMacMenu = () => {
{ type: 'separator' },
{ role: 'cut' },
{ label: 'Copy', accelerator: 'Cmd+C', click: () => handleCopyAction() },
{ label: 'Add Selection to Chat', accelerator: 'Cmd+L', registerAccelerator: false, click: () => dispatchAddSelectionToChat() },
{ role: 'paste' },
{ role: 'selectAll' },
],
@@ -4582,7 +4590,7 @@ const buildMacMenu = () => {
{ label: 'Dark Theme', click: () => dispatchAction('theme-dark') },
{ label: 'System Theme', click: () => dispatchAction('theme-system') },
{ type: 'separator' },
{ label: 'Toggle Session Sidebar', accelerator: 'Cmd+L', click: () => dispatchAction('toggle-sidebar') },
{ label: 'Toggle Session Sidebar', accelerator: 'Cmd+Alt+L', click: () => dispatchAction('toggle-sidebar') },
{ label: 'Toggle Memory Debug', accelerator: 'Cmd+Shift+D', click: () => dispatchAction('toggle-memory-debug') },
{ type: 'separator' },
{ role: 'togglefullscreen' },
@@ -4661,6 +4669,7 @@ const buildAutoHiddenMenu = () => {
{ type: 'separator' },
{ role: 'cut' },
{ label: 'Copy', accelerator: 'Ctrl+C', click: () => handleCopyAction() },
{ label: 'Add Selection to Chat', accelerator: 'Ctrl+L', registerAccelerator: false, click: () => dispatchAddSelectionToChat() },
{ role: 'paste' },
{ role: 'selectAll' },
],
@@ -4683,7 +4692,7 @@ const buildAutoHiddenMenu = () => {
{ label: 'Dark Theme', click: () => dispatchAction('theme-dark') },
{ label: 'System Theme', click: () => dispatchAction('theme-system') },
{ type: 'separator' },
{ label: 'Toggle Session Sidebar', accelerator: 'Ctrl+L', click: () => dispatchAction('toggle-sidebar') },
{ label: 'Toggle Session Sidebar', accelerator: 'Ctrl+Alt+L', click: () => dispatchAction('toggle-sidebar') },
{ label: 'Toggle Memory Debug', accelerator: 'Ctrl+Shift+D', click: () => dispatchAction('toggle-memory-debug') },
{ type: 'separator' },
{ role: 'togglefullscreen' },