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.

Evan/anchor fr (#1413)

Evan Hutnik67027665e17c
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index 0534cd3a16..bf3af60e40 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -310,6 +310,7 @@ export function BaseInput(props: {
onMarkDone?: () => void;
setShowReply?: Setter<boolean>;
markdownDomRef?: (ref: HTMLDivElement) => void | HTMLDivElement;
+ onHasContentChange?: (hasContent: boolean) => void;
}) {
const ctx = useEmailContext();
const form = createMemo(() => {
@@ -372,6 +373,14 @@ export function BaseInput(props: {
const [shouldMarkDoneOnSuccess, setShouldMarkDoneOnSuccess] =
createSignal(false);
+ const hasContent = createMemo(
+ () => bodyMacro().trim() !== '' || form().attachments.list().length > 0
+ );
+
+ createEffect(() => {
+ props.onHasContentChange?.(hasContent());
+ });
+
const sendMutation = useSendMessageMutation({
onSuccess: async ({ message }) => {
toast.success('Email sent');
diff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsx
index e8975a0eb7..6343024fbe 100644
--- a/js/app/packages/block-email/component/Email.tsx
+++ b/js/app/packages/block-email/component/Email.tsx
@@ -407,6 +407,13 @@ function EmailContent(props: EmailViewProps) {
hide: true,
});
+ const [localHasContent, setLocalHasContent] = createSignal<
+ boolean | undefined
+ >(undefined);
+ const [composeFocused, setComposeFocused] = createSignal(false);
+ const stickyCompose = () =>
+ (localHasContent() ?? !!emailReplyInfo()?.draft) || composeFocused();
+
const emailReplyInfo = createMemo(() => {
const filtered = context.messages.list();
@@ -488,39 +495,53 @@ function EmailContent(props: EmailViewProps) {
initialLoadComplete={context.initialLoadComplete()}
onScrollPositionChange={handleScrollPositionChange}
title={props.title}
+ composeSlot={
+ <Show
+ when={
+ context.permissions().isOwner &&
+ context.drafts.initialDraftsSettled() &&
+ emailReplyInfo()
+ }
+ >
+ {(info) => (
+ <div
+ class="w-full px-4 pb-2 bg-panel"
+ classList={{
+ 'sticky bottom-0 z-30': stickyCompose(),
+ }}
+ onfocusin={() => setComposeFocused(true)}
+ onfocusout={(e) => {
+ if (
+ !e.currentTarget.contains(e.relatedTarget as Node)
+ ) {
+ setComposeFocused(false);
+ }
+ }}
+ >
+ <div class="relative w-full flex flex-row justify-center bg-panel macro-message-width mx-auto">
+ <FloatingInputLoader
+ isLoading={context.query.isFetching}
+ loadingText="Loading messages"
+ />
+ <EmailInput
+ replyingTo={() => info().replyingTo}
+ draft={info().draft}
+ markdownDomRef={(el) => {
+ markdownDomRef = el;
+ }}
+ onHasContentChange={setLocalHasContent}
+ />
+ </div>
+ </div>
+ )}
+ </Show>
+ }
/>
<CustomScrollbar
reverse
scrollContainer={context.messagesListRef}
/>
</div>
- <Show
- when={
- context.permissions().isOwner &&
- context.drafts.initialDraftsSettled() &&
- emailReplyInfo()
- }
- >
- {(info) => {
- return (
- <div class="shrink-0 w-full px-4 pb-2">
- <div class="relative w-full flex flex-row justify-center bg-panel macro-message-width mx-auto">
- <FloatingInputLoader
- isLoading={context.query.isFetching}
- loadingText="Loading messages"
- />
- <EmailInput
- replyingTo={() => info().replyingTo}
- draft={info().draft}
- markdownDomRef={(el) => {
- markdownDomRef = el;
- }}
- />
- </div>
- </div>
- );
- }}
- </Show>
</div>
</EmailFormContextProvider>
</Match>
diff --git a/js/app/packages/block-email/component/EmailInput.tsx b/js/app/packages/block-email/component/EmailInput.tsx
index fe5c171446..5b3667df92 100644
--- a/js/app/packages/block-email/component/EmailInput.tsx
+++ b/js/app/packages/block-email/component/EmailInput.tsx
@@ -12,6 +12,7 @@ interface EmailInputProps {
draft?: MessageWithBodyReplyless;
setShowReply?: Setter<boolean>;
markdownDomRef?: (ref: HTMLDivElement) => void | HTMLDivElement;
+ onHasContentChange?: (hasContent: boolean) => void;
}
export function EmailInput(props: EmailInputProps) {
@@ -43,6 +44,7 @@ export function EmailInput(props: EmailInputProps) {
setShowReply={props.setShowReply}
markdownDomRef={props.markdownDomRef}
isEditingExisting={props.replyingTo() == null && props.draft != null}
+ onHasContentChange={props.onHasContentChange}
/>
</Show>
);
diff --git a/js/app/packages/block-email/component/MessageList.tsx b/js/app/packages/block-email/component/MessageList.tsx
index 59d4ae5060..70fc8c8da4 100644
--- a/js/app/packages/block-email/component/MessageList.tsx
+++ b/js/app/packages/block-email/component/MessageList.tsx
@@ -2,13 +2,14 @@ import { useEmailContext } from '@block-email/component/EmailContext';
import { isScrollingToMessage } from '@block-email/signal/scrollState';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { isMobile } from '@core/mobile/isMobile';
-import { createMemo, createSelector, Index, Show } from 'solid-js';
+import { createMemo, createSelector, Index, type JSX, Show } from 'solid-js';
import { MessageContainer } from './MessageContainer';
interface MessageListProps {
initialLoadComplete: boolean;
onScrollPositionChange?: (scrollFromTop: number) => void;
title?: string;
+ composeSlot?: JSX.Element;
}
export function MessageList(props: MessageListProps) {
@@ -25,7 +26,7 @@ export function MessageList(props: MessageListProps) {
return (
<div
- class="pt-3 w-full flex flex-col-reverse items-center overflow-y-scroll overflow-x-hidden suppress-css-brackets hide-scrollbar text-sm touch:mobile-width:text-base"
+ class="pt-3 w-full flex-1 min-h-0 flex flex-col-reverse items-center overflow-y-scroll overflow-x-hidden suppress-css-brackets hide-scrollbar text-sm touch:mobile-width:text-base"
ref={context.registerMessagesList}
onscroll={(e) => {
// Since the list is reversed, calculate scroll from visual top
@@ -51,6 +52,8 @@ export function MessageList(props: MessageListProps) {
}
}}
>
+ {props.composeSlot}
+ <div class="flex-grow" />
<StaticMarkdownContext>
{/* We use Index because the index of the messages should always be stable and
only the value changes. This also helps prevent nested inputs from rerendering
@@ -112,11 +115,9 @@ export function MessageList(props: MessageListProps) {
</Index>
</StaticMarkdownContext>
<Show when={isMobile() && props.title}>
- <div class="shrink-0 w-full flex justify-center pb-4">
+ <div class="shrink-0 w-full flex justify-center pb-2">
<div class="macro-message-width w-full">
- <h1 class="text-3xl font-semibold text-ink pt-1 pb-4">
- {props.title}
- </h1>
+ <h1 class="text-2xl font-semibold text-ink pb-2">{props.title}</h1>
</div>
</div>
</Show>