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
unified-list: add meta/ctrl click to entity row to open entity in new tab (#776)
Caleb Taylorc8c3003d39bf
diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsxindex 68e4c22d84..5d471fd08b 100644--- a/js/app/packages/app/component/UnifiedListView.tsx+++ b/js/app/packages/app/component/UnifiedListView.tsx@@ -15,7 +15,10 @@ import { ContextMenuContent, MenuSeparator } from '@core/component/Menu';import { useTaskProperties } from '@core/component/Properties/hooks';import { getSuggestedProperties } from '@core/component/Properties/utils';import { RecipientSelector } from '@core/component/RecipientSelector';-import { blockAcceptsFileExtension } from '@core/constant/allBlocks';+import {+ blockAcceptsFileExtension,+ fileTypeToBlockName,+} from '@core/constant/allBlocks';import {ENABLE_FRECENCY,ENABLE_PROPERTY_DISPLAY,@@ -52,6 +55,7 @@ import {importantFilterFn,isTaskEntity,notDoneFilterFn,+ type SearchLocation,type SortOption,sortByCreatedAt,sortByFrecencyScore,@@ -109,6 +113,7 @@ import {type SetStoreFunction,unwrap,} from 'solid-js/store';+import type { EntityPointerDownHandler } from '../../macro-entity/src/components/Entity';import {ENTITY_HEIGHT,EntityWithEverything,@@ -1097,6 +1102,81 @@ export function UnifiedListView(props: UnifiedListViewProps) {});});+ const openEntityInNewTab = ({+ entity,+ location,+ }: {+ entity: EntityData;+ location?: SearchLocation;+ }) => {+ // Build URL for the entity+ let entityPath: string;+ if (entity.type === 'document') {+ const { fileType, subType } = entity;+ const blockName = fileTypeToBlockName(subType ?? fileType);+ entityPath = `/app/${blockName}/${entity.id}`;+ } else {+ entityPath = `/app/${entity.type}/${entity.id}`;+ }++ // Add location params if present+ const entityUrl = new URL(entityPath, window.location.origin);+ if (location) {+ switch (location.type) {+ case 'channel':+ if (location.messageId) {+ entityUrl.searchParams.set(+ 'channel_message_id',+ location.messageId+ );+ }+ if (location.threadId) {+ entityUrl.searchParams.set('thread', location.threadId);+ }+ break;+ case 'email':+ if (location.messageId) {+ entityUrl.searchParams.set('email_message_id', location.messageId);+ }++ break;+ case 'md':+ if (location.nodeId) {+ entityUrl.searchParams.set('node_id', location.nodeId);+ }+ break;+ case 'pdf':+ if (location.searchPage !== undefined) {+ entityUrl.searchParams.set(+ 'search_page',+ location.searchPage.toString()+ );+ }+ if (location.searchRawQuery) {+ entityUrl.searchParams.set(+ 'search_raw_query',+ location.searchRawQuery+ );+ }+ if (location.highlightTerms) {+ entityUrl.searchParams.set(+ 'search_highlight_terms',+ JSON.stringify(location.highlightTerms)+ );+ }+ if (location.searchSnippet) {+ entityUrl.searchParams.set(+ 'search_snippet',+ location.searchSnippet+ );+ }+ break;+ }+ }++ window.open(entityUrl.toString(), '_blank', 'noopener');+ };+const entityClickHandler: EntityClickHandler<EntityData> = async (entity,event,@@ -1109,6 +1189,11 @@ export function UnifiedListView(props: UnifiedListViewProps) {return;}+ if (event.metaKey || event.ctrlKey) {+ openEntityInNewTab({ entity, location });+ return;+ }+await openEntityInSplitFromUnifiedList(entity, {openInNewSplit: event.altKey,location,@@ -1116,6 +1201,23 @@ export function UnifiedListView(props: UnifiedListViewProps) {});};+ const entityPointerDownHandler: EntityPointerDownHandler<EntityData> = async (+ entity,+ event,+ location,+ options+ ) => {+ if (preview() && !options?.ignorePreview) {+ return;+ }++ // middle mouse button pressed+ if (event.button === 1 && event.pointerType === 'mouse') {+ // TODO: current page should remain focused after opening new tab+ openEntityInNewTab({ entity, location });+ }+ };+const StyledTriggerLabel = (props: ParentProps) => {return <span class="text-[0.625rem]">{props.children}</span>;};@@ -1649,6 +1751,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {properties={properties()}timestamp={timestamp()}onClick={entityClickHandler}+ onPointerDown={entityPointerDownHandler}onClickRowAction={soupContext.actionRegistry.isActionEnabled('mark_as_done',diff --git a/js/app/packages/macro-entity/src/components/Entity.tsx b/js/app/packages/macro-entity/src/components/Entity.tsxindex 882bb1d05b..7a4de324e1 100644--- a/js/app/packages/macro-entity/src/components/Entity.tsx+++ b/js/app/packages/macro-entity/src/components/Entity.tsx@@ -11,12 +11,21 @@ import type { SearchLocation } from '../types/search';export type EntityClickEvent = Parameters<JSX.EventHandler<HTMLDivElement, MouseEvent>>[0];+type EntityPointerDownEvent = Parameters<+ JSX.EventHandler<HTMLDivElement, PointerEvent>+>[0];export type EntityClickHandler<T extends EntityData> = (entity: T,event: EntityClickEvent,location?: SearchLocation,options?: { ignorePreview?: boolean }) => void;+export type EntityPointerDownHandler<T extends EntityData> = (+ entity: T,+ event: EntityPointerDownEvent,+ location?: SearchLocation,+ options?: { ignorePreview?: boolean }+) => void;interface EntityProps<T extends EntityData> extends ParentProps {entity: T;timestamp?: number;diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsxindex ef1972a0e2..995464e230 100644--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx@@ -437,6 +437,7 @@ interface EntityProps<T extends WithNotification<EntityData>>focused?: boolean;timestamp?: number;onClick?: EntityClickHandler<T>;+ onPointerDown?: EntityClickHandler<T>;onClickRowAction?: (entity: T, type: 'done') => void;onClickNotification?: NotificationClickHandler<T>;onMouseOver?: () => void;@@ -906,6 +907,10 @@ export function EntityWithEverything(if (blocksNavigation(e)) return;e.preventDefault();}}+ onPointerDown={(e) => {+ if (blocksNavigation(e)) return;+ props.onPointerDown?.(props.entity, e);+ }}// Action List is also rendered based on focus, but when focused via Shift+Tab, parent is focused due to Action List dom not present. Here we check if current browser task has captured Shift+Tab focus on Action ListonFocusIn={(e) => {if (