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(crm): remove duplicate sharing visibility toggles (#9511)

gbirman27da9cbb3eab
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index d2b361ae67..67b135330a 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -413,6 +413,8 @@ resolved session ID; keep the existing `AgentSessionProvider` subscription to
Record search fills the row beside filters with header spacing; section creation
replaces the default floating dock action through FloatRegion. See
`src/features/crm/README.md` and `docs/agent-guide/crm.md` at the repo root.
+ Keep record Remove/Restore actions out of the information panel: contact Sharing
+ is absent, and company Sharing contains only permission-gated Sync Emails.
Company Team lists exclude hidden contacts for every role; keep authorized
detail/restore access and invalidate embedded company contacts on hide/restore.
People display options expose removed records only after an explicit admin/owner
diff --git a/apps/web/src/features/crm/README.md b/apps/web/src/features/crm/README.md
index 4fcd7b7ea4..cca769797f 100644
--- a/apps/web/src/features/crm/README.md
+++ b/apps/web/src/features/crm/README.md
@@ -65,7 +65,8 @@ CRM-specific state again.
Company Overview and contact headers expose `RecordVisibilityAction` for removal
and restoration through the existing hidden mutations. Keep admin/owner checks,
confirmation of the company-wide contact cascade, and the restore action on the
-open record. The information panel's visibility checkbox uses the same state.
+open record. Do not duplicate visibility controls in the information panel: contacts
+have no Sharing section, and company Sharing contains only Sync Emails.
Company Team lists filter hidden contacts for every role without changing the
underlying response or admin detail access. Contact visibility mutations invalidate
the company query family because those responses embed contacts: mounted lists
diff --git a/apps/web/src/features/crm/views/company-detail.tsx b/apps/web/src/features/crm/views/company-detail.tsx
index 78b4e1e2bd..b489daf3c0 100644
--- a/apps/web/src/features/crm/views/company-detail.tsx
+++ b/apps/web/src/features/crm/views/company-detail.tsx
@@ -41,7 +41,6 @@ type CompanyProps = {
companyId: string;
section?: CompanySection;
headerToggle?: boolean;
- onHidden?: () => void;
onOpenContact?: (contact: CompanyContact) => void;
onOpenPipeline?: (pipelineId: string) => void;
};
@@ -193,7 +192,7 @@ function CompanyContent(props: CompanyProps) {
</Suspense>
</Show>
<SidePanel.Section id="company-sharing" title="Sharing" order={25}>
- <CompanySharingSection company={company()} onHidden={props.onHidden} />
+ <CompanySharingSection company={company()} />
</SidePanel.Section>
<SidePanel.Section id="company-references" title="References" order={30}>
<RecordReferencesSection scope={scope()} />
diff --git a/apps/web/src/features/crm/views/company-sharing-section.tsx b/apps/web/src/features/crm/views/company-sharing-section.tsx
index dc3da63c98..64414afc03 100644
--- a/apps/web/src/features/crm/views/company-sharing-section.tsx
+++ b/apps/web/src/features/crm/views/company-sharing-section.tsx
@@ -3,48 +3,12 @@ import { fireAndForget } from '@core/util/fireAndForget';
import type { CrmCompanyEntity } from '@entity';
import { cn, InlineCheckbox } from '@ui';
import { Show } from 'solid-js';
-import { useCrmContext } from '../context/crm-context';
-import {
- useIsTeamAdmin,
- useSetCompanyHiddenMutation,
- useSetEmailSyncMutation,
-} from './use-crm';
+import { useIsTeamAdmin, useSetEmailSyncMutation } from './use-crm';
-const TOGGLE_BUTTON_CLASS =
- 'inline-flex items-center gap-2 rounded-md h-7 px-2.5 text-xs select-none w-fit border border-ink-muted/[0.08] bg-ink-muted/[0.025] text-ink hover:bg-ink-muted/[0.06]';
-
-export function CompanySharingSection(props: {
- company?: CrmCompanyEntity;
- onHidden?: () => void;
-}) {
- const hideMutation = useSetCompanyHiddenMutation();
+export function CompanySharingSection(props: { company?: CrmCompanyEntity }) {
const emailSyncMutation = useSetEmailSyncMutation();
- const { showCompanies } = useCrmContext().createNavigation();
const isTeamAdmin = useIsTeamAdmin();
- const handleToggleShare = async (
- company: CrmCompanyEntity,
- nextShared: boolean
- ) => {
- const willHide = !nextShared;
- try {
- await hideMutation.mutateAsync({
- companyId: company.id,
- hidden: willHide,
- });
- // On hide (un-share), drop the user back to the companies list and toast.
- // Un-hide leaves them on the block.
- if (willHide) {
- toast.success('Company hidden.');
- if (props.onHidden) props.onHidden();
- else showCompanies();
- }
- } catch (error) {
- console.error('failed to update company sharing', error);
- toast.failure('Could not update company visibility');
- }
- };
-
const handleToggleEmailSync = async (
company: CrmCompanyEntity,
nextEmailSync: boolean
@@ -66,47 +30,18 @@ export function CompanySharingSection(props: {
fallback={<div class="text-xs text-ink-muted">Loading…</div>}
>
{(company) => {
- const isShared = () => !company().hidden;
// The detail query always supplies a real boolean; `?? false` only
// covers the type-level "not loaded" case (search-derived entities).
const isSyncing = () => company().emailSync ?? false;
// Disable interaction during pending mutations, when the backend
// would reject (409 CompanyHidden on re-enabling sync for a hidden
- // company — un-share first), or for non-admins. The greyed-out
+ // company — restore it first), or for non-admins. The greyed-out
// visual is reserved for the non-admin case only.
- const shareDisabled = () => hideMutation.isPending || !isTeamAdmin();
const syncDisabled = () =>
emailSyncMutation.isPending || company().hidden || !isTeamAdmin();
return (
<div class="flex flex-col gap-4 text-xs">
- {/* Admin/owner-only: if a non-admin can see the company at all,
- it's already visible to them. */}
- <Show when={isTeamAdmin()}>
- <div class="flex flex-col gap-2">
- <button
- type="button"
- role="checkbox"
- aria-checked={isShared()}
- disabled={shareDisabled()}
- onClick={() =>
- fireAndForget(
- handleToggleShare(company(), !isShared()),
- 'crm'
- )
- }
- class={cn(TOGGLE_BUTTON_CLASS)}
- >
- <InlineCheckbox checked={isShared()} />
- <span class="whitespace-nowrap">Visible in CRM</span>
- </button>
- <p class="text-ink-muted leading-5">
- Shows this company in your team's CRM lists and search. Hide
- companies that aren't relevant to your team's CRM.
- </p>
- </div>
- </Show>
-
<div class="flex flex-col gap-2">
<button
type="button"
@@ -120,7 +55,7 @@ export function CompanySharingSection(props: {
)
}
class={cn(
- TOGGLE_BUTTON_CLASS,
+ 'inline-flex items-center gap-2 rounded-md h-7 px-2.5 text-xs select-none w-fit border border-ink-muted/[0.08] bg-ink-muted/[0.025] text-ink hover:bg-ink-muted/[0.06]',
!isTeamAdmin() && 'pointer-events-none opacity-50'
)}
>
diff --git a/apps/web/src/features/crm/views/contact-detail.tsx b/apps/web/src/features/crm/views/contact-detail.tsx
index f614d8e615..8f378b86db 100644
--- a/apps/web/src/features/crm/views/contact-detail.tsx
+++ b/apps/web/src/features/crm/views/contact-detail.tsx
@@ -12,20 +12,19 @@ import {
import { ContactDiscussionSection } from './contact-discussion-section';
import { ContactEmailsSection } from './contact-emails-section';
import { ContactHeader } from './contact-header';
-import { ContactSharingSection } from './contact-sharing-section';
import {
RecordCallsSection,
RecordDatabasesSection,
RecordFilesSection,
RecordReferencesSection,
} from './record-associations';
-import { useContactQuery, useIsTeamAdmin } from './use-crm';
+import { useContactQuery } from './use-crm';
/**
* Root of the contact detail view, laid out like a project: the host's top
* bar picks the section, Overview shows the contact and its discussion, and
- * the other sections list its emails, files, tasks and calls. Sharing and
- * references stay in the floating information panel.
+ * the other sections list its emails, files, tasks and calls. References
+ * stay in the floating information panel.
*/
type ContactProps = {
contactId: string;
@@ -63,7 +62,6 @@ function ContactContent(props: ContactProps) {
companyId: contact()?.companyId,
}))
);
- const isTeamAdmin = useIsTeamAdmin();
const section = () => props.section ?? 'overview';
const scope = createMemo(
(): CrmRecordScope | undefined => {
@@ -130,13 +128,6 @@ function ContactContent(props: ContactProps) {
</div>
</div>
- {/* Sharing is admin-only; hide the whole section for non-admins
- rather than rendering it empty. */}
- <Show when={isTeamAdmin()}>
- <SidePanel.Section id="contact-sharing" title="Sharing" order={25}>
- <ContactSharingSection contact={contact()} />
- </SidePanel.Section>
- </Show>
<SidePanel.Section id="contact-references" title="References" order={30}>
<RecordReferencesSection scope={scope()} />
</SidePanel.Section>
diff --git a/apps/web/src/features/crm/views/contact-sharing-section.tsx b/apps/web/src/features/crm/views/contact-sharing-section.tsx
deleted file mode 100644
index e8bf5625d4..0000000000
--- a/apps/web/src/features/crm/views/contact-sharing-section.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { toast } from '@core/component/Toast/Toast';
-import { fireAndForget } from '@core/util/fireAndForget';
-import { cn, InlineCheckbox } from '@ui';
-import { Show } from 'solid-js';
-import type { CrmContact as CrmContactResponse } from '../core/contact';
-import { useSetContactHiddenMutation } from './use-crm';
-
-const TOGGLE_BUTTON_CLASS =
- 'inline-flex items-center gap-2 rounded-md h-7 px-2.5 text-xs select-none w-fit border border-ink-muted/[0.08] bg-ink-muted/[0.025] text-ink hover:bg-ink-muted/[0.06]';
-
-/**
- * Admin-only (the parent gates the whole section on `useIsTeamAdmin`):
- * if a non-admin can see the contact at all, it's already visible to them.
- */
-export function ContactSharingSection(props: { contact?: CrmContactResponse }) {
- const hiddenMutation = useSetContactHiddenMutation();
-
- const handleToggle = async (
- contact: CrmContactResponse,
- nextShared: boolean
- ) => {
- const willHide = !nextShared;
- try {
- await hiddenMutation.mutateAsync({
- contactId: contact.id,
- hidden: willHide,
- });
- if (willHide) {
- toast.success('Contact hidden.');
- }
- } catch (error) {
- console.error('failed to update contact sharing', error);
- toast.failure('Could not update contact visibility');
- }
- };
-
- return (
- <Show
- when={props.contact}
- fallback={<div class="text-xs text-ink-muted">Loading…</div>}
- >
- {(contact) => {
- const isShared = () => !contact().hidden;
- return (
- <div class="flex flex-col gap-4 text-xs">
- <div class="flex flex-col gap-2">
- <button
- type="button"
- role="checkbox"
- aria-checked={isShared()}
- disabled={hiddenMutation.isPending}
- onClick={() =>
- fireAndForget(handleToggle(contact(), !isShared()), 'crm')
- }
- class={cn(TOGGLE_BUTTON_CLASS)}
- >
- <InlineCheckbox checked={isShared()} />
- <span class="whitespace-nowrap">Visible in CRM</span>
- </button>
- <p class="text-ink-muted leading-5">
- Shows this contact in their company's contact list. Hide
- contacts that aren't relevant to your team's CRM.
- </p>
- </div>
- </div>
- );
- }}
- </Show>
- );
-}
diff --git a/apps/web/src/features/crm/views/record-detail.test.tsx b/apps/web/src/features/crm/views/record-detail.test.tsx
index 2a825e4441..6194ef42c9 100644
--- a/apps/web/src/features/crm/views/record-detail.test.tsx
+++ b/apps/web/src/features/crm/views/record-detail.test.tsx
@@ -190,9 +190,6 @@ vi.mock('./contact-emails-section', () => ({
ContactEmailsSection: () => null,
}));
vi.mock('./contact-header', () => ({ ContactHeader: () => null }));
-vi.mock('./contact-sharing-section', () => ({
- ContactSharingSection: () => null,
-}));
vi.mock('./record-associations', () => ({
RecordCallsSection: () => null,
RecordFilesSection: () => null,
diff --git a/apps/web/src/features/crm/views/record-detail.tsx b/apps/web/src/features/crm/views/record-detail.tsx
index 3fe3a91a0c..ac142e27cd 100644
--- a/apps/web/src/features/crm/views/record-detail.tsx
+++ b/apps/web/src/features/crm/views/record-detail.tsx
@@ -240,7 +240,6 @@ export function CrmRecordDetail(props: {
companyId={record.id}
section={companySection()}
headerToggle={false}
- onHidden={back}
onOpenPipeline={props.onOpenPipeline}
onOpenContact={(contact) =>
open({
diff --git a/docs/agent-guide/crm.md b/docs/agent-guide/crm.md
index 04eb1a88b9..8f69ddc1c8 100644
--- a/docs/agent-guide/crm.md
+++ b/docs/agent-guide/crm.md
@@ -246,9 +246,9 @@ email sync off; re-enable **Sync Emails** under the information panel's **Sharin
section if needed. A company's Team tab excludes hidden contacts for every role,
including search results. Admins can find removed contacts in People display options and retain direct-link
access for restoration. Removing or restoring a person refreshes open company Team lists;
-returning to a previously visited company reloads its contacts. The existing
-**Sharing → Visible in CRM** checkbox and company row **Hide /
-Unhide** actions control the same state.
+returning to a previously visited company reloads its contacts. Company row
+**Hide / Unhide** actions control the same state. The information panel has no
+visibility toggle; company Sharing contains only **Sync Emails**.
Restoring a person under a hidden company does not make them appear in People
until that company is restored too. People without a company can be restored
directly; a person without a name or email is labeled **Contact** in the confirmation.
@@ -346,8 +346,8 @@ interacted`, followed by the contact's Pipelines cards. Its Files, Tasks, Calls,
and References show items associated with the contact itself (its `Contacts`
property or an @mention of it), not everything associated with its company;
Files also includes attachments of emails with its address. Tasks created from a
-contact also reference its company. The side panel keeps Sharing (admins only)
-and adds References.
+contact also reference its company. The side panel contains References, with no
+empty Sharing section.
In workspace activity and a company or contact's embedded sections, clicking a
Task, Email, Note, Call, or Database opens its authorized detail inside Customers.