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.

rm(contact): remove block contact + remove from command menu (#686)

teo45110c8a61fe
diff --git a/js/app/bun.lock b/js/app/bun.lock
index 802c969250..7fc9f44bbb 100644
--- a/js/app/bun.lock
+++ b/js/app/bun.lock
@@ -1,5 +1,6 @@
{
"lockfileVersion": 1,
+ "configVersion": 0,
"workspaces": {
"": {
"name": "@coparse/monorepo",
@@ -197,9 +198,6 @@
"packages/block-code": {
"name": "block-code",
},
- "packages/block-contact": {
- "name": "block-contact",
- },
"packages/block-image": {
"name": "block-image",
},
@@ -1449,8 +1447,6 @@
"block-code": ["block-code@workspace:packages/block-code"],
- "block-contact": ["block-contact@workspace:packages/block-contact"],
-
"block-image": ["block-image@workspace:packages/block-image"],
"block-markdown": ["block-markdown@workspace:packages/block-md"],
diff --git a/js/app/packages/app/component/command/useCommandItems.ts b/js/app/packages/app/component/command/useCommandItems.ts
index 367097d4c4..bdd674e421 100644
--- a/js/app/packages/app/component/command/useCommandItems.ts
+++ b/js/app/packages/app/component/command/useCommandItems.ts
@@ -1,7 +1,6 @@
import { useChannelsContext } from '@core/component/ChannelsProvider';
import { getActiveCommandsFromScope } from '@core/hotkey/getCommands';
import { activeScope } from '@core/hotkey/state';
-import { useContacts } from '@core/user';
import { mapFromListsByKey } from '@core/util/compareUtils';
import type { Channel } from '@service-comms/generated/models/channel';
import type { ChannelType } from '@service-comms/generated/models/channelType';
@@ -30,7 +29,6 @@ export function useCommandItems() {
const history = useHistory();
const channelsContext = useChannelsContext();
const channels = () => channelsContext.channels();
- const contactItems = useContacts();
const activeCommands = getActiveCommandsFromScope(activeScope(), {
sortByScopeLevel: false,
hideShadowedCommands: false,
@@ -101,22 +99,10 @@ export function useCommandItems() {
updatedAt: channel.updated_at,
}));
- const contacts = contactItems().map<CommandItemCard>((contact) => {
- return {
- type: 'contact',
- data: {
- id: contact.id,
- name: contact.name,
- email: contact.email,
- },
- };
- });
-
return mapFromListsByKey<CommandItemCard>(
(item) => item.data.id,
items,
channels_,
- contacts,
commands
);
});
diff --git a/js/app/packages/block-contact/MACRO_BEST_PRACTICES.md b/js/app/packages/block-contact/MACRO_BEST_PRACTICES.md
deleted file mode 100644
index 69328159eb..0000000000
--- a/js/app/packages/block-contact/MACRO_BEST_PRACTICES.md
+++ /dev/null
@@ -1,184 +0,0 @@
-# Macro's SolidJS Best Practices vs Standard React Patterns
-
-This document outlines the key differences between Macro's idiomatic SolidJS code patterns and typical React "midtier coder slop".
-
-## Key Principles
-
-### 1. **Signal/Store Management**
-
-**✅ Macro Way (SolidJS)**
-```typescript
-// Single source of truth with typed signals
-export const blockDataSignal = blockDataSignalAs<ContactData>('contact');
-
-// Clean signal exports
-export const emailPreviewsSignal = createBlockSignal<ThreadPreview[]>([]);
-
-// Direct getter access
-const emailPreviews = emailPreviewsSignal.get;
-```
-
-**❌ React Slop**
-```typescript
-// Multiple useState scattered around
-const [emailPreviews, setEmailPreviews] = useState<ThreadPreview[]>([]);
-const [isLoading, setIsLoading] = useState(false);
-const [error, setError] = useState<string | null>(null);
-
-// Props drilling everywhere
-<ChildComponent emailPreviews={emailPreviews} setEmailPreviews={setEmailPreviews} />
-```
-
-### 2. **Component Structure**
-
-**✅ Macro Way**
-```typescript
-// Default export for main blocks
-export default function BlockContact() {
- const blockData = blockDataSignal.get;
- // Direct signal access, no props needed
-}
-
-// Simple function components for internals
-function EmailPreviewItem(props: { preview: ThreadPreview }) {
- // Minimal props, only what's needed
-}
-```
-
-**❌ React Slop**
-```typescript
-// Named exports everywhere
-export const BlockContact: React.FC<BlockContactProps> = ({
- data,
- onUpdate,
- isLoading,
- // ... 20 more props
-}) => {
- // Component bloated with prop handling
-}
-```
-
-### 3. **Effects & Lifecycle**
-
-**✅ Macro Way**
-```typescript
-// Clear separation of concerns
-onMount(() => {
- initializeData();
-});
-
-createEffect(() => {
- const data = blockData();
- if (!data) return;
- // Reactive updates only
-});
-```
-
-**❌ React Slop**
-```typescript
-// useEffect hell
-useEffect(() => {
- // Everything mixed together
- fetchData();
- setupListeners();
- // Forgot cleanup
-}, [dep1, dep2, dep3, dep4]);
-```
-
-### 4. **Store Patterns**
-
-**✅ Macro Way**
-```typescript
-// Single typed store for related data
-export const mdStore = createBlockStore<MdData>({});
-
-// Direct access
-mdStore.set({ editor: lexicalEditor });
-```
-
-**❌ React Slop**
-```typescript
-// Context wrapper hell
-<EditorProvider>
- <ThemeProvider>
- <DataProvider>
- <YourComponent />
- </DataProvider>
- </ThemeProvider>
-</EditorProvider>
-```
-
-### 5. **Component Composition**
-
-**✅ Macro Way**
-```typescript
-// Clean, focused components
-<Show when={emailPreviews().length > 0} fallback={<EmptyState />}>
- <VList data={emailPreviews()}>
- {(preview) => <EmailPreviewItem preview={preview} />}
- </VList>
-</Show>
-```
-
-**❌ React Slop**
-```typescript
-// Ternary operator abuse
-{isLoading ? (
- <Spinner />
-) : error ? (
- <Error message={error} />
-) : data.length > 0 ? (
- data.map(item => <Item key={item.id} {...item} />)
-) : (
- <Empty />
-)}
-```
-
-### 6. **Imports Organization**
-
-**✅ Macro Way**
-```typescript
-// Type imports first
-import type { ContactData } from '../definition';
-
-// External deps
-import { createSignal } from 'solid-js';
-
-// Core imports
-import { useBlockId } from '@core/block';
-
-// Service imports
-import { emailClient } from '@service-email/client';
-
-// Local imports
-import { EmailPreviewList } from './EmailPreviewList';
-```
-
-**❌ React Slop**
-```typescript
-// Random order
-import React from 'react';
-import './styles.css';
-import { useState } from 'react';
-import type { Props } from './types';
-import axios from 'axios';
-```
-
-## Applied Refactoring
-
-The block-contact code has been refactored to follow these patterns:
-
-1. **Signals**: Converted all React-style useState to createBlockSignal
-2. **Component Structure**: Used default export for main block, simple functions for sub-components
-3. **Direct Access**: Removed props drilling, components access signals directly
-4. **Clean Effects**: Separated onMount logic from reactive createEffect
-5. **Focused Components**: Each component has a single responsibility
-6. **No Wrappers**: Removed unnecessary div wrappers and component nesting
-
-## Benefits
-
-- **Performance**: SolidJS's fine-grained reactivity > React's virtual DOM
-- **Simplicity**: Direct signal access > props drilling
-- **Type Safety**: Better TypeScript inference with signals
-- **Readability**: Clear separation of concerns
-- **Maintainability**: Less boilerplate, more focused code
\ No newline at end of file
diff --git a/js/app/packages/block-contact/README.md b/js/app/packages/block-contact/README.md
deleted file mode 100644
index 0f645ca795..0000000000
--- a/js/app/packages/block-contact/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Contact Block
-
-View and manage contact information with integrated email history.
-
-## Features
-
-- Contact profile display
-- Company/organization detection
-- Profile picture preview
-- Email history timeline
-- Quick email navigation
-- Side-by-side email viewing
\ No newline at end of file
diff --git a/js/app/packages/block-contact/component/Block.tsx b/js/app/packages/block-contact/component/Block.tsx
deleted file mode 100644
index c41fd94ce7..0000000000
--- a/js/app/packages/block-contact/component/Block.tsx
+++ /dev/null
@@ -1,241 +0,0 @@
-import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';
-import { UserIcon } from '@core/component/UserIcon';
-import { emailToId } from '@core/user';
-import { createMemo, createSignal, Show } from 'solid-js';
-import { useSplitLayout } from '../../app/component/split-layout/layout';
-import { blockDataSignal } from '../signal/contactBlockData';
-import { extractDomainFromEmail, isConsumerEmail } from '../util/emailUtils';
-import { ChannelsList } from './ChannelsList';
-import { CompanyProfile } from './CompanyProfile';
-import { PeopleList } from './PeopleList';
-import { SharedFilesSection } from './SharedFilesSection';
-import { TopBar } from './TopBar';
-
-export default function BlockContact() {
- const blockData = blockDataSignal.get;
- const [showProfilePreview, setShowProfilePreview] = createSignal(false);
- const { replaceOrInsertSplit } = useSplitLayout();
-
- const contactData = createMemo(() => {
- const data = blockData();
- if (!data) return null;
- return data;
- });
-
- const contactType = createMemo(() => contactData()?.type || 'person');
-
- const userId = createMemo(() => {
- const data = contactData();
- if (!data || data.type !== 'person') return null;
- return emailToId(data.email!);
- });
-
- const userName = createMemo(() => {
- const data = contactData();
- if (!data) return 'Unknown';
- if (data.type === 'company') return data.domain?.substring(1) || 'Unknown';
- return data.contact?.name || data.email || 'Unknown';
- });
-
- const userCompany = createMemo(() => {
- const data = contactData();
- if (!data || data.type !== 'person') return 'Unknown';
-
- const domain = extractDomainFromEmail(data.email!);
- if (isConsumerEmail(domain)) {
- return 'Consumer';
- }
-
- return domain.charAt(0).toUpperCase() + domain.slice(1);
- });
-
- const userCompanyDomain = createMemo(() => {
- const data = contactData();
- if (!data || data.type !== 'person') return null;
-
- const email = data.email!;
- const atIndex = email.lastIndexOf('@');
- if (atIndex === -1) return null;
-
- const fullDomain = email.substring(atIndex + 1);
-
- // Check if it's a consumer email domain using the utility function
- // The function checks both with and without .com extension
- const domainName = extractDomainFromEmail(email);
- if (isConsumerEmail(domainName)) {
- return null;
- }
-
- // Return the full domain for use in navigation
- return fullDomain;
- });
-
- const title = createMemo(() => {
- const data = contactData();
- if (!data) return 'Contact';
- if (data.type === 'company') {
- return data.unfurlData?.title || data.domain?.substring(1) || 'Company';
- }
- return userName() || 'Contact';
- });
-
- const emailOrDomain = createMemo(() => {
- const data = contactData();
- if (!data) return '';
- return data.type === 'person' ? data.email! : data.domain!;
- });
-
- return (
- <DocumentBlockContainer title={title()}>
- <div class="flex flex-col h-full bg-background">
- <TopBar email={emailOrDomain()} type={contactType()} />
-
- <div class="flex-1 flex flex-col overflow-hidden">
- {/* Top section with contact/company info and shared files */}
- <div class="flex border-b border-edge">
- {/* Contact/Company info section */}
- <div class="p-6 flex-1">
- <Show
- when={contactType() === 'person'}
- fallback={
- <Show when={contactData()}>
- {(data) => (
- <>
- <CompanyProfile
- domain={data().domain!}
- unfurlData={data().unfurlData}
- />
- <div class="mt-4">
- <PeopleList domain={data().domain!} />
- </div>
- </>
- )}
- </Show>
- }
- >
- <div class="flex gap-6">
- <div
- class="w-32 h-32 aspect-square cursor-pointer rounded-lg overflow-hidden"
- onClick={() => setShowProfilePreview(true)}
- >
- <Show
- when={userId()}
- fallback={<div class="w-full h-full" />}
- >
- <UserIcon id={userId()!} size="fill" isDeleted={false} />
- </Show>
- </div>
-
- <div class="flex-1 space-y-4">
- <div class="space-y-2">
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- Name:
- </span>
- <span class="text-base text-ink truncate flex-1">
- {userName()}
- </span>
- </div>
-
- <Show when={contactData()?.email}>
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- Email:
- </span>
- <span class="text-base text-ink truncate flex-1">
- {contactData()!.email}
- </span>
- </div>
- </Show>
-
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- Company:
- </span>
- <Show
- when={userCompanyDomain()}
- fallback={
- <span class="text-base text-ink truncate flex-1">
- {userCompany()}
- </span>
- }
- >
- <button
- class="text-base text-accent-ink hover:text-accent-ink-ink hover:underline truncate flex-1 text-left"
- onClick={() => {
- const domain = userCompanyDomain();
- if (domain) {
- replaceOrInsertSplit({
- type: 'contact',
- id: `@${domain}`,
- });
- }
- }}
- >
- {userCompany()}
- </button>
- </Show>
- </div>
-
- <Show when={contactData()?.email}>
- {(email) => <ChannelsList contactEmail={email()} />}
- </Show>
- </div>
- </div>
- </div>
- </Show>
- </div>
-
- {/* Shared files section */}
- <Show when={contactType() === 'person' && contactData()?.email}>
- {(email) => (
- <div class="w-[400px] border-l border-edge">
- <SharedFilesSection contactEmail={email()} />
- </div>
- )}
- </Show>
- </div>
- </div>
-
- {/* Profile Picture Preview Modal - only for people */}
- <Show when={showProfilePreview() && contactType() === 'person'}>
- <div
- class="fixed inset-0 bg-ink/50 flex items-center justify-center z-50"
- onClick={() => setShowProfilePreview(false)}
- >
- <div class="relative max-w-[75vw] max-h-[90vh]">
- <button
- class="absolute -top-10 right-0 text-panel hover:text-edge"
- onClick={(e) => {
- e.stopPropagation();
- setShowProfilePreview(false);
- }}
- >
- <svg
- width="24"
- height="24"
- viewBox="0 0 24 24"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M18 6L6 18M6 6L18 18"
- stroke="currentColor"
- stroke-width="2"
- stroke-linecap="round"
- stroke-linejoin="round"
- />
- </svg>
- </button>
- <Show when={userId()}>
- <div class="rounded-lg overflow-hidden">
- <UserIcon id={userId()!} size="fill" isDeleted={false} />
- </div>
- </Show>
- </div>
- </div>
- </Show>
- </div>
- </DocumentBlockContainer>
- );
-}
diff --git a/js/app/packages/block-contact/component/ChannelsList.tsx b/js/app/packages/block-contact/component/ChannelsList.tsx
deleted file mode 100644
index 33e288a61e..0000000000
--- a/js/app/packages/block-contact/component/ChannelsList.tsx
+++ /dev/null
@@ -1,128 +0,0 @@
-import { CircleSpinner } from '@core/component/CircleSpinner';
-import { type ChannelWithParticipants, emailToId } from '@core/user';
-import { isErr } from '@core/util/maybeResult';
-import Hash from '@icon/regular/hash.svg?component-solid';
-import Users from '@icon/regular/users.svg?component-solid';
-import { commsServiceClient } from '@service-comms/client';
-import { For, onMount, Show } from 'solid-js';
-import { useSplitLayout } from '../../app/component/split-layout/layout';
-import {
- contactChannelsSignal,
- isLoadingChannelsSignal,
-} from '../signal/channelsSignal';
-
-export function ChannelsList(props: { contactEmail: string }) {
- const contactChannels = contactChannelsSignal.get;
- const setContactChannels = contactChannelsSignal.set;
- const isLoadingChannels = isLoadingChannelsSignal.get;
- const setIsLoadingChannels = isLoadingChannelsSignal.set;
-
- const { replaceOrInsertSplit } = useSplitLayout();
-
- onMount(async () => {
- await loadChannelsForContact();
- });
-
- async function loadChannelsForContact() {
- setIsLoadingChannels(true);
-
- try {
- // Get all channels the current user is in
- const channelsResult = await commsServiceClient.getChannels();
-
- if (!isErr(channelsResult)) {
- const [, channelsData] = channelsResult;
- const allChannels = channelsData.channels || [];
-
- // Convert email to user ID format
- const contactUserId = emailToId(props.contactEmail);
-
- // Filter channels that include our contact
- const channelsWithContact = allChannels.filter((channel) =>
- channel.participants.some(
- (participant) =>
- participant.user_id === contactUserId && !participant.left_at
- )
- );
-
- // Sort by channel name or ID
- channelsWithContact.sort((a, b) => {
- const aName = a.name || a.id;
- const bName = b.name || b.id;
- return aName.localeCompare(bName);
- });
-
- setContactChannels(channelsWithContact);
- }
- } catch (error) {
- console.error('Error loading channels:', error);
- } finally {
- setIsLoadingChannels(false);
- }
- }
-
- const getChannelIcon = (channel: ChannelWithParticipants) => {
- // DM channels typically have exactly 2 participants
- return channel.participants.length === 2 ? Users : Hash;
- };
-
- const getChannelDisplayName = (channel: ChannelWithParticipants) => {
- if (channel.name) return channel.name;
-
- // For DMs without a name, show "Direct Message"
- if (channel.participants.length === 2) {
- return 'Direct Message';
- }
-
- return channel.id;
- };
-
- return (
- <div class="space-y-2">
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- Channels:
- </span>
- <Show
- when={!isLoadingChannels()}
- fallback={
- <div class="flex items-center">
- <CircleSpinner />
- </div>
- }
- >
- <Show
- when={contactChannels().length > 0}
- fallback={
- <span class="text-sm text-ink-extra-muted italic">
- No shared channels
- </span>
- }
- >
- <div class="flex-1 flex flex-wrap gap-2">
- <For each={contactChannels()}>
- {(channel) => {
- const Icon = getChannelIcon(channel);
- return (
- <button
- class="inline-flex items-center gap-1 px-2 py-1 text-xs bg-edge/30 hover:bg-hover rounded-md hover-transition-bg"
- onClick={() =>
- replaceOrInsertSplit({
- type: 'channel',
- id: channel.id,
- })
- }
- >
- <Icon class="w-3 h-3" />
- <span>{getChannelDisplayName(channel)}</span>
- </button>
- );
- }}
- </For>
- </div>
- </Show>
- </Show>
- </div>
- </div>
- );
-}
diff --git a/js/app/packages/block-contact/component/CompanyProfile.tsx b/js/app/packages/block-contact/component/CompanyProfile.tsx
deleted file mode 100644
index 3d8ed1b112..0000000000
--- a/js/app/packages/block-contact/component/CompanyProfile.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import Building from '@icon/regular/buildings.svg?component-solid';
-import { proxyResource } from '@service-unfurl/client';
-import type { GetUnfurlResponse } from '@service-unfurl/generated/schemas/getUnfurlResponse';
-import { Show } from 'solid-js';
-
-export function CompanyProfile(props: {
- domain: string;
- unfurlData: GetUnfurlResponse | null;
-}) {
- // Remove @ prefix for display
- const domainName = props.domain.substring(1);
-
- // Get proxied image URL
- const imageUrl = () => {
- if (props.unfurlData?.image_url) {
- return proxyResource(props.unfurlData.image_url);
- } else if (props.unfurlData?.favicon_url) {
- return proxyResource(props.unfurlData.favicon_url);
- }
- return null;
- };
-
- return (
- <div class="flex gap-6">
- {/* Company Logo/Icon */}
- <div class="w-32 h-32 aspect-square rounded-lg overflow-hidden bg-edge/30 flex items-center justify-center">
- <Show
- when={imageUrl()}
- fallback={<Building class="w-16 h-16 text-ink-extra-muted" />}
- >
- <img
- src={imageUrl()!}
- alt={domainName}
- class="w-full h-full object-contain"
- onError={(e) => {
- // If image fails to load, hide it and show fallback
- (e.target as HTMLImageElement).style.display = 'none';
- }}
- />
- </Show>
- </div>
-
- {/* Company Details */}
- <div class="flex-1 space-y-4">
- <div class="space-y-2">
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- Domain:
- </span>
- <span class="text-base text-ink truncate flex-1">{domainName}</span>
- </div>
-
- <Show when={props.unfurlData?.title}>
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- Name:
- </span>
- <span class="text-base text-ink truncate flex-1">
- {props.unfurlData!.title}
- </span>
- </div>
- </Show>
-
- <Show when={props.unfurlData?.description}>
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- About:
- </span>
- <span class="text-sm text-ink flex-1 line-clamp-2">
- {props.unfurlData!.description}
- </span>
- </div>
- </Show>
- </div>
- </div>
- </div>
- );
-}
diff --git a/js/app/packages/block-contact/component/PeopleList.tsx b/js/app/packages/block-contact/component/PeopleList.tsx
deleted file mode 100644
index 1660018011..0000000000
--- a/js/app/packages/block-contact/component/PeopleList.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import { createBlockSignal } from '@core/block';
-import { CircleSpinner } from '@core/component/CircleSpinner';
-import { UserIcon } from '@core/component/UserIcon';
-import { type ContactInfo, emailToId } from '@core/user';
-import { isErr } from '@core/util/maybeResult';
-import { emailClient } from '@service-email/client';
-import { For, onMount, Show } from 'solid-js';
-import { useSplitLayout } from '../../app/component/split-layout/layout';
-
-const peopleAtCompanySignal = createBlockSignal<ContactInfo[]>([]);
-const isLoadingPeopleSignal = createBlockSignal(false);
-
-export function PeopleList(props: { domain: string }) {
- const peopleAtCompany = peopleAtCompanySignal.get;
- const setPeopleAtCompany = peopleAtCompanySignal.set;
- const isLoadingPeople = isLoadingPeopleSignal.get;
- const setIsLoadingPeople = isLoadingPeopleSignal.set;
-
- const { replaceOrInsertSplit } = useSplitLayout();
-
- onMount(async () => {
- await loadPeopleAtCompany();
- });
-
- async function loadPeopleAtCompany() {
- setIsLoadingPeople(true);
-
- try {
- // Get the domain without @ prefix
- const domainWithoutAt = props.domain.substring(1);
-
- // Get all contacts from the email service
- const contactsResult = await emailClient.listContacts();
-
- if (!isErr(contactsResult)) {
- const [, contactsData] = contactsResult;
- const allContacts: ContactInfo[] = [];
-
- // Flatten all contacts from the response
- for (const contacts of Object.values(contactsData.contacts)) {
- allContacts.push(...contacts);
- }
-
- // Filter contacts that have the company domain
- const companyContacts = allContacts.filter((contact) =>
- contact.email
- .toLowerCase()
- .endsWith(`@${domainWithoutAt.toLowerCase()}`)
- );
-
- // Remove duplicates by email
- const uniqueContacts = Array.from(
- new Map(
- companyContacts.map((c) => [c.email.toLowerCase(), c])
- ).values()
- );
-
- // Sort by name or email
- uniqueContacts.sort((a, b) => {
- const aName = a.name || a.email;
- const bName = b.name || b.email;
- return aName.localeCompare(bName);
- });
-
- setPeopleAtCompany(uniqueContacts);
- }
- } catch (error) {
- console.error('Error loading people at company:', error);
- } finally {
- setIsLoadingPeople(false);
- }
- }
-
- const EmptyState = () => (
- <div class="flex items-center gap-2">
- <span class="text-sm text-ink-extra-muted italic">
- No people found at this company
- </span>
- </div>
- );
-
- return (
- <div class="space-y-2">
- <div class="flex items-baseline gap-2">
- <span class="text-sm font-medium text-ink-muted min-w-[60px]">
- People:
- </span>
- <Show
- when={!isLoadingPeople()}
- fallback={
- <div class="flex items-center">
- <CircleSpinner width={4} height={4} />
- </div>
- }
- >
- <Show when={peopleAtCompany().length > 0} fallback={<EmptyState />}>
- <div class="flex-1 flex flex-wrap gap-2">
- <For each={peopleAtCompany()}>
- {(person) => {
- const userId = emailToId(person.email);
- return (
- <button
- class="inline-flex items-center gap-2 px-3 py-1.5 text-xs bg-edge/30 hover:bg-hover rounded-md hover-transition-bg"
- onClick={() =>
- replaceOrInsertSplit({
- type: 'contact',
- id: person.email,
- })
- }
- >
- <div class="w-5 h-5 overflow-hidden">
- <UserIcon id={userId} size="fill" isDeleted={false} />
- </div>
- <span class="font-medium">
- {person.name || person.email.split('@')[0]}
- </span>
- </button>
- );
- }}
- </For>
- </div>
- </Show>
- </Show>
- </div>
- </div>
- );
-}
diff --git a/js/app/packages/block-contact/component/SharedFilesSection.tsx b/js/app/packages/block-contact/component/SharedFilesSection.tsx
deleted file mode 100644
index 8c710ce946..0000000000
--- a/js/app/packages/block-contact/component/SharedFilesSection.tsx
+++ /dev/null
@@ -1,258 +0,0 @@
-import { CircleSpinner } from '@core/component/CircleSpinner';
-import { HoverButtonWrapper } from '@core/component/FileList/HoverButtonWrapper';
-import { ContextMenuContent, MenuItem } from '@core/component/Menu';
-import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { isMobileWidth } from '@core/mobile/mobileWidth';
-import { formatDate } from '@core/util/date';
-import { isErr } from '@core/util/maybeResult';
-import ArrowsOutSimple from '@icon/regular/arrows-out-simple.svg?component-solid';
-import ThreeDotsIcon from '@icon/regular/dots-three.svg?component-solid';
-import FileIcon from '@icon/regular/file.svg?component-solid';
-import FileDocIcon from '@icon/regular/file-doc.svg?component-solid';
-import FileImageIcon from '@icon/regular/file-image.svg?component-solid';
-import FilePdfIcon from '@icon/regular/file-pdf.svg?component-solid';
-import { ContextMenu } from '@kobalte/core/context-menu';
-import { commsServiceClient } from '@service-comms/client';
-import type { Attachment } from '@service-comms/generated/models/attachment';
-import { type Component, createSignal, onMount, Show } from 'solid-js';
-import { VList } from 'virtua/solid';
-import { useSplitLayout } from '../../app/component/split-layout/layout';
-import {
- channelIdSignal,
- isLoadingFilesSignal,
- sharedFilesSignal,
-} from '../signal/sharedFilesSignal';
-
-export function SharedFilesSection(props: { contactEmail: string }) {
- const sharedFiles = sharedFilesSignal.get;
- const setSharedFiles = sharedFilesSignal.set;
- const isLoadingFiles = isLoadingFilesSignal.get;
- const setIsLoadingFiles = isLoadingFilesSignal.set;
- const setChannelId = channelIdSignal.set;
-
- onMount(async () => {
- console.log(
- '[SharedFiles] Component mounted for contact:',
- props.contactEmail
- );
- await loadSharedFiles();
- });
-
- async function loadSharedFiles() {
- setIsLoadingFiles(true);
- console.log(
- '[SharedFiles] Starting to load shared files for:',
- props.contactEmail
- );
-
- try {
- // Get or create the DM channel with this contact
- console.log(
- '[SharedFiles] Calling getOrCreateDirectMessage with recipient_id:',
- props.contactEmail
- );
- const dmResult = await commsServiceClient.getOrCreateDirectMessage({
- recipient_id: props.contactEmail,
- });
-
- console.log('[SharedFiles] DM Result:', dmResult);
-
- if (isErr(dmResult)) {
- console.error('[SharedFiles] Failed to get DM channel:', dmResult);
- setIsLoadingFiles(false);
- return;
- }
-
- const [, dmData] = dmResult;
- console.log('[SharedFiles] DM Data:', dmData);
- console.log('[SharedFiles] Channel ID:', dmData.channel_id);
-
- setChannelId(dmData.channel_id);
-
- // Get the channel data including attachments
- console.log(
- '[SharedFiles] Calling getChannel with channel_id:',
- dmData.channel_id
- );
- const channelResult = await commsServiceClient.getChannel({
- channel_id: dmData.channel_id,
- });
-
- console.log('[SharedFiles] Channel Result:', channelResult);
-
- if (!isErr(channelResult)) {
- const [, channelData] = channelResult;
- console.log('[SharedFiles] Channel Data:', channelData);
- console.log(
- '[SharedFiles] Attachments array:',
- channelData.attachments
- );
- console.log(
- '[SharedFiles] Number of attachments:',
- channelData.attachments?.length || 0
- );
-
- // Log each attachment for debugging
- if (channelData.attachments && channelData.attachments.length > 0) {
- channelData.attachments.forEach((att, index) => {
- console.log(`[SharedFiles] Attachment ${index}:`, att);
- });
- }
-
- // Sort attachments by date, most recent first
- const sortedAttachments = [...channelData.attachments].sort((a, b) => {
- const aTime = new Date(a.created_at).getTime();
- const bTime = new Date(b.created_at).getTime();
- return bTime - aTime;
- });
-
- console.log('[SharedFiles] Sorted attachments:', sortedAttachments);
- setSharedFiles(sortedAttachments);
- } else {
- console.error(
- '[SharedFiles] Failed to get channel data:',
- channelResult
- );
- }
- } catch (error) {
- console.error('[SharedFiles] Error loading shared files:', error);
- } finally {
- setIsLoadingFiles(false);
- console.log(
- '[SharedFiles] Finished loading. Final shared files count:',
- sharedFiles().length
- );
- }
- }
-
- const EmptyState = () => (
- <div class="flex flex-col items-center justify-center py-8 text-ink-muted">
- <FileIcon class="w-8 h-8 mb-2" />
- <span class="text-sm">No files shared</span>
- </div>
- );
-
- return (
- <div class="flex flex-col h-full">
- <div class="flex items-center justify-between px-4 py-2 border-b border-edge">
- <h3 class="text-sm font-medium">Files Shared in Channel</h3>
- <Show when={sharedFiles().length > 0}>
- <span class="text-xs text-ink-muted">
- {sharedFiles().length} files
- </span>
- </Show>
- </div>
-
- <div class="flex-1 overflow-hidden">
- <Show
- when={!isLoadingFiles()}
- fallback={
- <div class="flex items-center justify-center h-full">
- <CircleSpinner />
- </div>
- }
- >
- <Show when={sharedFiles().length > 0} fallback={<EmptyState />}>
- <VList data={sharedFiles()} class="flex-1 px-4 py-2" overscan={5}>
- {(attachment) => <FileItem attachment={attachment} />}
- </VList>
- </Show>
- </Show>
- </div>
- </div>
- );
-}
-
-const getFileIcon = (entityType: string) => {
- switch (entityType.toLowerCase()) {
- case 'document':
- case 'doc':
- case 'docx':
- return FileDocIcon;
- case 'pdf':
- return FilePdfIcon;
- case 'image':
- case 'jpg':
- case 'jpeg':
- case 'png':
- case 'gif':
- return FileImageIcon;
- default:
- return FileIcon;
- }
-};
-
-const FileItem: Component<{ attachment: Attachment }> = (props) => {
- const [hovering, setHovering] = createSignal(false);
- const FileIconComponent = getFileIcon(props.attachment.entity_type);
-
- const { replaceOrInsertSplit } = useSplitLayout();
-
- return (
- <ContextMenu>
- <ContextMenu.Trigger>
- <div
- class="h-14 rounded p-2 text-xs hover:bg-hover hover-transition-bg mb-2 cursor-pointer flex items-center gap-3"
- onClick={() => {
- replaceOrInsertSplit({
- type: props.attachment.entity_type as any,
- id: props.attachment.entity_id,
- });
- }}
- onpointerenter={() => setHovering(true)}
- onpointerleave={() => setHovering(false)}
- >
- <div class="flex-shrink-0">
- <FileIconComponent class="w-5 h-5 text-ink-muted" />
- </div>
- <div class="flex-1 min-w-0">
- <div class="truncate font-medium">{props.attachment.entity_id}</div>
- <div class="text-ink-muted text-xs">
- {formatDate(
- new Date(props.attachment.created_at).getTime() / 1000
- )}
- </div>
- </div>
- <Show when={!isTouchDevice}>
- <div class="flex-shrink-0">
- <HoverButtonWrapper
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- e.currentTarget.dispatchEvent(
- new MouseEvent('contextmenu', {
- bubbles: true,
- cancelable: true,
- view: window,
- button: 2,
- buttons: 2,
- clientX:
- e.currentTarget.getBoundingClientRect().left +
- e.currentTarget.offsetWidth / 2,
- clientY:
- e.currentTarget.getBoundingClientRect().top +
- e.currentTarget.offsetHeight / 2,
- })
- );
- }}
- size="sm"
- showOnHover={hovering()}
- >
- <ThreeDotsIcon class="size-full" />
- </HoverButtonWrapper>
- </div>
- </Show>
- </div>
- </ContextMenu.Trigger>
- <ContextMenu.Portal>
- <ContextMenuContent
- class={`z-item-options-menu ${isMobileWidth() && isTouchDevice ? 'w-[calc(100vw-1rem)]' : ''}`}
- >
- <ContextMenu.Item class="w-full">
- <MenuItem text="Open in New Tab" icon={ArrowsOutSimple} />
- </ContextMenu.Item>
- </ContextMenuContent>
- </ContextMenu.Portal>
- </ContextMenu>
- );
-};
diff --git a/js/app/packages/block-contact/component/TopBar.tsx b/js/app/packages/block-contact/component/TopBar.tsx
deleted file mode 100644
index 24e4eb9ebe..0000000000
--- a/js/app/packages/block-contact/component/TopBar.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import { IconButton } from '@core/component/IconButton';
-import { Bar } from '@core/component/TopBar/Bar';
-import { Left } from '@core/component/TopBar/Left';
-import { Right } from '@core/component/TopBar/Right';
-import { isOk } from '@core/util/maybeResult';
-import EnvelopeSimple from '@icon/regular/envelope-simple.svg?component-solid';
-import PaperPlaneRight from '@icon/regular/paper-plane-right.svg?component-solid';
-import { commsServiceClient } from '@service-comms/client';
-import { Show } from 'solid-js';
-import { useSplitLayout } from '../../app/component/split-layout/layout';
-
-export function TopBar(props: { email: string; type: 'person' | 'company' }) {
- const handleEmailClick = () => {
- replaceOrInsertSplit({ type: 'email', id: 'new' });
- };
-
- const { replaceOrInsertSplit } = useSplitLayout();
-
- const handleDMClick = async () => {
- // Convert email to user ID format (prepend 'macro|')
- const userId = `macro|${props.email}`;
-
- // Get or create DM channel
- const result = await commsServiceClient.getOrCreateDirectMessage({
- recipient_id: userId,
- });
-
- if (isOk(result) && result[1]?.channel_id) {
- replaceOrInsertSplit({
- type: 'channel',
- id: result[1].channel_id,
- });
- }
- };
-
- return (
- <Bar
- left={<Left />}
- center
- right={
- <Right>
- <div class="flex items-center gap-2">
- <IconButton
- icon={EnvelopeSimple}
- title="Send Email"
- onClick={handleEmailClick}
- />
- <Show when={props.type === 'person'}>
- <IconButton
- icon={PaperPlaneRight}
- title="Send Direct Message"
- onClick={handleDMClick}
- />
- </Show>
- </div>
- </Right>
- }
- />
- );
-}
diff --git a/js/app/packages/block-contact/definition.ts b/js/app/packages/block-contact/definition.ts
deleted file mode 100644
index 0b3f7ce48d..0000000000
--- a/js/app/packages/block-contact/definition.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-import { defineBlock, type ExtractLoadType, LoadErrors } from '@core/block';
-import type { ContactInfo } from '@core/user';
-import { isErr, ok } from '@core/util/maybeResult';
-import { emailClient } from '@service-email/client';
-import { UnfurlServiceClient } from '@service-unfurl/client';
-import BlockContact from './component/Block';
-
-export const definition = defineBlock({
- name: 'contact',
- description: 'View and manage contact information',
- accepted: {},
- component: BlockContact,
-
- async load(source, _intent) {
- if (source.type === 'dss') {
- // The source.id will be the email address or domain
- const id = decodeURIComponent(source.id);
-
- // Check if it's a domain (starts with @) or email address
- const isDomain = id.startsWith('@');
- const type = isDomain ? 'company' : 'person';
-
- if (type === 'company') {
- // For companies, get the domain without @
- const domain = id.substring(1);
-
- // Try to unfurl the company website to get logo/favicon
- let unfurlData = null;
- try {
- const unfurlResult = await UnfurlServiceClient.unfurl({
- url: `https://${domain}`,
- });
- if (!isErr(unfurlResult)) {
- const [, data] = unfurlResult;
- unfurlData = data;
- }
- } catch (error) {
- console.error('Failed to unfurl company website:', error);
- }
-
- return ok({
- type: 'company' as const,
- domain: id, // Keep the @ prefix
- unfurlData,
- email: null,
- contact: null,
- });
- }
-
- // For individual contacts
- const email = id;
-
- // Get contact data from the email service
- const contactsResponse = await emailClient.listContacts();
-
- if (isErr(contactsResponse)) {
- return LoadErrors.INVALID;
- }
-
- const [, data] = contactsResponse;
- let foundContact: ContactInfo | null = null;
-
- // Search through all contacts to find the one with matching email
- for (const contacts of Object.values(data.contacts)) {
- const match = contacts.find(
- (c) => c.email_address.toLowerCase() === email.toLowerCase()
- );
- if (match) {
- foundContact = match;
- break;
- }
- }
-
- if (!foundContact) {
- // If no contact found in email service, create a basic contact object
- foundContact = {
- email,
- name: null,
- };
- }
-
- return ok({
- type: 'person' as const,
- email,
- contact: foundContact,
- domain: null,
- unfurlData: null,
- });
- }
- return LoadErrors.INVALID;
- },
-});
-
-export type ContactData = ExtractLoadType<(typeof definition)['load']>;
diff --git a/js/app/packages/block-contact/package.json b/js/app/packages/block-contact/package.json
deleted file mode 100644
index ff6260f406..0000000000
--- a/js/app/packages/block-contact/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "block-contact",
- "private": true,
- "scripts": {},
- "dependencies": {}
-}
\ No newline at end of file
diff --git a/js/app/packages/block-contact/signal/channelsSignal.ts b/js/app/packages/block-contact/signal/channelsSignal.ts
deleted file mode 100644
index 08170a384b..0000000000
--- a/js/app/packages/block-contact/signal/channelsSignal.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createBlockSignal } from '@core/block';
-import type { ChannelWithParticipants } from '@core/user';
-
-export const contactChannelsSignal = createBlockSignal<
- ChannelWithParticipants[]
->([]);
-export const isLoadingChannelsSignal = createBlockSignal(false);
diff --git a/js/app/packages/block-contact/signal/contactBlockData.ts b/js/app/packages/block-contact/signal/contactBlockData.ts
deleted file mode 100644
index 52e31b536a..0000000000
--- a/js/app/packages/block-contact/signal/contactBlockData.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { blockDataSignalAs } from '@core/block';
-import type { ContactData } from '../definition';
-
-export const blockDataSignal = blockDataSignalAs<ContactData>('contact');
diff --git a/js/app/packages/block-contact/signal/emailPreviewSignal.ts b/js/app/packages/block-contact/signal/emailPreviewSignal.ts
deleted file mode 100644
index 3e95c1068d..0000000000
--- a/js/app/packages/block-contact/signal/emailPreviewSignal.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createBlockSignal } from '@core/block';
-import type { ThreadPreview } from '@core/types';
-
-export const emailPreviewsSignal = createBlockSignal<ThreadPreview[]>([]);
-export const isLoadingPreviewsSignal = createBlockSignal(false);
-export const hasMorePreviewsSignal = createBlockSignal(true);
diff --git a/js/app/packages/block-contact/signal/sharedFilesSignal.ts b/js/app/packages/block-contact/signal/sharedFilesSignal.ts
deleted file mode 100644
index d67b74b337..0000000000
--- a/js/app/packages/block-contact/signal/sharedFilesSignal.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createBlockSignal } from '@core/block';
-import type { Attachment } from '@service-comms/generated/models/attachment';
-
-export const sharedFilesSignal = createBlockSignal<Attachment[]>([]);
-export const isLoadingFilesSignal = createBlockSignal(false);
-export const channelIdSignal = createBlockSignal<string | null>(null);
diff --git a/js/app/packages/block-contact/tsconfig.json b/js/app/packages/block-contact/tsconfig.json
deleted file mode 100644
index 7e047e38b7..0000000000
--- a/js/app/packages/block-contact/tsconfig.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "jsx": "preserve",
- "jsxImportSource": "solid-js",
- "verbatimModuleSyntax": true,
- "declaration": true,
- "composite": true,
- "moduleResolution": "bundler"
- },
- "exclude": [
- "node_modules"
- ]
-}
\ No newline at end of file
diff --git a/js/app/packages/block-contact/util/emailUtils.ts b/js/app/packages/block-contact/util/emailUtils.ts
deleted file mode 100644
index cb43a3ea1c..0000000000
--- a/js/app/packages/block-contact/util/emailUtils.ts
+++ /dev/null
@@ -1,156 +0,0 @@
-// List of consumer email domains from the provided gist
-// https://gist.github.com/ammarshah/f5c2624d767f91a7cbdc4e54db8dd0bf
-const CONSUMER_EMAIL_DOMAINS = [
- 'gmail.com',
- 'yahoo.com',
- 'hotmail.com',
- 'aol.com',
- 'hotmail.co.uk',
- 'hotmail.fr',
- 'msn.com',
- 'yahoo.fr',
- 'wanadoo.fr',
- 'orange.fr',
- 'comcast.net',
- 'yahoo.co.uk',
- 'yahoo.com.br',
- 'yahoo.co.in',
- 'live.com',
- 'rediffmail.com',
- 'free.fr',
- 'gmx.de',
- 'web.de',
- 'yandex.ru',
- 'ymail.com',
- 'libero.it',
- 'outlook.com',
- 'uol.com.br',
- 'bol.com.br',
- 'mail.ru',
- 'cox.net',
- 'hotmail.it',
- 'sbcglobal.net',
- 'sfr.fr',
- 'live.fr',
- 'verizon.net',
- 'live.co.uk',
- 'googlemail.com',
- 'yahoo.es',
- 'ig.com.br',
- 'live.nl',
- 'bigpond.com',
- 'terra.com.br',
- 'yahoo.it',
- 'neuf.fr',
- 'yahoo.de',
- 'alice.it',
- 'rocketmail.com',
- 'att.net',
- 'laposte.net',
- 'facebook.com',
- 'bellsouth.net',
- 'yahoo.in',
- 'hotmail.es',
- 'charter.net',
- 'yahoo.ca',
- 'yahoo.com.au',
- 'rambler.ru',
- 'hotmail.de',
- 'tiscali.it',
- 'shaw.ca',
- 'yahoo.co.jp',
- 'sky.com',
- 'earthlink.net',
- 'optonline.net',
- 'freenet.de',
- 't-online.de',
- 'aliceadsl.fr',
- 'virgilio.it',
- 'home.nl',
- 'qq.com',
- 'telenet.be',
- 'me.com',
- 'yahoo.com.ar',
- 'tiscali.co.uk',
- 'yahoo.com.mx',
- 'voila.fr',
- 'gmx.net',
- 'mail.com',
- 'planet.nl',
- 'tin.it',
- 'live.it',
- 'ntlworld.com',
- 'arcor.de',
- 'yahoo.co.id',
- 'frontiernet.net',
- 'hetnet.nl',
- 'live.com.au',
- 'yahoo.com.sg',
- 'zonnet.nl',
- 'club-internet.fr',
- 'juno.com',
- 'optusnet.com.au',
- 'blueyonder.co.uk',
- 'bluewin.ch',
- 'skynet.be',
- 'sympatico.ca',
- 'windstream.net',
- 'mac.com',
- 'centurytel.net',
- 'chello.nl',
- 'live.ca',
- 'aim.com',
- 'bigpond.net.au',
-];
-
-const secondLevelDomains = new Set([
- 'co',
- 'com',
- 'org',
- 'net',
- 'edu',
- 'gov',
- 'mil',
- 'ac',
- 'ltd',
- 'plc',
- 'me',
-]);
-
-export function extractDomainFromEmail(email: string): string {
- const atIndex = email.lastIndexOf('@');
- if (atIndex === -1) return '';
-
- const domain = email.substring(atIndex + 1);
- const parts = domain.split('.');
-
- // If no dots, return the whole domain
- if (parts.length === 1) return domain;
-
- if (parts.length >= 3) {
- const secondToLast = parts[parts.length - 2]; // N-2th entry
- if (secondLevelDomains.has(secondToLast)) {
- const domainPart = parts[parts.length - 3]; // N-3th entry
-
- if (domainPart && domainPart !== '') {
- return domainPart;
- }
-
- return parts[0];
- }
- }
-
- if (parts.length >= 3) {
- return parts[parts.length - 2];
- } else if (parts.length === 2) {
- return parts[0];
- }
-
- return parts[0];
-}
-
-export function isConsumerEmail(domain: string): boolean {
- // Check if the full domain (with TLD) is in the consumer list
- const emailDomain = domain.includes('.') ? domain : `${domain}.com`;
- return CONSUMER_EMAIL_DOMAINS.includes(emailDomain.toLowerCase());
-}
diff --git a/js/app/tsconfig.json b/js/app/tsconfig.json
index 644fd7bfef..3626feed08 100644
--- a/js/app/tsconfig.json
+++ b/js/app/tsconfig.json
@@ -145,9 +145,6 @@
"@block-ai/*": [
"./packages/block-ai/*"
],
- "@block-contact/*": [
- "./packages/block-contact/*"
- ],
"@macro-entity": [
"./packages/macro-entity/src/index.tsx"
],
@@ -219,9 +216,6 @@
{
"path": "./packages/block-pdf"
},
- {
- "path": "./packages/block-contact"
- },
{
"path": "./packages/observability"
},