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
fix(favicon): sync favicon across tabs (#1205)
Aidan Holloway-Bidwell29a7e8d6b825
diff --git a/js/app/bun.lock b/js/app/bun.lockindex 9062e68cd1..9f76a501ff 100644--- a/js/app/bun.lock+++ b/js/app/bun.lock@@ -1,6 +1,5 @@{"lockfileVersion": 1,- "configVersion": 0,"workspaces": {"": {"name": "@coparse/monorepo",@@ -39,6 +38,7 @@"@panzoom/panzoom": "^4.6.0","@phosphor-icons/core": "^2.1.1","@solid-primitives/audio": "^1.4.2",+ "@solid-primitives/broadcast-channel": "^0.1.1","@solid-primitives/context": "^0.3.2","@solid-primitives/deep": "^0.3.3","@solid-primitives/event-bus": "^1.1.2",@@ -1036,6 +1036,8 @@"@solid-primitives/bounds": ["@solid-primitives/[email protected]", "", { "dependencies": { "@solid-primitives/event-listener": "^2.4.1", "@solid-primitives/resize-observer": "^2.1.1", "@solid-primitives/static-store": "^0.1.1", "@solid-primitives/utils": "^6.3.1" }, "peerDependencies": { "solid-js": "^1.6.12" } }, "sha512-b4s8JClkRq2RQlU3K4qeCVASdtct5gfg3HNfWGeD7oPjWlSkp2RyDHJwt9ZtPaXOEOIHhNBbLgjtLax/4B6VUQ=="],+ "@solid-primitives/broadcast-channel": ["@solid-primitives/[email protected]", "", { "peerDependencies": { "solid-js": "^1.6.12" } }, "sha512-7wjQvY320E8elCcuruoJJohDHLzw6l7tAvHXZez5FAolb9BGsk3sPJ9wKDHsdRx0ww2cPg8GeUrGFdJ+5CnCxA=="],+"@solid-primitives/context": ["@solid-primitives/[email protected]", "", { "peerDependencies": { "solid-js": "^1.6.12" } }, "sha512-6fvTtpK17PFHnUf/UOc1TzBjd+kLFjtA62aRFEm1kDP9ufTo7FYW2kUzQAWbfbRHi30yjBJtopbR8qd6nShwyg=="],"@solid-primitives/deep": ["@solid-primitives/[email protected]", "", { "dependencies": { "@solid-primitives/memo": "^1.4.3" }, "peerDependencies": { "solid-js": "^1.6.12" } }, "sha512-YnCV2OFbBlNYlww0lSD7oDpk9zN20KQWr699s6euwd6+oRE1nbI+vqrfYuqC7E0WPDfk0DIG+ylY1xvY31ZlTg=="],diff --git a/js/app/package.json b/js/app/package.jsonindex 218868bc75..b771be431b 100644--- a/js/app/package.json+++ b/js/app/package.json@@ -55,6 +55,7 @@"@panzoom/panzoom": "^4.6.0","@phosphor-icons/core": "^2.1.1","@solid-primitives/audio": "^1.4.2",+ "@solid-primitives/broadcast-channel": "^0.1.1","@solid-primitives/context": "^0.3.2","@solid-primitives/deep": "^0.3.3","@solid-primitives/event-bus": "^1.1.2",diff --git a/js/app/packages/app/component/ReactiveFavicon.tsx b/js/app/packages/app/component/ReactiveFavicon.tsxindex 4758a15985..bb7caa7d6c 100644--- a/js/app/packages/app/component/ReactiveFavicon.tsx+++ b/js/app/packages/app/component/ReactiveFavicon.tsx@@ -1,40 +1,62 @@import { updateFavicon } from '@app/util/favicon';-import { createEffect, createSignal, onCleanup, onMount } from 'solid-js';+import { createBroadcastChannel } from '@solid-primitives/broadcast-channel';+import { createEffect, createSignal, on, onCleanup, onMount } from 'solid-js';import { useReactiveColorString } from '../../block-theme/signals/themeReactive';import { useGlobalNotificationSource } from './GlobalAppState';+type BadgeMessage = { hasBadge: boolean };+export function ReactiveFavicon() {const [showNotificationBadge, setShowNotificationBadge] = createSignal(false);const [isAppFocused, setIsAppFocused] = createSignal(!document.hidden);const globalNotifications = useGlobalNotificationSource();+ const accentColor = useReactiveColorString('a0');+ const badgeColor = useReactiveColorString('a1');++ // Create broadcast channel for badge state sync across tabs+ const { message: badgeMessage, postMessage: postBadgeMessage } =+ createBroadcastChannel<BadgeMessage>('macro-favicon-badge');++ // Listen for badge updates from other tabs+ createEffect(+ on(+ badgeMessage,+ (msg) => {+ if (msg) {+ setShowNotificationBadge(msg.hasBadge);+ }+ },+ { defer: true }+ )+ );+// Remove notification badge when app is focusedconst handleVisibilityChange = () => {setIsAppFocused(!document.hidden);if (!document.hidden) {setShowNotificationBadge(false);+ postBadgeMessage({ hasBadge: false });}};onMount(() => {document.addEventListener('visibilitychange', handleVisibilityChange);- const unsubscribe = globalNotifications.subscribe(() => {+ const unsubscribeNotifications = globalNotifications.subscribe(() => {if (!isAppFocused()) {setShowNotificationBadge(true);+ postBadgeMessage({ hasBadge: true });}});onCleanup(() => {document.removeEventListener('visibilitychange', handleVisibilityChange);- unsubscribe();+ unsubscribeNotifications();});});- const accentColor = useReactiveColorString('a0');- const badgeColor = useReactiveColorString('a1');-createEffect(() => {updateFavicon(accentColor(), badgeColor(), showNotificationBadge());});diff --git a/js/app/packages/app/util/favicon.ts b/js/app/packages/app/util/favicon.tsindex 8ac9224c11..2b7887a3a3 100644--- a/js/app/packages/app/util/favicon.ts+++ b/js/app/packages/app/util/favicon.ts@@ -17,8 +17,6 @@ function processSvg(svg: string, color: string) {/*** Return a data url for the macro logo svg filled with the given color.- * @param color- * @returns*/export function getFaviconUrl(color: string) {return processSvg(FaviconSvg, color);@@ -27,8 +25,6 @@ export function getFaviconUrl(color: string) {/*** Update the site's live favicon with a new color, and optionally a notification* badge with its own color.- * @param color- * @returns*/export function updateFavicon(faviconColor: string,