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
channel scrolling fixes and styling updates (#420)
Peter Chinman4112ba99030b
diff --git a/js/app/packages/block-channel/component/BaseInput.tsx b/js/app/packages/block-channel/component/BaseInput.tsxindex fc67894ecb..b3e2ec68cc 100644--- a/js/app/packages/block-channel/component/BaseInput.tsx+++ b/js/app/packages/block-channel/component/BaseInput.tsx@@ -26,6 +26,7 @@ import XIcon from '@icon/regular/x.svg';import { logger } from '@observability';import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';import ArrowFatLineUp from '@phosphor-icons/core/fill/arrow-fat-line-up-fill.svg?component-solid';+import Trash from '@phosphor-icons/core/regular/trash.svg?component-solid';import type { SimpleMention } from '@service-comms/generated/models/simpleMention';import { createCallback } from '@solid-primitives/rootless';import { leading, throttle } from '@solid-primitives/scheduled';@@ -94,6 +95,10 @@ type BaseInputProps = {/** the list of users in the channel */channelUsers?: () => IUser[];domRef?: (ref: HTMLDivElement) => void | HTMLDivElement;+ /** callback to delete draft */+ onDeleteDraft?: () => void;+ /** whether this input is for a reply (affects styling) */+ isReplyInput?: boolean;};/** the time after a user stops typing before we consider them idle */@@ -378,6 +383,9 @@ export function BaseInput(props: BaseInputProps) {return (<divclass="relative flex flex-col flex-1 items-center justify-between bg-input border-t border-x border-edge-muted rounded-t-[5px] -mb-[7px]"+ classList={{+ 'rounded-b-[5px] border-b mb-4': props.isReplyInput,+ }}ref={containerRef}use:fileDrop={{onDrop: (files) => {@@ -393,7 +401,9 @@ export function BaseInput(props: BaseInputProps) {},}}>- <BrightJoins dots={[false, false, true, true]} />+ <Show when={!props.isReplyInput}>+ <BrightJoins dots={[false, false, true, true]} />+ </Show><Show when={isDraggedOver() || isDraggingOverChannel()}><FileDropOverlay valid={isValidChannelDrag()}><Show when={!isValidChannelDrag()}>@@ -504,6 +514,17 @@ export function BaseInput(props: BaseInputProps) {><FormatIcon width={20} height={20} /></ActionButton>+ <Show when={props.onDeleteDraft}>+ <ActionButton+ tooltip="Delete reply"+ onClick={(e) => {+ e.preventDefault();+ props.onDeleteDraft?.();+ }}+ >+ <Trash width={20} height={20} />+ </ActionButton>+ </Show></div><buttondisabled={hasPendingAttachments()}diff --git a/js/app/packages/block-channel/component/Message/MessageContainer.tsx b/js/app/packages/block-channel/component/Message/MessageContainer.tsxindex 929f2c41ed..6733b71d61 100644--- a/js/app/packages/block-channel/component/Message/MessageContainer.tsx+++ b/js/app/packages/block-channel/component/Message/MessageContainer.tsx@@ -213,8 +213,14 @@ export function MessageContainer(props: MessageProps) {return props.index() === 0;});+ // A message can be the last message if it's 1. the last message or 2. in the last thread at the collapsed thread index cutoff and the thread is not expandedconst isLastMessage = createMemo(() => {- return props.index() === props.orderedMessages().length - 1;+ return (+ props.index() === props.orderedMessages().length - 1 ||+ (props.listContext.isInLastThread &&+ !props.threadViewStore[message.thread_id ?? '']?.threadExpanded &&+ props.listContext.threadIndex === COLLAPSED_THREAD_INDEX_CUTOFF)+ );});// currently arbitrarily limiting thread depth to 1, in the future we may want to support deeper threads@@ -587,7 +593,6 @@ export function MessageContainer(props: MessageProps) {><ContextMenu.Trigger><MessageComponent- ref={isLastMessage() ? props.setLastMessageRef : undefined}id={message.id}focused={props.isFocused}senderId={message.sender_id}diff --git a/js/app/packages/block-channel/component/MessageList/MessageList.tsx b/js/app/packages/block-channel/component/MessageList/MessageList.tsxindex 25fc3b57dd..716d3712ac 100644--- a/js/app/packages/block-channel/component/MessageList/MessageList.tsx+++ b/js/app/packages/block-channel/component/MessageList/MessageList.tsx@@ -299,6 +299,7 @@ export function MessageList(props: MessageListProps) {const [localTyping, setLocalTyping] = createSignal(false);let updateDelayedByTyping = false;+ // TODO something wrong with localTyping signal. When a message from another user comes in, on a thread that a user is typing a reply to, localTyping gets set to false. Investigate why.createEffect(on([flattenedThreaded, localTyping], ([flat, typing], prev) => {const oldFlat = prev?.[0];diff --git a/js/app/packages/block-channel/component/ReplyInputsPortaler.tsx b/js/app/packages/block-channel/component/ReplyInputsPortaler.tsxindex 15737805fa..22b0935b70 100644--- a/js/app/packages/block-channel/component/ReplyInputsPortaler.tsx+++ b/js/app/packages/block-channel/component/ReplyInputsPortaler.tsx@@ -88,6 +88,15 @@ export function ReplyInputsPortaler(props: ReplyInputsPortalerProps) {);};+ const onDeleteReply = (threadId: string) => () => {+ clearDraftMessage(props.channelId, threadId);+ props.setThreadViewStore(threadId, (prev) =>+ prev+ ? { ...prev, threadExpanded: true, hasActiveReply: false }+ : { threadExpanded: true, hasActiveReply: false }+ );+ };+const onFocusLeaveStart = (e: KeyboardEvent, threadId: string) => {e.preventDefault();e.stopPropagation();@@ -110,9 +119,12 @@ export function ReplyInputsPortaler(props: ReplyInputsPortalerProps) {)}>{(threadId) => {+ // This create effect maintains focus on reply inputs when the mount target changes due to new messages in the thread coming in+ // TODO: this should only fire if this reply input was focusedcreateEffect((prev) => {if (props.threadViewStore[threadId].replyInputMountTarget &&+ prev &&prev !== props.threadViewStore[threadId].replyInputMountTarget) {props.setThreadViewStore(threadId, (prev) => ({@@ -173,6 +185,8 @@ export function ReplyInputsPortaler(props: ReplyInputsPortalerProps) {onFocusLeaveStart={(e) => {onFocusLeaveStart(e, threadId);}}+ onDeleteDraft={onDeleteReply(threadId)}+ isReplyInput/></div></Portal>diff --git a/js/app/packages/block-channel/tests/listContext.test.ts b/js/app/packages/block-channel/tests/listContext.test.tsindex 9c76d1a4ae..97fe93b66e 100644--- a/js/app/packages/block-channel/tests/listContext.test.ts+++ b/js/app/packages/block-channel/tests/listContext.test.ts@@ -120,4 +120,44 @@ describe('createMessageListContextLookup', () => {expect(context.msg3.isParentNewMessage).toBe(true);expect(context.msg4.isParentNewMessage).toBe(false);});++ it('should identify messages in the last thread when messages are threaded to last top-level', () => {+ const messagesWithLastThread: MinimalMessage[] = [+ {+ id: 'msg0',+ created_at: '2024-01-01T10:00:00Z',+ sender_id: 'user1',+ },+ {+ id: 'msg1',+ created_at: '2024-01-01T10:01:00Z',+ sender_id: 'user2',+ },+ {+ id: 'msg2',+ created_at: '2024-01-01T10:02:00Z',+ sender_id: 'user3',+ thread_id: 'msg1',+ },+ {+ id: 'msg3',+ created_at: '2024-01-01T10:03:00Z',+ sender_id: 'user1',+ thread_id: 'msg1',+ },+ ];++ const context = createMessageListContextLookup({+ messages: messagesWithLastThread,+ isNewMessageFn: neverNewMessage,+ });++ // msg1 is the last top-level message+ expect(context.msg0.isInLastThread).toBe(false);+ expect(context.msg1.isInLastThread).toBe(false);++ // msg2 and msg3 are threaded to msg1, which is the last top-level message+ expect(context.msg2.isInLastThread).toBe(true);+ expect(context.msg3.isInLastThread).toBe(true);+ });});diff --git a/js/app/packages/block-channel/utils/listContext.ts b/js/app/packages/block-channel/utils/listContext.tsindex 087dd76900..39bef05462 100644--- a/js/app/packages/block-channel/utils/listContext.ts+++ b/js/app/packages/block-channel/utils/listContext.ts@@ -14,6 +14,8 @@ export type MessageListContext<T extends MinimalMessage = Message> = {threadIndex: number;/** The previous non-threaded message outside of the current thread */previousNonThreadedMessage: T | undefined;+ /** True if the message is in a thread and the parent is the last top-level message */+ isInLastThread: boolean;};export type MessageListContextLookup<T extends MinimalMessage = Message> =@@ -49,6 +51,15 @@ export function createMessageListContextLookup<messagesById.set(message.id, [index, message]);}+ // Find the last top-level message (last message without a thread_id)+ let lastTopLevelMessageId: string | undefined;+ for (let i = messages.length - 1; i >= 0; i--) {+ if (!messages[i].thread_id) {+ lastTopLevelMessageId = messages[i].id;+ break;+ }+ }+for (const [messageIndex, message] of messages.entries()) {const isNewMessage = !message.thread_id && isNewMessageFn(message);let threadIndex = -1;@@ -86,12 +97,19 @@ export function createMessageListContextLookup<}}+ // Check if message is in the last thread+ const isInLastThread =+ message.thread_id !== null &&+ message.thread_id !== undefined &&+ message.thread_id === lastTopLevelMessageId;+context[message.id] = {index: messageIndex,isNewMessage: isNewMessage,isParentNewMessage: isParentNewMessage,threadIndex,previousNonThreadedMessage,+ isInLastThread,};}diff --git a/js/app/packages/core/component/Message.tsx b/js/app/packages/core/component/Message.tsxindex 456497a95f..cdb543eaa5 100644--- a/js/app/packages/core/component/Message.tsx+++ b/js/app/packages/core/component/Message.tsx@@ -172,7 +172,11 @@ export const NestedConnectorLines: Component<NestedConnectorLinesProps> = (for (let i = 0; i < (props.threadDepth ?? 0); i++) {NestedLines.push(<div- class={`absolute h-full w-[1px] ${props.isParentNewMessage ? 'bg-accent' : 'bg-edge'}`}+ class="absolute h-full w-[1px]"+ classList={{+ 'bg-accent': props.isParentNewMessage,+ 'bg-edge-muted': !props.isParentNewMessage,+ }}style={{left: `calc(${i} * var(--thread-shift) + var(--left-of-connector))`,}}@@ -180,7 +184,11 @@ export const NestedConnectorLines: Component<NestedConnectorLinesProps> = ();}- return <div class="absolute left-0 top-0 w-full h-full">{NestedLines}</div>;+ return (+ <div class="absolute left-0 top-0 w-full h-full z-1 pointer-events-none">+ {NestedLines}+ </div>+ );};/* Root */@@ -246,19 +254,25 @@ const Root: Component<MessageRootProps> = (props) => {data-message-body-id={props.id}><div- class={`relative z-0 flex-1 flex flex-col justify-start w-[calc(100%-28px)] min-w-0 pl-[var(--left-of-connector)]- ${props.hideConnectors ? '' : 'border-l'}- ${props.isNewMessage ? 'border-accent' : 'border-edge-muted'}- ${props.isConsecutive || props.isFirstMessage || props.isFirstInThread ? '' : 'pt-4'}- ${props.isLastMessage && !props.isLastInThread ? 'pb-2' : ''}- ${props.hasThreadChildren ? 'pb-4' : ''}- `}+ class="relative flex-1 flex flex-col justify-start w-[calc(100%-28px)] min-w-0 pl-[var(--left-of-connector)]"+ classList={{+ 'border-l': !props.hideConnectors,+ 'border-accent': props.isNewMessage ?? false,+ 'border-edge-muted': !props.isNewMessage,+ 'pt-4': !(+ props.isConsecutive ||+ props.isFirstMessage ||+ props.isFirstInThread+ ),+ 'pb-2': props.isLastMessage && !props.isLastInThread,+ 'pb-4': props.hasThreadChildren ?? false,+ }}style={{'margin-left': `var(--left-of-connector)`,}}>{/* User Icon */}- <div class="z-2 absolute -left-[.5px] -translate-x-1/2">+ <div class="absolute -left-[.5px] -translate-x-1/2"><Show when={!props.isConsecutive}><div class="relative"><Show when={props.isFirstInThread}>@@ -315,9 +329,11 @@ const Root: Component<MessageRootProps> = (props) => {</BozzyBracket><Show when={props.hoverActions && !isTouchDevice}><div- class={`absolute right-2 -top-2 border border-edge bg-panel ${- hover() || props.shouldHover ? 'block' : 'hidden'- }`}+ class="absolute right-2 -top-2 border border-edge bg-panel"+ classList={{+ block: hover() || !!props.shouldHover,+ hidden: !(hover() || !!props.shouldHover),+ }}onMouseEnter={() => setHover(true)}onMouseLeave={() => setHover(false)}>@@ -338,7 +354,10 @@ const Root: Component<MessageRootProps> = (props) => {}fallback={<div- class={`w-min -translate-x-1/2 icon-plus ${props.isLastInThread && props.isLastMessage ? 'pb-3' : ''} allow-css-brackets`}+ class="w-min -translate-x-1/2 icon-plus allow-css-brackets"+ classList={{+ 'pb-3': props.isLastInThread && props.isLastMessage,+ }}style={{'margin-left': `calc(var(--thread-shift) + var(--left-of-connector))`,}}@@ -356,7 +375,10 @@ const Root: Component<MessageRootProps> = (props) => {}><div- class={`relative ${props.isLastInThread && props.isLastMessage ? 'pb-3' : ''}`}+ class="relative"+ classList={{+ 'pb-3': props.isLastInThread && props.isLastMessage,+ }}style={{'margin-left': `calc(var(--left-of-connector) + var(--thread-shift) + var(--user-icon-width) / 2)`,}}@@ -364,7 +386,7 @@ const Root: Component<MessageRootProps> = (props) => {ref={(el) => props.setThreadAppendMountTarget?.(el)}><div- class="absolute border-b border-l border-edge"+ class="absolute border-b border-l border-edge-muted"style={{left: `calc((var(--user-icon-width) / 2) * -1)`,width: `calc(var(--user-icon-width) / 2)`,