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(soup): only allow marking supported entities as done (#2946)

dev-rbab3d3f168c89
diff --git a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
index b5667e4791..f4853e3dce 100644
--- a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
@@ -1,6 +1,6 @@
import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';
import { toast } from '@core/component/Toast/Toast';
-import { type EntityData, isTaskEntity } from '@entity';
+import type { EntityData } from '@entity';
import type { NotificationSource } from '@notifications';
import { useUndoableMutation } from '@queries/undo';
import {
@@ -13,6 +13,20 @@ import {
} from '@app/component/next-soup/utils';
import { useMaybePreviewPanel } from '@app/component/PreviewPanel';
import type { SoupState } from '../create-soup-state';
+import type { ListView } from '@app/constants/list-views';
+
+// Valid list views where the mark done should be allowed to run
+const VALID_MARK_DONE_LIST_VIEWS: `${ListView}-${string}`[] = [
+ 'inbox-signal',
+ 'mail-important',
+ 'mail-all',
+ 'mail-noise',
+ 'mail-shared',
+];
+
+export const canExecuteMarkDoneOnView = (view: ListView, tabId: string) => {
+ return VALID_MARK_DONE_LIST_VIEWS.includes(`${view}-${tabId}`);
+};
type MakeMarkDoneOptions = {
userId?: () => string | undefined;
@@ -124,8 +138,7 @@ export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {
entity.type === 'channel' ||
entity.type === 'chat' ||
entity.type === 'document' ||
- entity.type === 'project' ||
- isTaskEntity(entity)
+ entity.type === 'project'
) {
return true;
}
diff --git a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
index 0fc7f98a86..a852da86c6 100644
--- a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
@@ -28,10 +28,12 @@ import type { SplitHandle } from '@app/component/split-layout/layoutManager';
import { openEntityInSplitFromUnifiedList } from '@app/component/next-soup/utils';
import { onCleanup } from 'solid-js';
import { isListViewID } from '@app/constants/list-views';
+import { canExecuteMarkDoneOnView } from '@app/component/next-soup/actions/make-mark-done-action';
type UseEntityActionHotkeysOptions = {
scopeId: string;
soup: SoupState;
+ activeSoupViewTab?: () => string | undefined;
splitHandle?: SplitHandle;
condition?: () => boolean;
/** Fallback entity getter used when soup has no selection/focus (e.g., block views) */
@@ -135,6 +137,17 @@ export const useEntityActionHotkeys = (
},
condition: () => {
if (condition && !condition()) return false;
+
+ const contentId = splitHandle?.content().id;
+
+ const soupViewTab = options.activeSoupViewTab?.();
+
+ if (
+ !isListViewID(contentId) ||
+ (soupViewTab && !canExecuteMarkDoneOnView(contentId, soupViewTab))
+ )
+ return false;
+
const entities = getEntitiesForAction();
return entities.length > 0 && entities.every(markDone.canExecute);
},
diff --git a/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsx b/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsx
index d0925bd645..ecb7b5d2ab 100644
--- a/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsx
@@ -7,8 +7,10 @@ import { For, Show } from 'solid-js';
import { createSoupEntityActions } from './create-soup-entity-actions';
import { useSoupEntityActionDrawer } from './soup-entity-action-drawer-context';
import { useSoupView } from './soup-view-context';
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
export function SoupEntityActionDrawer() {
+ const panel = useSplitPanelOrThrow();
const drawerState = useSoupEntityActionDrawer();
const { activeTab } = useSoupView();
const { buildActionGroups } = createSoupEntityActions();
@@ -22,7 +24,10 @@ export function SoupEntityActionDrawer() {
const e = drawerState.entity();
const s = drawerState.soup();
if (!e || !s) return [];
- return buildActionGroups([e], s, activeTab());
+ return buildActionGroups(s, [e], {
+ activeTab: activeTab(),
+ activeListView: panel.handle.content().id,
+ });
};
return (
diff --git a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts
index 9f9073ef50..a8bf8e25c9 100644
--- a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts
@@ -21,6 +21,8 @@ import { useUserId } from '@core/context/user';
import { useAnalytics } from '@app/component/analytics-context';
import { getChannelParams } from '@block-channel/utils/link';
import { isMobile } from '@core/mobile/isMobile';
+import { canExecuteMarkDoneOnView } from '@app/component/next-soup/actions/make-mark-done-action';
+import { isListViewID } from '@app/constants/list-views';
const SIGNAL_TABS = new Set<string | undefined>([
undefined,
@@ -40,12 +42,17 @@ export type SoupEntityActionGroup = {
items: SoupEntityActionItem[];
};
+type BuildActionGroups = (
+ soup: SoupState,
+ entities: EntityData[],
+ context: {
+ activeListView: string;
+ activeTab: string | undefined;
+ }
+) => SoupEntityActionGroup[];
+
export function createSoupEntityActions(): {
- buildActionGroups: (
- entities: EntityData[],
- soup: SoupState,
- activeTab: string | undefined
- ) => SoupEntityActionGroup[];
+ buildActionGroups: BuildActionGroups;
} {
const analytics = useAnalytics();
const userId = useUserId();
@@ -74,11 +81,11 @@ export function createSoupEntityActions(): {
const markSenderSignalAction = makeMarkSenderSignalAction();
const markSenderNoiseAction = makeMarkSenderNoiseAction();
- const buildActionGroups = (
- entities: EntityData[],
- soup: SoupState,
- activeTab: string | undefined
- ): SoupEntityActionGroup[] => {
+ const buildActionGroups: BuildActionGroups = (
+ soup,
+ entities,
+ { activeTab, activeListView }
+ ) => {
const canExecuteAll = (canExecute: (e: EntityData) => boolean) =>
entities.length > 0 && entities.every(canExecute);
@@ -90,7 +97,12 @@ export function createSoupEntityActions(): {
// Top group: Mark Done, Open in new split
const topItems: SoupEntityActionItem[] = [];
- if (canExecuteAll(markDone.canExecute)) {
+ if (
+ activeTab &&
+ isListViewID(activeListView) &&
+ canExecuteMarkDoneOnView(activeListView, activeTab) &&
+ canExecuteAll(markDone.canExecute)
+ ) {
topItems.push({
id: 'mark-done',
label: 'Mark Done',
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
index 8e1d4a024d..e342cb0cce 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
@@ -4,6 +4,7 @@ import { For, Show } from 'solid-js';
import type { SoupState } from '../create-soup-state';
import { createSoupEntityActions } from './create-soup-entity-actions';
import { useSoupView } from './soup-view-context';
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
interface SoupEntityActionsMenuProps {
entities: EntityData[];
@@ -12,11 +13,15 @@ interface SoupEntityActionsMenuProps {
}
export const SoupEntityActionsMenu = (props: SoupEntityActionsMenuProps) => {
+ const panel = useSplitPanelOrThrow();
const { activeTab } = useSoupView();
const { buildActionGroups } = createSoupEntityActions();
const groups = () =>
- buildActionGroups(props.entities, props.soup, activeTab());
+ buildActionGroups(props.soup, props.entities, {
+ activeTab: activeTab(),
+ activeListView: panel.handle.content().id,
+ });
const handleAction = async (onClick: () => void | Promise<void>) => {
await onClick();
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index 7384f14e01..b883bbb420 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -113,6 +113,7 @@ import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
import SearchIcon from '@macro-icons/macro-magnifying-glass.svg';
import type { SetPredicatesInput } from '@app/component/next-soup/filters/filter-store/predicates-store';
import { VIEW_TAB_PRESETS } from '@app/component/app-sidebar/soup-filter-presets';
+import { canExecuteMarkDoneOnView } from '@app/component/next-soup/actions/make-mark-done-action';
const useSoupNotificationInvalidators = () => {
const notificationSource = useGlobalNotificationSource();
@@ -496,6 +497,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
useEntityActionHotkeys({
scopeId: scopeId(),
soup,
+ activeSoupViewTab: activeTab,
splitHandle: panel.handle,
});
@@ -873,6 +875,15 @@ export const SoupViewList = (props: SoupViewListProps) => {
canSwipeLeft={(entityId) => {
const entity = entityById().get(entityId);
if (!entity) return false;
+
+ const tab = activeTab();
+
+ if (
+ !isListViewID(contentId) ||
+ (tab && !canExecuteMarkDoneOnView(contentId, tab))
+ )
+ return false;
+
return markDoneAction.canExecute(entity.original);
}}
onSwipeLeft={(entityId) => {