Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(channel): keep selected message edit shortcuts in scope (#6683)
teo02276ab8734a
diff --git a/apps/web/src/features/channel/Channel/create-channel-hotkeys.ts b/apps/web/src/features/channel/Channel/create-channel-hotkeys.tsindex 5f50e6dce0..caa11f85da 100644--- a/apps/web/src/features/channel/Channel/create-channel-hotkeys.ts+++ b/apps/web/src/features/channel/Channel/create-channel-hotkeys.ts@@ -152,6 +152,18 @@ export function createChannelHotkeys(options: CreateChannelHotkeysOptions) {},});+ registerHotkey({+ scopeId: messageListScope,+ hotkey: 'e',+ description: 'Keep edit shortcut on selected message',+ registrationType: 'add',+ hide: true,+ condition: canRunSelectionActionHotkeys,+ // The real edit command runs first when available. A selected incoming+ // message still owns E; otherwise it reaches Home's Mark done shortcut.+ keyDownHandler: () => true,+ });+registerHotkey({scopeId: messageListScope,hotkey: 'backspace',diff --git a/apps/web/src/features/channel/Channel/tests/selection-hotkeys.test.tsx b/apps/web/src/features/channel/Channel/tests/selection-hotkeys.test.tsxnew file mode 100644index 0000000000..a04a070358--- /dev/null+++ b/apps/web/src/features/channel/Channel/tests/selection-hotkeys.test.tsx@@ -0,0 +1,192 @@+import {+ attachGlobalDOMScope,+ registerHotkey,+ useHotKeyRoot,+ useHotkeyDOMScope,+} from '@core/hotkey/hotkeys';+import { TOKENS } from '@core/hotkey/tokens';+import { getActiveCommandByToken } from '@core/hotkey/utils';+import type { Message, MessageListItem } from '@service-storage/messages';+import { fireEvent, render, screen } from '@solidjs/testing-library';+import { describe, expect, it, vi } from 'vitest';+import { createThreadHotkeys } from '../../Thread/create-thread-hotkeys';+import { createChannelHotkeys } from '../create-channel-hotkeys';+import { createMessageSelection } from '../create-message-selection';++const timestamp = '2026-09-20T12:00:00Z';+function message(id: string, senderId: string): Message {+ return {+ id,+ sender_id: senderId,+ content: id,+ created_at: timestamp,+ updated_at: timestamp,+ parent: { type: 'channel', id: 'channel' },+ mentions: [],+ attachments: [],+ reactions: [],+ };+}++function rootMessage(id: string, senderId: string): MessageListItem {+ return {+ ...message(id, senderId),+ state: {+ root_id: id,+ user_id: senderId,+ resolved: false,+ created_at: timestamp,+ updated_at: timestamp,+ },+ thread: { preview: [], reply_count: 0 },+ };+}++const own = rootMessage('own', 'alice');+const incoming = rootMessage('incoming', 'bob');+const ownReply = message('own-reply', 'alice');+const incomingReply = message('incoming-reply', 'bob');++function setup(selectedId?: string, selectedReplyId?: string) {+ const onEdit = vi.fn();+ const onDone = vi.fn(() => true);+ render(() => {+ useHotKeyRoot();+ const [attachParent, parentScope] = useHotkeyDOMScope('home');+ registerHotkey({+ scopeId: parentScope,+ hotkey: 'e',+ description: 'Mark done',+ keyDownHandler: onDone,+ });+ const selection = createMessageSelection({+ keys: () => [own.id, incoming.id],+ });+ if (selectedId) selection.select(selectedId);+ const replySelection = createMessageSelection({+ keys: () => [ownReply.id, incomingReply.id],+ });+ if (selectedReplyId) replySelection.select(selectedReplyId);+ const getMessageActions = (item: Pick<Message, 'sender_id'>) =>+ item.sender_id === 'alice' ? { onEdit } : {};+ const channel = createChannelHotkeys({+ selection,+ scrollToMessage: () => false,+ messageById: () =>+ new Map([+ [own.id, own],+ [incoming.id, incoming],+ ]),+ getMessageActions,+ userId: () => 'alice',+ isInputEmpty: () => false,+ isEditing: () => false,+ onOpenFindBar: vi.fn(),+ onGoToBottom: vi.fn(),+ });+ createThreadHotkeys({+ messageListScopeId: channel.messageListScopeId,+ replySelection,+ isThreadFocused: () => !!replySelection.selectedId(),+ isEditing: () => false,+ activeReplies: () => [ownReply, incomingReply],+ threadId: () => own.id,+ getMessageActions,+ userId: () => 'alice',+ parentMessage: () => own,+ collapseThread: vi.fn(),+ isSelected: () => selection.selectedId() === own.id,+ hasReplies: () => true,+ expandThread: vi.fn(),+ isThreadExpanded: () => true,+ setIsReplying: vi.fn(),+ });+ return (+ <div ref={attachGlobalDOMScope}>+ <div ref={attachParent}>+ <div+ ref={channel.attachMessageListRef}+ tabIndex={-1}+ data-testid="messages"+ >+ <div ref={channel.attachInputRef}>+ <input aria-label="Message" />+ </div>+ </div>+ </div>+ </div>+ );+ });+ const list = screen.getByTestId('messages');+ list.focus();+ const pressEdit = () => {+ fireEvent.keyDown(list, { key: 'e' });+ fireEvent.keyUp(list, { key: 'e' });+ };+ return { onEdit, onDone, list, pressEdit };+}++describe('selected message shortcuts in a Home split', () => {+ it('keeps E on an incoming message from marking the parent item done', () => {+ const { pressEdit, onEdit, onDone } = setup(incoming.id);+ expect(+ getActiveCommandByToken(TOKENS.channel.editMessage)?.condition?.()+ ).toBe(false);+ pressEdit();+ expect(onEdit).not.toHaveBeenCalled();+ expect(onDone).not.toHaveBeenCalled();+ });++ it('still edits the selected own message', () => {+ const { pressEdit, onEdit, onDone } = setup(own.id);+ pressEdit();+ expect(onEdit).toHaveBeenCalledWith({ message: own });+ expect(onDone).not.toHaveBeenCalled();+ });++ it('allows the parent shortcut when no message is selected', () => {+ const { pressEdit, onEdit, onDone } = setup();+ pressEdit();+ expect(onDone).toHaveBeenCalledOnce();+ expect(onEdit).not.toHaveBeenCalled();+ });++ it('keeps E on an incoming reply from editing its own root or marking Home done', () => {+ const { pressEdit, onEdit, onDone } = setup(own.id, incomingReply.id);+ expect(+ getActiveCommandByToken(TOKENS.channel.threadEditReply)?.condition?.()+ ).toBe(false);+ pressEdit();+ expect(onEdit).not.toHaveBeenCalled();+ expect(onDone).not.toHaveBeenCalled();+ });++ it('edits the selected own reply instead of its root message', () => {+ const { pressEdit, onEdit, onDone } = setup(own.id, ownReply.id);+ pressEdit();+ expect(onEdit).toHaveBeenCalledExactlyOnceWith({+ message: { ...ownReply, thread_id: own.id },+ });+ expect(onDone).not.toHaveBeenCalled();+ });++ it('leaves E available for typing in the composer', () => {+ const { onEdit, onDone } = setup(incoming.id);+ const input = screen.getByRole('textbox', { name: 'Message' });+ input.focus();+ expect(fireEvent.keyDown(input, { key: 'e' })).toBe(true);+ fireEvent.keyUp(input, { key: 'e' });+ expect(onEdit).not.toHaveBeenCalled();+ expect(onDone).not.toHaveBeenCalled();+ });++ it('releases the shortcut after clearing the selected message', () => {+ const { pressEdit, onDone, list } = setup(incoming.id);+ pressEdit();+ expect(onDone).not.toHaveBeenCalled();+ fireEvent.keyDown(list, { key: 'Escape' });+ fireEvent.keyUp(list, { key: 'Escape' });+ pressEdit();+ expect(onDone).toHaveBeenCalledOnce();+ });+});diff --git a/apps/web/src/features/channel/Thread/create-thread-hotkeys.ts b/apps/web/src/features/channel/Thread/create-thread-hotkeys.tsindex ae6ffcaf09..c81933e67c 100644--- a/apps/web/src/features/channel/Thread/create-thread-hotkeys.ts+++ b/apps/web/src/features/channel/Thread/create-thread-hotkeys.ts@@ -220,6 +220,22 @@ export function createThreadHotkeys(options: CreateThreadHotkeysOptions) {},}).withGroup(group);+ registerHotkey({+ scopeId: scope,+ hotkey: 'e',+ description: 'Keep edit shortcut on selected reply',+ registrationType: 'add',+ handlerPriority: HOTKEY_PRIORITY_HIGH,+ hide: true,+ condition: () =>+ options.isThreadFocused() &&+ !!options.replySelection.selectedId() &&+ !options.isEditing(),+ // Keep the reply's priority after its edit command: an uneditable reply+ // must not fall through to editing the root or marking Home done.+ keyDownHandler: () => true,+ }).withGroup(group);+registerHotkey({scopeId: scope,hotkey: 'backspace',diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.mdindex 45b926db8c..a95af9c514 100644--- a/docs/AGENT_GUIDE/channels.md+++ b/docs/AGENT_GUIDE/channels.md@@ -262,6 +262,11 @@ document should update to its fetched title afterward.Message and reply links reveal the target inside its thread. Keyboard messagenavigation scrolls only when the selected message is outside the usable viewport.+With a message selected, `E` edits your own message and does nothing on someone+else's message. Check both root messages and thread replies from a Home split:+an incoming selection must not mark the Home item done or edit the thread root.+Press `Escape` to clear selection; the parent Home shortcut is then available+again. Typing `e` in the composer or inline editor should still enter text.Returning through split navigation restores the saved message position and expandedthreads. Switching channel tabs currently opens Messages at latest. The `Scroll to bottom` control appears when scrolling down through history;it returns to the latest page even after opening a link into old history.