Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(web): let H remind on grouped entity rows (#7309)

gbirman1a9e853f7805
diff --git a/apps/web/src/components/list/use-list-interactions.test.ts b/apps/web/src/components/list/use-list-interactions.test.ts
new file mode 100644
index 0000000000..c3fb6779fc
--- /dev/null
+++ b/apps/web/src/components/list/use-list-interactions.test.ts
@@ -0,0 +1,78 @@
+import { registerHotkey } from '@core/hotkey/hotkeys';
+import { createRoot, createSignal } from 'solid-js';
+import { beforeEach, expect, it, vi } from 'vitest';
+import { createListController } from './create-list-controller';
+import { useListInteractions } from './use-list-interactions';
+
+vi.mock('@core/hotkey/hotkeys', () => ({
+ registerHotkey: vi.fn(() => ({ withGroup: vi.fn() })),
+ createHotkeyGroup: () => ({ dispose: vi.fn() }),
+}));
+vi.mock('@core/hotkey/utils', () => ({
+ isScopeInActiveBranch: () => true,
+ registerScope: vi.fn(),
+}));
+
+beforeEach(() => vi.clearAllMocks());
+
+it('keeps H on entities available for reminders and consumes it on headers', () => {
+ createRoot((dispose) => {
+ try {
+ const [expanded, setExpanded] = createSignal(true);
+ const list = createListController({
+ items: () => [
+ { id: 'header', header: true },
+ { id: 'task', header: false },
+ ],
+ getKey: (item) => item.id,
+ });
+ useListInteractions({
+ controller: list,
+ scopeId: 'test',
+ scrollHandle: () => undefined,
+ disclosure: {
+ isHeader: (item) => item.header,
+ getKey: () => 'group',
+ isExpanded: expanded,
+ setExpanded: (_key, value) => setExpanded(value),
+ getFocusKey: () => 'header',
+ },
+ });
+ const handler = (key: 'h' | 'arrowleft') => {
+ const call = vi
+ .mocked(registerHotkey)
+ .mock.calls.find(
+ ([options]) =>
+ Array.isArray(options.hotkey) && options.hotkey.includes(key)
+ );
+ expect(call).toBeDefined();
+ return call![0].keyDownHandler!();
+ };
+ const collapseCommands = vi
+ .mocked(registerHotkey)
+ .mock.calls.map(([options]) => options)
+ .filter(
+ (options) =>
+ typeof options.description === 'string' &&
+ options.description.startsWith('Collapse')
+ );
+ expect(
+ new Set(collapseCommands.map((command) => command.hotkeyToken)).size
+ ).toBe(2);
+ list.focus.set('task');
+ expect(handler('h')).toBe(false);
+ expect(expanded()).toBe(true);
+ expect(list.focus.key()).toBe('task');
+ expect(handler('arrowleft')).toBe(true);
+ expect(expanded()).toBe(false);
+ expect(list.focus.key()).toBe('header');
+ expect(handler('h')).toBe(true);
+ expect(expanded()).toBe(false);
+ setExpanded(true);
+ expect(handler('h')).toBe(true);
+ expect(expanded()).toBe(false);
+ } finally {
+ dispose();
+ }
+ });
+});
diff --git a/apps/web/src/components/list/use-list-interactions.ts b/apps/web/src/components/list/use-list-interactions.ts
index 328ab6180c..daa57ea1e1 100644
--- a/apps/web/src/components/list/use-list-interactions.ts
+++ b/apps/web/src/components/list/use-list-interactions.ts
@@ -64,6 +64,8 @@ export type ListInteractionActivation<TMetadata> = {
};
export type ListInteractionDisclosure<TItem> = {
+ /** H collapses only structural headers; entity rows keep their own actions. */
+ isHeader: (item: TItem) => boolean;
getKey: (item: TItem) => string | undefined;
isExpanded: (key: string) => boolean;
setExpanded: (key: string, expanded: boolean) => void;
@@ -218,7 +220,24 @@ export function useListInteractions<TItem, TMetadata = unknown>(
};
registerHotkey({
- hotkey: ['h', 'arrowleft'],
+ hotkey: ['h'],
+ hotkeyToken: TOKENS.unifiedList.navigation.collapseGroup,
+ scopeId: options.scopeId,
+ description: 'Collapse group',
+ condition: () => canHandle(options.conditions?.disclosure),
+ keyDownHandler: () => {
+ const item = list.focus.item();
+ if (item === undefined || !disclosure.isHeader(item)) return false;
+ setExpanded(false);
+ return true;
+ },
+ registrationType: 'add',
+ handlerPriority: 4,
+ hide: true,
+ }).withGroup(group);
+
+ registerHotkey({
+ hotkey: ['arrowleft'],
hotkeyToken: TOKENS.unifiedList.navigation.parent,
scopeId: options.scopeId,
description: 'Collapse item',
diff --git a/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx
index 75ffe7e8cf..4aef071ba1 100644
--- a/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ChannelsRail.tsx
@@ -775,6 +775,7 @@ export function ChannelsRail(props: ChannelsRailProps) {
// Labels disclose like sections: `h`/`l` on a label heading or one of
// its channels collapse or expand that label; anywhere else, the section.
disclosure: {
+ isHeader: (row) => row.kind === 'section' || row.kind === 'label',
getKey: (row) =>
row.kind === 'label'
? row.id
diff --git a/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts b/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts
index 82317e4fa1..6187cd36cc 100644
--- a/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts
+++ b/apps/web/src/features/next-soup/actions/use-entity-action-hotkeys.ts
@@ -585,10 +585,8 @@ export const useEntityActionHotkeys = (
tags: [HotkeyTags.SelectionModification],
}).withGroup(group);
- // Set a reminder - 'h'. This shares the scope with the list's 'h' ("Collapse
- // item", handlerPriority 4), so 'add' keeps both registered instead of one
- // evicting the other. Collapse sorts first and returns false when there is
- // nothing to collapse, which falls through to here.
+ // H reminds on entity rows. The higher-priority collapse handler consumes
+ // H only on group headers; 'add' keeps both actions in the same scope.
registerHotkey({
hotkey: ['h'],
hotkeyToken: TOKENS.entity.action.createReminder,
diff --git a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts
index 89646d5ecd..6e0e22897d 100644
--- a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts
+++ b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts
@@ -58,6 +58,7 @@ vi.mock('@core/hotkey/tokens', () => ({
unifiedList: {
navigation: {
parent: 'unifiedList.navigation.parent',
+ collapseGroup: 'unifiedList.navigation.collapseGroup',
child: 'unifiedList.navigation.child',
},
},
@@ -95,7 +96,7 @@ const createTestGroup = (key: string, count: number): GroupMeta => ({
label: key,
value: key,
count,
- isExpanded: () => true,
+ isExpanded: vi.fn(() => true),
toggle: () => {},
});
@@ -169,6 +170,39 @@ describe('useSoupNavigationHotkeys', () => {
);
});
+ it('reserves H for reminders on child rows while ArrowLeft collapses their group', () => {
+ const { soup, dispose } = setupHotkeys();
+ try {
+ soup.focus.set('a1');
+ const group = soup.focus.row()!.group!;
+ const toggle = vi.spyOn(group, 'toggle');
+ expect(handlerFor('h')()).toBe(false);
+ expect(toggle).not.toHaveBeenCalled();
+ expect(soup.focus.id()).toBe('a1');
+ expect(handlerFor('arrowleft')()).toBe(true);
+ expect(toggle).toHaveBeenCalledOnce();
+ expect(soup.focus.id()).toBe('header:a');
+ } finally {
+ dispose();
+ }
+ });
+
+ it('consumes H on expanded and collapsed headers', () => {
+ const { soup, dispose } = setupHotkeys();
+ try {
+ soup.focus.set('header:a');
+ const group = soup.focus.row()!.group!;
+ const toggle = vi.spyOn(group, 'toggle');
+ expect(handlerFor('h')()).toBe(true);
+ expect(toggle).toHaveBeenCalledOnce();
+ vi.mocked(group.isExpanded).mockReturnValue(false);
+ expect(handlerFor('h')()).toBe(true);
+ expect(toggle).toHaveBeenCalledOnce();
+ } finally {
+ dispose();
+ }
+ });
+
it('makes the legacy list available to a separate native detail split', async () => {
let finishLoading!: () => void;
const fetchNextPage = vi.fn(
diff --git a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts
index 629c49a118..ec39b4726d 100644
--- a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts
+++ b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts
@@ -291,7 +291,20 @@ export const useSoupNavigationHotkeys = (
};
registerHotkey({
- hotkey: ['h', 'arrowleft'],
+ hotkey: ['h'],
+ scopeId,
+ description: 'Collapse group',
+ hotkeyToken: TOKENS.unifiedList.navigation.collapseGroup,
+ // Consume H on headers even when already collapsed; selected entities
+ // elsewhere must not turn this into a reminder action.
+ keyDownHandler: () => toggleFocusedGroupHeader(false) !== undefined,
+ registrationType: 'add',
+ handlerPriority: 4,
+ hide: true,
+ }).withGroup(group);
+
+ registerHotkey({
+ hotkey: ['arrowleft'],
scopeId,
description: 'Collapse item',
hotkeyToken: TOKENS.unifiedList.navigation.parent,
diff --git a/apps/web/src/features/projects/views/projects-collection.tsx b/apps/web/src/features/projects/views/projects-collection.tsx
index 3fea0d68fb..e920304ffe 100644
--- a/apps/web/src/features/projects/views/projects-collection.tsx
+++ b/apps/web/src/features/projects/views/projects-collection.tsx
@@ -129,6 +129,7 @@ export function ProjectsCollection(props: {
alternateDescription: 'Open project in new split',
},
disclosure: {
+ isHeader: (row) => row.kind === 'group-header',
getKey: (row) =>
row.kind === 'section-header' ? undefined : row.groupId,
isExpanded: collection.disclosure.isExpanded,
diff --git a/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx b/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
index 7cfed9306b..9fe77a8151 100644
--- a/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
+++ b/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
@@ -315,6 +315,7 @@ export function TaskList(props: TaskListProps) {
alternateDescription: 'Open in new split',
},
disclosure: {
+ isHeader: (row) => row.kind === 'group-header',
getKey: (row) =>
row.kind === 'section-header' ? undefined : row.groupId,
isExpanded: isGroupExpanded,
diff --git a/apps/web/src/lib/core/hotkey/tokens.ts b/apps/web/src/lib/core/hotkey/tokens.ts
index 9317c9f3d4..275f342777 100644
--- a/apps/web/src/lib/core/hotkey/tokens.ts
+++ b/apps/web/src/lib/core/hotkey/tokens.ts
@@ -29,6 +29,7 @@ export const TOKENS = {
unifiedList: {
navigation: {
parent: 'unifiedList.navigation.parent',
+ collapseGroup: 'unifiedList.navigation.collapseGroup',
child: 'unifiedList.navigation.child',
},
},
diff --git a/docs/AGENT_GUIDE/tasks.md b/docs/AGENT_GUIDE/tasks.md
index 8ca1fc6051..239c10cccc 100644
--- a/docs/AGENT_GUIDE/tasks.md
+++ b/docs/AGENT_GUIDE/tasks.md
@@ -26,6 +26,11 @@ are pills and the leading sliders button opens one drawer containing Sort, Group
Filters (including Tags). The mobile bottom dock has the Ask AI input, a separate **+ Task**
button, and Search.
+**Keyboard:** Focus one task and press **H** to set or edit its reminder, even
+inside an expanded group. **←** collapses the focused item or its parent group.
+On a focused group header, **H** collapses only that group; pressing it again
+does nothing. Typing H in a text field remains ordinary input.
+
New accounts are seeded with three sample tasks (`Intro to tasks`, `Advanced task features`,
`How we use tasks at Macro`).