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
Revert "feat(notys): make new content more visible to tab re-focus" (#3434)
teo29d5c4bb87c7
diff --git a/js/app/packages/app/component/ReactiveFavicon.tsx b/js/app/packages/app/component/ReactiveFavicon.tsxindex 82bf39932c..30fc057cac 100644--- a/js/app/packages/app/component/ReactiveFavicon.tsx+++ b/js/app/packages/app/component/ReactiveFavicon.tsx@@ -1,13 +1,4 @@-import {- addBadgeNotification,- removeBadgeNotifications,-} from '@app/signal/sidebarBadges';-import { globalSplitManager } from '@app/signal/splitLayout';import { updateFavicon } from '@app/util/favicon';-import { notificationToSidebarId } from '@app/util/notification-sidebar-id';-import { runRefocusPulses } from '@app/util/refocus-highlight';-import { ENABLE_REFOCUS_HIGHLIGHT } from '@core/constant/featureFlags';-import type { UnifiedNotification } from '@notifications';import { createBroadcastChannel } from '@solid-primitives/broadcast-channel';import { createEffect, createSignal, on, onCleanup, onMount } from 'solid-js';import { useReactiveColorString } from '../../theme/signals/themeReactive';@@ -18,7 +9,6 @@ type BadgeMessage = { hasBadge: boolean };export function ReactiveFavicon() {const [showNotificationBadge, setShowNotificationBadge] = createSignal(false);const [isAppFocused, setIsAppFocused] = createSignal(!document.hidden);- const pendingNotifications: UnifiedNotification[] = [];const globalNotifications = useGlobalNotificationSource();@@ -48,28 +38,18 @@ export function ReactiveFavicon() {if (!document.hidden) {setShowNotificationBadge(false);postBadgeMessage({ hasBadge: false });- const toProcess = pendingNotifications.splice(0);- if (ENABLE_REFOCUS_HIGHLIGHT) {- runRefocusPulses(toProcess, globalSplitManager());- }}};onMount(() => {document.addEventListener('visibilitychange', handleVisibilityChange);- const unsubscribeNotifications = globalNotifications.subscribe(- (newNotification) => {- const sidebarId = notificationToSidebarId(newNotification);- if (sidebarId) addBadgeNotification(sidebarId, newNotification.id);-- if (!isAppFocused()) {- setShowNotificationBadge(true);- postBadgeMessage({ hasBadge: true });- pendingNotifications.push(newNotification);- }+ const unsubscribeNotifications = globalNotifications.subscribe(() => {+ if (!isAppFocused()) {+ setShowNotificationBadge(true);+ postBadgeMessage({ hasBadge: true });}- );+ });onCleanup(() => {document.removeEventListener('visibilitychange', handleVisibilityChange);@@ -81,13 +61,5 @@ export function ReactiveFavicon() {updateFavicon(accentColor(), badgeColor(), showNotificationBadge());});- createEffect(() => {- const viewedOrDone = globalNotifications- .notifications()- .filter((n) => n.viewed_at || n.done)- .map((n) => n.id);- if (viewedOrDone.length > 0) removeBadgeNotifications(viewedOrDone);- });-return null;}diff --git a/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsxindex 067cfe1a10..d87ca456b3 100644--- a/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx+++ b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx@@ -148,19 +148,11 @@ function ChannelGroupItem(props: {const canOpenInNewSplit = () =>globalSplitManager()?.canAppendSplit() ?? false;- const navigateToLatestNotification = async (newSplit = false) => {+ const navigateToLatestNotification = (newSplit = false) => {const manager = globalSplitManager();if (!manager) return;const notification = latestNotification();- try {- await openNotification(notification, manager, newSplit);- await notificationSource.markAsRead(notification);- } catch (error) {- console.error(- 'Failed to open unread notification from sidebar widget:',- error- );- }+ openNotification(notification, manager, newSplit);};const openInCurrentSplit = () => {@@ -204,7 +196,6 @@ function ChannelGroupItem(props: {draggable={false}variant="ghost"size="sm"- data-unread-entity-id={props.group.entityId}classList={{'opacity-0 -translate-y-2': !isVisible(),'opacity-100 translate-y-0': isVisible(),diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsxindex c6d686d909..d368ed7b39 100644--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx@@ -16,7 +16,6 @@ import {} from '@app/constants/list-views';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { useHotkeyInterceptor } from '@app/signal/hotkeyRoot';-import { clearSidebarBadge, hasSidebarBadge } from '@app/signal/sidebarBadges';import { globalSplitManager } from '@app/signal/splitLayout';import { InCallPanel } from '@channel/Call';import { useCallContextOptional } from '@channel/Call/CallContext';@@ -69,7 +68,6 @@ import { useLocation } from '@solidjs/router';import { Button, cn, Dropdown, Hotkey, Layer } from '@ui';import {type Component,- createEffect,createMemo,createSignal,For,@@ -977,7 +975,6 @@ const SidebarLink = (props: SidebarLinkProps) => {const analytics = useAnalytics();const layout = useSplitLayout();const layoutManager = globalSplitManager();- const hasUnread = () => hasSidebarBadge(props.id);const location = useLocation();@@ -994,10 +991,6 @@ const SidebarLink = (props: SidebarLinkProps) => {return activeContent?.id === props.id;};- createEffect(() => {- if (isActive()) clearSidebarBadge(props.id);- });-const content = () =>({type: 'component',@@ -1060,7 +1053,6 @@ const SidebarLink = (props: SidebarLinkProps) => {onMouseLeave={() => setIsHovering(false)}onMouseDown={(e) => {if (e.button !== 0) return;- clearSidebarBadge(props.id);analytics.track('sidebar_click', {view: props.id,});@@ -1090,11 +1082,8 @@ const SidebarLink = (props: SidebarLinkProps) => {}}><Show when={props.icon}>- <div class="relative shrink-0 [&_svg]:size-4">+ <div class="shrink-0 [&_svg]:size-4"><Dynamic component={props.icon} triggerAnimation={isHovering()} />- <Show when={hasUnread() && !isActive()}>- <div class="absolute -top-0.5 -right-0.5 size-1.5 bg-accent rounded-full ring-surface ring-2" />- </Show></div></Show>diff --git a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx b/js/app/packages/app/component/split-layout/components/SplitPanel.tsxindex 111e4cf800..f6640261a2 100644--- a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitPanel.tsx@@ -179,7 +179,6 @@ export function SplitPanel(props: SplitPanelProps) {depth={1}><Panel.Header- data-split-headerclass={cn('block min-h-10.25 touch:min-h-11.25 p-0 overflow-visible',shouldHideSplitHeader() && 'hidden'diff --git a/js/app/packages/app/signal/sidebarBadges.ts b/js/app/packages/app/signal/sidebarBadges.tsdeleted file mode 100644index c5c42d744c..0000000000--- a/js/app/packages/app/signal/sidebarBadges.ts+++ /dev/null@@ -1,59 +0,0 @@-import type { ListView } from '@app/constants/list-views';-import { createSignal } from 'solid-js';--const [badgeMap, setBadgeMap] = createSignal(new Map<ListView, Set<string>>());--export function hasSidebarBadge(id: ListView): boolean {- return (badgeMap().get(id)?.size ?? 0) > 0;-}--export function addBadgeNotification(- id: ListView,- notificationId: string-): void {- setBadgeMap((prev) => {- const existing = prev.get(id);- if (existing?.has(notificationId)) return prev;- const next = new Map(prev);- const set = new Set(existing ?? []);- set.add(notificationId);- next.set(id, set);- return next;- });-}--export function removeBadgeNotifications(- notificationIds: Iterable<string>-): void {- const ids = new Set(notificationIds);- if (ids.size === 0) return;- setBadgeMap((prev) => {- let changed = false;- const next = new Map(prev);- for (const [listView, set] of prev) {- let dropped = false;- const updated = new Set<string>();- for (const nid of set) {- if (ids.has(nid)) {- dropped = true;- continue;- }- updated.add(nid);- }- if (!dropped) continue;- changed = true;- if (updated.size === 0) next.delete(listView);- else next.set(listView, updated);- }- return changed ? next : prev;- });-}--export function clearSidebarBadge(id: ListView): void {- setBadgeMap((prev) => {- if (!prev.has(id)) return prev;- const next = new Map(prev);- next.delete(id);- return next;- });-}diff --git a/js/app/packages/app/util/notification-sidebar-id.ts b/js/app/packages/app/util/notification-sidebar-id.tsdeleted file mode 100644index 2db13ff11d..0000000000--- a/js/app/packages/app/util/notification-sidebar-id.ts+++ /dev/null@@ -1,32 +0,0 @@-import type { ListView } from '@app/constants/list-views';-import type { NotificationType } from '@core/types';-import type { UnifiedNotification } from '@notifications';--export function notificationToSidebarId(- n: UnifiedNotification-): ListView | null {- const tag = n.notification_metadata.tag as NotificationType;- switch (tag) {- case 'channel_mention':- case 'channel_message_send':- case 'channel_message_reply':- case 'channel_invite':- case 'call-started':- case 'document_mention':- return 'channels';- case 'new_email':- return 'mail';- case 'task_assigned':- return 'tasks';- case 'mentioned_in_document_comment':- case 'replied_to_document_comment_thread':- case 'commented_on_document':- return 'documents';- case 'ai_response':- return 'agents';- case 'invite_to_team':- return null;- default:- return null;- }-}diff --git a/js/app/packages/app/util/refocus-highlight.ts b/js/app/packages/app/util/refocus-highlight.tsdeleted file mode 100644index 285de834b8..0000000000--- a/js/app/packages/app/util/refocus-highlight.ts+++ /dev/null@@ -1,218 +0,0 @@-import type { SplitManager } from '@app/component/split-layout/layoutManager';-import type { ListView } from '@app/constants/list-views';-import { globalSplitManager } from '@app/signal/splitLayout';-import { notificationToSidebarId } from '@app/util/notification-sidebar-id';-import { toast } from '@core/component/Toast/Toast';-import { isElementVisibleInViewport } from '@core/util/isElementVisibleInViewport';-import {- getChannelNotificationParams,- openNotification,- type UnifiedNotification,-} from '@notifications';--const MAX_PULSES = 5;-const TOAST_DURATION = 6000;--// For new_email, the split is opened with threadId from metadata, not entity_id.-function getSplitEntityId(n: UnifiedNotification): string {- const meta = n.notification_metadata;- if (meta.tag === 'new_email') return meta.content.threadId;- return n.entity_id;-}--function pulseElement(el: Element): void {- const rect = el.getBoundingClientRect();- if (rect.width === 0 || rect.height === 0) return;-- const isSlimSidebar = !!el.closest('[data-slim="true"]');- const glowExtension = isSlimSidebar ? 60 : 0;-- const accentBg = 'oklch(var(--a0l) var(--a0c) var(--a0h) / 0.25)';- const background = isSlimSidebar- ? `linear-gradient(to right, ${accentBg} ${rect.width}px, transparent ${rect.width + glowExtension}px)`- : accentBg;-- const overlay = document.createElement('div');- Object.assign(overlay.style, {- position: 'fixed',- top: `${rect.top}px`,- left: `${rect.left}px`,- width: `${rect.width + glowExtension}px`,- height: `${rect.height}px`,- background,- borderRadius: isSlimSidebar ? '4px 0 0 4px' : '4px',- pointerEvents: 'none',- zIndex: '2147483647',- });- document.body.appendChild(overlay);-- const reducedMotion = window.matchMedia(- '(prefers-reduced-motion: reduce)'- ).matches;-- const keyframes: Keyframe[] = reducedMotion- ? [{ opacity: '0.6' }, { opacity: '0' }]- : [- { opacity: '0.4', transform: 'scale(1.04)', offset: 0 },- { opacity: '0.8', transform: 'scale(1)', offset: 0.07 },- { opacity: '0', transform: 'scale(1)', offset: 1 },- ];-- overlay- .animate(keyframes, {- duration: reducedMotion ? 400 : 3000,- easing: 'ease-out',- fill: 'forwards',- })- .addEventListener('finish', () => overlay.remove());-}--type ToastSection = ListView | 'unknown';--const TOAST_LABEL: Partial<Record<ToastSection, string>> = {- channels: 'message',- mail: 'email',- tasks: 'task',- documents: 'document update',- agents: 'agent response',- unknown: 'notification',-};--function buildToastMessage(countsBySection: Map<ToastSection, number>): string {- const parts: string[] = [];- for (const [type, count] of countsBySection.entries()) {- const label = TOAST_LABEL[type] ?? 'notification';- parts.push(`${count} new ${label}${count > 1 ? 's' : ''}`);- }- return parts.join(', ');-}--// Returns true if the notification was handled (element pulsed, or already pulsed-// by an earlier notification in this batch). Returns false only when the global-// pulse cap was hit — in that case the caller should fall through to the toast bucket.-function tryPulse(- el: Element,- pulsed: Set<Element>,- pulseCount: { value: number }-): boolean {- if (pulsed.has(el)) return true;- if (pulseCount.value >= MAX_PULSES) return false;- pulsed.add(el);- pulseCount.value++;- pulseElement(el);- return true;-}--export function runRefocusPulses(- notifications: UnifiedNotification[],- splitManager: SplitManager | undefined-): void {- if (notifications.length === 0) return;-- const pulsed = new Set<Element>();- const pulseCount = { value: 0 };- const toastBucket: UnifiedNotification[] = [];-- for (const notification of notifications) {- // Rule 1: channel message bubble- const { messageId } = getChannelNotificationParams(notification);- if (messageId) {- const msgEl = document.querySelector(- `[data-message-id="${CSS.escape(messageId)}"]`- );- if (msgEl instanceof HTMLElement && isElementVisibleInViewport(msgEl)) {- if (!tryPulse(msgEl, pulsed, pulseCount))- toastBucket.push(notification);- continue;- }- }-- // Rule 2: a split is open for this entity → pulse the header- if (splitManager) {- const entityIdForSplit = getSplitEntityId(notification);- const matchingSplit = splitManager- .splits()- .find(- (s) =>- s.content.id === entityIdForSplit && s.content.type !== 'component'- );- if (matchingSplit) {- const containerEl = document.querySelector(- `[data-split-id="${CSS.escape(matchingSplit.id)}"] [data-split-header]`- );- if (containerEl) {- if (!tryPulse(containerEl, pulsed, pulseCount))- toastBucket.push(notification);- continue;- }- }- }-- // Rule 3: generic entity row visible in the soup/list view- const entityEl = document.querySelector(- `[data-entity-id="${CSS.escape(notification.entity_id)}"]`- );- if (- entityEl instanceof HTMLElement &&- isElementVisibleInViewport(entityEl)- ) {- if (!tryPulse(entityEl, pulsed, pulseCount))- toastBucket.push(notification);- continue;- }-- // Rule 4: unread sidebar item (e.g. channel/DM entry in the Unread widget)- const unreadEl = document.querySelector(- `[data-unread-entity-id="${CSS.escape(notification.entity_id)}"]`- );- if (unreadEl) {- if (!tryPulse(unreadEl, pulsed, pulseCount))- toastBucket.push(notification);- continue;- }-- // Rule 5: type-specific sidebar nav entry (never inbox)- const sidebarId = notificationToSidebarId(notification);- if (sidebarId) {- const sidebarEl = document.querySelector(- `[data-sidebar-link="${sidebarId}"]`- );- if (sidebarEl) {- if (!tryPulse(sidebarEl, pulsed, pulseCount))- toastBucket.push(notification);- continue;- }- }-- // Rule 6: no visible affordance — falls through to grouped toast- toastBucket.push(notification);- }-- if (toastBucket.length === 0) return;-- const countsBySection = new Map<ToastSection, number>();- let mostRecent = toastBucket[0]!;- for (const n of toastBucket) {- const key: ToastSection = notificationToSidebarId(n) ?? 'unknown';- countsBySection.set(key, (countsBySection.get(key) ?? 0) + 1);- if (n.created_at > mostRecent.created_at) mostRecent = n;- }-- toast.custom(- {- title: buildToastMessage(countsBySection),- actions: [- {- label: 'View',- onClick: () => {- // Re-read the split manager at click time — the layout may have- // changed between toast creation and the user clicking "View".- const manager = globalSplitManager();- if (manager) openNotification(mostRecent, manager);- },- },- ],- },- { duration: TOAST_DURATION }- );-}diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex 369afc3fe8..690d1922f9 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -353,8 +353,3 @@ export const ENABLE_MARKDOWN_SIDE_PANEL = resolveFeatureFlag('ENABLE_MARKDOWN_SIDE_PANEL',true);--export const ENABLE_REFOCUS_HIGHLIGHT = resolveFeatureFlag(- 'ENABLE_REFOCUS_HIGHLIGHT',- true-);diff --git a/js/app/packages/queries/notification/tests/user-notifications.test.tsx b/js/app/packages/queries/notification/tests/user-notifications.test.tsxindex 3d9a85966b..e946b7481d 100644--- a/js/app/packages/queries/notification/tests/user-notifications.test.tsx+++ b/js/app/packages/queries/notification/tests/user-notifications.test.tsx@@ -33,11 +33,6 @@ vi.mock('@queries/soup/normalized-cache', () => ({optimisticUpdateSoupItemUpdatedAt: vi.fn(),}));-vi.mock('@app/signal/sidebarBadges', () => ({- removeBadgeNotifications: vi.fn(),-}));--import { removeBadgeNotifications } from '@app/signal/sidebarBadges';import { optimisticUpdateSoupItemUpdatedAt } from '@queries/soup/normalized-cache';import { notificationServiceClient } from '@service-notification/client';@@ -50,7 +45,6 @@ const mockBulkMarkNotificationAsDone = vi.mocked(const mockOptimisticUpdateSoupItemUpdatedAt = vi.mocked(optimisticUpdateSoupItemUpdatedAt);-const mockRemoveBadgeNotifications = vi.mocked(removeBadgeNotifications);let testQueryClient: QueryClient;@@ -185,7 +179,6 @@ describe('notification realtime status updates', () => {expect(notifications[0].viewed_at).toBe('2024-01-01T00:00:00.000Z');expect(notifications[0].updated_at).toBe('2024-01-01T00:00:01.000Z');expect(notifications[1].viewed_at).toBe(null);- expect(mockRemoveBadgeNotifications).toHaveBeenCalledWith(['n1']);});it('removes deleted and done notifications from the user cache', () => {@@ -211,7 +204,6 @@ describe('notification realtime status updates', () => {});expect(getNotificationsFromCache().map((n) => n.id)).toEqual(['n3']);- expect(mockRemoveBadgeNotifications).toHaveBeenCalledWith(['n1', 'n2']);});});diff --git a/js/app/packages/queries/notification/user-notifications.ts b/js/app/packages/queries/notification/user-notifications.tsindex efb23b5993..0106f52e4e 100644--- a/js/app/packages/queries/notification/user-notifications.ts+++ b/js/app/packages/queries/notification/user-notifications.ts@@ -1,4 +1,3 @@-import { removeBadgeNotifications } from '@app/signal/sidebarBadges';import type { Maybe } from '@core/types';import { type ResultError, throwOnErr } from '@core/util/result';import type { UnifiedNotification } from '@notifications/types';@@ -447,9 +446,6 @@ export function applyNotificationStatusUpdate(.map((patch) => patch.id));const removeIds = new Set([...deleteIds, ...doneIds]);- const viewedIds = patches- .filter((patch) => patch.viewed_at)- .map((patch) => patch.id);queryClient.setQueriesData<NotificationData<UserNotificationsPageParam>>({ queryKey: notificationKeys.user._def },@@ -473,8 +469,6 @@ export function applyNotificationStatusUpdate(});- removeBadgeNotifications([...removeIds, ...viewedIds]);-queryClient.invalidateQueries({queryKey: notificationKeys.user._def,refetchType: 'none',