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(inbox): Enter on single-item channel notification opens that message (#2548)

gbirmancc6746972063
diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
index fefe22893e..fe1aaf8f8c 100644
--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
@@ -10,7 +10,14 @@ import {
isScopeInActiveBranch,
runCommand,
} from '@core/hotkey/utils';
-import { isSearchEntity } from '@entity';
+import {
+ isSearchEntity,
+ isWithNotification,
+ filterNotDoneNotifications,
+ filterValidNotifications,
+} from '@entity';
+import { openSingleStackNotification } from '@notifications';
+import { globalSplitManager } from '@app/signal/splitLayout';
import { onCleanup, type Accessor } from 'solid-js';
import type { VirtualizerHandle } from 'virtua/solid';
import type { SoupState } from '../create-soup-state';
@@ -124,6 +131,20 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
hide: true,
}).withGroup(group);
+ const tryOpenChannelNotification = (newSplit: boolean): boolean => {
+ const entity = soup.focus.item();
+ if (!entity) return false;
+ if (entity.type !== 'channel' || !isWithNotification(entity)) return false;
+ const validNotifs = filterNotDoneNotifications(
+ filterValidNotifications(entity.notifications?.() ?? [])
+ );
+ const splitManager = globalSplitManager();
+ return (
+ !!splitManager &&
+ openSingleStackNotification(validNotifs, splitManager, newSplit)
+ );
+ };
+
// enter - Open entity in split
registerHotkey({
hotkey: ['enter'],
@@ -132,6 +153,8 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
description: 'Open',
hide: true,
keyDownHandler: () => {
+ if (tryOpenChannelNotification(false)) return true;
+
const entity = soup.focus.item();
if (!entity) return false;
@@ -293,6 +316,8 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
description: 'Open in new split',
condition: () => soup.focus.id() !== undefined,
keyDownHandler: () => {
+ if (tryOpenChannelNotification(true)) return true;
+
const entity = soup.focus.item();
if (!entity) return false;
openEntityInSplitFromUnifiedList(entity, {
diff --git a/js/app/packages/notifications/index.ts b/js/app/packages/notifications/index.ts
index 69e13bc183..e38723dee0 100644
--- a/js/app/packages/notifications/index.ts
+++ b/js/app/packages/notifications/index.ts
@@ -41,6 +41,7 @@ export {
} from './notification-metadata';
export { openNotificationFromId } from './notification-navigation';
export { openNotification } from './notification-navigation';
+export { openSingleStackNotification } from './notification-navigation';
export { CHANNEL_EVENT_TYPES } from './notification-source';
export type {
PlatformNotificationData,
diff --git a/js/app/packages/notifications/notification-navigation.ts b/js/app/packages/notifications/notification-navigation.ts
index 90548cbbc0..a103237fc1 100644
--- a/js/app/packages/notifications/notification-navigation.ts
+++ b/js/app/packages/notifications/notification-navigation.ts
@@ -10,6 +10,10 @@ import type { NotificationSource } from './notification-source';
import { getChannelParams } from '@block-channel/utils/link';
import { isChannelNotification } from './notification-helpers';
import { CHANNEL_EVENT_TYPES } from './notification-source';
+import {
+ stackNotifications,
+ getMostRecentNotification,
+} from './notification-stacking';
/**
* Opens a split if it is not already open.
@@ -210,6 +214,18 @@ export function openNotification(
return ResultAsync.fromSafePromise(handler(layoutManager, newSplit));
}
+export function openSingleStackNotification(
+ notifications: UnifiedNotification[],
+ layoutManager: SplitManager,
+ newSplit: boolean = false
+): boolean {
+ const stacks = stackNotifications(notifications);
+ if (stacks.length !== 1) return false;
+ const mostRecent = getMostRecentNotification(stacks[0]!);
+ openNotification(mostRecent, layoutManager, newSplit);
+ return true;
+}
+
export function openNotificationFromId(
notificationId: string,
layoutManager: SplitManager,