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(soup): can filter for snippets without md collision, hide snippet team sharing (#4047)
Seamus6c9fe5652124
diff --git a/js/app/packages/app/component/next-soup/filters/configs/document.ts b/js/app/packages/app/component/next-soup/filters/configs/document.tsindex b00a703e52..325e31d499 100644--- a/js/app/packages/app/component/next-soup/filters/configs/document.ts+++ b/js/app/packages/app/component/next-soup/filters/configs/document.ts@@ -9,7 +9,15 @@ import {const docMarkdownFilter = config({id: 'doc-markdown',- predicate: (e) => isDocumentEntity(e) && e.fileType === 'md',+ predicate: (e) => isDocumentEntity(e) && e.fileType === 'md' && !e.subType,+ query: { include: { fileAssoc: ['assoc:md'] } },+});++const docSnippetFilter = config({+ id: 'doc-snippet',+ predicate: (e) => isDocumentEntity(e) && e.subType?.type === 'snippet',+ // Snippets are markdown documents in storage; subtype is enforced client-side+ // so this composes with other file-type OR filters.query: { include: { fileAssoc: ['assoc:md'] } },});@@ -31,6 +39,7 @@ export const emailAttachmentsFilter = config({export const DOCUMENT_CONTEXTUAL_FILTERS = [docMarkdownFilter,+ docSnippetFilter,docCanvasFilter,emailAttachmentsFilter,] as const;diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/field-values.ts b/js/app/packages/app/component/next-soup/filters/filter-store/field-values.tsindex e58223fe40..ef0b37e809 100644--- a/js/app/packages/app/component/next-soup/filters/filter-store/field-values.ts+++ b/js/app/packages/app/component/next-soup/filters/filter-store/field-values.ts@@ -21,13 +21,10 @@ export const addFieldValues = (if (!value.length) continue;const existing = (target[key] ?? []) as unknown[];- const updated = [...existing];-- for (const v of value) {- if (!updated.some((e) => deepEqual(e, v))) updated.push(v);- }-- result[key] = updated;+ // Keep duplicates as lightweight reference counts. Markdown and Snippets+ // both contribute assoc:md; removing one filter must leave the other's+ // backend query value in place.+ result[key] = [...existing, ...value];}return result as FieldFilters;@@ -53,10 +50,12 @@ export const removeFieldValues = (const existing = target[key] as unknown[];if (!value.length || !Array.isArray(existing)) continue;- const toRemove = value as unknown[];- const filtered = existing.filter(- (e) => !toRemove.some((v) => deepEqual(e, v))- );+ const filtered = [...existing];+ // Remove one occurrence per contributed value rather than every equal value.+ for (const v of value as unknown[]) {+ const index = filtered.findIndex((e) => deepEqual(e, v));+ if (index !== -1) filtered.splice(index, 1);+ }if (filtered.length === 0) {delete result[key];diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsxindex b645c22c45..e66e7ca70a 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx@@ -330,6 +330,11 @@ const DOCUMENTS_FILTER_CATEGORIES: FilterCategory[] = [label: 'Videos',icon: () => <EntityIcon targetType="video" size="xs" />,},+ {+ id: 'doc-snippet',+ label: 'Snippets',+ icon: () => <EntityIcon targetType="snippet" size="xs" />,+ },{id: 'file-other',label: 'Other',diff --git a/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsxindex 5ec5ac9629..0270d907a2 100644--- a/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx+++ b/js/app/packages/block-md/component/sidepanel/MarkdownSidePanelSections.tsx@@ -13,6 +13,7 @@ import {import { Notifications } from '@core/component/Notifications';import { References } from '@core/component/References';import { UserIcon } from '@core/component/UserIcon';+import { useUserId } from '@core/context/user';import type { Entity, EntityType } from '@core/types';import { tryMacroId, useDisplayName } from '@core/user';import { type DateValue, formatDate } from '@core/util/date';@@ -79,7 +80,7 @@ export function MarkdownSidePanelSections(<DetailsSectionContent /></SidePanel.Section><Show when={isSnippet()}>- <SnippetSharingSectionConditional documentId={blockId} />+ <SnippetSharingOwnerSectionConditional documentId={blockId} /></Show><SidePanel.Sectionid="properties"@@ -111,13 +112,29 @@ export function MarkdownSidePanelSections(// Sharing Section (snippets)// ─────────────────────────────────────────────────────────────────────────────+function SnippetSharingOwnerSectionConditional(props: { documentId: string }) {+ const currentUserId = useUserId();+ const metadataQuery = useDocumentMetadataQuery(() => props.documentId);++ const isOwner = createMemo(() => {+ const ownerId = metadataQuery.data?.owner;+ const userId = currentUserId();+ return !!ownerId && !!userId && ownerId === userId;+ });++ return (+ <Show when={isOwner()}>+ <SnippetSharingTeamSectionConditional documentId={props.documentId} />+ </Show>+ );+}+/**- * "Share with team" toggle for snippets — same UI and behavior as the Calls- * and CRM sharing sections. Only rendered when the snippet owner belongs to a- * team; sharing grants the team Edit access so the snippet shows up in- * teammates' `;` menus and they can collaboratively maintain it.+ * "Share with team" toggle for snippets. Only mounted for the snippet owner;+ * sharing grants the owner's team Edit access so teammates can insert and+ * maintain the snippet.*/-function SnippetSharingSectionConditional(props: { documentId: string }) {+function SnippetSharingTeamSectionConditional(props: { documentId: string }) {const teamShareQuery = useDocumentTeamShareQuery(() => props.documentId);return (