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
Lazy-load views and emoji data to improve startup performance (#7573)
Jacob Beckerman0ec7b11e0c60
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 68dbd1b35b..96b05fb989 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -68,6 +68,12 @@ Then trigger the interaction and read `window.__inst.log`. `'1,2,3' → '' → '- When adding or changing a feature flag, follow the `define-feature-flag` skill.- When adding or changing a view's feature tour, follow the `add-tour` skill.+### Startup bundle+- Everything statically reachable from `src/index.tsx` downloads and runs before the first screen. Views, block components, and modals load through `lazy()` / `lazyNamed` (`@core/util/lazyNamed`) inside a `<Suspense>`; never statically import one into a shared hub (`Root`, `Layout`, `componentRegistry`, `app-router-view`, block `definition.ts`, Lexical `init.ts`).+- `index.html` draws a boot shell (rail, view sidebar, Home's composer) before any JS runs, from the saved theme and the `rememberBootShell` layout hint; `Root` hands off once auth is known. Keep its geometry in step with `SidebarRail`, `ViewSidebar`, and `HomeChatStart`.+- Production web builds register `public/sw.js`: it serves the cached `index.html` and content-hashed assets from Cache Storage and moves tabs to newer builds. Set localStorage `macro:sw` to `off` to bypass it while debugging.+- The build fails if any emitted file exceeds CloudFront's 10 MB compression limit; split it rather than raising the limit.+### SolidJs- Avoid createEffect. Legitimate uses: syncing with external/imperative systems (DOM APIs, third-party libs). If you're using it to derive state or trigger updates, use a derived signal or wrap the setter instead.- Prefer wrapping the setter over `createEffect(() => { if (signal()) sideEffect() })`. When setting focus/selection should also clear another stop, blur a control, or scroll, put that work in the setter (or a named helper the setter calls) so the action is explicit at the call site — not a distant effect watching the signal.diff --git a/apps/web/index.html b/apps/web/index.htmlindex d72208fda4..65dd213ea5 100644--- a/apps/web/index.html+++ b/apps/web/index.html@@ -26,10 +26,439 @@user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/--><link rel="manifest" href="/manifest.json" />+ <!-- The first API calls wait for the bundle; open their connection meanwhile. -->+ <link+ rel="preconnect"+ href="%GATEWAY_ORIGIN%"+ crossorigin="use-credentials"+ />+ <!--+ Boot shell: a static likeness of the app frame (rail, view sidebar, Home's+ composer), painted with the HTML so the screen is never blank while the+ bundle downloads and starts. The inline script in <body> fills it in from+ the saved theme and layout; the app fades it out once its own frame mounts+ (see dismissBootShell). Geometry mirrors the sidebar rail, ViewSidebar, and+ the Agents new-chat layout.+ -->+ <style>+ #boot-shell {+ --bs-page: oklch(0.17 0 0);+ --bs-panel: oklch(0.1949 0 0);+ --bs-ink: oklch(1 0 0);+ --bs-muted: color-mix(in oklch, var(--bs-ink) 62%, transparent);+ --bs-bar: color-mix(in oklch, var(--bs-ink) 10%, transparent);+ --bs-shine: color-mix(in oklch, var(--bs-ink) 18%, transparent);+ --bs-edge: color-mix(in oklch, var(--bs-ink) 8%, transparent);+ position: fixed;+ inset: 0;+ z-index: 2147483000;+ display: flex;+ overflow: hidden;+ background: var(--bs-panel);+ color: var(--bs-ink);+ font-family: -apple-system, BlinkMacSystemFont, "Inter Variable", Roboto,+ "Helvetica Neue", Arial, sans-serif;+ transition: opacity 180ms ease-out;+ pointer-events: none;+ }+ @media (prefers-color-scheme: light) {+ #boot-shell {+ --bs-page: oklch(0.964 0 0);+ --bs-panel: oklch(1 0 0);+ --bs-ink: oklch(0.16 0 0);+ }+ }+ #boot-shell[data-leaving] {+ opacity: 0;+ }+ #boot-shell svg {+ flex: none;+ fill: currentColor;+ }+ .bs-bar {+ flex: none;+ height: 10px;+ border-radius: 999px;+ /* One fixed-position gradient shared by every bar, so the shimmer+ sweeps across the whole frame as a single band. */+ background: linear-gradient(+ 100deg,+ transparent 40%,+ var(--bs-shine) 50%,+ transparent 60%+ )+ var(--bs-bar);+ background-size: 200vw 100%;+ background-attachment: fixed;+ animation: bs-shimmer 1.6s linear infinite;+ }+ @keyframes bs-shimmer {+ from {+ background-position: 100vw 0;+ }+ to {+ background-position: -100vw 0;+ }+ }+ @media (prefers-reduced-motion: reduce) {+ .bs-bar {+ animation: none;+ }+ }+ /* Rail: SidebarRail's 56px column of 40px icon buttons. */+ .bs-rail {+ display: flex;+ width: 56px;+ flex: none;+ flex-direction: column;+ align-items: center;+ gap: 4px;+ padding: 8px 8px 12px;+ border-right: 1px solid var(--bs-edge);+ }+ .bs-btn {+ display: flex;+ width: 40px;+ height: 40px;+ flex: none;+ align-items: center;+ justify-content: center;+ border-radius: 12px;+ color: var(--bs-muted);+ }+ .bs-btn svg {+ width: 20px;+ height: 20px;+ }+ .bs-btn[data-active] {+ background: color-mix(in oklch, var(--bs-ink) 7%, transparent);+ color: var(--bs-ink);+ }+ .bs-nav {+ display: flex;+ flex-direction: column;+ gap: 4px;+ padding-top: 16px;+ }+ /* View sidebar: ViewSidebar's 256px aside. */+ .bs-aside {+ display: flex;+ width: 256px;+ flex: none;+ flex-direction: column;+ border-right: 1px solid var(--bs-edge);+ }+ .bs-head {+ display: flex;+ height: 48px;+ flex: none;+ align-items: center;+ gap: 6px;+ padding: 0 12px 0 16px;+ font-size: 14px;+ font-weight: 600;+ letter-spacing: -0.03em;+ }+ .bs-head svg {+ width: 16px;+ height: 16px;+ color: var(--bs-muted);+ }+ .bs-head > :last-child {+ margin-left: auto;+ }+ .bs-row {+ display: flex;+ height: 32px;+ flex: none;+ align-items: center;+ gap: 8px;+ margin: 0 8px 2px;+ padding: 0 8px;+ font-size: 14px;+ }+ .bs-row svg {+ width: 16px;+ height: 16px;+ margin: 0 2px;+ color: var(--bs-muted);+ }+ .bs-ico {+ width: 16px;+ height: 16px;+ margin: 0 2px;+ border-radius: 4px;+ }+ .bs-row > .bs-time {+ width: 28px;+ height: 8px;+ margin-left: auto;+ }+ .bs-label {+ display: flex;+ height: 28px;+ align-items: center;+ margin: 14px 8px 2px;+ padding: 0 8px;+ }+ .bs-label > .bs-bar {+ width: 76px;+ height: 8px;+ }+ .bs-main {+ position: relative;+ display: flex;+ min-width: 0;+ flex: 1;+ flex-direction: column;+ }+ /* Home's composer: the Agents new-chat grid, under the 48px top bar. */+ .bs-newchat {+ display: grid;+ flex: 1;+ grid-template-rows: max(0px, calc(40% - 60px)) auto 1fr;+ justify-items: center;+ padding: 72px 24px 64px;+ }+ /* Without the Agents flag, Home centers a smaller greeting (HomeChatStart). */+ .bs-newchat[data-legacy] {+ grid-template-rows: 1fr auto 1fr;+ padding: 0 24px 64px;+ }+ .bs-newchat[data-legacy] .bs-col {+ display: contents;+ }+ .bs-newchat[data-legacy] .bs-composer {+ max-width: 720px;+ grid-row: 2;+ }+ .bs-newchat[data-legacy] .bs-greeting {+ align-self: end;+ grid-row: 1;+ margin-bottom: 24px;+ font-size: 24px;+ font-weight: 400;+ letter-spacing: normal;+ line-height: 42px;+ }+ .bs-col {+ display: flex;+ width: 100%;+ max-width: 720px;+ grid-row: 2;+ flex-direction: column;+ align-items: center;+ gap: 20px;+ }+ .bs-greeting {+ margin: 0 0 12px;+ font-size: 28px;+ font-weight: 500;+ letter-spacing: -0.03em;+ line-height: 1.2;+ }+ .bs-composer {+ display: flex;+ width: 100%;+ height: 48px;+ align-items: center;+ gap: 12px;+ padding: 0 8px 0 18px;+ border: 1px solid var(--bs-edge);+ border-radius: 999px;+ background: color-mix(in oklch, var(--bs-ink) 3%, var(--bs-panel));+ color: var(--bs-muted);+ }+ .bs-composer svg {+ width: 18px;+ height: 18px;+ }+ .bs-composer > .bs-bar {+ height: 8px;+ }+ .bs-send {+ display: flex;+ width: 32px;+ height: 32px;+ align-items: center;+ justify-content: center;+ border-radius: 999px;+ background: color-mix(in oklch, var(--bs-ink) 8%, transparent);+ }+ .bs-send svg {+ width: 16px;+ height: 16px;+ }+ /* Any other view: a header and content lines. */+ .bs-page {+ display: flex;+ flex-direction: column;+ gap: 14px;+ padding: 18px 32px;+ }+ .bs-page > .bs-bar:first-child {+ width: 160px;+ height: 12px;+ margin-bottom: 18px;+ }+ .bs-mark {+ width: 44px;+ height: 44px;+ margin: auto;+ color: color-mix(in oklch, var(--bs-ink) 18%, transparent);+ }+ /* Narrow windows overlay the view sidebar, so it starts hidden. */+ @media (max-width: 800px) {+ .bs-aside {+ display: none;+ }+ }+ /* Touch devices: no rail; a full-width list and the floating dock. */+ .bs-dock {+ display: none;+ }+ @media (pointer: coarse) {+ #boot-shell {+ background: var(--bs-page);+ padding: env(safe-area-inset-top) env(safe-area-inset-right) 0+ env(safe-area-inset-left);+ }+ .bs-rail,+ .bs-newchat,+ .bs-head,+ .bs-head + .bs-row {+ display: none;+ }+ .bs-aside {+ display: flex;+ width: auto;+ flex: 1;+ padding-top: 48px;+ border: 0;+ }+ .bs-main {+ display: none;+ }+ .bs-row {+ height: 60px;+ gap: 12px;+ margin: 0 4px;+ }+ .bs-ico {+ width: 32px;+ height: 32px;+ margin: 0;+ border-radius: 999px;+ }+ .bs-dock {+ position: absolute;+ bottom: calc(env(safe-area-inset-bottom) + 12px);+ left: 50%;+ display: flex;+ gap: 20px;+ padding: 12px 22px;+ border: 1px solid var(--bs-edge);+ border-radius: 999px;+ background: var(--bs-panel);+ transform: translateX(-50%);+ }+ .bs-dock > .bs-bar {+ width: 24px;+ height: 24px;+ }+ }+ </style></head><body><noscript>You need to enable JavaScript to run this app.</noscript>+ <div id="boot-shell" aria-hidden="true"></div>+ <script>+ // Draw the boot shell for this route in the saved theme and layout.+ // App code writes the `macro:boot-shell` hint (rail items) and the theme+ // colors; everything degrades to Home's default layout without them.+ try {+ const shell = document.getElementById("boot-shell");+ const read = (key) => {+ try {+ return JSON.parse(localStorage.getItem(key) || "null");+ } catch {+ return null;+ }+ };+ const theme = read("html-color-theme");+ if (theme && theme.color) {+ document.body.style.backgroundColor = theme.color;+ shell.style.setProperty("--bs-page", theme.color);+ shell.style.setProperty("--bs-panel", theme.panel || theme.color);+ // Saves from older builds have no ink; infer it from page lightness.+ const lightness = parseFloat(/oklch\(\s*([\d.]+)/.exec(theme.color)?.[1]);+ const ink = theme.ink || (lightness > 0.6 ? "oklch(0.16 0 0)" : lightness >= 0 ? "oklch(1 0 0)" : "");+ if (ink) shell.style.setProperty("--bs-ink", ink);+ }++ const I = {"plus":"<path d=\"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z\"/>","search":"<path d=\"M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z\"/>","home":"<path d=\"M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V160h32v56a8,8,0,0,0,8,8h64a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68ZM208,208H160V152a8,8,0,0,0-8-8H104a8,8,0,0,0-8,8v56H48V120l80-80,80,80Z\"/>","home-fill":"<path d=\"M224,120v96a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V164a4,4,0,0,0-4-4H108a4,4,0,0,0-4,4v52a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V120a16,16,0,0,1,4.69-11.31l80-80a16,16,0,0,1,22.62,0l80,80A16,16,0,0,1,224,120Z\"/>","reminders":"<path d=\"M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z\"/>","documents":"<path d=\"M216,72H130.67L102.93,51.2a16.12,16.12,0,0,0-9.6-3.2H40A16,16,0,0,0,24,64V200a16,16,0,0,0,16,16H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72Zm0,128H40V64H93.33L123.2,86.4A8,8,0,0,0,128,88h88Z\"/>","mail":"<path d=\"M224,48H32a8,8,0,0,0-8,8V192a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A8,8,0,0,0,224,48Zm-96,85.15L52.57,64H203.43ZM98.71,128,40,181.81V74.19Zm11.84,10.85,12,11.05a8,8,0,0,0,10.82,0l12-11.05,58,53.15H52.57ZM157.29,128,216,74.18V181.82Z\"/>","channels":"<path d=\"M232.07,186.76a80,80,0,0,0-62.5-114.17A80,80,0,1,0,23.93,138.76l-7.27,24.71a16,16,0,0,0,19.87,19.87l24.71-7.27a80.39,80.39,0,0,0,25.18,7.35,80,80,0,0,0,108.34,40.65l24.71,7.27a16,16,0,0,0,19.87-19.86ZM62,159.5a8.28,8.28,0,0,0-2.26.32L32,168l8.17-27.76a8,8,0,0,0-.63-6,64,64,0,1,1,26.26,26.26A8,8,0,0,0,62,159.5Zm153.79,28.73L224,216l-27.76-8.17a8,8,0,0,0-6,.63,64.05,64.05,0,0,1-85.87-24.88A79.93,79.93,0,0,0,174.7,89.71a64,64,0,0,1,41.75,92.48A8,8,0,0,0,215.82,188.23Z\"/>","tasks":"<path d=\"M224,128a8,8,0,0,1-8,8H128a8,8,0,0,1,0-16h88A8,8,0,0,1,224,128ZM128,72h88a8,8,0,0,0,0-16H128a8,8,0,0,0,0,16Zm88,112H128a8,8,0,0,0,0,16h88a8,8,0,0,0,0-16ZM82.34,42.34,56,68.69,45.66,58.34A8,8,0,0,0,34.34,69.66l16,16a8,8,0,0,0,11.32,0l32-32A8,8,0,0,0,82.34,42.34Zm0,64L56,132.69,45.66,122.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0-11.32-11.32Zm0,64L56,196.69,45.66,186.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0-11.32-11.32Z\"/>","calendar":"<path d=\"M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,48v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80H48V48ZM208,208H48V96H208V208Z\"/>","agents":"<path d=\"M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z\"/>","companies":"<path d=\"M240,208H224V96a16,16,0,0,0-16-16H144V32a16,16,0,0,0-24.88-13.32L39.12,72A16,16,0,0,0,32,85.34V208H16a8,8,0,0,0,0,16H240a8,8,0,0,0,0-16ZM208,96V208H144V96ZM48,85.34,128,32V208H48ZM112,112v16a8,8,0,0,1-16,0V112a8,8,0,1,1,16,0Zm-32,0v16a8,8,0,0,1-16,0V112a8,8,0,1,1,16,0Zm0,56v16a8,8,0,0,1-16,0V168a8,8,0,0,1,16,0Zm32,0v16a8,8,0,0,1-16,0V168a8,8,0,0,1,16,0Z\"/>","calls":"<path d=\"M144.27,45.93a8,8,0,0,1,9.8-5.66,86.22,86.22,0,0,1,61.66,61.66,8,8,0,0,1-5.66,9.8A8.23,8.23,0,0,1,208,112a8,8,0,0,1-7.73-5.94,70.35,70.35,0,0,0-50.33-50.33A8,8,0,0,1,144.27,45.93Zm-2.33,41.8c13.79,3.68,22.65,12.54,26.33,26.33A8,8,0,0,0,176,120a8.23,8.23,0,0,0,2.07-.27,8,8,0,0,0,5.66-9.8c-5.12-19.16-18.5-32.54-37.66-37.66a8,8,0,1,0-4.13,15.46Zm81.94,95.35A56.26,56.26,0,0,1,168,232C88.6,232,24,167.4,24,88A56.26,56.26,0,0,1,72.92,32.12a16,16,0,0,1,16.62,9.52l21.12,47.15,0,.12A16,16,0,0,1,109.39,104c-.18.27-.37.52-.57.77L88,129.45c7.49,15.22,23.41,31,38.83,38.51l24.34-20.71a8.12,8.12,0,0,1,.75-.56,16,16,0,0,1,15.17-1.4l.13.06,47.11,21.11A16,16,0,0,1,223.88,183.08Zm-15.88-2s-.07,0-.11,0h0l-47-21.05-24.35,20.71a8.44,8.44,0,0,1-.74.56,16,16,0,0,1-15.75,1.14c-18.73-9.05-37.4-27.58-46.46-46.11a16,16,0,0,1,1-15.7,6.13,6.13,0,0,1,.57-.77L96,95.15l-21-47a.61.61,0,0,1,0-.12A40.2,40.2,0,0,0,40,88,128.14,128.14,0,0,0,168,216,40.21,40.21,0,0,0,208,181.07Z\"/>","reviews":"<path d=\"M104,64A32,32,0,1,0,64,95v66a32,32,0,1,0,16,0V95A32.06,32.06,0,0,0,104,64ZM56,64A16,16,0,1,1,72,80,16,16,0,0,1,56,64ZM88,192a16,16,0,1,1-16-16A16,16,0,0,1,88,192Zm120-31V110.63a23.85,23.85,0,0,0-7-17L163.31,56H192a8,8,0,0,0,0-16H144a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31L189.66,105a8,8,0,0,1,2.34,5.66V161a32,32,0,1,0,16,0Zm-8,47a16,16,0,1,1,16-16A16,16,0,0,1,200,208Z\"/>","more":"<path d=\"M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z\"/>","gear":"<path d=\"M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z\"/>","filter":"<path d=\"M200,136a8,8,0,0,1-8,8H64a8,8,0,0,1,0-16H192A8,8,0,0,1,200,136Zm32-56H24a8,8,0,0,0,0,16H232a8,8,0,0,0,0-16Zm-80,96H104a8,8,0,0,0,0,16h48a8,8,0,0,0,0-16Z\"/>","sidebar":"<path d=\"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM40,56H80V200H40ZM216,200H96V56H216V200Z\"/>","mic":"<path d=\"M128,176a48.05,48.05,0,0,0,48-48V64a48,48,0,0,0-96,0v64A48.05,48.05,0,0,0,128,176ZM96,64a32,32,0,0,1,64,0v64a32,32,0,0,1-64,0Zm40,143.6V240a8,8,0,0,1-16,0V207.6A80.11,80.11,0,0,1,48,128a8,8,0,0,1,16,0,64,64,0,0,0,128,0,8,8,0,0,1,16,0A80.11,80.11,0,0,1,136,207.6Z\"/>","send":"<path d=\"M205.66,117.66a8,8,0,0,1-11.32,0L136,59.31V216a8,8,0,0,1-16,0V59.31L61.66,117.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,205.66,117.66Z\"/>","caret":"<path d=\"M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z\"/>","mobile-app":"<path d=\"M176,16H80A24,24,0,0,0,56,40V216a24,24,0,0,0,24,24h96a24,24,0,0,0,24-24V40A24,24,0,0,0,176,16ZM72,64H184V192H72Zm8-32h96a8,8,0,0,1,8,8v8H72V40A8,8,0,0,1,80,32Zm96,192H80a8,8,0,0,1-8-8v-8H184v8A8,8,0,0,1,176,224Z\"/><path d=\"M128,92v72M100,136l28,28,28-28\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"16\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"};+ const icon = (name) => `<svg viewBox="0 0 256 256">${I[name] || ""}</svg>`;+ const bar = (width, style = "") => `<div class="bs-bar" style="width:${width};${style}"></div>`;+ const square = `<div class="bs-bar bs-ico"></div>`;+ const row = (width, time) => `<div class="bs-row">${square}${bar(width)}${time ? `<div class="bs-bar bs-time"></div>` : ""}</div>`;++ if (localStorage.getItem("macro:login") !== "true") {+ // Signed out: the app opens on a login page, so show only the mark.+ shell.style.background = "var(--bs-page)";+ shell.innerHTML = `<svg class="bs-mark" viewBox="0 0 24 24"><path d="m6.25 4.038-2.242.879v5.818l-1.756-1.658-2.242.879v6.677c0 .257.106.502.292.678l2.794 2.642 2.244-.879v-5.818l7.084 6.697 2.244-.879v-5.818l7.086 6.698 2.24-.879v-6.677c0-.257-.104-.502-.292-.678l-8.124-7.682-2.244.879v5.818z"/></svg>`;+ } else {+ const hint = read("macro:boot-shell") || {};+ const path = (location.hash.startsWith("#/") ? location.hash.slice(1) : location.pathname)+ .replace(/^\/app(?=\/|$)/, "");+ const view = path.split("/")[1] || "home";+ const isHomeStart = view === "home" && !path.split("/")[2];+ const listViews = ["home", "mail", "documents", "tasks", "channels", "agents", "routines", "reminders", "companies", "calls", "reviews", "recent", "folders", "search", "activity"];+ const collapsed = read(`macro:pref:view-sidebar:collapsed:${view}`) === true;+ const showAside = listViews.includes(view) && !collapsed;++ const railItems = Array.isArray(hint.rail) && hint.rail.length+ ? hint.rail+ : ["home", "reminders", "documents", "mail", "channels", "tasks", "calendar", "agents", "companies"];+ const railButton = (id) =>+ I[id] ? `<div class="bs-btn"${id === view ? " data-active" : ""}>${icon(id === "home" && view === "home" ? "home-fill" : id)}</div>` : "";+ const rail = `<div class="bs-rail">+ <div class="bs-btn">${icon("plus")}</div>+ <div class="bs-btn">${icon("search")}</div>+ <div class="bs-nav">${railItems.map(railButton).join("")}<div class="bs-btn">${icon("more")}</div></div>+ <div style="flex:1"></div>+ ${hint.mobileApp === false ? "" : `<div class="bs-btn">${icon("mobile-app")}</div>`}+ <div class="bs-btn">${icon("gear")}</div>+ </div>`;++ const widths = ["58%", "72%", "46%", "64%", "52%", "78%", "40%", "60%", "70%", "48%", "56%", "66%", "44%", "62%"];+ let rows = "";+ [3, 6, 4, 2, 4].forEach((count, group) => {+ rows += `<div class="bs-label">${bar("76px")}</div>`;+ for (let i = 0; i < count; i++) rows += row(widths[(group * 3 + i) % widths.length], i === 1);+ });+ const aside = `<div class="bs-aside">+ <div class="bs-head">${view === "home" ? `<span>Home</span>${icon("filter")}` : bar("72px", "height:12px")}${icon("sidebar")}</div>+ ${view === "home" ? `<div class="bs-row" style="margin-top:8px">${icon("plus")}<span>New chat</span></div>` : `<div class="bs-row" style="margin-top:8px">${square}${bar("38%")}</div>`}+ ${rows}+ </div>`;++ const legacyComposer = hint.homeComposer === "legacy";+ const main = isHomeStart+ ? `<div class="bs-newchat"${legacyComposer ? " data-legacy" : ""}><div class="bs-col">+ <h2 class="bs-greeting">${legacyComposer ? "What should we get done in Macro?" : "What should we work on?"}</h2>+ <div class="bs-composer">${icon("plus")}${bar("38%")}<div style="flex:1"></div>${bar("72px")}${icon("mic")}<div class="bs-send">${icon("send")}</div></div>+ </div></div>`+ : `<div class="bs-page">${bar("160px")}${["92%", "86%", "95%", "70%", "88%", "80%", "60%"].map((w) => bar(w)).join("")}</div>`;++ shell.innerHTML = `${rail}${showAside ? aside : ""}<div class="bs-main">${main}</div>+ <div class="bs-dock">${bar("24px") + bar("24px") + bar("24px") + bar("24px") + bar("24px")}</div>`;+ if (!showAside && matchMedia("(pointer: coarse)").matches) shell.insertAdjacentHTML("afterbegin", aside);+ }+ } catch (err) {+ console.error("Failed to draw boot shell: ", err);+ }+ </script><div id="root" class="h-[calc(var(--dvh,1dvh)*100)]"></div><div id="modal" class="z-modal"></div><!--@@ -39,17 +468,5 @@<script>window.__START_TIME__ = performance.now();</script>- <!-- Sets blank page to theme surface color to prevent background color flash -->- <script>- try {- let htmlColorString = localStorage.getItem("html-color-theme");- if (htmlColorString) {- let htmlColor = JSON.parse(htmlColorString);- document.body.style.backgroundColor = htmlColor.color;- }- } catch (err) {- console.error("Failed parse macro-selected-theme: ", err);- }- </script></body></html>diff --git a/apps/web/public/sw.js b/apps/web/public/sw.jsnew file mode 100644index 0000000000..445ef0b513--- /dev/null+++ b/apps/web/public/sw.js@@ -0,0 +1,192 @@+/**+ * Macro web app service worker (scope /app/). Registered by+ * src/lib/service-worker/register.ts in production web builds only.+ *+ * - Navigations get the cached app shell (index.html) immediately and+ * revalidate it in the background, so a new tab skips the HTML round trip.+ * A shell is cached only after its entry JS and CSS are, so a cached shell+ * can always boot.+ * - Content-hashed assets are immutable: served cache-first from Cache+ * Storage, tagged with the build that fetched them, and pruned to the+ * current and previous builds.+ * - When revalidation finds a newer build, open tabs get a+ * `macro:newer-build` message so a tab still on the cached build can move+ * to it.+ *+ * Kill switch: ship a sw.js whose install handler calls+ * `self.registration.unregister()`; a client also unregisters it when its+ * localStorage `macro:sw` is `off`.+ */++const SHELL_CACHE = 'macro-shell-v1';+const ASSET_CACHE = 'macro-assets-v1';+const SCOPE_PATH = new URL(self.registration.scope).pathname;+const SHELL_KEY = `${SCOPE_PATH}__shell`;+const BUILD_HEADER = 'x-macro-build';+const ASSETS_HEADER = 'x-macro-shell-assets';++// Vite output names end in an 8-character base64url content hash.+const HASHED_ASSET =+ /-(?=[A-Za-z0-9_-]*[A-Z0-9_])[A-Za-z0-9_-]{8}\.(?:js|css|wasm|woff2?|ttf|svg|png|jpe?g|webp|glb)$/;++self.addEventListener('install', (event) => {+ self.skipWaiting();+ // Warm the shell for the next tab; a failure only means a cold next tab.+ event.waitUntil(refreshShell(new Request(SCOPE_PATH)).catch(() => {}));+});++self.addEventListener('activate', (event) => {+ event.waitUntil(+ (async () => {+ const keep = new Set([SHELL_CACHE, ASSET_CACHE]);+ for (const name of await caches.keys()) {+ if (name.startsWith('macro-') && !keep.has(name)) {+ await caches.delete(name);+ }+ }+ await self.clients.claim();+ })()+ );+});++self.addEventListener('fetch', (event) => {+ const { request } = event;+ if (request.method !== 'GET') return;+ const url = new URL(request.url);+ if (url.origin !== self.location.origin) return;+ if (!url.pathname.startsWith(SCOPE_PATH)) return;++ if (request.mode === 'navigate') {+ // Mirror the routing lambda: paths that look like files are not the app.+ const leaf = url.pathname.split('/').pop() ?? '';+ if (leaf.includes('.') && !url.pathname.includes('@')) return;+ event.respondWith(serveShell(event));+ } else if (HASHED_ASSET.test(url.pathname)) {+ event.respondWith(serveAsset(request));+ }+});++async function serveShell(event) {+ const cache = await caches.open(SHELL_CACHE);+ const cached = await cache.match(SHELL_KEY);+ const refreshed = refreshShell(event.request).catch(() => undefined);+ if (cached && (await shellAssetsCached(cached))) {+ event.waitUntil(refreshed);+ return cached;+ }+ // No bootable shell yet: wait for the network, falling back to whatever+ // is cached when offline.+ const response = await refreshed;+ return response ?? cached ?? Response.error();+}++/** Fetches index.html, caches it as the shell once its entry is cached, and returns the network response. */+async function refreshShell(request) {+ const response = await fetch(request, { cache: 'no-store' });+ if (!response.ok || response.redirected) return response;+ if (!response.headers.get('content-type')?.includes('text/html')) {+ return response;+ }+ const html = await response.clone().text();+ const build = /<meta name="macro-bundle-build" content="(\d+)"/.exec(+ html+ )?.[1];+ if (!build) return response;++ const cache = await caches.open(SHELL_CACHE);+ const current = await cache.match(SHELL_KEY);+ const currentBuild = current?.headers.get(BUILD_HEADER);+ if (currentBuild === build && (await shellAssetsCached(current))) {+ return response;+ }++ // The routing lambda adds a per-document <title>; the shell serves every route.+ const shell = html.replace(/<title data-sm="">[\s\S]*?<\/title>/, '');+ const assets = entryAssets(shell);+ const assetCache = await caches.open(ASSET_CACHE);+ await Promise.all(+ assets.map(async (path) => {+ if (await assetCache.match(path)) return;+ const assetResponse = await fetch(path);+ if (!assetResponse.ok) throw new Error(`Failed to cache ${path}`);+ await assetCache.put(path, tagged(assetResponse, build));+ })+ );+ // Keep the document's own headers (COOP for login popups, frame options).+ const headers = new Headers(response.headers);+ for (const name of ['content-length', 'content-encoding', 'date', 'age']) {+ headers.delete(name);+ }+ headers.set(BUILD_HEADER, build);+ headers.set(ASSETS_HEADER, assets.join(' '));+ await cache.put(SHELL_KEY, new Response(shell, { headers }));++ if (currentBuild && Number(build) > Number(currentBuild)) {+ for (const client of await self.clients.matchAll({ type: 'window' })) {+ client.postMessage({ type: 'macro:newer-build', build });+ }+ }+ if (currentBuild !== build) {+ await pruneAssets(new Set([build, currentBuild ?? build]));+ }+ return response;+}++/** The entry module, its preloads, and stylesheets referenced by a shell. */+function entryAssets(html) {+ const paths = new Set();+ for (const match of html.matchAll(+ /<(?:script|link)\b[^>]*\b(?:src|href)="([^"]+)"[^>]*>/g+ )) {+ const tag = match[0];+ const isEntry =+ tag.startsWith('<script') ||+ /\brel="(?:stylesheet|modulepreload)"/.test(tag);+ const path = new URL(match[1], self.location.origin).pathname;+ if (isEntry && HASHED_ASSET.test(path)) paths.add(path);+ }+ return [...paths];+}++async function shellAssetsCached(shell) {+ const assets = shell.headers.get(ASSETS_HEADER)?.split(' ') ?? [];+ if (assets.length === 0) return false;+ const assetCache = await caches.open(ASSET_CACHE);+ const hits = await Promise.all(assets.map((path) => assetCache.match(path)));+ return hits.every(Boolean);+}++async function serveAsset(request) {+ const cache = await caches.open(ASSET_CACHE);+ const hit = await cache.match(request, { ignoreVary: true });+ if (hit) return hit;+ const response = await fetch(request);+ if (response.ok && response.type === 'basic') {+ const shell = await (await caches.open(SHELL_CACHE)).match(SHELL_KEY);+ const build = shell?.headers.get(BUILD_HEADER) ?? '';+ cache.put(request, tagged(response.clone(), build)).catch(() => {});+ }+ return response;+}++/** Copies a response with the build that fetched it, for pruning. */+function tagged(response, build) {+ const headers = new Headers(response.headers);+ headers.set(BUILD_HEADER, build);+ return new Response(response.body, {+ status: response.status,+ statusText: response.statusText,+ headers,+ });+}++/** Drops cached assets fetched by builds other than `keep`. */+async function pruneAssets(keep) {+ const cache = await caches.open(ASSET_CACHE);+ for (const request of await cache.keys()) {+ const response = await cache.match(request);+ if (!keep.has(response?.headers.get(BUILD_HEADER) ?? '')) {+ await cache.delete(request);+ }+ }+}diff --git a/apps/web/src/components/app/ContentLoading.tsx b/apps/web/src/components/app/ContentLoading.tsxindex bd45a5a286..af8595ca84 100644--- a/apps/web/src/components/app/ContentLoading.tsx+++ b/apps/web/src/components/app/ContentLoading.tsx@@ -1,14 +1,34 @@-import { LoadingSpinner } from '@core/component/LoadingSpinner';+import { ListSkeleton } from '@app/components/view-shell/ListSkeleton';+import { For } from 'solid-js';-/** Visible immediately, even when the surrounding mobile chrome is hidden. */+const ROW_WIDTHS = ['w-1/2', 'w-2/3', 'w-2/5', 'w-3/5', 'w-3/4', 'w-1/2'];++/**+ * A view's frame while its code or data loads: a header and a few rows, in the+ * same shimmer as list skeletons. Visible immediately, even when the+ * surrounding mobile chrome is hidden.+ */export function ContentLoading() {return (<divrole="status"aria-label="Loading"- class="flex size-full min-h-24 items-center justify-center"+ class="flex size-full min-h-24 flex-col overflow-hidden">- <LoadingSpinner />+ <span class="sr-only">Loading</span>+ <div aria-hidden="true" class="flex h-12 shrink-0 items-center px-4">+ <ListSkeleton.Bar class="h-3 w-24" />+ </div>+ <div aria-hidden="true" class="flex flex-col gap-(--sidebar-row-gap)">+ <For each={ROW_WIDTHS}>+ {(width) => (+ <ListSkeleton.Row class="mx-(--sidebar-gutter)">+ <ListSkeleton.Bar class="size-4 shrink-0 rounded" />+ <ListSkeleton.Bar class={width} />+ </ListSkeleton.Row>+ )}+ </For>+ </div></div>);}diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsxindex 31e62acab5..3d4f18e7d2 100644--- a/apps/web/src/components/app/Layout.tsx+++ b/apps/web/src/components/app/Layout.tsx@@ -25,11 +25,8 @@ import {import { MacroMcpSetupModal } from '@app/features/integrations/mcp-setup/MacroMcpSetupModal';import { AiUsageLimitDialog } from '@app/features/paywall/AiUsageLimitDialog';import { observeAiUsageLimitMutations } from '@app/features/paywall/ai-usage-limit-handling';-import { Paywall } from '@app/features/paywall/Paywall';-import { PropertyEditorModal } from '@app/features/property/editor/PropertyEditorModal';import { ReminderComposerModal } from '@app/features/reminders/ReminderComposerModal';import { MobileSettingsProvider } from '@app/features/settings/context/mobile-settings';-import { MobileSettings } from '@app/features/settings/MobileSettings';import { NativeShareSheet } from '@app/features/sharing/native-share-sheet/NativeShareSheet';import { ShowFeatureFlag } from '@app/lib/analytics/posthog';import { mountGlobalFocusListener } from '@app/signal/focus';@@ -52,6 +49,7 @@ import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';import { updateCookie } from '@core/util/cookies';+import { lazyNamed } from '@core/util/lazyNamed';import { useUserInfoQuery } from '@queries/auth/user-info';import { queryClient } from '@queries/client';import {@@ -88,6 +86,21 @@ const StarterDatabase = lazy(async () => {return { default: module.StarterDatabase };});+// Modals and mobile-only surfaces stay out of the entry chunk; each one+// renders inside a Suspense boundary and loads when it first mounts.+const Paywall = lazyNamed(+ () => import('@app/features/paywall/Paywall'),+ 'Paywall'+);+const PropertyEditorModal = lazyNamed(+ () => import('@app/features/property/editor/PropertyEditorModal'),+ 'PropertyEditorModal'+);+const MobileSettings = lazyNamed(+ () => import('@app/features/settings/MobileSettings'),+ 'MobileSettings'+);+const AUTH_URLS = [`${ROUTER_BASE_CONCAT}login`,`${ROUTER_BASE_CONCAT}login/popup`,@@ -292,7 +305,9 @@ function LayoutInner(props: RouteSectionProps) {<UserCardDrawer /></Suspense><Show when={isMobile()}>- <MobileSettings />+ <Suspense>+ <MobileSettings />+ </Suspense></Show><MobileViewsRow /><FloatRegiondiff --git a/apps/web/src/components/app/boot-shell.test.ts b/apps/web/src/components/app/boot-shell.test.tsnew file mode 100644index 0000000000..9ff2fe1199--- /dev/null+++ b/apps/web/src/components/app/boot-shell.test.ts@@ -0,0 +1,58 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { dismissBootShell, rememberBootShell } from './boot-shell';++const HINT_KEY = 'macro:boot-shell';++afterEach(() => {+ localStorage.clear();+ document.body.innerHTML = '';+ vi.useRealTimers();+});++describe('rememberBootShell', () => {+ it('merges each part of the layout into one hint', () => {+ rememberBootShell({ rail: ['home', 'mail'] });+ rememberBootShell({ homeComposer: 'agents' });++ expect(JSON.parse(localStorage.getItem(HINT_KEY) ?? '')).toEqual({+ rail: ['home', 'mail'],+ homeComposer: 'agents',+ });+ });++ it('replaces a part that changed', () => {+ rememberBootShell({ rail: ['home', 'mail'] });+ rememberBootShell({ rail: ['home'] });++ expect(JSON.parse(localStorage.getItem(HINT_KEY) ?? '').rail).toEqual([+ 'home',+ ]);+ });++ it('replaces a corrupt hint', () => {+ localStorage.setItem(HINT_KEY, '{not json');++ rememberBootShell({ mobileApp: false });++ expect(JSON.parse(localStorage.getItem(HINT_KEY) ?? '')).toEqual({+ mobileApp: false,+ });+ });+});++describe('dismissBootShell', () => {+ it('fades the shell, then removes it', () => {+ vi.useFakeTimers();+ document.body.innerHTML = '<div id="boot-shell"></div>';++ dismissBootShell();++ expect(document.getElementById('boot-shell')?.dataset.leaving).toBe('');+ vi.advanceTimersByTime(400);+ expect(document.getElementById('boot-shell')).toBeNull();+ });++ it('does nothing once the shell is gone', () => {+ expect(() => dismissBootShell()).not.toThrow();+ });+});diff --git a/apps/web/src/components/app/boot-shell.ts b/apps/web/src/components/app/boot-shell.tsnew file mode 100644index 0000000000..1e151f9c3a--- /dev/null+++ b/apps/web/src/components/app/boot-shell.ts@@ -0,0 +1,46 @@+/**+ * Fades out the static skeleton index.html paints before any JS runs. Called+ * once the app's own frame has mounted, so the screen goes straight from the+ * boot shell to the real shell without a blank frame in between.+ */+export function dismissBootShell(): void {+ const shell = document.getElementById('boot-shell');+ if (!shell || shell.dataset.leaving !== undefined) return;+ shell.dataset.leaving = '';+ const remove = () => shell.remove();+ shell.addEventListener('transitionend', remove, { once: true });+ // transitionend never fires in a background tab or with reduced motion.+ setTimeout(remove, 400);+}++const BOOT_SHELL_HINT_KEY = 'macro:boot-shell';++/** Layout the boot shell in index.html draws on the next load, before JS. */+export type BootShellHint = {+ /** Visible SidebarRail nav item ids, in order. */+ rail?: string[];+ /** Whether the rail shows the Get-the-mobile-app button. */+ mobileApp?: boolean;+ /** Home's composer: the Agents new-chat layout or the legacy greeting. */+ homeComposer?: 'agents' | 'legacy';+};++/** Records part of the current layout for the next load's boot shell. */+export function rememberBootShell(hint: BootShellHint): void {+ try {+ const stored = localStorage.getItem(BOOT_SHELL_HINT_KEY);+ const next = JSON.stringify({ ...parseHint(stored), ...hint });+ if (next !== stored) localStorage.setItem(BOOT_SHELL_HINT_KEY, next);+ } catch {+ // Storage can be unavailable or full; the boot shell has defaults.+ }+}++function parseHint(stored: string | null): BootShellHint {+ try {+ const parsed: unknown = JSON.parse(stored ?? '{}');+ return parsed && typeof parsed === 'object' ? parsed : {};+ } catch {+ return {};+ }+}diff --git a/apps/web/src/components/app/sidebar-next/footer-actions.tsx b/apps/web/src/components/app/sidebar-next/footer-actions.tsxindex 08dffbc5f1..f22adbe836 100644--- a/apps/web/src/components/app/sidebar-next/footer-actions.tsx+++ b/apps/web/src/components/app/sidebar-next/footer-actions.tsx@@ -1,6 +1,7 @@import { useAnalytics } from '@app/lib/analytics/analytics-context';import { globalSplitManager } from '@app/signal/splitLayout';import { SidebarOpenInSplitMenu } from '@components/app/app-sidebar/sidebar';+import { rememberBootShell } from '@components/app/boot-shell';import { UserIcon } from '@core/component/UserIcon';import { useSettingsState } from '@core/constant/SettingsState';import { useSettingsTabAvailable } from '@core/constant/settingsTabsConfig';@@ -11,7 +12,7 @@ import GearIcon from '@phosphor/gear.svg';import GearFillIcon from '@phosphor-fill/gear-fill.svg';import { isRealNamePart, useOwnUserName } from '@queries/auth/user-name-self';import { Button, cn, pressHandlers } from '@ui';-import { createMemo, Show } from 'solid-js';+import { createEffect, createMemo, Show } from 'solid-js';import { NavGlyph } from './nav-glyph';/**@@ -43,6 +44,10 @@ const MobileAppButton = () => {const isActive = () => isSettingsActive() && activeTabId() === 'Mobile App';+ createEffect(() =>+ rememberBootShell({ mobileApp: isTabAvailable('Mobile App') })+ );+const open = (event: MouseEvent) => {event.preventDefault();analytics.track('sidebar_click', { view: 'mobile-app' });diff --git a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsxindex 76a23e0ee0..acb042f663 100644--- a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx+++ b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx@@ -2,10 +2,11 @@ import { useHasActiveChannelsCall } from '@app/features/channels-view/use-has-acimport { useAnalytics } from '@app/lib/analytics/analytics-context';import { globalSplitManager } from '@app/signal/splitLayout';import { navigateToSidebarView } from '@components/app/app-sidebar/sidebar';+import { rememberBootShell } from '@components/app/boot-shell';import { useSplitLayout } from '@components/app/split-layout/layout';import { hotkeyScopeNeutralAttribute } from '@core/dom-selectors';import { cn } from '@ui';-import { For, Show, Suspense } from 'solid-js';+import { createEffect, For, Show, Suspense } from 'solid-js';import { SidebarRailCreateButton } from './create-button';import { FooterActions } from './footer-actions';import { ListNav, type ListNavProps } from './list-nav';@@ -43,6 +44,11 @@ const SidebarRailContent = () => {const layout = useSplitLayout();const hasUnread = useSidebarUnread();+ // The next load's boot shell draws this rail before any JS runs.+ createEffect(() =>+ rememberBootShell({ rail: visibleNavItems(gates()).map((item) => item.id) })+ );+const _openHome = (event: MouseEvent) => {if (event.button !== 0) return;event.preventDefault();diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsxindex 94f631a055..7e3ea25936 100644--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx@@ -1,44 +1,12 @@-import { ActivityRouteView } from '@app/features/activity/route-views';import { parseAgentsRoute } from '@app/features/agents-view/core/route';-import { AgentsRouteView } from '@app/features/agents-view/route-views';import { useSpreadsheetAccess } from '@app/features/block-spreadsheet/primitives/use-spreadsheet-access';import type { EventEditorInitialValues } from '@app/features/calendar/components/composer/event-form-model';import type { CalendarEvent } from '@app/features/calendar/types';-import { CalendarRouteView } from '@app/features/calendar-view/route-views';-import { ChannelsRouteView } from '@app/features/channels-view/route-views';-import { CompaniesRouteView } from '@app/features/crm/route-views';-import { DriveRouteView } from '@app/features/drive-view/route-views';-import { EmailCompose } from '@app/features/email-compose/email-compose';-import { MailRouteView } from '@app/features/email-view/route-views';-import { GettingStartedRouteView } from '@app/features/getting-started/route-views';import { HomeRouteView } from '@app/features/home/route-views';-import {- CallsRouteView,- FoldersRouteView,- RecentRouteView,- SearchRouteView,-} from '@app/features/next-soup/route-views';import { parseProjectRoute } from '@app/features/projects/core/route';-import {- CreateProjectView,- ProjectsListView,- ProjectView,-} from '@app/features/projects/project-view';-import { ReminderEditorSplit } from '@app/features/reminders/ReminderEditorSplit';import { REMINDER_DETAIL_COMPONENT_ID } from '@app/features/reminders/reminder-navigation';-import { RemindersRouteView } from '@app/features/reminders/route-views';-import { ReviewsRouteView } from '@app/features/reviews-view/route-views';-import { RoutineCreator } from '@app/features/routines/routine-creator';-import { SettingsRouteView } from '@app/features/settings/route-views';-import { TasksRouteView } from '@app/features/tasks-view/route-views';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { NOT_FOUND_ROUTE_ID } from '@app/routes/app-route';-import { EventComposerSplit } from '@block-calendar/components/EventComposerSplit';-import { ChannelCompose } from '@block-channel/component/Compose';-import { ComposeSkill } from '@block-md/component/ComposeSkill';-import { ComposeTask } from '@block-md/component/ComposeTask';-import { ComposeDocument } from '@block-md/views/compose-document';-import NotFound from '@core/component/AccessErrorViews/NotFound';import { LoadingBlock } from '@core/component/LoadingBlock';import {DEV_MODE_ENV,@@ -49,7 +17,9 @@ import {} from '@core/constant/featureFlags';import { isTouchDevice } from '@core/mobile/isTouchDevice';import type { ViewId } from '@core/types/view';+import { lazyNamed } from '@core/util/lazyNamed';import {+ type ComponentProps,type JSXElement,lazy,onMount,@@ -63,6 +33,119 @@ import {withAuth,} from './split-router/app-route-shell';+// Views load as their own chunks the first time a split opens them.+const ActivityRouteView = lazyNamed(+ () => import('@app/features/activity/route-views'),+ 'ActivityRouteView'+);+const AgentsRouteView = lazyNamed(+ () => import('@app/features/agents-view/route-views'),+ 'AgentsRouteView'+);+const CalendarRouteView = lazyNamed(+ () => import('@app/features/calendar-view/route-views'),+ 'CalendarRouteView'+);+const ChannelsRouteView = lazyNamed(+ () => import('@app/features/channels-view/route-views'),+ 'ChannelsRouteView'+);+const CompaniesRouteView = lazyNamed(+ () => import('@app/features/crm/route-views'),+ 'CompaniesRouteView'+);+const DriveRouteView = lazyNamed(+ () => import('@app/features/drive-view/route-views'),+ 'DriveRouteView'+);+const EmailCompose = lazyNamed(+ () => import('@app/features/email-compose/email-compose'),+ 'EmailCompose'+);+const MailRouteView = lazyNamed(+ () => import('@app/features/email-view/route-views'),+ 'MailRouteView'+);+const GettingStartedRouteView = lazyNamed(+ () => import('@app/features/getting-started/route-views'),+ 'GettingStartedRouteView'+);+const CallsRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'CallsRouteView'+);+const FoldersRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'FoldersRouteView'+);+const RecentRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'RecentRouteView'+);+const SearchRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'SearchRouteView'+);+const CreateProjectView = lazyNamed(+ () => import('@app/features/projects/project-view'),+ 'CreateProjectView'+);+const ProjectsListView = lazyNamed(+ () => import('@app/features/projects/project-view'),+ 'ProjectsListView'+);+const ProjectView = lazyNamed(+ () => import('@app/features/projects/project-view'),+ 'ProjectView'+);+const ReminderEditorSplit = lazyNamed(+ () => import('@app/features/reminders/ReminderEditorSplit'),+ 'ReminderEditorSplit'+);+const RemindersRouteView = lazyNamed(+ () => import('@app/features/reminders/route-views'),+ 'RemindersRouteView'+);+const ReviewsRouteView = lazyNamed(+ () => import('@app/features/reviews-view/route-views'),+ 'ReviewsRouteView'+);+const RoutineCreator = lazyNamed(+ () => import('@app/features/routines/routine-creator'),+ 'RoutineCreator'+);+const SettingsRouteView = lazyNamed(+ () => import('@app/features/settings/route-views'),+ 'SettingsRouteView'+);+const TasksRouteView = lazyNamed(+ () => import('@app/features/tasks-view/route-views'),+ 'TasksRouteView'+);+const EventComposerSplit = lazyNamed(+ () => import('@block-calendar/components/EventComposerSplit'),+ 'EventComposerSplit'+);+const ChannelCompose = lazyNamed(+ () => import('@block-channel/component/Compose'),+ 'ChannelCompose'+);+const ComposeSkill = lazyNamed(+ () => import('@block-md/component/ComposeSkill'),+ 'ComposeSkill'+);+const ComposeTask = lazyNamed(+ () => import('@block-md/component/ComposeTask'),+ 'ComposeTask'+);+const ComposeDocument = lazyNamed(+ () => import('@block-md/views/compose-document'),+ 'ComposeDocument'+);+const NotFound = lazy(+ () => import('@core/component/AccessErrorViews/NotFound')+);+type ComponentParams = Record<string, unknown>;type ComponentFactory = (params: ComponentParams) => JSXElement;@@ -177,7 +260,9 @@ function ProjectsRouteGate(props: ParentProps) {);}-const GatedCreateProjectView: typeof CreateProjectView = (props) => (+const GatedCreateProjectView = (+ props: ComponentProps<typeof CreateProjectView>+) => (<ProjectsRouteGate><CreateProjectView {...props} /></ProjectsRouteGate>diff --git a/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsx b/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsxindex a5624a0cd8..aac0cd08d4 100644--- a/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsx+++ b/apps/web/src/components/app/split-layout/tests/activity-registration.test.tsx@@ -149,9 +149,13 @@ beforeEach(() => {});afterEach(cleanup);-function renderActivity() {+/** Registry views are lazy chunks; settle the chunk so assertions see the view. */+async function renderActivity() {const activity = resolveComponent('activity');- return render(() => <Suspense>{activity.element()}</Suspense>);+ const result = render(() => <Suspense>{activity.element()}</Suspense>);+ await import('@app/features/activity/route-views');+ await new Promise((resolve) => setTimeout(resolve, 0));+ return result;}describe('calendar layout registration', () => {it('owns desktop chrome but keeps the floating split header on touch', () => {@@ -164,8 +168,8 @@ describe('calendar layout registration', () => {});describe('activity registration', () => {- it('redirects a disabled feed to inbox without mounting or tracking it', () => {- renderActivity();+ it('redirects a disabled feed to inbox without mounting or tracking it', async () => {+ await renderActivity();expect(state.replace).toHaveBeenCalledExactlyOnceWith({next: { type: 'component', id: 'home', entryMetadata: { search: {} } },@@ -181,7 +185,7 @@ describe('activity registration', () => {const [flagsLoaded, setFlagsLoaded] = createSignal(false);state.enabled = flagEnabled;state.flagsLoaded = flagsLoaded;- renderActivity();+ await renderActivity();expect(state.replace).not.toHaveBeenCalled();expect(state.mountActivity).not.toHaveBeenCalled();@@ -212,7 +216,7 @@ describe('activity registration', () => {const [authenticated, setAuthenticated] = createSignal(false);state.authenticated = authenticated;state.enabled = () => true;- renderActivity();+ await renderActivity();expect(screen.getByText('Authenticating')).toBeTruthy();expect(state.mountActivity).not.toHaveBeenCalled();diff --git a/apps/web/src/components/entity-detail/EntityDetail.tsx b/apps/web/src/components/entity-detail/EntityDetail.tsxindex 4c2e2eb023..c7a613b2d1 100644--- a/apps/web/src/components/entity-detail/EntityDetail.tsx+++ b/apps/web/src/components/entity-detail/EntityDetail.tsx@@ -14,10 +14,7 @@ import {MarkdownDetail,type MarkdownDetailContext,} from '@app/features/drive-view/views/MarkdownDetail';-import {- PdfDetail,- type PdfDetailContext,-} from '@app/features/drive-view/views/PdfDetail';+import type { PdfDetailContext } from '@app/features/drive-view/views/PdfDetail';import {UnknownDetail,type UnknownDetailContext,@@ -40,16 +37,24 @@ import { previewBlockTarget } from '@components/app/previewTarget';import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';import type { BlockAlias, BlockName } from '@core/block';import { fileTypeToBlockName } from '@core/constant/allBlocks';+import { lazyNamed } from '@core/util/lazyNamed';import {children,createMemo,type JSX,Match,+ Suspense,Switch,untrack,} from 'solid-js';import type { EntityDetailTarget } from './entity-detail-target';+// PDF.js and its viewer are only needed once a PDF is opened.+const PdfDetail = lazyNamed(+ () => import('@app/features/drive-view/views/PdfDetail'),+ 'PdfDetail'+);+type DocumentDetailContext =| MarkdownDetailContext| CodeDetailContext@@ -222,9 +227,11 @@ export function EntityDetail(props: EntityDetailProps) {</VideoDetail></Match><Match when={blockType() === 'pdf'}>- <PdfDetail documentId={props.target.id}>- {(context) => <>{renderChildren(context)}</>}- </PdfDetail>+ <Suspense>+ <PdfDetail documentId={props.target.id}>+ {(context) => <>{renderChildren(context)}</>}+ </PdfDetail>+ </Suspense></Match><Match when={blockType() === 'unknown'}><UnknownDetail documentId={props.target.id}>diff --git a/apps/web/src/features/block-call/definition.ts b/apps/web/src/features/block-call/definition.tsindex a7f73232d8..f2f0ea0b27 100644--- a/apps/web/src/features/block-call/definition.ts+++ b/apps/web/src/features/block-call/definition.ts@@ -9,14 +9,15 @@ import { callKeys } from '@queries/call/keys';import { queryClient } from '@queries/client';import { callServiceClient } from '@service-call/client';import { err, ok } from 'neverthrow';--import { CallBlockAdapter } from './component/CallBlockAdapter';+import { lazy } from 'solid-js';export const definition = defineBlock({name: 'call',description: '',defaultFilename: 'Call',- component: CallBlockAdapter,+ component: lazy(async () => ({+ default: (await import('./component/CallBlockAdapter')).CallBlockAdapter,+ })),async load(source, _intent) {if (!ENABLE_CALLS) return LoadErrors.MISSING;if (source.type !== 'dss') return LoadErrors.MISSING;diff --git a/apps/web/src/features/block-canvas/definition.ts b/apps/web/src/features/block-canvas/definition.tsindex 279c28dec0..44ab0d213f 100644--- a/apps/web/src/features/block-canvas/definition.ts+++ b/apps/web/src/features/block-canvas/definition.ts@@ -9,13 +9,13 @@ import { fetchBinaryDocumentData } from '@queries/storage/binary-document';import { fetchBinary } from '@service-storage/util/fetchBinary';import { makeFileFromBlob } from '@service-storage/util/makeFileFromBlob';import { err, ok } from 'neverthrow';-import CanvasBlock from './component/Block';+import { lazy } from 'solid-js';import type { Canvas } from './model/CanvasModel';export const definition = defineBlock({name: 'canvas',description: 'edit canvas',- component: CanvasBlock,+ component: lazy(() => import('./component/Block')),accepted: {canvas: 'application/x-macro-canvas',},diff --git a/apps/web/src/features/block-channel/definition.ts b/apps/web/src/features/block-channel/definition.tsindex 5ac015e3f3..9adc1f419c 100644--- a/apps/web/src/features/block-channel/definition.ts+++ b/apps/web/src/features/block-channel/definition.ts@@ -1,12 +1,14 @@import { defineBlock, type ExtractLoadType, LoadErrors } from '@core/block';import { ok } from 'neverthrow';--import { NewChannelBlockAdapter } from './component/NewChannelBlockAdapter';+import { lazy } from 'solid-js';export const definition = defineBlock({name: 'channel',description: '',- component: NewChannelBlockAdapter,+ component: lazy(async () => ({+ default: (await import('./component/NewChannelBlockAdapter'))+ .NewChannelBlockAdapter,+ })),liveTrackingEnabled: true,async load(source, _intent) {if (source.type === 'dss') {diff --git a/apps/web/src/features/block-chat/definition.ts b/apps/web/src/features/block-chat/definition.tsindex 1520a20471..54d16fd6b9 100644--- a/apps/web/src/features/block-chat/definition.ts+++ b/apps/web/src/features/block-chat/definition.ts@@ -9,7 +9,7 @@ import { fetchAndCacheChat } from '@queries/cognition/chat-data';import type { Entity } from '@service-cognition/generated/schemas/entity';import type { DocumentMetadata } from '@service-storage/generated/schemas/documentMetadata';import { err, ok } from 'neverthrow';-import BlockChat from './component/Block';+import { lazy } from 'solid-js';export const DEFAULT_CHAT_NAME = 'New Chat';@@ -19,7 +19,7 @@ export const definition = defineBlock({name: 'chat',description: '',defaultFilename: DEFAULT_CHAT_NAME,- component: BlockChat,+ component: lazy(() => import('./component/Block')),liveTrackingEnabled: true,async load(source, intent) {if (source.type === 'dss') {diff --git a/apps/web/src/features/block-code/definition.ts b/apps/web/src/features/block-code/definition.tsindex ab591d8b31..b34e2d6fc5 100644--- a/apps/web/src/features/block-code/definition.ts+++ b/apps/web/src/features/block-code/definition.ts@@ -6,14 +6,14 @@ import {} from '@core/block';import { storageServiceClient } from '@service-storage/client';import { err, ok } from 'neverthrow';-import BlockCode from './component/Block';+import { lazy } from 'solid-js';import { supportedExtensions } from './util/languageSupport';export const definition = defineBlock({name: 'code',description: 'Edit code files with syntax highlighting and formatting',aliases: [{ name: 'csv', defaultFileName: 'New CSV' }],- component: BlockCode,+ component: lazy(() => import('./component/Block')),async load(source, intent) {if (intent === 'preload') {return ok({diff --git a/apps/web/src/features/block-company/definition.ts b/apps/web/src/features/block-company/definition.tsindex 86baffeaa3..af5335e83c 100644--- a/apps/web/src/features/block-company/definition.ts+++ b/apps/web/src/features/block-company/definition.ts@@ -1,12 +1,14 @@import { defineBlock, type ExtractLoadType, LoadErrors } from '@core/block';import { ok } from 'neverthrow';--import { CompanyBlockAdapter } from './component/CompanyBlockAdapter';+import { lazy } from 'solid-js';export const definition = defineBlock({name: 'company',description: 'View a CRM company',- component: CompanyBlockAdapter,+ component: lazy(async () => ({+ default: (await import('./component/CompanyBlockAdapter'))+ .CompanyBlockAdapter,+ })),liveTrackingEnabled: false,async load(source, _intent) {if (source.type === 'dss') {diff --git a/apps/web/src/features/block-contact/definition.ts b/apps/web/src/features/block-contact/definition.tsindex 91f32df703..55075233b6 100644--- a/apps/web/src/features/block-contact/definition.ts+++ b/apps/web/src/features/block-contact/definition.ts@@ -1,12 +1,14 @@import { defineBlock, type ExtractLoadType, LoadErrors } from '@core/block';import { ok } from 'neverthrow';--import { ContactBlockAdapter } from './component/ContactBlockAdapter';+import { lazy } from 'solid-js';export const definition = defineBlock({name: 'contact',description: 'View a CRM contact',- component: ContactBlockAdapter,+ component: lazy(async () => ({+ default: (await import('./component/ContactBlockAdapter'))+ .ContactBlockAdapter,+ })),liveTrackingEnabled: false,async load(source, _intent) {if (source.type === 'dss') {diff --git a/apps/web/src/features/block-email/definition.ts b/apps/web/src/features/block-email/definition.tsindex a8e6493277..6d9f751573 100644--- a/apps/web/src/features/block-email/definition.ts+++ b/apps/web/src/features/block-email/definition.ts@@ -1,11 +1,11 @@import { defineBlock, LoadErrors } from '@core/block';import { ok } from 'neverthrow';-import EmailBlock from './component/Block';+import { lazy } from 'solid-js';export const definition = defineBlock({name: 'email',description: 'View and manage email threads',- component: EmailBlock,+ component: lazy(() => import('./component/Block')),liveTrackingEnabled: true,syncServiceEnabled: false,defaultFilename: '[No subject]',diff --git a/apps/web/src/features/block-md/definition.ts b/apps/web/src/features/block-md/definition.tsindex 2a994bd55d..cf1d930fcd 100644--- a/apps/web/src/features/block-md/definition.ts+++ b/apps/web/src/features/block-md/definition.ts@@ -4,7 +4,7 @@ import { fetchSyncDocumentOpenContext } from '@queries/storage/documentLoad/syncimport { makeFileFromBlob } from '@service-storage/util/makeFileFromBlob';import { createSyncServiceSource } from '@service-sync/source';import { err, ok } from 'neverthrow';-import MarkdownBlock from './component/Block';+import { lazy } from 'solid-js';import {endDocumentSpan,registerDocumentSpan,@@ -21,7 +21,7 @@ export const definition = defineBlock({{ name: 'snippet', defaultFileName: 'New Snippet' },{ name: 'skill', defaultFileName: 'New Skill' },],- component: MarkdownBlock,+ component: lazy(() => import('./component/Block')),accepted: {md: 'text/markdown',},diff --git a/apps/web/src/features/block-unknown/definition.ts b/apps/web/src/features/block-unknown/definition.tsindex 9cef4a04f4..7e79f8d7e3 100644--- a/apps/web/src/features/block-unknown/definition.ts+++ b/apps/web/src/features/block-unknown/definition.ts@@ -6,12 +6,12 @@ import {} from '@core/block';import { storageServiceClient } from '@service-storage/client';import { err, ok } from 'neverthrow';-import BlockUnknown from './component/Block';+import { lazy } from 'solid-js';export const definition = defineBlock({name: 'unknown',description: 'fallback block for unknown files types',- component: BlockUnknown,+ component: lazy(() => import('./component/Block')),async load(source, intent) {if (source.type === 'dss') {const maybeDocument = await loadResult(diff --git a/apps/web/src/features/block-video/definition.ts b/apps/web/src/features/block-video/definition.tsindex 7edafbb25d..db2dabf0f4 100644--- a/apps/web/src/features/block-video/definition.ts+++ b/apps/web/src/features/block-video/definition.ts@@ -8,7 +8,7 @@ import { toast } from '@core/component/Toast/Toast';import { storageServiceClient } from '@service-storage/client';import { getPresignedUrl } from '@service-storage/util/presignedUrl';import { err, ok } from 'neverthrow';-import BlockVideo from './component/Block';+import { lazy } from 'solid-js';import {isVideoPlaybackEnabled,PLAYBACK_ENABLED_MIMES,@@ -20,7 +20,7 @@ export { PLAYBACK_ENABLED_MIMES, VIDEO_MIMES };export const definition = defineBlock({name: 'video',description: 'block for video file types',- component: BlockVideo,+ component: lazy(() => import('./component/Block')),liveTrackingEnabled: false,accepted: VIDEO_MIMES,async load(source, intent) {diff --git a/apps/web/src/features/home/components/HomeChatStart.tsx b/apps/web/src/features/home/components/HomeChatStart.tsxindex cf61b2b023..322592c6a0 100644--- a/apps/web/src/features/home/components/HomeChatStart.tsx+++ b/apps/web/src/features/home/components/HomeChatStart.tsx@@ -4,10 +4,11 @@ import {ViewSidebar,} from '@app/components/view-shell';import { useFeatureFlag } from '@app/lib/analytics/posthog';+import { rememberBootShell } from '@components/app/boot-shell';import { DragDropWrapper } from '@core/component/AI/component/DragDrop';import { ChatInputProvider } from '@core/component/AI/context';import { enableChatV3Agents } from '@core/constant/featureFlags';-import { Show } from 'solid-js';+import { createEffect, Show } from 'solid-js';import { HomeChatInput } from '../home-chat-input';import { HomeGettingStartedLink } from '../home-getting-started-link';import { useHomePreferences } from '../home-prefs';@@ -20,6 +21,11 @@ export function HomeChatStart() {const preferences = useHomePreferences();const showHomeTopBar = () =>shell.aside.isCollapsed() || shell.aside.isOverlay();+ // The next load's boot shell draws this greeting and composer layout.+ createEffect(() => {+ if (agents().loading) return;+ rememberBootShell({ homeComposer: agents().enabled ? 'agents' : 'legacy' });+ });return (<ChatInputProvider><Show when={showHomeTopBar()}>diff --git a/apps/web/src/features/home/home-view.tsx b/apps/web/src/features/home/home-view.tsxindex fadb5a3fdc..55217c63b4 100644--- a/apps/web/src/features/home/home-view.tsx+++ b/apps/web/src/features/home/home-view.tsx@@ -1,6 +1,5 @@import { useViewShell, ViewShell } from '@app/components/view-shell';import { calendarSearch } from '@app/features/calendar-view/calendar-url';-import { CalendarView } from '@app/features/calendar-view/calendar-view';import { ViewTour } from '@app/features/tours/ViewTour';import { createSearchParams, SplitRouter } from '@app/lib/split-router';import { homeCalendarRoute } from '@app/routes/routes';@@ -12,6 +11,7 @@ import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';import { SplitPanel } from '@components/app/split-panel';import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { lazyNamed } from '@core/util/lazyNamed';import { ListEntityMetadataQueryProvider } from '@entity';import { createEffect, onMount, Show } from 'solid-js';import { HomeChatStart } from './components/HomeChatStart';@@ -24,6 +24,12 @@ import { HomeViewProvider, useHomeView } from './home-view-context';import { homeTour } from './tour';import type { HomeViewStateOptions } from './types';+// The calendar grid (FullCalendar) only loads once Home's calendar route opens.+const CalendarView = lazyNamed(+ () => import('@app/features/calendar-view/calendar-view'),+ 'CalendarView'+);+export type HomeViewProps = {/** Explicit navigation state. When present, it wins over entry restoration. */initialState?: HomeViewStateOptions;diff --git a/apps/web/src/features/routines/definition.ts b/apps/web/src/features/routines/definition.tsindex f07d33446f..2616a74a84 100644--- a/apps/web/src/features/routines/definition.ts+++ b/apps/web/src/features/routines/definition.ts@@ -1,13 +1,14 @@import { defineBlock, type ExtractLoadType, LoadErrors } from '@core/block';import { ok } from 'neverthrow';--import { Routine } from './routine-detail';+import { lazy } from 'solid-js';export const definition = defineBlock({name: 'routine',description: 'view and edit a single routine',defaultFilename: 'Untitled routine',- component: Routine,+ component: lazy(async () => ({+ default: (await import('./routine-detail')).Routine,+ })),accepted: {},async load(source, intent) {if (source.type === 'dss') {diff --git a/apps/web/src/features/theme/signals/themeSignals.ts b/apps/web/src/features/theme/signals/themeSignals.tsindex 309ebd4b7a..993db6f7d5 100644--- a/apps/web/src/features/theme/signals/themeSignals.ts+++ b/apps/web/src/features/theme/signals/themeSignals.ts@@ -22,8 +22,9 @@ import { isThemeV2, isThemeV3 } from '../utils/themeValidation';export const [isThemeSaved, setIsThemeSaved] = createSignal<boolean>(true);+/** First-paint colors for index.html: page (`color`), panel, and ink. */export const [htmlColor, setHtmlColor] = makePersisted(- createSignal({ color: '' }),+ createSignal<{ color: string; panel?: string; ink?: string }>({ color: '' }),{ name: 'html-color-theme' });diff --git a/apps/web/src/features/theme/utils/themeUtils.ts b/apps/web/src/features/theme/utils/themeUtils.tsindex 8d54d603b4..c706c733cd 100644--- a/apps/web/src/features/theme/utils/themeUtils.ts+++ b/apps/web/src/features/theme/utils/themeUtils.ts@@ -235,7 +235,12 @@ export function systemThemeEffect(): void {/** Only committed colors affect browser/notification icons and first paint. */function syncCommittedColors(): void {const colors = resolvedThemeColors();- setHtmlColor({ color: formatOklch(colors['surface-0']) });+ // index.html reads these before any JS loads to paint the boot shell.+ setHtmlColor({+ color: formatOklch(colors['surface-0']),+ panel: formatOklch(colors['surface-1']),+ ink: formatOklch(colors['content-0']),+ });setCommittedThemeAccent(formatOklch(colors.accent));}diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsxindex 4c9e8dccad..7a290ae61d 100644--- a/apps/web/src/index.tsx+++ b/apps/web/src/index.tsx@@ -13,6 +13,10 @@ import { platformFetch } from '@core/util/platformFetch';import { initMonochromeIcons } from '@ui/utils/monochromeIcons';import { ErrorBoundary, render } from 'solid-js/web';import { FatalError } from './components/app/FatalError';+import {+ isNewerBuildAvailable,+ registerServiceWorker,+} from './lib/service-worker/register';import { Root } from './routes/Root';// Override global fetch with platformFetch for Tauri compatibility@@ -96,12 +100,19 @@ async function main() {if (!import.meta.hot) {// this event is emitted when dynamically loading a module fails// for example when you're using the app and a new version is deployed- window.addEventListener('vite:preloadError', () =>- window.alert('Please refresh page to update app to new version')- );+ window.addEventListener('vite:preloadError', (event) => {+ // The service worker already cached the newer build; move to it.+ if (isNewerBuildAvailable()) {+ event.preventDefault();+ window.location.reload();+ return;+ }+ window.alert('Please refresh page to update app to new version');+ });}renderApp();+ registerServiceWorker();}// unawaiteddiff --git a/apps/web/src/lib/core/component/Emoji/emojis.test.ts b/apps/web/src/lib/core/component/Emoji/emoji-catalog.test.tssimilarity index 98%rename from apps/web/src/lib/core/component/Emoji/emojis.test.tsrename to apps/web/src/lib/core/component/Emoji/emoji-catalog.test.tsindex 69d38b0573..4d1cc6dfc2 100644--- a/apps/web/src/lib/core/component/Emoji/emojis.test.ts+++ b/apps/web/src/lib/core/component/Emoji/emoji-catalog.test.ts@@ -1,5 +1,5 @@import { afterEach, describe, expect, it } from 'vitest';-import { resolveEmoji, searchEmojis } from './emojis';+import { resolveEmoji, searchEmojis } from './emoji-catalog';import {clearEmojiUsage,frequentEmojiChars,diff --git a/apps/web/src/lib/core/component/Emoji/emoji-catalog.ts b/apps/web/src/lib/core/component/Emoji/emoji-catalog.tsnew file mode 100644index 0000000000..0f55aa701f--- /dev/null+++ b/apps/web/src/lib/core/component/Emoji/emoji-catalog.ts@@ -0,0 +1,193 @@+import GithubShortcodes from 'emojibase-data/en/shortcodes/github.json';+import EmojiLib from 'emojilib';+import { match } from 'ts-pattern';+import GroupedEmojiData from 'unicode-emoji-json/data-by-group.json';+import OrderedEmojiData from 'unicode-emoji-json/data-ordered-emoji.json';+import CldrTags from './cldr-tags.json';+import { emojiUsageCount, frequentEmojiChars } from './emojiUsage';++export type SimpleEmoji = {+ emoji: string;+ slug: string;+ shortcodes: string[];+ terms: string[];+};++// emojibase appends FE0F variation selectors where unicode-emoji-json (and our+// stored reactions) use the bare canonical form, so both sides of the shortcode+// join drop FE0F. Emitted emoji strings always come from unicode-emoji-json.+function fe0fInsensitiveKey(codepoints: string[]): string {+ return codepoints.filter((hex) => hex !== 'FE0F').join('-');+}++const SHORTCODES_BY_KEY = new Map<string, string[]>(+ Object.entries(GithubShortcodes).map(([hexcode, codes]) => [+ fe0fInsensitiveKey(hexcode.split('-')),+ Array.isArray(codes) ? codes : [codes],+ ])+);++function emojiKey(emoji: string): string {+ return fe0fInsensitiveKey(+ [...emoji].map(+ (char) => char.codePointAt(0)?.toString(16).toUpperCase() ?? ''+ )+ );+}++function buildEmoji(emoji: string): SimpleEmoji {+ const keywords = EmojiLib[emoji] ?? [];+ const github = SHORTCODES_BY_KEY.get(emojiKey(emoji));+ const shortcodes = github ?? [keywords.at(0) ?? emoji];+ const cldrTags: string[] =+ (CldrTags as Record<string, string[]>)[emojiKey(emoji)] ?? [];+ const terms = [...new Set([...keywords, ...cldrTags])];+ return { emoji, slug: shortcodes[0], shortcodes, terms };+}++const ORDERED_EMOJI_DATA: SimpleEmoji[] = OrderedEmojiData.map(buildEmoji);++const EMOJI_BY_CHAR = new Map(+ ORDERED_EMOJI_DATA.map((entry) => [entry.emoji, entry])+);++const EMOJI_DATA_GROUPED = GroupedEmojiData.map((group) => {+ return {+ name: group.name,+ emojis: group.emojis.map(+ ({ emoji }) => EMOJI_BY_CHAR.get(emoji) ?? buildEmoji(emoji)+ ),+ };+});++const EMOJI_BY_NAME = new Map<string, string>();+for (const { emoji, shortcodes } of ORDERED_EMOJI_DATA) {+ for (const name of shortcodes) {+ if (!EMOJI_BY_NAME.has(name)) {+ EMOJI_BY_NAME.set(name, emoji);+ }+ }+}++export function resolveEmoji(key: string): string | undefined {+ return EMOJI_BY_NAME.get(key.replaceAll(':', '').toLowerCase());+}++// Lower tier = better match. Exact shortcode first, then one shared tier for+// exact keywords and shortcode prefixes (CLDR keywords are inconsistent+// enough that neither should dominate the other — "thumbs" is a keyword of+// thumbs_down only), then keyword prefixes, word boundaries, and substrings.+function tokenScore(token: string, entry: SimpleEmoji): number {+ return match(entry)+ .when(+ ({ shortcodes }) => shortcodes.includes(token),+ () => 0+ )+ .when(+ ({ shortcodes, terms }) =>+ terms.includes(token) ||+ shortcodes.some((code) => code.startsWith(token)),+ () => 1+ )+ .when(+ ({ terms }) => terms.some((term) => term.startsWith(token)),+ () => 2+ )+ .when(+ ({ shortcodes }) => shortcodes.some((code) => code.includes(`_${token}`)),+ () => 3+ )+ .when(+ ({ terms }) =>+ terms.some(+ (term) => term.includes(`_${token}`) || term.includes(` ${token}`)+ ),+ () => 4+ )+ .when(+ ({ shortcodes }) => shortcodes.some((code) => code.includes(token)),+ () => 5+ )+ .when(+ ({ terms }) => terms.some((term) => term.includes(token)),+ () => 6+ )+ .otherwise(() => -1);+}++export function searchEmojis(query: string): SimpleEmoji[] {+ const tokens = query+ .trim()+ .toLowerCase()+ .split(/[\s_]+/)+ .filter(Boolean);+ if (tokens.length === 0) {+ return ORDERED_EMOJI_DATA;+ }++ const joined = tokens.join('_');+ const scored: {+ entry: SimpleEmoji;+ score: number;+ usage: number;+ order: number;+ }[] = [];+ for (let order = 0; order < ORDERED_EMOJI_DATA.length; order++) {+ const entry = ORDERED_EMOJI_DATA[order];+ let score = tokenScore(joined, entry);+ if (tokens.length > 1) {+ const perToken = tokens.map((token) => tokenScore(token, entry));+ if (perToken.every((tier) => tier >= 0)) {+ const mean =+ perToken.reduce((sum, tier) => sum + tier, 0) / tokens.length;+ if (score < 0 || mean < score) {+ score = mean;+ }+ }+ }+ if (score >= 0) {+ scored.push({ entry, score, usage: emojiUsageCount(entry.emoji), order });+ }+ }++ // Usage only breaks ties within a match tier, so exact matches stay on top+ // no matter how often another emoji is picked.+ scored.sort(+ (a, b) => a.score - b.score || b.usage - a.usage || a.order - b.order+ );+ return scored.map(({ entry }) => entry);+}++const FREQUENT_EMOJI_LIMIT = 12;++function frequentEmojis(): SimpleEmoji[] {+ return frequentEmojiChars(FREQUENT_EMOJI_LIMIT)+ .map((emoji) => EMOJI_BY_CHAR.get(emoji))+ .filter((entry): entry is SimpleEmoji => entry !== undefined);+}++/** Every emoji, frequently used first, or the ranked matches for `query`. */+export function emojisForQuery(query: string): SimpleEmoji[] {+ if (!query || query.trim().length <= 1) {+ const frequent = frequentEmojis();+ if (frequent.length === 0) {+ return ORDERED_EMOJI_DATA;+ }+ const frequentSet = new Set(frequent.map(({ emoji }) => emoji));+ return [+ ...frequent,+ ...ORDERED_EMOJI_DATA.filter(({ emoji }) => !frequentSet.has(emoji)),+ ];+ }++ return searchEmojis(query);+}++/** The picker's groups, with a "Frequently used" group once there is usage. */+export function emojiGroups(): { name: string; emojis: SimpleEmoji[] }[] {+ const frequent = frequentEmojis();+ if (frequent.length === 0) {+ return EMOJI_DATA_GROUPED;+ }+ return [{ name: 'Frequently used', emojis: frequent }, ...EMOJI_DATA_GROUPED];+}diff --git a/apps/web/src/lib/core/component/Emoji/emojis.ts b/apps/web/src/lib/core/component/Emoji/emojis.tsindex 20f3578e8b..f89c840e4f 100644--- a/apps/web/src/lib/core/component/Emoji/emojis.ts+++ b/apps/web/src/lib/core/component/Emoji/emojis.ts@@ -1,205 +1,50 @@-import GithubShortcodes from 'emojibase-data/en/shortcodes/github.json';-import EmojiLib from 'emojilib';import { createMemo, createSignal } from 'solid-js';-import { match } from 'ts-pattern';-import GroupedEmojiData from 'unicode-emoji-json/data-by-group.json';-import OrderedEmojiData from 'unicode-emoji-json/data-ordered-emoji.json';-import CldrTags from './cldr-tags.json';-import { emojiUsageCount, frequentEmojiChars } from './emojiUsage';+import type { SimpleEmoji } from './emoji-catalog';-export type SimpleEmoji = {- emoji: string;- slug: string;- shortcodes: string[];- terms: string[];-};--// emojibase appends FE0F variation selectors where unicode-emoji-json (and our-// stored reactions) use the bare canonical form, so both sides of the shortcode-// join drop FE0F. Emitted emoji strings always come from unicode-emoji-json.-function fe0fInsensitiveKey(codepoints: string[]): string {- return codepoints.filter((hex) => hex !== 'FE0F').join('-');-}--const SHORTCODES_BY_KEY = new Map<string, string[]>(- Object.entries(GithubShortcodes).map(([hexcode, codes]) => [- fe0fInsensitiveKey(hexcode.split('-')),- Array.isArray(codes) ? codes : [codes],- ])-);--function emojiKey(emoji: string): string {- return fe0fInsensitiveKey(- [...emoji].map(- (char) => char.codePointAt(0)?.toString(16).toUpperCase() ?? ''- )- );-}--function buildEmoji(emoji: string): SimpleEmoji {- const keywords = EmojiLib[emoji] ?? [];- const github = SHORTCODES_BY_KEY.get(emojiKey(emoji));- const shortcodes = github ?? [keywords.at(0) ?? emoji];- const cldrTags: string[] =- (CldrTags as Record<string, string[]>)[emojiKey(emoji)] ?? [];- const terms = [...new Set([...keywords, ...cldrTags])];- return { emoji, slug: shortcodes[0], shortcodes, terms };-}--const ORDERED_EMOJI_DATA: SimpleEmoji[] = OrderedEmojiData.map(buildEmoji);+export type { SimpleEmoji } from './emoji-catalog';-const EMOJI_BY_CHAR = new Map(- ORDERED_EMOJI_DATA.map((entry) => [entry.emoji, entry])-);+type EmojiCatalog = typeof import('./emoji-catalog');-const EMOJI_DATA_GROUPED = GroupedEmojiData.map((group) => {- return {- name: group.name,- emojis: group.emojis.map(- ({ emoji }) => EMOJI_BY_CHAR.get(emoji) ?? buildEmoji(emoji)- ),- };-});+// The emoji tables are several hundred KB, so they load as their own chunk the+// first time a picker or the `:` menu reads them rather than at app start.+const [catalog, setCatalog] = createSignal<EmojiCatalog>();+let catalogLoad: Promise<EmojiCatalog> | undefined;-const EMOJI_BY_NAME = new Map<string, string>();-for (const { emoji, shortcodes } of ORDERED_EMOJI_DATA) {- for (const name of shortcodes) {- if (!EMOJI_BY_NAME.has(name)) {- EMOJI_BY_NAME.set(name, emoji);- }- }+function loadEmojiCatalog(): Promise<EmojiCatalog> {+ catalogLoad ??= import('./emoji-catalog').then((module) => {+ setCatalog(() => module);+ return module;+ });+ return catalogLoad;}+/** Resolves `:shortcode:` once the catalog has loaded; starts the load otherwise. */export function resolveEmoji(key: string): string | undefined {- return EMOJI_BY_NAME.get(key.replaceAll(':', '').toLowerCase());-}--// Lower tier = better match. Exact shortcode first, then one shared tier for-// exact keywords and shortcode prefixes (CLDR keywords are inconsistent-// enough that neither should dominate the other — "thumbs" is a keyword of-// thumbs_down only), then keyword prefixes, word boundaries, and substrings.-function tokenScore(token: string, entry: SimpleEmoji): number {- return match(entry)- .when(- ({ shortcodes }) => shortcodes.includes(token),- () => 0- )- .when(- ({ shortcodes, terms }) =>- terms.includes(token) ||- shortcodes.some((code) => code.startsWith(token)),- () => 1- )- .when(- ({ terms }) => terms.some((term) => term.startsWith(token)),- () => 2- )- .when(- ({ shortcodes }) => shortcodes.some((code) => code.includes(`_${token}`)),- () => 3- )- .when(- ({ terms }) =>- terms.some(- (term) => term.includes(`_${token}`) || term.includes(` ${token}`)- ),- () => 4- )- .when(- ({ shortcodes }) => shortcodes.some((code) => code.includes(token)),- () => 5- )- .when(- ({ terms }) => terms.some((term) => term.includes(token)),- () => 6- )- .otherwise(() => -1);-}--export function searchEmojis(query: string): SimpleEmoji[] {- const tokens = query- .trim()- .toLowerCase()- .split(/[\s_]+/)- .filter(Boolean);- if (tokens.length === 0) {- return ORDERED_EMOJI_DATA;- }-- const joined = tokens.join('_');- const scored: {- entry: SimpleEmoji;- score: number;- usage: number;- order: number;- }[] = [];- for (let order = 0; order < ORDERED_EMOJI_DATA.length; order++) {- const entry = ORDERED_EMOJI_DATA[order];- let score = tokenScore(joined, entry);- if (tokens.length > 1) {- const perToken = tokens.map((token) => tokenScore(token, entry));- if (perToken.every((tier) => tier >= 0)) {- const mean =- perToken.reduce((sum, tier) => sum + tier, 0) / tokens.length;- if (score < 0 || mean < score) {- score = mean;- }- }- }- if (score >= 0) {- scored.push({ entry, score, usage: emojiUsageCount(entry.emoji), order });- }+ const loaded = catalog();+ if (!loaded) {+ void loadEmojiCatalog();+ return undefined;}-- // Usage only breaks ties within a match tier, so exact matches stay on top- // no matter how often another emoji is picked.- scored.sort(- (a, b) => a.score - b.score || b.usage - a.usage || a.order - b.order- );- return scored.map(({ entry }) => entry);-}--const FREQUENT_EMOJI_LIMIT = 12;--function frequentEmojis(): SimpleEmoji[] {- return frequentEmojiChars(FREQUENT_EMOJI_LIMIT)- .map((emoji) => EMOJI_BY_CHAR.get(emoji))- .filter((entry): entry is SimpleEmoji => entry !== undefined);+ return loaded.resolveEmoji(key);}export const useEmojiData = () => {const [query, setQuery] = createSignal('');- const emojis = createMemo(() => {- if (!query() || query().trim().length <= 1) {- const frequent = frequentEmojis();- if (frequent.length === 0) {- return ORDERED_EMOJI_DATA;- }- const frequentSet = new Set(frequent.map(({ emoji }) => emoji));- return [- ...frequent,- ...ORDERED_EMOJI_DATA.filter(({ emoji }) => !frequentSet.has(emoji)),- ];- }-- return searchEmojis(query());- });-- const groups = createMemo(() => {- const frequent = frequentEmojis();- if (frequent.length === 0) {- return EMOJI_DATA_GROUPED;- }- return [- { name: 'Frequently used', emojis: frequent },- ...EMOJI_DATA_GROUPED,- ];- });+ const emojis = createMemo(+ (): SimpleEmoji[] => catalog()?.emojisForQuery(query()) ?? []+ );+ const groups = createMemo(() => catalog()?.emojiGroups() ?? []);return {- groups,- emojis,+ groups: () => {+ void loadEmojiCatalog();+ return groups();+ },+ emojis: () => {+ void loadEmojiCatalog();+ return emojis();+ },filter: (query: string) => {setQuery(query);},diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsxindex d1f6b63e52..27e2e0af3a 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx@@ -7,6 +7,7 @@ import { ENABLE_BLOCK_IN_BLOCK } from '@core/constant/featureFlags';import { canNestBlock, createBlockInstance } from '@core/orchestrator';import { blockElementSignal } from '@core/signal/blockElement';import { getDisplayName, tryMacroId } from '@core/user';+import { lazyNamed } from '@core/util/lazyNamed';import { matches } from '@core/util/match';import {$convertCardToMention,@@ -64,10 +65,14 @@ import { UPDATE_DOCUMENT_NAME_COMMAND } from '../../plugins';import { removeNodeAndRestoreSelection } from '../../plugins/shared/removeNodeAndRestoreSelection';import { dispatchInternalLayoutShift } from '../../plugins/shared/utils';import { BlockLink } from '../core/BlockLink';-import { ChannelMessageThreadCard } from './ChannelMessageThreadCard';false && floatWithElement;+const ChannelMessageThreadCard = lazyNamed(+ () => import('./ChannelMessageThreadCard'),+ 'ChannelMessageThreadCard'+);+const stringifyPreviewBox = ([width, height]: PreviewBox): [string, string] => {const widthStr = typeof width === 'string' ? width : `${width}px`;const heightStr = typeof height === 'string' ? height : `${height}px`;@@ -245,10 +250,12 @@ function DocumentCardInner(props: DocumentCardDecoratorProps) {} else {getElement = () => (<div class="p-2">- <ChannelMessageThreadCard- channelId={props.documentId}- messageId={msgId!}- />+ <Suspense>+ <ChannelMessageThreadCard+ channelId={props.documentId}+ messageId={msgId!}+ />+ </Suspense></div>);}diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/init.ts b/apps/web/src/lib/core/component/LexicalMarkdown/init.tsindex 46703ba986..5038cd1474 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/init.ts+++ b/apps/web/src/lib/core/component/LexicalMarkdown/init.ts@@ -1,3 +1,4 @@+import { lazyNamed } from '@core/util/lazyNamed';import {AgentContextNode,AgentSessionMentionNode,@@ -31,6 +32,8 @@ import {clearDecorators,setDecorator,} from '@macro-inc/lexical-core/decoratorRegistry';+import type { HtmlRenderDecoratorProps } from '@macro-inc/lexical-core/nodes/HtmlRenderNode';+import { createComponent, Suspense } from 'solid-js';import { AgentContext } from './component/decorator/AgentContext';import { AgentSessionMention } from './component/decorator/AgentSessionMention';import { Await } from './component/decorator/Await';@@ -45,7 +48,6 @@ import { DocumentMention } from './component/decorator/DocumentMention';import { Equation } from './component/decorator/Equation';import { GroupMention } from './component/decorator/GroupMention';import { HorizontalRule } from './component/decorator/HorizontalRule';-import { HtmlRender } from './component/decorator/HtmlRender';import { MagicChip } from './component/decorator/MagicChip';import { MarkdownImage } from './component/decorator/MarkdownImage';import { MarkdownVideo } from './component/decorator/MarkdownVideo';@@ -60,6 +62,19 @@ import { UserMention } from './component/decorator/UserMention';import { Watermark } from './component/decorator/Watermark';import { registerDiffNodeFactory } from './component/dom-factory/diff-factory';+// The email HTML renderer (parse5, css-tree) loads with the first rendered+// HTML node. Its own Suspense keeps a loading node from suspending the editor.+const LazyHtmlRender = lazyNamed(+ () => import('./component/decorator/HtmlRender'),+ 'HtmlRender'+);+const HtmlRender = (props: HtmlRenderDecoratorProps) =>+ createComponent(Suspense, {+ get children() {+ return createComponent(LazyHtmlRender, props);+ },+ });+/*** This has to run once before any Lexicals mount. Currently imported in index.tsx.*/diff --git a/apps/web/src/lib/core/util/lazyNamed.ts b/apps/web/src/lib/core/util/lazyNamed.tsnew file mode 100644index 0000000000..00fd258d46--- /dev/null+++ b/apps/web/src/lib/core/util/lazyNamed.ts@@ -0,0 +1,12 @@+import { type Component, lazy } from 'solid-js';++/**+ * `lazy()` for a named export: the module becomes its own chunk, loaded the+ * first time the component renders or `preload()` is called.+ */+export function lazyNamed<+ K extends string,+ M extends Record<K, Component<any>>,+>(load: () => Promise<M>, name: K) {+ return lazy(async () => ({ default: (await load())[name] }));+}diff --git a/apps/web/src/lib/service-worker/register.ts b/apps/web/src/lib/service-worker/register.tsnew file mode 100644index 0000000000..c522d7a165--- /dev/null+++ b/apps/web/src/lib/service-worker/register.ts@@ -0,0 +1,109 @@+import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';+import { isTauri } from '@core/util/platform';+import { reloadForNewerBuild } from '@core/util/reloadForNewerBuild';++/**+ * Set localStorage `macro:sw` to `off` to unregister the worker. Its caches+ * are cleared on the first load it no longer controls.+ */+const OPT_OUT_KEY = 'macro:sw';+/** How long after load an untouched tab may silently reload into a newer build. */+const SILENT_RELOAD_WINDOW_MS = 10_000;++let newerBuildAvailable = false;+let interacted = false;++/** The bundle build this page booted, from index.html. */+function runningBuild(): number {+ const content = document+ .querySelector<HTMLMetaElement>('meta[name="macro-bundle-build"]')+ ?.getAttribute('content');+ return Number(content);+}++function optedOut(): boolean {+ try {+ return localStorage.getItem(OPT_OUT_KEY) === 'off';+ } catch {+ return false;+ }+}++async function unregister(): Promise<void> {+ const registrations = await navigator.serviceWorker.getRegistrations();+ await Promise.all(+ registrations.map((registration) => registration.unregister())+ );+ const names = await caches.keys();+ await Promise.all(+ names+ .filter((name) => name.startsWith('macro-'))+ .map((name) => caches.delete(name))+ );+}++/**+ * The worker cached a newer build than this tab runs: a tab that booted the+ * cached shell right after a deploy. Untouched tabs reload straight away (the+ * boot shell shows again); otherwise the regular newer-build flow decides.+ */+function onWorkerMessage(event: MessageEvent<unknown>): void {+ const data = event.data as { type?: unknown; build?: unknown } | null;+ if (data?.type !== 'macro:newer-build') return;+ const running = runningBuild();+ if (!Number.isFinite(running) || Number(data.build) <= running) return;+ newerBuildAvailable = true;+ if (!interacted && performance.now() < SILENT_RELOAD_WINDOW_MS) {+ window.location.reload();+ return;+ }+ reloadForNewerBuild();+}++/**+ * Whether a failed lazy chunk is explained by a newer deployed build, so the+ * tab should reload into it instead of reporting an error.+ */+export function isNewerBuildAvailable(): boolean {+ return newerBuildAvailable;+}++/**+ * Registers public/sw.js, which serves the app shell and hashed assets from+ * Cache Storage so new tabs skip the HTML round trip. Production web only:+ * Tauri ships its own bundle and dev servers rebuild assets in place.+ */+export function registerServiceWorker(): void {+ if (!import.meta.env.PROD || isTauri()) return;+ if (!('serviceWorker' in navigator) || !window.isSecureContext) return;+ if (!window.location.pathname.startsWith(ROUTER_BASE_CONCAT.slice(0, -1))) {+ return;+ }+ if (optedOut()) {+ void unregister().catch(() => {});+ return;+ }++ for (const type of ['pointerdown', 'keydown'] as const) {+ window.addEventListener(type, () => (interacted = true), {+ capture: true,+ once: true,+ });+ }+ navigator.serviceWorker.addEventListener('message', onWorkerMessage);++ // Registration installs the worker, which fetches the shell and entry+ // assets; keep that off the critical path of this load.+ const register = () =>+ navigator.serviceWorker+ .register(`${ROUTER_BASE_CONCAT}sw.js`, { scope: ROUTER_BASE_CONCAT })+ .catch((error: unknown) =>+ console.warn('Service worker registration failed', error)+ );+ const whenIdle = () =>+ 'requestIdleCallback' in window+ ? window.requestIdleCallback(register, { timeout: 5000 })+ : setTimeout(register, 1000);+ if (document.readyState === 'complete') whenIdle();+ else window.addEventListener('load', whenIdle, { once: true });+}diff --git a/apps/web/src/routes/Root.tsx b/apps/web/src/routes/Root.tsxindex a8c4390692..e4f378f1e8 100644--- a/apps/web/src/routes/Root.tsx+++ b/apps/web/src/routes/Root.tsx@@ -6,7 +6,6 @@ import { IncomingMeetingInvitationsProvider } from '@app/features/meetings/incomimport { MeetingSessionProvider } from '@app/features/meetings/meeting-session-provider';import { usePendingNotificationNavigationEffect } from '@app/features/notifications/PendingNotificationNavigationEffect';import { SearchProvider } from '@app/features/soup/search/context';-import { InteractiveOnboardingModal } from '@app/features/tutorial/InteractiveOnboardingModal';import {AnalyticsContextProvider,useAnalytics,@@ -22,6 +21,7 @@ import { CallProvider } from '@channel/Call/CallContext';import { CallStartedNotifier } from '@channel/Call/CallStartedNotifier';import { isMeetingPath } from '@channel/Call/call-link';import { CallKitSync } from '@channel/Call/use-callkit';+import { dismissBootShell } from '@components/app/boot-shell';import { GlobalAppStateProvider } from '@components/app/GlobalAppState';import { Layout } from '@components/app/Layout';import { ReactiveFavicon } from '@components/app/ReactiveFavicon';@@ -33,6 +33,7 @@ import { QuickAccessProvider } from '@core/context/quickAccess';import { TeamContextProvider } from '@core/context/team';import {UserContextProvider,+ useIsAuthenticated,useUserId,useUserInfo,} from '@core/context/user';@@ -50,6 +51,7 @@ import {syncLoginStorage,updateCookie,} from '@core/util/cookies';+import { lazyNamed } from '@core/util/lazyNamed';import { licenseChannel } from '@core/util/licenseUpdateBroadcastChannel';import { isTauri } from '@core/util/platform';import { transformShortIdInUrlPathname } from '@core/util/url';@@ -104,10 +106,17 @@ import {onMount,type ParentProps,Show,+ Suspense,} from 'solid-js';import { useReminderAlerts } from '../features/reminders/reminder-alerts';import { AppRouterView } from './app-router-view';+// Only first-time mobile web users see it, and only once it opens.+const InteractiveOnboardingModal = lazyNamed(+ () => import('@app/features/tutorial/InteractiveOnboardingModal'),+ 'InteractiveOnboardingModal'+);+/** Syncs login cookie with auth state. Only updates on successful query (not errors/loading). */function useSyncLoginCookie() {const userInfoQuery = useUserInfoQuery();@@ -295,6 +304,9 @@ function InitialInteractiveOnboardingModal() {const userInfoQuery = useUserInfoQuery();const [open, setOpen] = createSignal(true);const [onboardingStarted, setOnboardingStarted] = createSignal(false);+ // Mounting waits for the first open so the modal's chunk stays off startup;+ // it stays mounted afterwards so closing can animate.+ const [hasOpened, setHasOpened] = createSignal(false);const modalOpen = () =>open() &&@@ -307,6 +319,7 @@ function InitialInteractiveOnboardingModal() {createEffect(() => {if (modalOpen()) {setOnboardingStarted(true);+ setHasOpened(true);}});@@ -340,25 +353,49 @@ function InitialInteractiveOnboardingModal() {};return (- <InteractiveOnboardingModal- open={modalOpen()}- isFirstTimeOnboarding- onOpenChange={handleOpenChange}- />+ <Show when={hasOpened()}>+ <Suspense>+ <InteractiveOnboardingModal+ open={modalOpen()}+ isFirstTimeOnboarding+ onOpenChange={handleOpenChange}+ />+ </Suspense>+ </Show>);}+/** Longest the boot shell waits for auth before showing whatever the app has. */+const BOOT_SHELL_MAX_WAIT_MS = 8000;++/**+ * Hands off from index.html's boot shell once the app frame can draw: when+ * auth is known (the rail or the login page renders), at once for public+ * links, and after a cap so an outage never hides the app's own error states.+ */+function useBootShellHandoff(isPublicPath: () => boolean) {+ const isAuthenticated = useIsAuthenticated();+ onMount(() => {+ const cap = setTimeout(dismissBootShell, BOOT_SHELL_MAX_WAIT_MS);+ onCleanup(() => clearTimeout(cap));+ });+ createEffect(() => {+ if (isPublicPath() || isAuthenticated() !== undefined) dismissBootShell();+ });+}+/** Meeting and booking links have a focused shell and skip app onboarding. */function AppRouteLayout(props: RouteSectionProps) {const location = useLocation();+ const isBookingPath = () =>+ location.pathname.startsWith(`${ROUTER_BASE_CONCAT}book/`) ||+ location.pathname.startsWith(`${ROUTER_BASE_CONCAT}booking/`);+ useBootShellHandoff(+ () => isBookingPath() || isMeetingPath(location.pathname)+ );return (<Show- when={- !(- location.pathname.startsWith(`${ROUTER_BASE_CONCAT}book/`) ||- location.pathname.startsWith(`${ROUTER_BASE_CONCAT}booking/`)- )- }+ when={!isBookingPath()}fallback={<div class="h-dvh overflow-y-auto bg-page text-ink">{props.children}diff --git a/apps/web/src/routes/app-router-view.tsx b/apps/web/src/routes/app-router-view.tsxindex e54113c03b..dadcf8498d 100644--- a/apps/web/src/routes/app-router-view.tsx+++ b/apps/web/src/routes/app-router-view.tsx@@ -1,55 +1,9 @@import { ROUTER_BASE } from '@app/constants/routerBase';-import { ActivityRouteView } from '@app/features/activity/route-views';-import { AgentsRouteView } from '@app/features/agents-view/route-views';-import { MobileWebSignup } from '@app/features/auth/auth';-import { CallDetailRouteView } from '@app/features/block-call/route-views';-import { PrDetailRouteView } from '@app/features/block-pr/route-views';-import { CalendarRouteView } from '@app/features/calendar-view/route-views';-import { ChannelInviteAcceptance } from '@app/features/channel-invitations/ChannelInviteAcceptance';-import { ChannelDetailRouteView } from '@app/features/channels-view/channels-view';-import { ChannelsRouteView } from '@app/features/channels-view/route-views';-import { CompaniesRouteView } from '@app/features/crm/route-views';-import { DriveDetailView } from '@app/features/drive-view/components/DriveDetailView';-import {- DriveCallRouteView,- DriveRouteView,-} from '@app/features/drive-view/route-views';-import { EmailDetailRouteView } from '@app/features/email-view/components/EmailDetailView';-import { MailRouteView } from '@app/features/email-view/route-views';-import { GettingStartedRouteView } from '@app/features/getting-started/route-views';-import { InviteLinksPortal } from '@app/features/gtm-invite/InviteLinksPortal';-import { InviteWelcome } from '@app/features/gtm-invite/InviteWelcome';-import { HomeEntityDetailRouteView } from '@app/features/home/components/HomeEntityDetailRouteView';-import { HomeReminderDetailRouteView } from '@app/features/home/components/HomeReminderDetailRouteView';import {HomeCalendarRouteView,HomeDetailRouteView,} from '@app/features/home/home-view';import { HomeRouteView } from '@app/features/home/route-views';-import { MeetingRouter } from '@app/features/meetings/meeting-router';-import {- CallsRouteView,- FoldersRouteView,- RecentRouteView,- SearchRouteView,-} from '@app/features/next-soup/route-views';-import {- ReminderDetailRouteView,- RemindersRouteView,-} from '@app/features/reminders/route-views';-import {- ReviewsPrDetailRouteView,- ReviewsRouteView,-} from '@app/features/reviews-view/route-views';-import { RoutineCreateRouteView } from '@app/features/routines/route-views';-import { SettingsRouteView } from '@app/features/settings/route-views';-import { TasksDetailRouteView } from '@app/features/tasks-view/components/TasksDetailView';-import {- ProjectDetailRouteView,- ProjectTaskRouteView,- TasksRouteView,-} from '@app/features/tasks-view/route-views';-import { TeamInviteAcceptance } from '@app/features/team-invitations/TeamInviteAcceptance';import {createMemoryPaneStore,SplitRouter,@@ -63,26 +17,14 @@ import {splitContentFromLocation,upgradeLegacyPath,} from '@components/app/split-layout/split-router/legacy-route';-import NotFound from '@core/component/AccessErrorViews/NotFound';import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { lazyNamed } from '@core/util/lazyNamed';import { isTauri } from '@core/util/platform';import { transformShortIdInUrlPathname } from '@core/util/url';-import { lazy } from 'solid-js';+import { lazy, onMount } from 'solid-js';import { paneRoute } from './app-route';import { BasePathComponent } from './BasePath';-import {- BookingReceiptRoutePage,- EmailCallback,- EmailLinkCallback,- LoginPage,- LoginPopupSuccess,- OnboardingPage,- PublicBookingRoutePage,- SignupPage,- TaskSlugPage,- WelcomePage,-} from './pages';import {activityRoute,agentChatsRoute,@@ -153,6 +95,181 @@ import {const { Router, Route } = SplitRouter;+/**+ * Every view except Home (the default landing) loads as its own chunk. The+ * split router warms a route's chunks while it navigates, and+ * `prefetchRouteViews` fetches them once the first screen has settled.+ */+const ActivityRouteView = lazyNamed(+ () => import('@app/features/activity/route-views'),+ 'ActivityRouteView'+);+const AgentsRouteView = lazyNamed(+ () => import('@app/features/agents-view/route-views'),+ 'AgentsRouteView'+);+const MobileWebSignup = lazyNamed(+ () => import('@app/features/auth/auth'),+ 'MobileWebSignup'+);+const CallDetailRouteView = lazyNamed(+ () => import('@app/features/block-call/route-views'),+ 'CallDetailRouteView'+);+const PrDetailRouteView = lazyNamed(+ () => import('@app/features/block-pr/route-views'),+ 'PrDetailRouteView'+);+const CalendarRouteView = lazyNamed(+ () => import('@app/features/calendar-view/route-views'),+ 'CalendarRouteView'+);+const ChannelInviteAcceptance = lazyNamed(+ () => import('@app/features/channel-invitations/ChannelInviteAcceptance'),+ 'ChannelInviteAcceptance'+);+const ChannelDetailRouteView = lazyNamed(+ () => import('@app/features/channels-view/channels-view'),+ 'ChannelDetailRouteView'+);+const ChannelsRouteView = lazyNamed(+ () => import('@app/features/channels-view/route-views'),+ 'ChannelsRouteView'+);+const CompaniesRouteView = lazyNamed(+ () => import('@app/features/crm/route-views'),+ 'CompaniesRouteView'+);+const DriveDetailView = lazyNamed(+ () => import('@app/features/drive-view/components/DriveDetailView'),+ 'DriveDetailView'+);+const DriveCallRouteView = lazyNamed(+ () => import('@app/features/drive-view/route-views'),+ 'DriveCallRouteView'+);+const DriveRouteView = lazyNamed(+ () => import('@app/features/drive-view/route-views'),+ 'DriveRouteView'+);+const EmailDetailRouteView = lazyNamed(+ () => import('@app/features/email-view/components/EmailDetailView'),+ 'EmailDetailRouteView'+);+const MailRouteView = lazyNamed(+ () => import('@app/features/email-view/route-views'),+ 'MailRouteView'+);+const GettingStartedRouteView = lazyNamed(+ () => import('@app/features/getting-started/route-views'),+ 'GettingStartedRouteView'+);+const InviteLinksPortal = lazyNamed(+ () => import('@app/features/gtm-invite/InviteLinksPortal'),+ 'InviteLinksPortal'+);+const InviteWelcome = lazyNamed(+ () => import('@app/features/gtm-invite/InviteWelcome'),+ 'InviteWelcome'+);+const HomeEntityDetailRouteView = lazyNamed(+ () => import('@app/features/home/components/HomeEntityDetailRouteView'),+ 'HomeEntityDetailRouteView'+);+const HomeReminderDetailRouteView = lazyNamed(+ () => import('@app/features/home/components/HomeReminderDetailRouteView'),+ 'HomeReminderDetailRouteView'+);+const MeetingRouter = lazyNamed(+ () => import('@app/features/meetings/meeting-router'),+ 'MeetingRouter'+);+const CallsRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'CallsRouteView'+);+const FoldersRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'FoldersRouteView'+);+const RecentRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'RecentRouteView'+);+const SearchRouteView = lazyNamed(+ () => import('@app/features/next-soup/route-views'),+ 'SearchRouteView'+);+const ReminderDetailRouteView = lazyNamed(+ () => import('@app/features/reminders/route-views'),+ 'ReminderDetailRouteView'+);+const RemindersRouteView = lazyNamed(+ () => import('@app/features/reminders/route-views'),+ 'RemindersRouteView'+);+const ReviewsPrDetailRouteView = lazyNamed(+ () => import('@app/features/reviews-view/route-views'),+ 'ReviewsPrDetailRouteView'+);+const ReviewsRouteView = lazyNamed(+ () => import('@app/features/reviews-view/route-views'),+ 'ReviewsRouteView'+);+const RoutineCreateRouteView = lazyNamed(+ () => import('@app/features/routines/route-views'),+ 'RoutineCreateRouteView'+);+const SettingsRouteView = lazyNamed(+ () => import('@app/features/settings/route-views'),+ 'SettingsRouteView'+);+const TasksDetailRouteView = lazyNamed(+ () => import('@app/features/tasks-view/components/TasksDetailView'),+ 'TasksDetailRouteView'+);+const ProjectDetailRouteView = lazyNamed(+ () => import('@app/features/tasks-view/route-views'),+ 'ProjectDetailRouteView'+);+const ProjectTaskRouteView = lazyNamed(+ () => import('@app/features/tasks-view/route-views'),+ 'ProjectTaskRouteView'+);+const TasksRouteView = lazyNamed(+ () => import('@app/features/tasks-view/route-views'),+ 'TasksRouteView'+);+const TeamInviteAcceptance = lazyNamed(+ () => import('@app/features/team-invitations/TeamInviteAcceptance'),+ 'TeamInviteAcceptance'+);+const BookingReceiptRoutePage = lazyNamed(+ () => import('./pages'),+ 'BookingReceiptRoutePage'+);+const EmailCallback = lazyNamed(() => import('./pages'), 'EmailCallback');+const EmailLinkCallback = lazyNamed(+ () => import('./pages'),+ 'EmailLinkCallback'+);+const LoginPage = lazyNamed(() => import('./pages'), 'LoginPage');+const LoginPopupSuccess = lazyNamed(+ () => import('./pages'),+ 'LoginPopupSuccess'+);+const OnboardingPage = lazyNamed(() => import('./pages'), 'OnboardingPage');+const PublicBookingRoutePage = lazyNamed(+ () => import('./pages'),+ 'PublicBookingRoutePage'+);+const SignupPage = lazyNamed(() => import('./pages'), 'SignupPage');+const TaskSlugPage = lazyNamed(() => import('./pages'), 'TaskSlugPage');+const WelcomePage = lazyNamed(() => import('./pages'), 'WelcomePage');+const NotFound = lazy(+ () => import('@core/component/AccessErrorViews/NotFound')+);+/** Debug views stay behind the registry's lazy import. */function debugView(componentId: string) {return lazy(async () => {@@ -163,8 +280,46 @@ function debugView(componentId: string) {});}+/**+ * Views a session is likely to open next. Fetching them while the browser is+ * idle keeps the first navigation as fast as it was with one big bundle.+ */+const LIKELY_NEXT_VIEWS = [+ HomeEntityDetailRouteView,+ ChannelsRouteView,+ ChannelDetailRouteView,+ MailRouteView,+ EmailDetailRouteView,+ DriveRouteView,+ DriveDetailView,+ TasksRouteView,+ AgentsRouteView,+ CalendarRouteView,+];++/** Warms the likely-next view chunks one at a time, without competing with startup work. */+function prefetchRouteViews(): void {+ const idle = (run: () => void) =>+ 'requestIdleCallback' in window+ ? window.requestIdleCallback(run, { timeout: 5000 })+ : setTimeout(run, 1000);+ const queue = [...LIKELY_NEXT_VIEWS];+ const next = () => {+ const view = queue.shift();+ if (!view) return;+ view+ .preload()+ .catch(() => {})+ .finally(() => idle(next));+ };+ // Leave the first seconds to the landing view's own data and chunks.+ setTimeout(() => idle(next), 2500);+}+/** The app's router: the first pane's top-level route renders here, and app URLs render the split layout. */export function AppRouterView() {+ onMount(prefetchRouteViews);+const debugRouteElements = debugRoutes.map(({ componentId, route }) => (<Route definition={route} component={debugView(componentId)} />));diff --git a/apps/web/vite.base.ts b/apps/web/vite.base.tsindex a4e550f571..5ea4476bdd 100644--- a/apps/web/vite.base.ts+++ b/apps/web/vite.base.ts@@ -72,6 +72,64 @@ function gitBranchHmrPlugin(): Plugin {};}+/**+ * Orval's generated schemas are top-level `zod.object(...)` chains. Rollup+ * cannot prove those calls are side-effect free, so every schema (≈700 for the+ * storage service alone) stayed in the entry chunk and was constructed at+ * startup, used or not. Annotating each one pure lets Rollup drop the unused+ * ones; the annotation is applied at build time so regenerated files keep it.+ */+function pureGeneratedZodSchemas(): Plugin {+ return {+ name: 'pure-generated-zod-schemas',+ enforce: 'pre',+ transform(code, id) {+ if (!/[\\/]generated[\\/]zod\.ts$/.test(id)) return;+ return {+ code: code.replace(+ /^(export const [\w$]+ = )(zod\b)/gm,+ '$1/* @__PURE__ */ $2'+ ),+ map: null,+ };+ },+ };+}++/**+ * CloudFront compresses responses of at most 10,000,000 bytes and serves+ * anything larger raw. The entry chunk once crossed that limit and every+ * visitor downloaded 11.9 MB uncompressed instead of ~3 MB, so fail the build+ * rather than ship that again. (Cache WASM is precompressed at deploy.)+ */+function cloudFrontCompressionLimit(): Plugin {+ const limitBytes = 10_000_000;+ return {+ name: 'cloudfront-compression-limit',+ apply: 'build',+ generateBundle(_options, bundle) {+ const oversized = Object.values(bundle)+ .filter((file) => /\.(js|css|html|json|svg)$/.test(file.fileName))+ .map((file) => ({+ name: file.fileName,+ bytes:+ file.type === 'chunk'+ ? Buffer.byteLength(file.code)+ : typeof file.source === 'string'+ ? Buffer.byteLength(file.source)+ : file.source.byteLength,+ }))+ .filter((file) => file.bytes > limitBytes);+ if (oversized.length === 0) return;+ this.error(+ `These files exceed CloudFront's ${limitBytes}-byte compression limit and would be served uncompressed: ${oversized+ .map((file) => `${file.name} (${file.bytes} bytes)`)+ .join(', ')}. Split them behind lazy() boundaries.`+ );+ },+ };+}+export const createAppViteConfig = (): UserConfigFn => {return ({ command, mode }) => {const ENV_MODE = process.env.MODE ?? mode;@@ -91,6 +149,7 @@ export const createAppViteConfig = (): UserConfigFn => {devHttps(),hostedDevProxy(),// solidDevtools({ autoname: true }),+ pureGeneratedZodSchemas(),solid(),wasm(),tailwind(),@@ -99,6 +158,7 @@ export const createAppViteConfig = (): UserConfigFn => {root: './',}),gitBranchHmrPlugin(),+ cloudFrontCompressionLimit(),],define: defineEnv(ENV_MODE, command),clearScreen: false,@@ -256,6 +316,12 @@ function defineEnv(mode: string, command: string) {'import.meta.env.__APP_VERSION__': JSON.stringify(appVersion),'import.meta.env.__APP_BUILD_TIME__': JSON.stringify(appBuildTime),'import.meta.env.ASSETS_PATH': JSON.stringify(getAssetsPath(mode, command)),+ // index.html preconnects to the API gateway; keep in sync with servers.ts.+ 'import.meta.env.GATEWAY_ORIGIN': JSON.stringify(+ mode === 'development'+ ? 'https://dev-gateway.macro.com'+ : 'https://gateway.macro.com'+ ),'import.meta.env.__LOCAL_DOCKER__': process.env.LOCAL_DOCKER === 'true','import.meta.env.__LOCAL_JWT__': JSON.stringify(process.env.LOCAL_JWT),'import.meta.env.__GIT_BRANCH__': JSON.stringify(