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.

[channels]: improve rail styling (#1473)

Peter Chinmana8c960d5b649
diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.css
index 8385908d80..d49107d645 100644
--- a/js/app/packages/app/index.css
+++ b/js/app/packages/app/index.css
@@ -729,8 +729,8 @@ html[data-modality="keyboard"] [contenteditable="true"]:focus-visible::after {
@media (min-width: 640px) {
:root {
- --thread-shift: 46px;
- --user-icon-width: 40px;
+ --thread-shift: 40px;
+ --user-icon-width: 36px;
--left-of-connector: 28px;
--left-of-user-icon: calc(var(--left-of-connector) - var(--user-icon-width) / 2);
}
diff --git a/js/app/packages/block-channel/component/Channel.tsx b/js/app/packages/block-channel/component/Channel.tsx
index a4f1f36775..5e4a7f7ef1 100644
--- a/js/app/packages/block-channel/component/Channel.tsx
+++ b/js/app/packages/block-channel/component/Channel.tsx
@@ -24,7 +24,10 @@ import {
createEffectOnEntityTypeNotification,
useEntityHasUnreadNotifications,
} from '@notifications';
-import { useUpdateChannelsActivityMutation } from '@queries/channel/activity';
+import {
+ invalidateChannelsActivity,
+ useUpdateChannelsActivityMutation,
+} from '@queries/channel/activity';
import type { Message } from '@service-comms/generated/models';
import { connectionGatewayClient } from '@service-connection/client';
import { useBeforeLeave, useSearchParams } from '@solidjs/router';
@@ -86,7 +89,11 @@ export function Channel(props: {
const [openedChannel, setOpenedChannel] = createSignal<Date>();
- const updateActivityMutation = useUpdateChannelsActivityMutation();
+ const updateActivityMutation = useUpdateChannelsActivityMutation({
+ onSuccess: () => {
+ invalidateChannelsActivity();
+ },
+ });
const updateActivityOnOpen = () => {
setOpenedChannel(new Date());
diff --git a/js/app/packages/block-channel/component/Message/MessageAttachments.tsx b/js/app/packages/block-channel/component/Message/MessageAttachments.tsx
index 4ef0c27dfd..af36fff946 100644
--- a/js/app/packages/block-channel/component/Message/MessageAttachments.tsx
+++ b/js/app/packages/block-channel/component/Message/MessageAttachments.tsx
@@ -4,6 +4,7 @@ import type { Attachment } from '@service-comms/generated/models/attachment';
import { stringToItemType } from '@service-storage/client';
import { type Accessor, For, Show } from 'solid-js';
import { DynamicImageList } from './DynamicImageList';
+import { cn } from '@ui/utils/classname';
type MessageAttachmentsProps = {
videoAttachments: Accessor<Attachment[]>;
@@ -18,9 +19,19 @@ type MessageAttachmentsProps = {
export function MessageAttachments(props: MessageAttachmentsProps) {
return (
- <div class="allow-css-brackets">
+ <div
+ class={cn(
+ 'allow-css-brackets mb-2',
+ !(
+ props.documentAttachments()?.length > 0 ||
+ props.imageAttachments()?.length > 0 ||
+ props.videoAttachments()?.length > 0
+ ) ||
+ (props.isDeleted() && 'hidden')
+ )}
+ >
{/* Video attachments */}
- <Show when={props.videoAttachments()?.length > 0 && !props.isDeleted()}>
+ <Show when={props.videoAttachments()?.length > 0}>
<For each={props.videoAttachments()}>
{(item) => (
<VideoPreview
@@ -33,7 +44,7 @@ export function MessageAttachments(props: MessageAttachmentsProps) {
</For>
</Show>
{/* Image attachments */}
- <Show when={props.imageAttachments()?.length > 0 && !props.isDeleted()}>
+ <Show when={props.imageAttachments()?.length > 0}>
<div class="flex not-first:mt-2">
<DynamicImageList
images={props.imageAttachments()?.map((a) => ({
@@ -50,9 +61,7 @@ export function MessageAttachments(props: MessageAttachmentsProps) {
</div>
</Show>
{/* Document attachments */}
- <Show
- when={props.documentAttachments()?.length > 0 && !props.isDeleted()}
- >
+ <Show when={props.documentAttachments()?.length > 0}>
<div class={`flex flex-row mt-2 gap-2 flex-wrap max-w-full`}>
<For each={props.documentAttachments()}>
{(attachment) => (
diff --git a/js/app/packages/block-channel/component/Message/MessageContainer.tsx b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
index aed773c273..d23e3f71a7 100644
--- a/js/app/packages/block-channel/component/Message/MessageContainer.tsx
+++ b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
@@ -57,6 +57,7 @@ import { MessageAttachments } from './MessageAttachments';
import { MessageReactions } from './MessageReactions';
import { ThreadReplyIndicator } from './ThreadReplyIndicator';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
+import { cn } from '@ui/utils/classname';
type MessageFlagProps = {
text: string;
@@ -67,18 +68,18 @@ export function MessageFlag(props: MessageFlagProps) {
return (
<div class="flex flex-row items-stretch justify-start ml-[var(--left-of-connector)]">
<div class="flex flex-col items-center justify-center">
- <div class="border-l border-edge-muted min-h-1/2 ]" />
+ <div class="border-l border-edge-muted min-h-1/2" />
<div
class={`border-l ${props.highlight ? 'border-accent' : 'border-edge-muted'} min-h-1/2 `}
/>
</div>
<div class="flex flex-col items-center justify-center">
<div
- class={`w-8 border-b ${props.highlight ? 'border-accent' : 'border-edge-muted'}`}
+ class={`w-7 border-b ${props.highlight ? 'border-accent' : 'border-edge-muted'}`}
/>
</div>
<div
- class={`text-xs text-panel uppercase font-mono p-1 my-3 ${props.highlight ? 'bg-accent' : 'bg-edge'}`}
+ class={`text-xs text-panel uppercase font-mono p-1 my-6 mt ${props.highlight ? 'bg-accent' : 'bg-edge'}`}
>
{props.text}
</div>
@@ -86,17 +87,12 @@ export function MessageFlag(props: MessageFlagProps) {
);
}
-type NewIndicatorProps = {
- setNewIndicatorShown: Setter<number | undefined>;
- id: number;
-};
-
-function NewMessageIndicator(props: NewIndicatorProps) {
- onMount(() => {
- props.setNewIndicatorShown(props.id);
- });
-
- return <MessageFlag text="New" highlight />;
+function NewMessageIndicator(props: { onClick?: () => void }) {
+ return (
+ <button type="button" class="w-full text-left" onClick={props.onClick}>
+ <MessageFlag text="New" highlight />
+ </button>
+ );
}
type MessageProps = {
@@ -107,8 +103,6 @@ type MessageProps = {
orderedMessages: Accessor<MessageType[]>;
threadChildren?: MessageType[];
threadSiblings?: MessageType[];
- newIndicatorShown: Accessor<number | undefined>;
- setNewIndicatorShown: Setter<number | undefined>;
virtualHandle: VirtualizerHandle;
container?: HTMLDivElement;
listContext: MessageListContext;
@@ -117,6 +111,7 @@ type MessageProps = {
channelId: Accessor<string>;
attachments: Attachment[];
reactions: GetChannelResponseReactions;
+ onDismissNewMessages?: () => void;
};
export function MessageContainer(props: MessageProps) {
@@ -515,17 +510,8 @@ export function MessageContainer(props: MessageProps) {
<MessageFlag text={formatRelativeDate(message.created_at)} />
</Show>
{/* New message indicator */}
- <Show
- when={
- isNewMessage() &&
- (!props.newIndicatorShown() ||
- props.newIndicatorShown() === props.index())
- }
- >
- <NewMessageIndicator
- id={props.index()}
- setNewIndicatorShown={props.setNewIndicatorShown}
- />
+ <Show when={props.listContext.isFirstNewMessage}>
+ <NewMessageIndicator onClick={props.onDismissNewMessages} />
</Show>
{/* Message item */}
@@ -619,7 +605,10 @@ export function MessageContainer(props: MessageProps) {
</MessageComponent>
<Show when={isLastInCollapsedThread()}>
<div
- class="border-l border-edge-muted pb-1"
+ class={cn(
+ 'border-l border-edge-muted pb-1',
+ isParentNewMessage() && 'border-accent'
+ )}
style={{
'margin-left': `var(--left-of-connector)`,
}}
@@ -638,6 +627,7 @@ export function MessageContainer(props: MessageProps) {
users={threadReplyUsers()}
onClick={handleThreadToggle}
isThreadOpen={threadState()?.threadExpanded}
+ isParentNewMessage={isParentNewMessage()}
/>
</div>
</div>
diff --git a/js/app/packages/block-channel/component/Message/ThreadReplyIndicator.tsx b/js/app/packages/block-channel/component/Message/ThreadReplyIndicator.tsx
index f5c581263b..e56c029889 100644
--- a/js/app/packages/block-channel/component/Message/ThreadReplyIndicator.tsx
+++ b/js/app/packages/block-channel/component/Message/ThreadReplyIndicator.tsx
@@ -4,6 +4,7 @@ import { isMobileWidth } from '@core/mobile/mobileWidth';
import { onKeyDownClick, onKeyUpClick } from '@core/util/click';
import { formatRelativeDate } from '@core/util/time';
import CaretRight from '@phosphor-icons/core/regular/caret-right.svg?component-solid';
+import { cn } from '@ui/utils/classname';
import { createMemo, createSignal, For, Match, Show, Switch } from 'solid-js';
export function ThreadReplyIndicator(props: {
@@ -14,6 +15,7 @@ export function ThreadReplyIndicator(props: {
justifyRight?: boolean;
isThreadOpen?: boolean;
hasDraft?: boolean;
+ isParentNewMessage?: boolean;
}) {
const [hover, setHover] = createSignal(false);
let countText = () => {
@@ -27,7 +29,10 @@ export function ThreadReplyIndicator(props: {
return (
<div
- class="flex flex-row gap-2 items-center justify-between pb-2 pt-2 text-xs w-full max-w-fit border-edge-muted border pr-2 select-none hover:bg-hover focus:bracket-offset-2"
+ class={cn(
+ 'flex flex-row gap-2 items-center justify-between pb-2 pt-2 text-xs w-full max-w-fit border-edge-muted border pr-2 select-none hover:bg-hover focus:bracket-offset-2',
+ props.isParentNewMessage && 'border-accent'
+ )}
onClick={props.onClick}
onKeyDown={onKeyDownClick(props.onClick)}
onKeyUp={onKeyUpClick(props.onClick)}
diff --git a/js/app/packages/block-channel/component/MessageList/MessageList.tsx b/js/app/packages/block-channel/component/MessageList/MessageList.tsx
index 107044ff1a..763ebd7544 100644
--- a/js/app/packages/block-channel/component/MessageList/MessageList.tsx
+++ b/js/app/packages/block-channel/component/MessageList/MessageList.tsx
@@ -79,6 +79,7 @@ const createDefaultMessageListContext = (index: Accessor<number>) =>
createMemo<MessageListContext>(() => ({
index: index(),
isNewMessage: false,
+ isFirstNewMessage: false,
isParentNewMessage: false,
threadIndex: -1,
previousNonThreadedMessage: undefined,
@@ -361,7 +362,6 @@ function MessageListImpl(props: MessageListProps) {
const [virtualHandle, setVirtualHandle] = createSignal<VirtualizerHandle>();
const [containerRef, setContainerRef] = createSignal<HTMLDivElement>();
- const [newIndicatorShown, setNewIndicatorShown] = createSignal<number>();
const [hasUserScrolled, setHasUserScrolled] = createSignal(false);
const [messageListContext, setMessageListContext] =
createStore<MessageListContextLookup>({});
@@ -435,11 +435,18 @@ function MessageListImpl(props: MessageListProps) {
});
});
- const lastViewed = createMemo(() => {
+ // Snapshot the lastViewed time so it reflects the pre-session value.
+ // Without this, the activity mutation on channel open would update
+ // lastViewed reactively, causing the "New" indicator to disappear.
+ const lastViewed = createMemo<string | null | undefined>((prev) => {
+ if (prev !== undefined) return prev;
return props?.latestActivity?.viewed_at;
});
+ const [newMessagesDismissed, setNewMessagesDismissed] = createSignal(false);
+
const checkIfNewMessage = (message: Message) => {
+ if (newMessagesDismissed()) return false;
const lastViewed_ = lastViewed();
const openedChannel_ = props.openedChannel;
return (
@@ -451,6 +458,11 @@ function MessageListImpl(props: MessageListProps) {
);
};
+ const dismissNewMessages = () => {
+ setNewMessagesDismissed(true);
+ computeListContext(flattenedThreaded());
+ };
+
// Keep some additional timing information for goToLocationFromParams
// race conditions.
const [lastTargetMessageTimestamp, setLastTargetMessageTimestamp] =
@@ -906,8 +918,6 @@ function MessageListImpl(props: MessageListProps) {
orderedMessages={props.orderedMessages}
threadChildren={params.threadChildren}
threadSiblings={params.threadSiblings}
- newIndicatorShown={newIndicatorShown}
- setNewIndicatorShown={setNewIndicatorShown}
virtualHandle={virtualHandle()!}
container={containerRef()}
listContext={params.listContext}
@@ -915,6 +925,7 @@ function MessageListImpl(props: MessageListProps) {
channelId={() => props.channelId}
attachments={props.attachments}
reactions={props.reactions}
+ onDismissNewMessages={dismissNewMessages}
/>
);
diff --git a/js/app/packages/block-channel/tests/listContext.test.ts b/js/app/packages/block-channel/tests/listContext.test.ts
index 97fe93b66e..466fe53c25 100644
--- a/js/app/packages/block-channel/tests/listContext.test.ts
+++ b/js/app/packages/block-channel/tests/listContext.test.ts
@@ -78,17 +78,16 @@ describe('createMessageListContextLookup', () => {
expect(context.msg4.threadIndex).toBe(-1);
});
- it('should identify new messages for non-threaded messages only', () => {
+ it('should identify new messages for all messages including threaded', () => {
const context = createMessageListContextLookup({
messages: mockMessages,
isNewMessageFn: alwaysNewMessage,
});
- // All non threaded messages are new (if new function is always true)
+ expect(context.msg0.isNewMessage).toBe(true);
expect(context.msg1.isNewMessage).toBe(true);
- expect(context.msg1.isNewMessage).toBe(true);
- expect(context.msg2.isNewMessage).toBe(false);
- expect(context.msg3.isNewMessage).toBe(false);
+ expect(context.msg2.isNewMessage).toBe(true);
+ expect(context.msg3.isNewMessage).toBe(true);
expect(context.msg4.isNewMessage).toBe(true);
});
@@ -121,6 +120,32 @@ describe('createMessageListContextLookup', () => {
expect(context.msg4.isParentNewMessage).toBe(false);
});
+ it('should mark only the first new top-level message as isFirstNewMessage', () => {
+ const context = createMessageListContextLookup({
+ messages: mockMessages,
+ isNewMessageFn: alwaysNewMessage,
+ });
+
+ // msg0 is the first top-level message marked as new
+ // threaded messages (msg2, msg3) are new but not isFirstNewMessage
+ expect(context.msg0.isFirstNewMessage).toBe(true);
+ expect(context.msg1.isFirstNewMessage).toBe(false);
+ expect(context.msg2.isFirstNewMessage).toBe(false);
+ expect(context.msg3.isFirstNewMessage).toBe(false);
+ expect(context.msg4.isFirstNewMessage).toBe(false);
+ });
+
+ it('should not mark any message as isFirstNewMessage when none are new', () => {
+ const context = createMessageListContextLookup({
+ messages: mockMessages,
+ isNewMessageFn: neverNewMessage,
+ });
+
+ expect(context.msg0.isFirstNewMessage).toBe(false);
+ expect(context.msg1.isFirstNewMessage).toBe(false);
+ expect(context.msg4.isFirstNewMessage).toBe(false);
+ });
+
it('should identify messages in the last thread when messages are threaded to last top-level', () => {
const messagesWithLastThread: MinimalMessage[] = [
{
diff --git a/js/app/packages/block-channel/utils/listContext.ts b/js/app/packages/block-channel/utils/listContext.ts
index 39bef05462..b7932cf54b 100644
--- a/js/app/packages/block-channel/utils/listContext.ts
+++ b/js/app/packages/block-channel/utils/listContext.ts
@@ -11,6 +11,8 @@ export type MessageListContext<T extends MinimalMessage = Message> = {
index: number;
isNewMessage: boolean;
isParentNewMessage: boolean;
+ /** True only for the first (oldest) new message — where the "New" indicator should appear */
+ isFirstNewMessage: boolean;
threadIndex: number;
/** The previous non-threaded message outside of the current thread */
previousNonThreadedMessage: T | undefined;
@@ -46,6 +48,7 @@ export function createMessageListContextLookup<
const context: MessageListContextLookup<T> = {};
const threadIndexCounters = new Map<string, number>();
const messagesById = new Map<string, [number, T]>();
+ let foundFirstNewMessage = false;
for (const [index, message] of messages.entries()) {
messagesById.set(message.id, [index, message]);
@@ -61,7 +64,7 @@ export function createMessageListContextLookup<
}
for (const [messageIndex, message] of messages.entries()) {
- const isNewMessage = !message.thread_id && isNewMessageFn(message);
+ const isNewMessage = isNewMessageFn(message);
let threadIndex = -1;
let previousNonThreadedMessage: T | undefined;
let isParentNewMessage = false;
@@ -103,9 +106,16 @@ export function createMessageListContextLookup<
message.thread_id !== undefined &&
message.thread_id === lastTopLevelMessageId;
+ const isFirstNewMessage =
+ isNewMessage && !message.thread_id && !foundFirstNewMessage;
+ if (isFirstNewMessage) {
+ foundFirstNewMessage = true;
+ }
+
context[message.id] = {
index: messageIndex,
isNewMessage: isNewMessage,
+ isFirstNewMessage,
isParentNewMessage: isParentNewMessage,
threadIndex,
previousNonThreadedMessage,
diff --git a/js/app/packages/core/component/Message.tsx b/js/app/packages/core/component/Message.tsx
index 1339d3e810..033be281d9 100644
--- a/js/app/packages/core/component/Message.tsx
+++ b/js/app/packages/core/component/Message.tsx
@@ -15,13 +15,14 @@ import {
useContext,
} from 'solid-js';
import { BozzyBracket } from './BozzyBracket';
-import { DeprecatedIconButton } from './DeprecatedIconButton';
import {
CustomEntityIcon,
EntityIcon,
type EntityWithValidIcon,
} from './EntityIcon';
import { UserIcon } from './UserIcon';
+import { Button } from '@ui/components/Button';
+import { cn } from '@ui/utils/classname';
false && observedSize;
@@ -262,7 +263,7 @@ const Root: Component<MessageRootProps> = (props) => {
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-accent': props.isNewMessage,
'border-edge-muted': !props.isNewMessage,
'pt-1.5': !(
props.isConsecutive ||
@@ -281,16 +282,32 @@ const Root: Component<MessageRootProps> = (props) => {
<Show when={!props.isConsecutive}>
<div class="relative">
<Show when={props.isFirstInThread}>
+ {/* Slanted Line Connector */}
<div
- class="absolute border-b border-l border-edge-muted"
+ class={cn(
+ 'absolute text-edge-muted -z-1',
+ props.isNewMessage && 'text-accent'
+ )}
style={{
- left: `calc((var(--thread-shift) - var(--left-of-connector) + var(--left-of-user-icon) + 0.5px) * -1)`,
- top: '.5px',
- width: `calc(var(--thread-shift) - var(--left-of-connector) + var(--left-of-user-icon) + 0.5px)`,
- height: '50%',
- 'border-bottom-left-radius': `calc(var(--thread-shift) / 2)`,
+ left: `calc((var(--thread-shift) - var(--left-of-connector) + var(--left-of-user-icon) + 1px) * -1)`,
+ bottom:
+ 'calc(var(--user-icon-width) / 2 - 0.0375 * var(--user-icon-width))',
+ width: `calc(var(--thread-shift) - var(--left-of-connector) + var(--left-of-user-icon) + 3px)`,
}}
- />
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ viewBox="0 0 24 18"
+ width="100%"
+ >
+ <path
+ stroke="currentColor"
+ vector-effect="non-scaling-stroke"
+ d="M23 17 4 6.0303C2.5 5.1643.5 4 .5.5"
+ />
+ </svg>
+ </div>
</Show>
<Show
when={props.customIcon || props.customIconTargetType}
@@ -377,14 +394,17 @@ const Root: Component<MessageRootProps> = (props) => {
}}
onMouseEnter={() => setHover(false)}
>
- <DeprecatedIconButton
- icon={IconPlus}
- theme="base"
- iconSize={16}
+ <Button
onClick={props.onThreadAppend}
- border
tabIndex={0}
- />
+ class="text-ink-muted border border-edge-muted bg-menu hover:bg-hover hover-transition-bg flex flex-row justify-center items-center relative px-0 py-0 mb-4"
+ style={{
+ width: 'var(--user-icon-width)',
+ height: 'var(--user-icon-width)',
+ }}
+ >
+ <IconPlus class="size-1/2" />
+ </Button>
</div>
}
>
@@ -400,14 +420,35 @@ const Root: Component<MessageRootProps> = (props) => {
ref={(el) => props.setThreadAppendMountTarget?.(el)}
>
<div
- class="absolute border-b border-l border-edge-muted"
+ class="absolute border-l border-edge-muted"
style={{
left: `calc((var(--user-icon-width) / 2) * -1)`,
- width: `calc(var(--user-icon-width) / 2)`,
- height: '50%',
- 'border-bottom-left-radius': `calc(var(--thread-shift) / 2)`,
+ height:
+ 'calc(50% - (var(--user-icon-width) / 2 + 1px) / 24 * 18 + 1px)',
}}
/>
+
+ <div
+ class="absolute text-edge-muted -z-1"
+ style={{
+ left: `calc((var(--user-icon-width) / 2) * -1)`,
+ bottom: '50%',
+ width: `calc(var(--user-icon-width) / 2 + 1px)`,
+ }}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ viewBox="0 0 24 18"
+ width="100%"
+ >
+ <path
+ stroke="currentColor"
+ vector-effect="non-scaling-stroke"
+ d="M23 17 4 6.0303C2.5 5.1643.5 4 .5.5"
+ />
+ </svg>
+ </div>
</div>
</Show>
</div>