Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

perf(web): better route and assets loading, better skeletons, refactor layouts (#7807)

dev-rb68ce11c6a67f
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 29c625fcf0..a234995591 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -73,8 +73,9 @@ Then trigger the interaction and read `window.__inst.log`. `'1,2,3' → '' → '
- 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`.
+- 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`, `AppProviders`, `componentRegistry`, `app-router-view`, `routes/shells.tsx`, block `definition.ts`, Lexical `init.ts`).
+- Each top-level route picks its shell in `app-router-view.tsx` (`routes/shells.tsx`): `authRoute` pages and booking links render without app chrome, and `appRoute` renders `AppShell` — the app's providers (`AppProviders`), chrome (`AppChrome` in `Layout.tsx`), and the split layout. Put state only the app's views use in `AppProviders`, not `Root`; `Root` keeps what every page or a call needs.
+- `index.html` paints a boot shell before any JS runs: the saved theme's background, the rail column, and the desktop app's content card — no app content. The first shell to mount dismisses it (`dismissBootShell`). Keep its rail width and desktop inset in step with `SidebarRail` and `SplitLayout`.
- 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.
diff --git a/apps/web/index.html b/apps/web/index.html
index 11813a7bf9..7451b590fe 100644
--- a/apps/web/index.html
+++ b/apps/web/index.html
@@ -33,37 +33,25 @@
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.
+ Boot shell: the app frame's background in the saved theme, painted with
+ the HTML so the screen is never blank while the bundle downloads and
+ starts — the rail column and, in the desktop app, the content card. It
+ draws no app content; the first route shell to mount fades it out (see
+ dismissBootShell).
-->
<style>
- /* The boot shell renders before Tailwind's preflight has loaded. */
- #boot-shell,
- #boot-shell * {
- box-sizing: border-box;
- }
#boot-shell {
--bs-page: oklch(0.17 0 0);
--bs-panel: oklch(0.17 0 0);
--bs-ink: oklch(1 0 0);
- --bs-muted: oklch(0.83 0 0);
- --bs-input: color-mix(in oklch, var(--bs-page) 95%, var(--bs-ink));
- --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;
+ box-sizing: border-box;
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;
}
@@ -72,355 +60,44 @@
--bs-page: oklch(0.964 0 0);
--bs-panel: oklch(1 0 0);
--bs-ink: oklch(0.16 0 0);
- --bs-muted: oklch(0.4 0 0);
- --bs-input: transparent;
}
}
#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. */
+ /* SidebarRail's 56px column. */
.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) 6%, transparent);
- color: var(--bs-ink);
- }
- .bs-nav {
- display: flex;
- flex-direction: column;
- gap: 4px;
- padding-top: 16px;
- min-height: 0;
- overflow: hidden;
- }
- /* View sidebar: ViewSidebar's 256px aside. */
- .bs-aside {
- display: flex;
- width: 256px;
- flex: none;
- flex-direction: column;
- box-shadow: 1px 0 var(--bs-edge);
- margin-right: 1px;
- }
- /* Home yields to its 640px main pane, after the 56px rail and 1px gutter. */
- #boot-shell[data-view="home"] .bs-aside {
- width: clamp(224px, calc(100vw - 56px - 1px - 640px), 256px);
- }
- .bs-head {
- display: flex;
- height: 48px;
- flex: none;
- align-items: center;
- gap: 4px;
- padding: 0 14px 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-control {
- display: flex;
- width: 24px;
- height: 24px;
- flex: none;
- align-items: center;
- justify-content: center;
- }
- .bs-filter svg {
- width: 12px;
- height: 12px;
- }
- .bs-row {
- display: flex;
- height: 32px;
- flex: none;
- align-items: center;
- gap: 6px;
- margin: 2px 8px;
- padding: 0 8px;
- font-size: 14px;
- color: var(--bs-muted);
- }
- .bs-primary {
- margin-top: 8px;
- margin-bottom: 0;
- }
- .bs-list {
- display: flex;
- flex-direction: column;
- min-height: 0;
- overflow: hidden;
- margin-top: 12px;
- }
- .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-text {
- min-width: 0;
- flex: 1;
- }
- .bs-label {
- display: flex;
- height: 28px;
- flex: none;
- align-items: center;
- padding: 0 16px;
- }
- .bs-label > .bs-bar {
- width: 64px;
- height: 8px;
- }
- .bs-main {
- position: relative;
- display: flex;
- min-width: 0;
- flex: 1;
- flex-direction: column;
- }
- .bs-desktop-content {
- display: flex;
+ .bs-content {
flex: 1;
min-width: 0;
- margin: 6px 6px 6px 0;
- overflow: hidden;
- border: 1px solid var(--bs-edge);
- border-radius: 6px;
}
+ /* The desktop app's bordered content card (SplitLayout's bento inset). */
#boot-shell[data-desktop] .bs-rail {
border-right: 0;
}
- #boot-shell[data-macos] .bs-head > :last-child {
- display: none;
- }
- /* 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;
+ #boot-shell[data-desktop] .bs-content {
+ margin: 6px 6px 6px 0;
border: 1px solid var(--bs-edge);
- border-radius: 999px;
- background: var(--bs-input);
- 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;
+ border-radius: 6px;
}
.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: 776px) {
- .bs-aside {
- display: none;
- }
- }
- /* Touch devices: no rail; a full-width list and the floating dock. */
- .bs-dock {
- display: none;
+ fill: color-mix(in oklch, var(--bs-ink) 18%, transparent);
}
+ /* Touch devices have no rail. */
@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;
}
- #boot-shell[data-view] .bs-aside {
- display: flex;
- width: auto;
- flex: 1;
- padding-top: 48px;
- border: 0;
- box-shadow: none;
- margin-right: 0;
- }
- .bs-main {
+ .bs-rail {
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>
@@ -429,27 +106,20 @@
<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.
+ // Paint the boot shell in the saved theme. Signed-out visitors land on a
+ // sign-in page, so they see the mark instead of the app frame.
try {
const shell = document.getElementById("boot-shell");
const nativeOs = window.__TAURI_OS_PLUGIN_INTERNALS__?.os_type;
- const nativeDesktop = nativeOs && nativeOs !== "ios" && nativeOs !== "android";
- if (nativeDesktop) shell.dataset.desktop = "";
- // Match Layout's native macOS overlay-titlebar clearance before JS loads.
- if (nativeOs === "macos") {
- shell.dataset.macos = "";
- shell.style.paddingTop = "40px";
- }
- const read = (key) => {
- try {
- return JSON.parse(localStorage.getItem(key) || "null");
- } catch {
- return null;
- }
- };
- const theme = read("html-color-theme");
+ if (nativeOs && nativeOs !== "ios" && nativeOs !== "android") {
+ shell.dataset.desktop = "";
+ }
+ // Match RootFrame's native macOS overlay-titlebar clearance before JS loads.
+ if (nativeOs === "macos") shell.style.paddingTop = "40px";
+ let theme = null;
+ try {
+ theme = JSON.parse(localStorage.getItem("html-color-theme") || "null");
+ } catch {}
if (theme && theme.color) {
document.body.style.backgroundColor = theme.color;
shell.style.setProperty("--bs-page", theme.color);
@@ -458,68 +128,12 @@
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);
- if (theme.muted) shell.style.setProperty("--bs-muted", theme.muted);
- if (theme.input) shell.style.setProperty("--bs-input", theme.input);
}
-
- 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) => `<div class="bs-row">${square}<div class="bs-row-text">${bar(width)}</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";
- shell.dataset.view = view;
- 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>
- <div class="bs-btn">${icon("more")}</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 = ["60%", "80%", "50%", "66.6667%", "75%", "50%", "80%", "60%"];
- // Match HomeListSkeleton: one group header followed by eight rows.
- let rows = `<div class="bs-label">${bar("64px")}</div>`;
- for (const width of widths) rows += row(width);
- const aside = `<div class="bs-aside">
- <div class="bs-head">${view === "home" ? `<span>Home</span><span class="bs-control bs-filter">${icon("filter")}</span>` : bar("72px", "height:12px")}<span class="bs-control">${icon("sidebar")}</span></div>
- ${view === "home" ? `<div class="bs-row bs-primary">${icon("plus")}<span>New chat</span></div>` : `<div class="bs-row bs-primary">${square}${bar("38%")}</div>`}
- <div class="bs-list">${rows}</div>
- </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>`;
-
- const content = `${showAside ? aside : ""}<div class="bs-main">${main}</div>`;
- shell.innerHTML = `${rail}${nativeDesktop ? `<div class="bs-desktop-content">${content}</div>` : content}
- <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);
+ shell.innerHTML = `<div class="bs-rail"></div><div class="bs-content"></div>`;
}
} catch (err) {
console.error("Failed to draw boot shell: ", err);
diff --git a/apps/web/public/sw.js b/apps/web/public/sw.js
index 445ef0b513..4b32adb373 100644
--- a/apps/web/public/sw.js
+++ b/apps/web/public/sw.js
@@ -4,8 +4,8 @@
*
* - 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.
+ * A shell is cached only after its entry JS, CSS, and preloaded WASM 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.
@@ -127,12 +127,15 @@ async function refreshShell(request) {
}
}
if (currentBuild !== build) {
- await pruneAssets(new Set([build, currentBuild ?? build]));
+ await pruneAssets(new Set([build, currentBuild ?? build]), new Set(assets));
}
return response;
}
-/** The entry module, its preloads, and stylesheets referenced by a shell. */
+/**
+ * The entry module, its preloads, and stylesheets referenced by a shell. A
+ * `rel="preload"` asset (Loro's WASM) is needed to boot, so it counts too.
+ */
function entryAssets(html) {
const paths = new Set();
for (const match of html.matchAll(
@@ -141,7 +144,7 @@ function entryAssets(html) {
const tag = match[0];
const isEntry =
tag.startsWith('<script') ||
- /\brel="(?:stylesheet|modulepreload)"/.test(tag);
+ /\brel="(?:stylesheet|modulepreload|preload)"/.test(tag);
const path = new URL(match[1], self.location.origin).pathname;
if (isEntry && HASHED_ASSET.test(path)) paths.add(path);
}
@@ -180,10 +183,15 @@ function tagged(response, build) {
});
}
-/** Drops cached assets fetched by builds other than `keep`. */
-async function pruneAssets(keep) {
+/**
+ * Drops cached assets fetched by builds other than `keep`, except the current
+ * shell's own: an asset whose hash survived several builds (Loro's WASM) is
+ * still tagged with the build that first fetched it.
+ */
+async function pruneAssets(keep, shellAssets) {
const cache = await caches.open(ASSET_CACHE);
for (const request of await cache.keys()) {
+ if (shellAssets.has(new URL(request.url).pathname)) continue;
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/AppProviders.tsx b/apps/web/src/components/app/AppProviders.tsx
new file mode 100644
index 0000000000..cd57d1475a
--- /dev/null
+++ b/apps/web/src/components/app/AppProviders.tsx
@@ -0,0 +1,97 @@
+import { IncomingMeetingInvitationsProvider } from '@app/features/meetings/incoming-meeting-invitations';
+import { usePendingNotificationNavigationEffect } from '@app/features/notifications/PendingNotificationNavigationEffect';
+import { SearchProvider } from '@app/features/soup/search/context';
+import { useCalendarCache } from '@app/lib/queries/calendar/graphql/use-calendar-cache';
+import { useInvalidateQueriesOnReconnect } from '@app/lib/queries/invalidate-on-reconnect';
+import { useSoupBackfills } from '@app/lib/queries/soup/backfill';
+import { globalSplitManager } from '@app/signal/splitLayout';
+import { GlobalAppStateProvider } from '@components/app/GlobalAppState';
+import { useReactiveFavicon } from '@components/app/useReactiveFavicon';
+import { useGlobalAttachableHistory } from '@core/component/AI/signal/globalAttachments';
+import { TeamContextProvider } from '@core/context/team';
+import { useUserId } from '@core/context/user';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
+import { createBlockOrchestrator } from '@core/orchestrator';
+import {
+ createNotificationSource,
+ type UnifiedNotification,
+ useNotificationUpdates,
+ usePlatformNotificationState,
+} from '@notifications';
+import { maybeHandlePlatformNotification } from '@notifications/notification-platform';
+import { useChatRenameWebsocketSync } from '@queries/chat';
+import { useQuerySync } from '@queries/sync/use-query-sync';
+import { MutationUndoProvider } from '@queries/undo';
+import {
+ useRefreshTrackedEntitiesOnFocus,
+ useReopenTrackedEntitiesOnReconnect,
+} from '@service-connection/client';
+import { ws as connectionGatewayWebsocket } from '@service-connection/websocket';
+import type { ParentProps } from 'solid-js';
+
+function ConfiguredGlobalAppStateProvider(props: ParentProps) {
+ // Initialize global notification helpers
+ const notifInterface = usePlatformNotificationState();
+ useChatRenameWebsocketSync();
+ useReopenTrackedEntitiesOnReconnect();
+ useRefreshTrackedEntitiesOnFocus();
+
+ if (isNativeMobilePlatform()) {
+ useInvalidateQueriesOnReconnect();
+ }
+
+ const onNotification = (notification: UnifiedNotification) => {
+ if (notifInterface === 'not-supported') return;
+ const layoutManager = globalSplitManager();
+ if (!layoutManager) return;
+ maybeHandlePlatformNotification(
+ notification,
+ notifInterface,
+ layoutManager
+ );
+ };
+ const notificationSource = createNotificationSource(
+ connectionGatewayWebsocket,
+ onNotification
+ );
+ useNotificationUpdates(notificationSource);
+ useReactiveFavicon(notificationSource);
+
+ const blockOrchestrator = createBlockOrchestrator();
+ usePendingNotificationNavigationEffect(notificationSource);
+
+ return (
+ <GlobalAppStateProvider
+ notificationSource={notificationSource}
+ blockOrchestrator={blockOrchestrator}
+ >
+ {props.children}
+ </GlobalAppStateProvider>
+ );
+}
+
+/**
+ * State only the app's views use: notifications, undo, search, and the caches
+ * and sync behind them. Auth, booking, and meeting pages render without it.
+ */
+export function AppProviders(props: ParentProps) {
+ const userId = useUserId();
+ useQuerySync(userId);
+ useSoupBackfills(userId);
+ useCalendarCache(() => userId() !== undefined);
+ useGlobalAttachableHistory();
+
+ return (
+ <TeamContextProvider>
+ <ConfiguredGlobalAppStateProvider>
+ <MutationUndoProvider>
+ <SearchProvider>
+ <IncomingMeetingInvitationsProvider>
+ {props.children}
+ </IncomingMeetingInvitationsProvider>
+ </SearchProvider>
+ </MutationUndoProvider>
+ </ConfiguredGlobalAppStateProvider>
+ </TeamContextProvider>
+ );
+}
diff --git a/apps/web/src/components/app/InitialInteractiveOnboardingModal.tsx b/apps/web/src/components/app/InitialInteractiveOnboardingModal.tsx
new file mode 100644
index 0000000000..6f42bf4db6
--- /dev/null
+++ b/apps/web/src/components/app/InitialInteractiveOnboardingModal.tsx
@@ -0,0 +1,77 @@
+import { initAndStartEmailSync } from '@core/email-link';
+import { isMobile } from '@core/mobile/isMobile';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
+import { lazyNamed } from '@core/util/lazyNamed';
+import { useUserInfoQuery } from '@queries/auth/user-info';
+import { createEffect, createSignal, Show, Suspense } from 'solid-js';
+
+// Only first-time mobile web users see it, and only once it opens.
+const InteractiveOnboardingModal = lazyNamed(
+ () => import('@app/features/tutorial/InteractiveOnboardingModal'),
+ 'InteractiveOnboardingModal'
+);
+
+export 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() &&
+ // Desktop first-run users go through /onboarding instead (Layout redirect).
+ isMobile() &&
+ !isNativeMobilePlatform() &&
+ userInfoQuery.data?.authenticated === true &&
+ (userInfoQuery.data.tutorialComplete === false || onboardingStarted());
+
+ createEffect(() => {
+ if (modalOpen()) {
+ setOnboardingStarted(true);
+ setHasOpened(true);
+ }
+ });
+
+ // First-time users (tutorial not yet completed) reach the app without passing
+ // through a login route that inits the email link — e.g. marketing SSO returns to
+ // /app, not /login — so kick off email sync once here. Idempotent on the backend;
+ // AlreadyInitialized is ignored. Keyed by user id (not a bare flag) so a native
+ // mobile logout→login of a different user in the same session still inits.
+ let emailInitForUserId: string | undefined;
+ createEffect(() => {
+ const data = userInfoQuery.data;
+ if (data?.authenticated !== true || data.tutorialComplete !== false) return;
+ if (emailInitForUserId === data.id) return;
+ emailInitForUserId = data.id;
+
+ void initAndStartEmailSync().match(
+ () => {},
+ (err) => {
+ if (err.tag !== 'AlreadyInitialized') {
+ console.error('Failed to init email link for new user', err);
+ }
+ }
+ );
+ });
+
+ const handleOpenChange = (nextOpen: boolean) => {
+ setOpen(nextOpen);
+ if (!nextOpen) {
+ setOnboardingStarted(false);
+ }
+ };
+
+ return (
+ <Show when={hasOpened()}>
+ <Suspense>
+ <InteractiveOnboardingModal
+ open={modalOpen()}
+ isFirstTimeOnboarding
+ onOpenChange={handleOpenChange}
+ />
+ </Suspense>
+ </Show>
+ );
+}
diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsx
index f6eff059a4..65f4f67fe8 100644
--- a/apps/web/src/components/app/Layout.tsx
+++ b/apps/web/src/components/app/Layout.tsx
@@ -13,9 +13,9 @@ import {
} from '@app/features/command/Launcher';
import { SearchState } from '@app/features/command/mobile/mobileSearchState';
import {
- CreateCompanyModal,
- CreateContactModal,
-} from '@app/features/crm/crm-create';
+ companyCreation,
+ contactCreation,
+} from '@app/features/crm/creation-adapter';
import { DevStatusBar } from '@app/features/devtools/DevStatusBar';
import { GlobalBulkEditEntityModal } from '@app/features/entity/bulk-edit/BulkEditEntityModal';
import {
@@ -47,16 +47,12 @@ import { isMobile } from '@core/mobile/isMobile';
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 { hasLoginCookie, updateCookie } from '@core/util/cookies';
import { lazyNamed } from '@core/util/lazyNamed';
import { isPlatform } from '@core/util/platform';
import { useUserInfoQuery } from '@queries/auth/user-info';
import { queryClient } from '@queries/client';
-import {
- type RouteSectionProps,
- useLocation,
- useNavigate,
-} from '@solidjs/router';
+import { useLocation, useNavigate } from '@solidjs/router';
import { type as osType } from '@tauri-apps/plugin-os';
import { cn, ImperativeDialogHost } from '@ui';
import {
@@ -66,14 +62,16 @@ import {
lazy,
onCleanup,
onMount,
+ type ParentProps,
Show,
Suspense,
} from 'solid-js';
import { ViewNavigationSlotContext } from '../view-shell/navigation-slot';
+import { AppProviders } from './AppProviders';
import { BundleUpdateProgressBar } from './BundleUpdateProgressBar';
-import { ContentLoading } from './ContentLoading';
import { DesktopTitleBar } from './DesktopTitleBar';
import GlobalShortcuts from './GlobalHotkeys';
+import { InitialInteractiveOnboardingModal } from './InitialInteractiveOnboardingModal';
import { ItemDndProvider } from './ItemDragAndDrop';
import { FloatRegion } from './mobile/float-regions/FloatRegion';
import { FloatRegionHost } from './mobile/float-regions/FloatRegionHost';
@@ -81,6 +79,7 @@ import { installGlassPress } from './mobile/glassPress';
import { MobileDockRow } from './mobile/MobileDockRow';
import { MobileViewsRow } from './mobile/MobileViewsRow';
import { SwipeDownDismissKeyboard } from './mobile/SwipeDownDismissKeyboard';
+import { SessionExpiredRedirect } from './SessionExpiredRedirect';
import { useAppSquishHandlers } from './useAppSquishHandlers';
const StarterDatabase = lazy(async () => {
@@ -104,86 +103,29 @@ const MobileSettings = lazyNamed(
() => import('@app/features/settings/MobileSettings'),
'MobileSettings'
);
+// The CRM create dialogs pull in the database views and table model.
+const CreateCompanyModal = lazyNamed(
+ () => import('@app/features/crm/crm-create'),
+ 'CreateCompanyModal'
+);
+const CreateContactModal = lazyNamed(
+ () => import('@app/features/crm/crm-create'),
+ 'CreateContactModal'
+);
-const AUTH_URLS = [
- `${ROUTER_BASE_CONCAT}login`,
- `${ROUTER_BASE_CONCAT}login/popup`,
- `${ROUTER_BASE_CONCAT}login/popup/success`,
- `${ROUTER_BASE_CONCAT}onboarding`,
- `${ROUTER_BASE_CONCAT}setup`,
- `${ROUTER_BASE_CONCAT}signup`,
- `${ROUTER_BASE_CONCAT}email-signup-callback`,
- `${ROUTER_BASE_CONCAT}welcome`,
- `${ROUTER_BASE_CONCAT}mobile-email-signup`,
- `${ROUTER_BASE_CONCAT}team-invite`,
- `${ROUTER_BASE_CONCAT}invite`,
- `${ROUTER_BASE_CONCAT}internal/invite-links`,
-];
-
-export function Layout(props: RouteSectionProps) {
- const isAuthenticated = useIsAuthenticated();
- const location = useLocation();
- const sidebarVisible = createMemo(
- () =>
- !isTouchDevice() &&
- isAuthenticated() === true &&
- !AUTH_URLS.includes(location.pathname)
- );
-
- return (
- <SidebarVisibilityContext.Provider value={sidebarVisible}>
- <MobileSettingsProvider>
- <Show when={isAuthenticated() === true}>
- <ShowFeatureFlag flag={enableDatabases}>
- <Suspense>
- <StarterDatabase />
- </Suspense>
- </ShowFeatureFlag>
- </Show>
- <LayoutInner {...props} />
- </MobileSettingsProvider>
- </SidebarVisibilityContext.Provider>
- );
+/** True from the first time `opened` is, so a dialog loads on first open and can animate closed. */
+function hasOpened(opened: () => boolean) {
+ return createMemo((seen: boolean) => seen || opened(), false);
}
/**
- * Sends first-time desktop users into the onboarding flow at /onboarding.
- * Fires from anywhere in the app (marketing SSO lands on /app, not /login),
- * but never off auth/full-screen routes — /onboarding itself included.
+ * The frame every page renders in: the macOS title bar, dialogs that can open
+ * anywhere (the paywall reads mobile settings), and the page itself. App chrome lives in `AppChrome`, inside the
+ * routes that show it.
*/
-function NewOnboardingRedirect() {
- const userInfoQuery = useUserInfoQuery();
- const navigate = useNavigate();
- const location = useLocation();
- createEffect(() => {
- if (isMobile() || isNativeMobilePlatform()) return;
- const data = userInfoQuery.data;
- if (data?.authenticated !== true || data.tutorialComplete !== false) {
- return;
- }
- if (AUTH_URLS.includes(location.pathname)) return;
- // Preserve the deep link the user arrived on (a shared doc, an invite):
- // onboarding carries it as ?next and its finish() returns there instead of
- // the post-setup landing. Base-relative so navigate() can resolve it
- // against the router.
- const target =
- location.pathname.slice(ROUTER_BASE_CONCAT.length - 1) + location.search;
- const isGenericEntry = target === '/' || target.startsWith(DEFAULT_ROUTE);
- navigate(
- isGenericEntry
- ? '/onboarding'
- : `/onboarding?next=${encodeURIComponent(target)}`,
- { replace: true }
- );
- });
-
- return null;
-}
-
-function LayoutInner(props: RouteSectionProps) {
+export function RootFrame(props: ParentProps) {
const hasOverlayTitleBar = isPlatform('desktop') && osType() === 'macos';
const [navigationSlot, setNavigationSlot] = createSignal<HTMLElement>();
- const isAuthenticated = useIsAuthenticated();
const { paywallOpen, showPaywall } = usePaywallState();
const { usageLimitOpen } = useAiUsageLimitState();
const location = useLocation();
@@ -218,32 +160,122 @@ function LayoutInner(props: RouteSectionProps) {
mountGlobalFocusListener();
+ attachGlobalDOMScope(document.body);
+
+ return (
+ <MobileSettingsProvider>
+ <ViewNavigationSlotContext.Provider value={navigationSlot}>
+ <div
+ class={cn(
+ 'relative flex flex-col justify-between not-touch:bg-panel w-dvw h-[calc(var(--dvh,1dvh)*100)] pl-(--safe-left) pr-(--safe-right)',
+ hasOverlayTitleBar && 'pt-[40px]'
+ )}
+ >
+ <Show when={hasOverlayTitleBar}>
+ <DesktopTitleBar navigationRef={setNavigationSlot} />
+ </Show>
+ <ImperativeDialogHost />
+ <BundleUpdateProgressBar />
+ <Show when={paywallOpen()}>
+ <Suspense>
+ <Paywall />
+ </Suspense>
+ </Show>
+ <Show when={usageLimitOpen()}>
+ <AiUsageLimitDialog />
+ </Show>
+ <div class="min-h-0 flex-1 flex flex-col">
+ {/* Route loading must not detach the frame. Routes draw their own
+ loading state, so the frame adds none. */}
+ <Suspense>{props.children}</Suspense>
+ </div>
+ <SwipeDownDismissKeyboard />
+ <DevStatusBar />
+ </div>
+ </ViewNavigationSlotContext.Provider>
+ </MobileSettingsProvider>
+ );
+}
+
+/** A page's content area: the space the app chrome or a full-screen shell leaves. */
+export function PageContent(props: ParentProps) {
+ return (
+ <div class="flex-1 w-full min-h-0 font-sans text-ink caret-current">
+ {props.children}
+ </div>
+ );
+}
+
+/**
+ * Sends first-time desktop users into the onboarding flow at /onboarding.
+ * App chrome runs it, so it fires on any app destination (marketing SSO lands
+ * on /app, not /login) and never on the onboarding pages themselves.
+ */
+function useNewOnboardingRedirect() {
+ const userInfoQuery = useUserInfoQuery();
+ const navigate = useNavigate();
+ const location = useLocation();
+ createEffect(() => {
+ if (isMobile() || isNativeMobilePlatform()) return;
+ // A pending read would suspend the chrome; wait for the user instead.
+ const data = userInfoQuery.isSuccess ? userInfoQuery.data : undefined;
+ if (data?.authenticated !== true || data.tutorialComplete !== false) {
+ return;
+ }
+ // Preserve the deep link the user arrived on (a shared doc, an invite):
+ // onboarding carries it as ?next and its finish() returns there instead of
+ // the post-setup landing. Base-relative so navigate() can resolve it
+ // against the router.
+ const target =
+ location.pathname.slice(ROUTER_BASE_CONCAT.length - 1) + location.search;
+ const isGenericEntry = target === '/' || target.startsWith(DEFAULT_ROUTE);
+ navigate(
+ isGenericEntry
+ ? '/onboarding'
+ : `/onboarding?next=${encodeURIComponent(target)}`,
+ { replace: true }
+ );
+ });
+}
+
+/**
+ * The app's providers and chrome — rail, hotkeys, command menu, launcher,
+ * global modals, and the mobile dock — around a page. The split layout and
+ * signed-in form pages render in it; auth, booking, and meeting pages don't.
+ */
+export function AppChrome(props: ParentProps) {
+ const isAuthenticated = useIsAuthenticated();
+ // A login cookie shows the rail while sign-in is confirmed; a stale one
+ // goes through SessionExpiredRedirect instead of leaving the app blank.
+ const sidebarVisible = () =>
+ !isTouchDevice() &&
+ (isAuthenticated() === true ||
+ (isAuthenticated() === undefined && hasLoginCookie()));
+
// Route mailto: links (via openExternalUrl) to the in-app email composer.
registerMailtoComposerHandler();
+ useNewOnboardingRedirect();
- attachGlobalDOMScope(document.body);
+ const companyDialogUsed = hasOpened(companyCreation.open);
+ const contactDialogUsed = hasOpened(
+ () => contactCreation.target() !== undefined
+ );
return (
- <ViewNavigationSlotContext.Provider value={navigationSlot}>
- <div
- class={cn(
- 'relative flex flex-col justify-between not-touch:bg-panel w-dvw h-[calc(var(--dvh,1dvh)*100)] pl-(--safe-left) pr-(--safe-right)',
- hasOverlayTitleBar && 'pt-[40px]'
- )}
- >
- <Show when={hasOverlayTitleBar}>
- <DesktopTitleBar navigationRef={setNavigationSlot} />
+ <AppProviders>
+ <SidebarVisibilityContext.Provider value={sidebarVisible}>
+ <Show when={isAuthenticated() === true}>
+ <ShowFeatureFlag flag={enableDatabases}>
+ <Suspense>
+ <StarterDatabase />
+ </Suspense>
+ </ShowFeatureFlag>
</Show>
- <ImperativeDialogHost />
- <BundleUpdateProgressBar />
<Suspense>
<Show when={isAuthenticated()}>
- <NewOnboardingRedirect />
- <Show when={!AUTH_URLS.includes(location.pathname)}>
- <GithubReauthenticationPrompt />
- <GmailReauthenticationPrompt />
- <CalendarPermissionPrompt />
- </Show>
+ <GithubReauthenticationPrompt />
+ <GmailReauthenticationPrompt />
+ <CalendarPermissionPrompt />
<GlobalShortcuts />
<Show when={!isTouchDevice()}>
<GoToHotkeys />
@@ -259,54 +291,39 @@ function LayoutInner(props: RouteSectionProps) {
<NativeShareSheet />
<MacroMcpSetupModal />
<CreateChannelModal />
- <CreateCompanyModal />
- <CreateContactModal />
+ <Show when={companyDialogUsed()}>
+ <Suspense>
+ <CreateCompanyModal />
+ </Suspense>
+ </Show>
+ <Show when={contactDialogUsed()}>
+ <Suspense>
+ <CreateContactModal />
+ </Suspense>
+ </Show>
<Show when={isAddInboxDialogOpen()}>
<AddInboxDialog />
</Show>
</Show>
- <Show
- when={
- isAuthenticated() === false &&
- !AUTH_URLS.includes(location.pathname)
- }
- >
- <Banner />
+ <Show when={isAuthenticated() === false}>
+ <Show when={hasLoginCookie()} fallback={<Banner />}>
+ <SessionExpiredRedirect />
+ </Show>
</Show>
</Suspense>
- {/* <Show when={isAuthenticated() && isTutorialCompleted() === false}>
- <Onboarding />
- </Show> */}
-
- <Show when={paywallOpen()}>
- <Suspense>
- <Paywall />
- </Suspense>
- </Show>
- <Show when={usageLimitOpen()}>
- <AiUsageLimitDialog />
- </Show>
<div class="min-h-0 flex-1 flex">
<ItemDndProvider>
<Show when={isSidebarVisible()}>
<SidebarRail />
</Show>
-
- <div class="flex-1 w-full min-h-0 font-sans text-ink caret-current">
- {/* Route loading must not detach the shell or mobile navigation. */}
- <Suspense fallback={<ContentLoading />}>
- {props.children}
- </Suspense>
- </div>
+ <PageContent>
+ {/* Route loading must not detach the chrome or mobile navigation;
+ the route draws its own loading state. */}
+ <Suspense>{props.children}</Suspense>
+ </PageContent>
</ItemDndProvider>
</div>
- <Show
- when={
- isTouchDevice() &&
- isAuthenticated() &&
- !AUTH_URLS.includes(location.pathname)
- }
- >
+ <Show when={isTouchDevice() && isAuthenticated()}>
<FloatRegionHost />
<Suspense>
<UserCardDrawer />
@@ -324,19 +341,16 @@ function LayoutInner(props: RouteSectionProps) {
<MobileDockRow />
</FloatRegion>
</Show>
- <SwipeDownDismissKeyboard />
+ <InitialInteractiveOnboardingModal />
<Suspense>
- <Show
- when={isAuthenticated() && !AUTH_URLS.includes(location.pathname)}
- >
+ <Show when={isAuthenticated()}>
<Launcher
open={createMenuOpen()}
onOpenChange={setCreateMenuOpen}
/>
</Show>
</Suspense>
- <DevStatusBar />
- </div>
- </ViewNavigationSlotContext.Provider>
+ </SidebarVisibilityContext.Provider>
+ </AppProviders>
);
}
diff --git a/apps/web/src/components/app/SessionExpiredRedirect.tsx b/apps/web/src/components/app/SessionExpiredRedirect.tsx
new file mode 100644
index 0000000000..de362c15f4
--- /dev/null
+++ b/apps/web/src/components/app/SessionExpiredRedirect.tsx
@@ -0,0 +1,47 @@
+import { clearLocalAuthSession } from '@core/auth/logout';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
+import { confirmSessionExpired } from '@core/util/fetchWithToken';
+import { thrownResultErrorHasCode } from '@core/util/result';
+import { authKeys, invalidateUserInfo } from '@queries/auth/user-info';
+import { queryClient } from '@queries/client';
+import { Navigate, useLocation } from '@solidjs/router';
+import { createResource, Show } from 'solid-js';
+
+export function getCurrentQueryString(routerSearch: string) {
+ const params = new URLSearchParams(
+ isNativeMobilePlatform() ? routerSearch : window.location.search
+ );
+ return params.toString().length > 0 ? `?${params.toString()}` : '';
+}
+
+/**
+ * Sends a session the server rejected to /welcome, after confirming it with a
+ * fresh refresh; the base path and the app chrome render it on a stale login.
+ */
+export function SessionExpiredRedirect() {
+ const location = useLocation();
+ // The UNAUTHORIZED that got us here can come from a latched refresh failure
+ // without the server ever being consulted, so confirm with a fresh refresh
+ // before destroying local session state. If the session turns out to be
+ // alive, refetch user-info instead and only treat a repeat 401 as real.
+ const [expired] = createResource(async () => {
+ if (!(await confirmSessionExpired())) {
+ await invalidateUserInfo();
+ const stillUnauthorized = thrownResultErrorHasCode(
+ queryClient.getQueryState(authKeys.userInfo.queryKey)?.error,
+ 'UNAUTHORIZED'
+ );
+ if (!stillUnauthorized) return false;
+ }
+ await clearLocalAuthSession().catch((error) => {
+ console.error('Failed to clear local auth session', error);
+ });
+ return true;
+ });
+
+ return (
+ <Show when={expired()}>
+ <Navigate href={`/welcome${getCurrentQueryString(location.search)}`} />
+ </Show>
+ );
+}
diff --git a/apps/web/src/components/app/boot-shell.test.ts b/apps/web/src/components/app/boot-shell.test.ts
index 9ff2fe1199..a54067e8dc 100644
--- a/apps/web/src/components/app/boot-shell.test.ts
+++ b/apps/web/src/components/app/boot-shell.test.ts
@@ -1,45 +1,11 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { dismissBootShell, rememberBootShell } from './boot-shell';
-
-const HINT_KEY = 'macro:boot-shell';
+import { dismissBootShell } from './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();
diff --git a/apps/web/src/components/app/boot-shell.ts b/apps/web/src/components/app/boot-shell.ts
index 1e151f9c3a..a8ce5f1889 100644
--- a/apps/web/src/components/app/boot-shell.ts
+++ b/apps/web/src/components/app/boot-shell.ts
@@ -1,7 +1,7 @@
/**
- * 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.
+ * Fades out the frame index.html paints before any JS runs. The first route
+ * shell to mount calls it, 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');
@@ -12,35 +12,3 @@ export function dismissBootShell(): void {
// 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/mobile/MobilePageActionRow.test.tsx b/apps/web/src/components/app/mobile/MobilePageActionRow.test.tsx
index 58b145ba99..83f9d7bc15 100644
--- a/apps/web/src/components/app/mobile/MobilePageActionRow.test.tsx
+++ b/apps/web/src/components/app/mobile/MobilePageActionRow.test.tsx
@@ -49,7 +49,7 @@ vi.mock(
vi.mock('@app/features/calendar/hooks/use-calendar-ui-flag', () => ({
useCalendarUiFlag: () => () => true,
}));
-vi.mock('@app/features/crm/crm-create', () => ({
+vi.mock('@app/features/crm/creation-adapter', () => ({
openCreateCompanyModal: mocks.openCompany,
}));
vi.mock('@core/mobile/haptics', () => ({ hapticImpact: vi.fn() }));
diff --git a/apps/web/src/components/app/mobile/MobilePageCreateButton.test.tsx b/apps/web/src/components/app/mobile/MobilePageCreateButton.test.tsx
index 5b7e709472..4f68fc0fa4 100644
--- a/apps/web/src/components/app/mobile/MobilePageCreateButton.test.tsx
+++ b/apps/web/src/components/app/mobile/MobilePageCreateButton.test.tsx
@@ -31,7 +31,7 @@ vi.mock(
useOpenEventComposer: () => sources.openEvent,
})
);
-vi.mock('@app/features/crm/crm-create', () => ({
+vi.mock('@app/features/crm/creation-adapter', () => ({
openCreateCompanyModal: sources.openCompany,
}));
vi.mock('@core/mobile/haptics', () => ({ hapticImpact: vi.fn() }));
diff --git a/apps/web/src/components/app/mobile/MobilePageCreateButton.tsx b/apps/web/src/components/app/mobile/MobilePageCreateButton.tsx
index d7a7ecea55..11a1ea1bd4 100644
--- a/apps/web/src/components/app/mobile/MobilePageCreateButton.tsx
+++ b/apps/web/src/components/app/mobile/MobilePageCreateButton.tsx
@@ -4,7 +4,7 @@ import {
setCreateMenuOpen,
useCreateMenuBlocks,
} from '@app/features/command/Launcher';
-import { openCreateCompanyModal } from '@app/features/crm/crm-create';
+import { openCreateCompanyModal } from '@app/features/crm/creation-adapter';
import { hapticImpact } from '@core/mobile/haptics';
import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
import CalendarIcon from '@phosphor/calendar-blank.svg';
diff --git a/apps/web/src/components/app/sidebar-next/app-update.ts b/apps/web/src/components/app/sidebar-next/app-update.ts
new file mode 100644
index 0000000000..a076dc657c
--- /dev/null
+++ b/apps/web/src/components/app/sidebar-next/app-update.ts
@@ -0,0 +1,104 @@
+import { pendingWebUpdate } from '@core/util/reloadForNewerBuild';
+import { useTauri } from '@macro/tauri';
+import { invoke } from '@tauri-apps/api/core';
+import { type Accessor, createMemo } from 'solid-js';
+
+/** An update this app can apply now, as the rail's update button offers it. */
+export type AppUpdate = {
+ /** Stable per update, so dismissing one doesn't hide the next. */
+ id: string;
+ title: string;
+ description: string;
+ actionLabel: string;
+ /** The action is running and the popover must stay open. */
+ busy: boolean;
+ apply: () => void;
+};
+
+type UpdateCopy = Pick<AppUpdate, 'title' | 'description' | 'actionLabel'>;
+
+/** What the popover says for each kind of update, by client. */
+export const UPDATE_COPY = {
+ web: {
+ title: 'New version available',
+ description: 'A new version of Macro is ready. Reload the page to use it.',
+ actionLabel: 'Reload',
+ },
+ webFailedLoad: {
+ title: 'New version available',
+ description:
+ "Part of Macro couldn't load because a new version is out. Reload the page to use it.",
+ actionLabel: 'Reload',
+ },
+ bundle: {
+ title: 'Update ready',
+ description:
+ 'A new version of the Macro desktop app has downloaded. Update to start using it.',
+ actionLabel: 'Update',
+ },
+ native: {
+ title: 'Desktop app update ready',
+ description:
+ 'Restart Macro to install it, or keep working and it installs when you quit.',
+ actionLabel: 'Restart and update',
+ },
+ nativePreparing: {
+ title: 'Desktop app update ready',
+ description:
+ 'Saving your work before Macro restarts to install the update.',
+ actionLabel: 'Preparing to restart…',
+ },
+} satisfies Record<string, UpdateCopy>;
+
+/** The bundle build this page booted, from index.html. */
+function runningBuild(): string {
+ return (
+ document
+ .querySelector<HTMLMetaElement>('meta[name="macro-bundle-build"]')
+ ?.getAttribute('content') ?? ''
+ );
+}
+
+/**
+ * The update ready to apply, if any: a downloaded desktop app update, a
+ * downloaded web bundle in the desktop app, or a newer web build.
+ */
+export function useAppUpdate(): Accessor<AppUpdate | undefined> {
+ const tauri = useTauri();
+
+ return createMemo(() => {
+ const native = tauri?.nativeUpdateStatus();
+ if (tauri && native?.status === 'Ready') {
+ const preparing = tauri.nativeUpdatePreparing();
+ return {
+ id: `native:${native.data.version}`,
+ ...(preparing ? UPDATE_COPY.nativePreparing : UPDATE_COPY.native),
+ busy: preparing,
+ apply: () => void tauri.restartNativeUpdate(),
+ };
+ }
+
+ if (tauri?.bundleUpdateStatus().status === 'Completed') {
+ return {
+ id: `bundle:${runningBuild()}`,
+ ...UPDATE_COPY.bundle,
+ busy: false,
+ apply: () => void invoke('perform_update'),
+ };
+ }
+
+ const web = pendingWebUpdate();
+ if (web) {
+ // Each failed load is a new id, so the popover opens again.
+ const failed = web.failedLoads ? `:failed-${web.failedLoads}` : '';
+ return {
+ id: `web:${web.build ?? runningBuild()}${failed}`,
+ ...(web.failedLoads ? UPDATE_COPY.webFailedLoad : UPDATE_COPY.web),
+ busy: false,
+ apply: web.reload,
+ };
+ }
+
+ return undefined;
+ });
+}
diff --git a/apps/web/src/components/app/sidebar-next/footer-actions.tsx b/apps/web/src/components/app/sidebar-next/footer-actions.tsx
index 5effd6f187..31f2f070a2 100644
--- a/apps/web/src/components/app/sidebar-next/footer-actions.tsx
+++ b/apps/web/src/components/app/sidebar-next/footer-actions.tsx
@@ -1,21 +1,20 @@
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';
import { useEmail, useUserId } from '@core/context/user';
import { TOKENS } from '@core/hotkey/tokens';
import DeviceMobileDownloadIcon from '@icon/device-mobile-download.svg';
-import { useTauri } from '@macro/tauri';
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 { createEffect, createMemo, Show } from 'solid-js';
-import { NativeUpdateButton } from './native-update-button';
+import { createMemo, Show } from 'solid-js';
+import { useAppUpdate } from './app-update';
import { NavGlyph } from './nav-glyph';
+import { UpdateButton } from './update-button';
/**
* Sizes the gear and punches a gap around the avatar badge (16px, centred at
@@ -46,10 +45,6 @@ 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' });
@@ -90,7 +85,7 @@ export const FooterActions = (props: {
onMenuOpenChange?: (open: boolean) => void;
}) => {
const analytics = useAnalytics();
- const tauri = useTauri();
+ const update = useAppUpdate();
const { openSettings, openSettingsInSplit, settingsOpen, activeTabId } =
useSettingsState();
const userId = useUserId();
@@ -118,13 +113,11 @@ export const FooterActions = (props: {
return (
<div class="flex w-full shrink-0 flex-col items-center gap-1">
- <Show when={tauri}>
- {(native) => (
- <Show when={native().nativeUpdateStatus().status === 'Ready'}>
- <NativeUpdateButton
- preparing={native().nativeUpdatePreparing()}
- onRestart={() => void native().restartNativeUpdate()}
- />
+ {/* Keyed by id: a new update remounts the button, so its popover opens again. */}
+ <Show when={update()?.id} keyed>
+ {(_id) => (
+ <Show when={update()}>
+ {(current) => <UpdateButton update={current} />}
</Show>
)}
</Show>
diff --git a/apps/web/src/components/app/sidebar-next/list-nav.tsx b/apps/web/src/components/app/sidebar-next/list-nav.tsx
index a9c7207fd9..76349c7357 100644
--- a/apps/web/src/components/app/sidebar-next/list-nav.tsx
+++ b/apps/web/src/components/app/sidebar-next/list-nav.tsx
@@ -65,6 +65,7 @@ export const ListNav = (props: ListNavProps) => {
const location = useLocation();
const content = () => sidebarContent(props.item.id, props.item.params);
+ const preload = () => layout.preloadContent(content());
// Read the manager signal live: it is undefined until the split layout
// mounts, which happens after the sidebar.
@@ -226,6 +227,8 @@ export const ListNav = (props: ListNavProps) => {
data-unread={props.unread ? '' : undefined}
data-active-call={props.activeCall ? '' : undefined}
data-badge={props.badge}
+ onMouseEnter={preload}
+ onFocus={preload}
onMouseDown={onMouseDown}
onClick={onClick}
>
diff --git a/apps/web/src/components/app/sidebar-next/more-menu.tsx b/apps/web/src/components/app/sidebar-next/more-menu.tsx
index e8fae0bdbd..028b7ab707 100644
--- a/apps/web/src/components/app/sidebar-next/more-menu.tsx
+++ b/apps/web/src/components/app/sidebar-next/more-menu.tsx
@@ -1,6 +1,9 @@
import { useAnalytics } from '@app/lib/analytics/analytics-context';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { navigateToSidebarView } from '@components/app/app-sidebar/sidebar';
+import {
+ navigateToSidebarView,
+ sidebarContent,
+} from '@components/app/app-sidebar/sidebar';
import { useSplitLayout } from '@components/app/split-layout/layout';
import DotsThreeIcon from '@phosphor/dots-three.svg';
import { Dropdown } from '@ui';
@@ -41,6 +44,8 @@ export function MoreMenu(props: MoreMenuProps) {
const [customizeSidebarOpen, setCustomizeSidebarOpen] = createSignal(false);
const analytics = useAnalytics();
const layout = useSplitLayout();
+ const preloadItem = (item: SidebarNextNavItem) =>
+ layout.preloadContent(sidebarContent(item.id, item.params));
const hiddenItems = () => moreMenuItems(props.gates);
return (
@@ -65,6 +70,8 @@ export function MoreMenu(props: MoreMenuProps) {
{(item) => (
<Dropdown.Item
class="gap-2"
+ onMouseEnter={() => preloadItem(item)}
+ onFocus={() => preloadItem(item)}
onSelect={() =>
navigateToItem(item, layout.openWithSplit, analytics)
}
diff --git a/apps/web/src/components/app/sidebar-next/native-update-button.tsx b/apps/web/src/components/app/sidebar-next/native-update-button.tsx
deleted file mode 100644
index 0f17bcef4f..0000000000
--- a/apps/web/src/components/app/sidebar-next/native-update-button.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import ArrowCircleUpIcon from '@phosphor/arrow-circle-up.svg';
-import { Button } from '@ui';
-import { createSignal, lazy, Show, Suspense } from 'solid-js';
-import { NavGlyph } from './nav-glyph';
-
-const NativeUpdateDialog = lazy(() => import('./native-update-dialog'));
-
-export function NativeUpdateButton(props: {
- preparing: boolean;
- onRestart: () => void;
-}) {
- const [open, setOpen] = createSignal(false);
- let trigger: HTMLButtonElement | undefined;
-
- return (
- <>
- <Button
- ref={trigger}
- variant="accent"
- size="icon-md"
- class="size-10 cursor-default rounded-xl"
- label="Update available"
- tooltip="Update available"
- tooltipPlacement="right"
- aria-haspopup="dialog"
- aria-expanded={open()}
- data-sidebar-next-item="app-update"
- onClick={() => setOpen(true)}
- >
- <NavGlyph icon={ArrowCircleUpIcon} class="size-6" />
- </Button>
- <Show when={open()}>
- <Suspense>
- <NativeUpdateDialog
- preparing={props.preparing}
- onClose={() => setOpen(false)}
- onRestoreFocus={() => trigger?.focus()}
- onRestart={props.onRestart}
- />
- </Suspense>
- </Show>
- </>
- );
-}
diff --git a/apps/web/src/components/app/sidebar-next/native-update-dialog.tsx b/apps/web/src/components/app/sidebar-next/native-update-dialog.tsx
deleted file mode 100644
index a1c7731efe..0000000000
--- a/apps/web/src/components/app/sidebar-next/native-update-dialog.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import ArrowCircleUpIcon from '@phosphor/arrow-circle-up.svg';
-import { Button, Dialog, Surface } from '@ui';
-
-export default function NativeUpdateDialog(props: {
- preparing: boolean;
- onClose: () => void;
- onRestoreFocus: () => void;
- onRestart: () => void;
-}) {
- return (
- <Dialog
- open
- onOpenChange={(open) => {
- if (!open && !props.preparing) props.onClose();
- }}
- onCloseAutoFocus={(event) => {
- // The sidebar button lives outside this lazily mounted dialog root.
- event.preventDefault();
- props.onRestoreFocus();
- }}
- position="center"
- animate
- class="w-100 max-w-[calc(100vw-16px)]"
- >
- <Surface depth={2}>
- <div class="flex flex-col gap-5 p-6" aria-busy={props.preparing}>
- <div class="flex flex-col gap-2">
- <ArrowCircleUpIcon
- class="mb-1 size-8 text-accent"
- aria-hidden="true"
- />
- <Dialog.Title class="text-lg font-semibold text-ink">
- Update Macro
- </Dialog.Title>
- <Dialog.Description class="text-sm leading-5 text-ink-muted">
- A new version of Macro is ready. Restart to install it, or keep
- working and it will update when you quit.
- </Dialog.Description>
- </div>
- <div class="flex justify-end gap-2">
- <Dialog.CloseButton
- as={Button}
- aria-label="Later"
- variant="strong"
- size="sm"
- disabled={props.preparing}
- >
- Later
- </Dialog.CloseButton>
- <Button
- variant="accent"
- size="sm"
- disabled={props.preparing}
- onClick={props.onRestart}
- >
- {props.preparing ? 'Preparing to restart…' : 'Restart and update'}
- </Button>
- </div>
- </div>
- </Surface>
- </Dialog>
- );
-}
diff --git a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx
index acba381e3e..63083b07d7 100644
--- a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx
+++ b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx
@@ -2,12 +2,11 @@ import { useHasActiveChannelsCall } from '@app/features/channels-view/use-has-ac
import { 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 { isPlatform } from '@core/util/platform';
import { cn } from '@ui';
-import { createEffect, For, Match, Suspense, Switch } from 'solid-js';
+import { For, Match, Suspense, Switch } from 'solid-js';
import { SidebarRailCreateButton } from './create-button';
import { FooterActions } from './footer-actions';
import { ListNav, type ListNavProps } from './list-nav';
@@ -51,11 +50,6 @@ 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/sidebar-next/update-button.tsx b/apps/web/src/components/app/sidebar-next/update-button.tsx
new file mode 100644
index 0000000000..903f119db2
--- /dev/null
+++ b/apps/web/src/components/app/sidebar-next/update-button.tsx
@@ -0,0 +1,99 @@
+import { Popover } from '@kobalte/core/popover';
+import DownloadIcon from '@phosphor/download-simple.svg';
+import { Button } from '@ui';
+import { createSignal } from 'solid-js';
+import type { AppUpdate } from './app-update';
+
+const DISMISSED_KEY = 'macro:app-update-dismissed';
+
+/**
+ * A hairline comet on the circle's edge: a soft head with a short tail that
+ * fades out, masked to a 1.5px ring.
+ */
+const COMET = {
+ background:
+ 'conic-gradient(from 0deg, transparent 0deg 230deg, color-mix(in oklch, var(--color-accent) 80%, transparent) 350deg, transparent 360deg)',
+ mask: 'radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px))',
+} as const;
+
+function dismissedUpdate(): string | null {
+ try {
+ return localStorage.getItem(DISMISSED_KEY);
+ } catch {
+ return null;
+ }
+}
+
+function dismissUpdate(id: string): void {
+ try {
+ localStorage.setItem(DISMISSED_KEY, id);
+ } catch {
+ // Storage can be unavailable; the popover just opens again next time.
+ }
+}
+
+/**
+ * The rail's update button: a download glyph in a subtle accent circle that a
+ * glowing comet circles every few seconds. Its popover opens by itself once per update, until it is
+ * dismissed; mount one per update id so a new update opens it again.
+ */
+export function UpdateButton(props: { update: () => AppUpdate }) {
+ const [open, setOpen] = createSignal(dismissedUpdate() !== props.update().id);
+
+ const onOpenChange = (next: boolean) => {
+ if (!next && props.update().busy) return;
+ setOpen(next);
+ if (!next) dismissUpdate(props.update().id);
+ };
+
+ return (
+ <Popover
+ open={open()}
+ onOpenChange={onOpenChange}
+ placement="right-end"
+ gutter={8}
+ >
+ <Popover.Trigger
+ as={Button}
+ variant="ghost"
+ size="icon-md"
+ class="size-10 cursor-default rounded-xl"
+ label="Update available"
+ draggable={false}
+ data-sidebar-next-item="app-update"
+ >
+ <span class="pointer-events-none relative flex size-7 items-center justify-center rounded-full bg-accent-bg text-accent">
+ <span
+ aria-hidden="true"
+ class="absolute -inset-px rounded-full opacity-0 animate-update-glow motion-reduce:hidden"
+ style={COMET}
+ />
+ <DownloadIcon class="size-4" aria-hidden="true" />
+ </span>
+ </Popover.Trigger>
+ <Popover.Portal>
+ <Popover.Content
+ class="z-modal w-64 rounded-xl border border-edge-muted bg-menu p-4 shadow-xl outline-none animate-menu-open"
+ aria-busy={props.update().busy}
+ >
+ <Popover.Title class="text-sm font-semibold text-ink">
+ {props.update().title}
+ </Popover.Title>
+ <Popover.Description class="mt-1 text-sm leading-5 text-ink-muted">
+ {props.update().description}
+ </Popover.Description>
+ <div class="mt-3 flex justify-end">
+ <Button
+ variant="cta"
+ size="sm"
+ disabled={props.update().busy}
+ onClick={() => props.update().apply()}
+ >
+ {props.update().actionLabel}
+ </Button>
+ </div>
+ </Popover.Content>
+ </Popover.Portal>
+ </Popover>
+ );
+}
diff --git a/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx b/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx
index 9651c4f4e7..b92e19c5bf 100644
--- a/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx
+++ b/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx
@@ -1,5 +1,4 @@
import { SoupContextProvider } from '@app/features/next-soup/soup-context';
-import { ContentLoading } from '@components/app/ContentLoading';
import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
import { useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
@@ -151,7 +150,7 @@ function PopoverSplitModal(props: {
<SoupContextProvider>
<Show when={props.popover.mount}>
<Panel.Body>
- <Suspense fallback={<ContentLoading />}>
+ <Suspense>
<Dynamic component={props.popover.mount.element} />
</Suspense>
</Panel.Body>
diff --git a/apps/web/src/components/app/split-layout/components/SplitPanel.tsx b/apps/web/src/components/app/split-layout/components/SplitPanel.tsx
index 3fd25b1f56..e3cdf0184c 100644
--- a/apps/web/src/components/app/split-layout/components/SplitPanel.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitPanel.tsx
@@ -4,7 +4,6 @@ import { SoupContextProvider } from '@app/features/next-soup/soup-context';
import { SoupViewContextProvider } from '@app/features/next-soup/soup-view/soup-view-context';
import { type PaneId, SplitRouter } from '@app/lib/split-router';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { ContentLoading } from '@components/app/ContentLoading';
import { MobileTopEdgeFade } from '@components/app/mobile/MobileEdgeFade';
import { MobilePageActionRow } from '@components/app/mobile/MobilePageActionRow';
import { SplitPanelControllerProvider } from '@components/app/split-panel';
@@ -158,7 +157,7 @@ export function SplitPanel(props: SplitPanelProps) {
close: props.handle.close,
}}
>
- <Suspense fallback={<ContentLoading />}>
+ <Suspense>
<Show
when={
props.split.mount.kind === 'component' &&
diff --git a/apps/web/src/components/app/split-layout/layout.ts b/apps/web/src/components/app/split-layout/layout.ts
index 3a6c3250ee..a965be6964 100644
--- a/apps/web/src/components/app/split-layout/layout.ts
+++ b/apps/web/src/components/app/split-layout/layout.ts
@@ -17,6 +17,11 @@ import type {
export function useSplitLayout() {
const splitPanelContext = useContext(SplitPanelContext);
+ /** Warms a destination on navigation intent (hover, focus) without opening it. */
+ function preloadContent(content: SplitContent) {
+ globalSplitManager()?.preloadContent(content);
+ }
+
function openWithSplit(
content: SplitContent,
options?: OpenWithSplitOptions
@@ -138,6 +143,7 @@ export function useSplitLayout() {
return {
openWithSplit,
+ preloadContent,
getSplitCount,
replaceOrInsertSplit,
replaceSplit,
diff --git a/apps/web/src/components/app/split-layout/layoutManager.ts b/apps/web/src/components/app/split-layout/layoutManager.ts
index d6eafbb57f..b72d318db3 100644
--- a/apps/web/src/components/app/split-layout/layoutManager.ts
+++ b/apps/web/src/components/app/split-layout/layoutManager.ts
@@ -340,6 +340,9 @@ export type SplitManager = {
options?: OpenWithSplitOptions
) => OpenSplitResult;
+ /** Starts loading `content`'s route, as on hover, without opening it. */
+ preloadContent: (content: SplitContent) => void;
+
/** Set a split as active by its split id */
activateSplit: (id: SplitId) => void;
@@ -1717,6 +1720,13 @@ export function createSplitLayout(
replaceAllSplits,
getSplit,
openWithSplit,
+ preloadContent: (content) => {
+ try {
+ void router.preload(toLocation(content));
+ } catch {
+ // Speculative: the navigation itself reports content it can't route.
+ }
+ },
removeSplit,
swapSplit,
canSwapSplit,
diff --git a/apps/web/src/components/app/split-layout/mobile/MobileSplitContainer.tsx b/apps/web/src/components/app/split-layout/mobile/MobileSplitContainer.tsx
index e4e8f47631..54d8fc377e 100644
--- a/apps/web/src/components/app/split-layout/mobile/MobileSplitContainer.tsx
+++ b/apps/web/src/components/app/split-layout/mobile/MobileSplitContainer.tsx
@@ -1,4 +1,3 @@
-import { ContentLoading } from '@components/app/ContentLoading';
import { useAndroidBackNavigation } from '@core/mobile/androidBack';
import {
type Accessor,
@@ -108,7 +107,7 @@ export function MobileSplitContainer(props: MobileSplitContainerProps) {
motion.handleTransitionEnd(e, isFront())
}
>
- <Suspense fallback={<ContentLoading />}>
+ <Suspense>
<SplitPanel
split={current().split}
handle={current().handle}
diff --git a/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx b/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx
index 89a434959b..a8b75a2524 100644
--- a/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx
+++ b/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx
@@ -3,7 +3,14 @@ import { isRecord, type PaneId, useSplitRouter } from '@app/lib/split-router';
import { useIsAuthenticated } from '@core/auth';
import { LoadingBlock } from '@core/component/LoadingBlock';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { type Component, type JSX, onMount, Show } from 'solid-js';
+import {
+ type Component,
+ type JSX,
+ Match,
+ onMount,
+ Show,
+ Switch,
+} from 'solid-js';
import type { SplitContent } from '../layoutManager';
import { useSplitPanelOrThrow } from '../layoutUtils';
@@ -15,13 +22,22 @@ export function usePageViewTracking(pageTitle: string) {
});
}
-export function withAuth<P extends object>(View: Component<P>): Component<P> {
+/** Renders `View` once signed in; `Pending`, if given, draws while sign-in is confirmed. */
+export function withAuth<P extends object>(
+ View: Component<P>,
+ Pending?: Component
+): Component<P> {
return (props) => {
const authenticated = useIsAuthenticated();
return (
- <Show when={authenticated()} fallback={<LoadingBlock />}>
- <View {...props} />
- </Show>
+ <Switch fallback={<LoadingBlock />}>
+ <Match when={authenticated()}>
+ <View {...props} />
+ </Match>
+ <Match when={Pending && authenticated() === undefined}>
+ {Pending && <Pending />}
+ </Match>
+ </Switch>
);
};
}
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.tsx
index afae6aff85..1944cbc4d7 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
@@ -108,6 +108,7 @@ vi.mock('@app/features/email-view/components/EmailDetailView', () => ({
vi.mock('@app/features/home/home-view', () => ({
HomeDetailRouteView: () => null,
HomeCalendarRouteView: () => null,
+ HomePendingView: () => null,
}));
vi.mock('@app/features/next-soup/filters/filter-store', () => ({}));
vi.mock('@app/features/next-soup/filters/filter-store/query-store', () => ({}));
diff --git a/apps/web/src/components/app/ReactiveFavicon.tsx b/apps/web/src/components/app/useReactiveFavicon.ts
similarity index 90%
rename from apps/web/src/components/app/ReactiveFavicon.tsx
rename to apps/web/src/components/app/useReactiveFavicon.ts
index a573db6645..1b15342bda 100644
--- a/apps/web/src/components/app/ReactiveFavicon.tsx
+++ b/apps/web/src/components/app/useReactiveFavicon.ts
@@ -1,9 +1,9 @@
import { updateFavicon } from '@app/util/favicon';
import { createCrossTabBus } from '@core/cross-tab/cross-tab-bus';
+import type { NotificationSource } from '@notifications';
import { committedThemeAccent } from '@theme/signals/themeSignals';
import { createEffect, createSignal, onCleanup, onMount } from 'solid-js';
import { match, P } from 'ts-pattern';
-import { useGlobalNotificationSource } from './GlobalAppState';
type BadgeMessage = {
hasBadge: boolean;
@@ -24,12 +24,13 @@ const badgeBus = createCrossTabBus<BadgeMessage>({
.otherwise(() => null),
});
-export function ReactiveFavicon() {
+/** Badges the favicon when a notification arrives while the app is in the background. */
+export function useReactiveFavicon(
+ globalNotifications: NotificationSource
+): void {
const [showNotificationBadge, setShowNotificationBadge] = createSignal(false);
const [isAppFocused, setIsAppFocused] = createSignal(!document.hidden);
- const globalNotifications = useGlobalNotificationSource();
-
const postBadgeMessage = (hasBadge: boolean) => {
badgeBus.publish({ hasBadge, sentAt: Date.now() });
};
@@ -73,6 +74,4 @@ export function ReactiveFavicon() {
showNotificationBadge()
);
});
-
- return null;
}
diff --git a/apps/web/src/components/view-shell/ViewSkeleton.tsx b/apps/web/src/components/view-shell/ViewSkeleton.tsx
new file mode 100644
index 0000000000..4856fc44f0
--- /dev/null
+++ b/apps/web/src/components/view-shell/ViewSkeleton.tsx
@@ -0,0 +1,135 @@
+import { SplitPanel } from '@components/app/split-panel';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
+import { For, type JSX, type ParentProps, Show } from 'solid-js';
+import { ListSkeleton } from './ListSkeleton';
+import { SidebarCreateHeader } from './SidebarCreateButton';
+import { ViewShell, type ViewShellRootProps } from './ViewShell';
+import { ViewSidebar } from './ViewSidebar';
+
+const ROW_WIDTHS = [
+ 'w-3/5',
+ 'w-4/5',
+ 'w-1/2',
+ 'w-2/3',
+ 'w-3/4',
+ 'w-1/2',
+ 'w-4/5',
+ 'w-3/5',
+];
+
+/** Shimmering rows, the shape of a list that hasn't loaded. */
+function Rows(props: { label: string; count?: number; class?: string }) {
+ return (
+ <ListSkeleton.Root label={props.label} class={props.class}>
+ <For each={ROW_WIDTHS.slice(0, props.count ?? ROW_WIDTHS.length)}>
+ {(width) => (
+ <ListSkeleton.Row>
+ <ListSkeleton.Bar class="size-4 shrink-0 rounded" />
+ <ListSkeleton.Bar class={width} />
+ </ListSkeleton.Row>
+ )}
+ </For>
+ </ListSkeleton.Root>
+ );
+}
+
+/**
+ * A view's frame while its code loads: the same pane and view shell the view
+ * renders, keyed by its aside preference so widths and collapse match.
+ */
+function Root(
+ props: ParentProps<{
+ asidePreferenceKey: string;
+ aside?: ViewShellRootProps['aside'];
+ main?: ViewShellRootProps['main'];
+ }>
+) {
+ return (
+ <SplitPanel.Root>
+ <SplitPanel.Body>
+ <div class="size-full min-h-0 bg-panel">
+ <ViewShell.Root
+ asidePreferenceKey={props.asidePreferenceKey}
+ aside={props.aside ?? { preserveDuringResize: false }}
+ main={props.main ?? { preferredWidth: 640 }}
+ resizable
+ >
+ {props.children}
+ </ViewShell.Root>
+ </div>
+ </SplitPanel.Body>
+ </SplitPanel.Root>
+ );
+}
+
+/** The view's sidebar: its title, its create action if it has one, and rows. */
+function Sidebar(props: {
+ title: string;
+ createLabel?: string;
+ children?: JSX.Element;
+}) {
+ return (
+ <ViewShell.Aside class="flex flex-col bg-panel">
+ <Show
+ when={props.createLabel}
+ fallback={
+ <Show when={!isTouchDevice()}>
+ <ViewSidebar.Header>
+ <div class="flex min-w-0 items-center gap-1">
+ <ViewSidebar.CloseButton class="shrink-0" />
+ <ViewSidebar.Title>{props.title}</ViewSidebar.Title>
+ </div>
+ </ViewSidebar.Header>
+ </Show>
+ }
+ >
+ {(label) => (
+ <SidebarCreateHeader
+ title={props.title}
+ label={label()}
+ onCreate={() => {}}
+ />
+ )}
+ </Show>
+ {props.children ?? <Rows label={`Loading ${props.title}`} class="mt-3" />}
+ </ViewShell.Aside>
+ );
+}
+
+/** The view's main area: its top bar title, its search box, and rows or `children`. */
+function Main(props: {
+ title?: string;
+ searchPlaceholder?: string;
+ children?: JSX.Element;
+}) {
+ return (
+ <ViewShell.Main class="flex flex-col overflow-hidden">
+ <Show when={props.title}>
+ {(title) => (
+ <ViewShell.TopBar>
+ <span class="truncate font-semibold text-ink text-sm">
+ {title()}
+ </span>
+ </ViewShell.TopBar>
+ )}
+ </Show>
+ <Show when={props.searchPlaceholder}>
+ {(placeholder) => (
+ <ViewShell.Header>
+ <div class="flex h-10 w-full max-w-md min-w-0 items-center gap-2 rounded-full border border-edge-button bg-control px-3 text-ink-placeholder text-sm">
+ <MagnifyingGlassIcon class="size-4 shrink-0 text-ink-extra-muted" />
+ <span class="truncate">{placeholder()}</span>
+ </div>
+ </ViewShell.Header>
+ )}
+ </Show>
+ {props.children ?? (
+ <Rows label={`Loading ${props.title ?? 'view'}`} class="px-2" />
+ )}
+ </ViewShell.Main>
+ );
+}
+
+/** Building blocks for a view's loading skeleton, rendered before its code arrives. */
+export const ViewSkeleton = { Root, Sidebar, Main, Rows };
diff --git a/apps/web/src/features/agents-view/agents-view-skeleton.tsx b/apps/web/src/features/agents-view/agents-view-skeleton.tsx
new file mode 100644
index 0000000000..f2df76d1ef
--- /dev/null
+++ b/apps/web/src/features/agents-view/agents-view-skeleton.tsx
@@ -0,0 +1,17 @@
+import { ViewSkeleton } from '@app/components/view-shell/ViewSkeleton';
+
+/** Agents while its code loads: the conversations sidebar and a new conversation. */
+export function AgentsViewSkeleton() {
+ return (
+ <ViewSkeleton.Root
+ asidePreferenceKey="agents"
+ aside={{ min: 224, max: 380, preserveDuringResize: false }}
+ main={{ min: 280, preferredWidth: 640 }}
+ >
+ <ViewSkeleton.Sidebar title="Agents" createLabel="New conversation" />
+ <ViewSkeleton.Main title="New conversation">
+ <div class="flex-1" />
+ </ViewSkeleton.Main>
+ </ViewSkeleton.Root>
+ );
+}
diff --git a/apps/web/src/features/agents-view/route-views.test.tsx b/apps/web/src/features/agents-view/route-views.test.tsx
index 178d747822..7ea7588808 100644
--- a/apps/web/src/features/agents-view/route-views.test.tsx
+++ b/apps/web/src/features/agents-view/route-views.test.tsx
@@ -42,6 +42,7 @@ vi.mock('@components/app/split-layout/split-router/app-route-shell', () => ({
},
}));
vi.mock('@core/component/LoadingBlock', () => ({ LoadingBlock: () => null }));
+vi.mock('./agents-view-skeleton', () => ({ AgentsViewSkeleton: () => null }));
vi.mock('@core/constant/featureFlags', () => ({
enableChatV3Agents: { key: 'enable-chat-v3-agents' },
}));
diff --git a/apps/web/src/features/agents-view/route-views.tsx b/apps/web/src/features/agents-view/route-views.tsx
index e23ec74e90..945bcb1490 100644
--- a/apps/web/src/features/agents-view/route-views.tsx
+++ b/apps/web/src/features/agents-view/route-views.tsx
@@ -7,13 +7,13 @@ import {
usePageViewTracking,
withAuth,
} from '@components/app/split-layout/split-router/app-route-shell';
-import { LoadingBlock } from '@core/component/LoadingBlock';
import { enableChatV3Agents } from '@core/constant/featureFlags';
import { useUserContext } from '@core/context/user';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { createRenderEffect, lazy, Show } from 'solid-js';
import { getViewPreset } from '../next-soup/sidebar/soup-filter-presets';
import { routineContent } from '../routines/routine-navigation';
+import { AgentsViewSkeleton } from './agents-view-skeleton';
import { parseAgentsRoute } from './core/route';
const SoupView = lazy(async () => ({
@@ -113,7 +113,7 @@ export const AgentsRouteView = withAuth(() => {
);
};
return (
- <Show when={!flag().loading} fallback={<LoadingBlock />}>
+ <Show when={!flag().loading} fallback={<AgentsViewSkeleton />}>
<Show
when={enabled()}
fallback={
@@ -178,4 +178,4 @@ export const AgentsRouteView = withAuth(() => {
</Show>
</Show>
);
-});
+}, AgentsViewSkeleton);
diff --git a/apps/web/src/features/block-form/form-respond-page.tsx b/apps/web/src/features/block-form/form-respond-page.tsx
index be28823a8b..7c331ba9e9 100644
--- a/apps/web/src/features/block-form/form-respond-page.tsx
+++ b/apps/web/src/features/block-form/form-respond-page.tsx
@@ -3,7 +3,7 @@
* shells: signed-in visitors see it inside the app shell (sidebar, command
* menu) and can edit their response; anonymous
* visitors get the focused shell, so a public form never meets the login
- * redirect (`routes/focused-shell.ts`). The form itself is the shared
+ * redirect (`withFormRespondShell` in `routes/shells.tsx`). The form itself is the shared
* `RespondView`.
*/
import { settingsTabToSlug } from '@core/constant/settingsTabsConfig';
diff --git a/apps/web/src/features/calendar-view/calendar-view-skeleton.tsx b/apps/web/src/features/calendar-view/calendar-view-skeleton.tsx
new file mode 100644
index 0000000000..aeb56b739f
--- /dev/null
+++ b/apps/web/src/features/calendar-view/calendar-view-skeleton.tsx
@@ -0,0 +1,25 @@
+import { ViewSkeleton } from '@app/components/view-shell/ViewSkeleton';
+import { CalendarGridSkeleton } from '@app/features/calendar/components/CalendarGridSkeleton';
+import { isMobile } from '@core/mobile/isMobile';
+
+const monthTitle = () =>
+ new Intl.DateTimeFormat(undefined, { month: 'long', year: 'numeric' }).format(
+ new Date()
+ );
+
+/** Calendar while its code loads: the month title over an empty week grid. */
+export function CalendarViewSkeleton() {
+ return (
+ <ViewSkeleton.Root
+ asidePreferenceKey="calendar"
+ aside={isMobile() ? false : { preserveDuringResize: false }}
+ >
+ <ViewSkeleton.Sidebar title="Calendar" createLabel="New" />
+ <ViewSkeleton.Main title={monthTitle()}>
+ <div class="flex min-h-0 flex-1">
+ <CalendarGridSkeleton dayCount={7} showDayHeader showAllDaySlot />
+ </div>
+ </ViewSkeleton.Main>
+ </ViewSkeleton.Root>
+ );
+}
diff --git a/apps/web/src/features/calendar-view/calendar-view.tsx b/apps/web/src/features/calendar-view/calendar-view.tsx
index 0b77929d45..503603a02d 100644
--- a/apps/web/src/features/calendar-view/calendar-view.tsx
+++ b/apps/web/src/features/calendar-view/calendar-view.tsx
@@ -10,7 +10,6 @@ import {
useParams,
} from '@app/lib/split-router';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
-import { LoadingBlock } from '@core/component/LoadingBlock';
import { useUserId } from '@core/context/user';
import { useCalendarOccurrencesQuery } from '@queries/calendar/occurrences';
import deepEqual from 'fast-deep-equal';
@@ -27,6 +26,7 @@ import { CalendarFocusContextProvider } from './calendar-focus-target';
import { resolveCalendarTarget } from './calendar-target';
import { createCalendarTargetAim } from './calendar-target-request';
import { calendarSearch, calendarSearchTarget } from './calendar-url';
+import { CalendarViewSkeleton } from './calendar-view-skeleton';
import { Workspace } from './components/Workspace';
import { CALENDAR_VIEW_ID, type CalendarViewTarget } from './types';
@@ -213,7 +213,7 @@ export function CalendarView(props: CalendarViewProps) {
<Show
when={calendarUiEnabled()}
fallback={
- <Show when={posthog.flagsLoaded()} fallback={<LoadingBlock />}>
+ <Show when={posthog.flagsLoaded()} fallback={<CalendarViewSkeleton />}>
<CalendarDisabledRedirect />
</Show>
}
diff --git a/apps/web/src/features/calendar-view/route-views.tsx b/apps/web/src/features/calendar-view/route-views.tsx
index 2e08ee1625..5251935e42 100644
--- a/apps/web/src/features/calendar-view/route-views.tsx
+++ b/apps/web/src/features/calendar-view/route-views.tsx
@@ -1,11 +1,13 @@
import { calendarSplitRoute } from '@app/routes/routes';
import { withAuth } from '@components/app/split-layout/split-router/app-route-shell';
import { lazy } from 'solid-js';
+import { CalendarViewSkeleton } from './calendar-view-skeleton';
const CalendarView = lazy(async () => ({
default: (await import('./calendar-view')).CalendarView,
}));
-export const CalendarRouteView = withAuth(() => (
- <CalendarView route={calendarSplitRoute} />
-));
+export const CalendarRouteView = withAuth(
+ () => <CalendarView route={calendarSplitRoute} />,
+ CalendarViewSkeleton
+);
diff --git a/apps/web/src/features/channel/Call/call-link.ts b/apps/web/src/features/channel/Call/call-link.ts
index 8d6a5fc08d..d0747477dc 100644
--- a/apps/web/src/features/channel/Call/call-link.ts
+++ b/apps/web/src/features/channel/Call/call-link.ts
@@ -15,13 +15,6 @@ export function getMeetingUrl(shareToken: string) {
return `${getWebOrigin()}/app${getMeetingPath(shareToken)}`;
}
-export function isMeetingPath(pathname: string) {
- return (
- /^\/(?:app\/)?meet\/new\/?$/.test(pathname) ||
- meetingShareTokenFromPath(pathname) !== undefined
- );
-}
-
function meetingShareTokenFromPath(pathname: string): string | undefined {
const match = pathname.match(/^\/(?:app\/)?meet\/(?:join\/)?([^/?#]+)\/?$/);
if (!match) return undefined;
diff --git a/apps/web/src/features/channel/Call/tests/call-link.test.ts b/apps/web/src/features/channel/Call/tests/call-link.test.ts
index e9da6ef67d..ba8412c9ff 100644
--- a/apps/web/src/features/channel/Call/tests/call-link.test.ts
+++ b/apps/web/src/features/channel/Call/tests/call-link.test.ts
@@ -4,7 +4,6 @@ import {
getMeetingPath,
getMeetingShareToken,
getMeetingUrl,
- isMeetingPath,
} from '../call-link';
vi.mock('@core/util/webOrigin', () => ({
@@ -22,29 +21,6 @@ describe('meeting paths', () => {
expect(getActiveMeetingPath(token)).toBe(`/meet/${token}`);
});
- it.each([
- `/meet/join/${token}`,
- `/app/meet/join/${token}/`,
- `/meet/${token}`,
- `/app/meet/${token}/`,
- '/meet/new',
- '/app/meet/new/',
- ])('recognizes the meeting shell for %s', (path) => {
- expect(isMeetingPath(path)).toBe(true);
- });
-
- it.each([
- '/meet',
- '/meet/join',
- '/app/meet/join/',
- '/meet/new/extra',
- `/meet/join/${token}/extra`,
- '/app/calendar',
- '/meet/%invalid',
- ])('rejects incomplete and unrelated meeting routes: %s', (path) => {
- expect(isMeetingPath(path)).toBe(false);
- });
-
it.each([
`/meet/join/${token}`,
`https://macro.com/app/meet/join/${token}/?source=calendar#setup`,
diff --git a/apps/web/src/features/channels-view/channels-view-skeleton.tsx b/apps/web/src/features/channels-view/channels-view-skeleton.tsx
new file mode 100644
index 0000000000..480fb5c2e4
--- /dev/null
+++ b/apps/web/src/features/channels-view/channels-view-skeleton.tsx
@@ -0,0 +1,15 @@
+import { ViewSkeleton } from '@app/components/view-shell/ViewSkeleton';
+
+/** Chat while its code loads: the conversation list and the empty main area. */
+export function ChannelsViewSkeleton() {
+ return (
+ <ViewSkeleton.Root asidePreferenceKey="channels">
+ <ViewSkeleton.Sidebar title="Chat" />
+ <ViewSkeleton.Main title="Chat">
+ <div class="flex flex-1 items-center justify-center text-ink-muted text-sm">
+ Select a conversation
+ </div>
+ </ViewSkeleton.Main>
+ </ViewSkeleton.Root>
+ );
+}
diff --git a/apps/web/src/features/channels-view/route-views.tsx b/apps/web/src/features/channels-view/route-views.tsx
index 81a8751356..8bbd8587d1 100644
--- a/apps/web/src/features/channels-view/route-views.tsx
+++ b/apps/web/src/features/channels-view/route-views.tsx
@@ -9,6 +9,7 @@ import {
import { Show } from 'solid-js';
import { channelsSearch } from './channels-route';
import { ChannelsView } from './channels-view';
+import { ChannelsViewSkeleton } from './channels-view-skeleton';
function ChannelsLegacyRouteView() {
const params = useParams<{ channelId?: string }>();
@@ -41,4 +42,4 @@ export const ChannelsRouteView = withAuth(() => {
<ChannelsView />
</AppView>
);
-});
+}, ChannelsViewSkeleton);
diff --git a/apps/web/src/features/drive-view/drive-view-skeleton.tsx b/apps/web/src/features/drive-view/drive-view-skeleton.tsx
new file mode 100644
index 0000000000..b5420f6401
--- /dev/null
+++ b/apps/web/src/features/drive-view/drive-view-skeleton.tsx
@@ -0,0 +1,11 @@
+import { ViewSkeleton } from '@app/components/view-shell/ViewSkeleton';
+
+/** Drive while its code loads: the folders sidebar and the searchable file list. */
+export function DriveViewSkeleton() {
+ return (
+ <ViewSkeleton.Root asidePreferenceKey="documents">
+ <ViewSkeleton.Sidebar title="Drive" createLabel="New" />
+ <ViewSkeleton.Main title="Drive" searchPlaceholder="Search files" />
+ </ViewSkeleton.Root>
+ );
+}
diff --git a/apps/web/src/features/drive-view/route-views.tsx b/apps/web/src/features/drive-view/route-views.tsx
index b70a693918..5e3b700b7c 100644
--- a/apps/web/src/features/drive-view/route-views.tsx
+++ b/apps/web/src/features/drive-view/route-views.tsx
@@ -8,6 +8,7 @@ import {
} from '@components/app/split-layout/split-router/app-route-shell';
import { lazy } from 'solid-js';
import { DriveView, type DriveViewProps } from './drive-view';
+import { DriveViewSkeleton } from './drive-view-skeleton';
const DriveCallDetail = lazy(async () => ({
default: (await import('./views/DriveCallDetail')).DriveCallDetail,
@@ -26,7 +27,7 @@ export const DriveRouteView = withAuth(() => {
<DriveView initialFacets={props().initialFacets} />
</AppView>
);
-});
+}, DriveViewSkeleton);
export function DriveCallRouteView() {
const params = useRouteParams(driveCallRoute);
diff --git a/apps/web/src/features/email-view/email-view-skeleton.tsx b/apps/web/src/features/email-view/email-view-skeleton.tsx
new file mode 100644
index 0000000000..d195a97824
--- /dev/null
+++ b/apps/web/src/features/email-view/email-view-skeleton.tsx
@@ -0,0 +1,11 @@
+import { ViewSkeleton } from '@app/components/view-shell/ViewSkeleton';
+
+/** Email while its code loads: the inbox sidebar and the searchable list. */
+export function EmailViewSkeleton() {
+ return (
+ <ViewSkeleton.Root asidePreferenceKey="email">
+ <ViewSkeleton.Sidebar title="Email" createLabel="New email" />
+ <ViewSkeleton.Main title="Inbox" searchPlaceholder="Search email" />
+ </ViewSkeleton.Root>
+ );
+}
diff --git a/apps/web/src/features/email-view/route-views.tsx b/apps/web/src/features/email-view/route-views.tsx
index 4c40504045..f0f12969b3 100644
--- a/apps/web/src/features/email-view/route-views.tsx
+++ b/apps/web/src/features/email-view/route-views.tsx
@@ -9,6 +9,7 @@ import { Show } from 'solid-js';
import { URL_PARAMS as EMAIL_URL_PARAMS } from '../email-thread/core/location';
import { emailDetailSearch } from './email-route';
import { EmailView } from './email-view';
+import { EmailViewSkeleton } from './email-view-skeleton';
function MailLegacyRouteView() {
const params = useParams<{ threadId?: string }>();
@@ -40,4 +41,4 @@ export const MailRouteView = withAuth(() => {
<EmailView />
</AppView>
);
-});
+}, EmailViewSkeleton);
diff --git a/apps/web/src/features/home/components/HomeChatStart.tsx b/apps/web/src/features/home/components/HomeChatStart.tsx
index caad996ff7..dc833d3669 100644
--- a/apps/web/src/features/home/components/HomeChatStart.tsx
+++ b/apps/web/src/features/home/components/HomeChatStart.tsx
@@ -4,11 +4,10 @@ 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 { createEffect, Show } from 'solid-js';
+import { Show } from 'solid-js';
import { HomeChatInput } from '../home-chat-input';
import { HomeRecommendedActions } from './home-recommended-actions';
@@ -18,11 +17,6 @@ export function HomeChatStart() {
const agents = useFeatureFlag(enableChatV3Agents);
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.tsx
index 70c90ee5ed..7221c6f833 100644
--- a/apps/web/src/features/home/home-view.tsx
+++ b/apps/web/src/features/home/home-view.tsx
@@ -1,4 +1,5 @@
import { useViewShell, ViewShell } from '@app/components/view-shell';
+import { SidebarCreateHeader } from '@app/components/view-shell/SidebarCreateButton';
import { calendarSearch } from '@app/features/calendar-view/calendar-url';
import { ViewTour } from '@app/features/tours/ViewTour';
import { createSearchParams, SplitRouter } from '@app/lib/split-router';
@@ -160,6 +161,51 @@ function HomeViewRoot() {
);
}
+/**
+ * Home's frame while sign-in is confirmed: the view's layout, header, and list
+ * skeleton. Home's persisted state and list query key on the user, so the view
+ * itself waits for identity; the frame keeps the screen from going blank.
+ */
+export function HomePendingView() {
+ const listSkeleton = (
+ <div class="mt-3 min-h-0 min-w-0 flex-1 overflow-hidden touch:mt-0 touch:pt-(--mobile-content-inset-top)">
+ <HomeListSkeleton grouped />
+ </div>
+ );
+
+ return (
+ <SplitPanel.Root>
+ <SplitPanel.Body>
+ <Show
+ when={isTouchDevice()}
+ fallback={
+ <div class="size-full min-h-0 bg-panel">
+ <ViewShell.Root
+ asidePreferenceKey="home"
+ aside={{ preserveDuringResize: false }}
+ main={{ preferredWidth: 640 }}
+ resizable
+ >
+ <ViewShell.Aside class="flex flex-col bg-panel">
+ <SidebarCreateHeader
+ title="Home"
+ label="New chat"
+ onCreate={() => {}}
+ />
+ {listSkeleton}
+ </ViewShell.Aside>
+ <ViewShell.Main class="overflow-hidden" />
+ </ViewShell.Root>
+ </div>
+ }
+ >
+ {listSkeleton}
+ </Show>
+ </SplitPanel.Body>
+ </SplitPanel.Root>
+ );
+}
+
/** The Calendar view aimed at an event, inside Home's inline preview chrome. */
function HomeCalendarRouteContent() {
const panel = useSplitPanelOrThrow();
diff --git a/apps/web/src/features/home/route-views.tsx b/apps/web/src/features/home/route-views.tsx
index 190bab5836..1ccdb8f8a6 100644
--- a/apps/web/src/features/home/route-views.tsx
+++ b/apps/web/src/features/home/route-views.tsx
@@ -15,7 +15,7 @@ import {
homePreviewLegacyTarget,
} from './home-route';
import type { HomePreviewRouteParams } from './home-route-schema';
-import { HomeView } from './home-view';
+import { HomePendingView, HomeView } from './home-view';
type HomeDetailParams = Partial<HomePreviewRouteParams> & {
channelId?: string;
@@ -63,4 +63,4 @@ export const HomeRouteView = withAuth(() => {
<HomeView />
</AppView>
);
-});
+}, HomePendingView);
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view-create-button.tsx b/apps/web/src/features/next-soup/soup-view/soup-view-create-button.tsx
index 6e39441f74..a36691bff2 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view-create-button.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view-create-button.tsx
@@ -5,7 +5,7 @@ import {
runCreateAction,
useCreatableEnabled,
} from '@app/features/command/Launcher';
-import { openCreateCompanyModal } from '@app/features/crm/crm-create';
+import { openCreateCompanyModal } from '@app/features/crm/creation-adapter';
import { useHandleFileUpload } from '@app/util/handleFileUpload';
import { openNewChannelModal } from '@channel/CreateChannelModal';
import { CollapsibleHeaderItem } from '@components/app/split-layout/components/CollapsibleItem';
diff --git a/apps/web/src/features/reviews-view/reviews-view-skeleton.tsx b/apps/web/src/features/reviews-view/reviews-view-skeleton.tsx
new file mode 100644
index 0000000000..cbbeb38d91
--- /dev/null
+++ b/apps/web/src/features/reviews-view/reviews-view-skeleton.tsx
@@ -0,0 +1,11 @@
+import { ViewSkeleton } from '@app/components/view-shell/ViewSkeleton';
+
+/** Reviews while its code loads: the scopes sidebar and the searchable list. */
+export function ReviewsViewSkeleton() {
+ return (
+ <ViewSkeleton.Root asidePreferenceKey="reviews">
+ <ViewSkeleton.Sidebar title="Reviews" />
+ <ViewSkeleton.Main title="Reviews" searchPlaceholder="Search reviews" />
+ </ViewSkeleton.Root>
+ );
+}
diff --git a/apps/web/src/features/reviews-view/route-views.tsx b/apps/web/src/features/reviews-view/route-views.tsx
index 24b34ca3ea..074f8a847e 100644
--- a/apps/web/src/features/reviews-view/route-views.tsx
+++ b/apps/web/src/features/reviews-view/route-views.tsx
@@ -5,9 +5,9 @@ import {
usePageViewTracking,
withAuth,
} from '@components/app/split-layout/split-router/app-route-shell';
-import { LoadingBlock } from '@core/component/LoadingBlock';
import { enableTasksReviews } from '@core/constant/featureFlags';
import { lazy, onMount, Show } from 'solid-js';
+import { ReviewsViewSkeleton } from './reviews-view-skeleton';
const ReviewsView = lazy(async () => ({
default: (await import('./reviews-view')).ReviewsView,
@@ -38,7 +38,7 @@ export const ReviewsRouteView = withAuth(() => {
<Show
when={params.foreignEntityId || flag().enabled}
fallback={
- <Show when={!flag().loading} fallback={<LoadingBlock />}>
+ <Show when={!flag().loading} fallback={<ReviewsViewSkeleton />}>
<DisabledReviewsRoute />
</Show>
}
@@ -46,4 +46,4 @@ export const ReviewsRouteView = withAuth(() => {
<TrackedReviewsView />
</Show>
);
-});
+}, ReviewsViewSkeleton);
diff --git a/apps/web/src/features/tasks-view/route-views.tsx b/apps/web/src/features/tasks-view/route-views.tsx
index 36f2a49749..506cf2e655 100644
--- a/apps/web/src/features/tasks-view/route-views.tsx
+++ b/apps/web/src/features/tasks-view/route-views.tsx
@@ -30,6 +30,7 @@ import { onMount, Show } from 'solid-js';
import { TasksDetailView } from './components/TasksDetailView';
import { projectDetailSearch } from './project-detail-search';
import { TasksView } from './tasks-view';
+import { TasksViewSkeleton } from './tasks-view-skeleton';
function TasksLegacyRouteView() {
const params = useParams<{ taskId?: string; projectId?: string }>();
@@ -54,7 +55,7 @@ export const TasksRouteView = withAuth(() => {
<TasksView />
</AppView>
);
-});
+}, TasksViewSkeleton);
function DisabledProjectRoute() {
const navigate = useNavigate();
diff --git a/apps/web/src/features/tasks-view/tasks-view-skeleton.tsx b/apps/web/src/features/tasks-view/tasks-view-skeleton.tsx
new file mode 100644
index 0000000000..172a0ce71e
--- /dev/null
+++ b/apps/web/src/features/tasks-view/tasks-view-skeleton.tsx
@@ -0,0 +1,11 @@
+import { ViewSkeleton } from '@app/components/view-shell/ViewSkeleton';
+
+/** Tasks while its code loads: the task lists and the searchable list. */
+export function TasksViewSkeleton() {
+ return (
+ <ViewSkeleton.Root asidePreferenceKey="tasks">
+ <ViewSkeleton.Sidebar title="Tasks" createLabel="New task" />
+ <ViewSkeleton.Main title="Tasks" searchPlaceholder="Search tasks" />
+ </ViewSkeleton.Root>
+ );
+}
diff --git a/apps/web/src/index.css b/apps/web/src/index.css
index f98e647843..f79319b449 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -576,6 +576,8 @@ body.tauri-ios {
--animate-swipe-out-left: swipeOutLeft 100ms ease-out;
--animate-indeterminate-bar: indeterminate-bar 1.1s ease-in-out infinite;
--animate-todo-pulse: todo-pulse 1.6s ease-in-out infinite;
+ /* Two laps around the circle, easing in and out, then a long rest before the next. */
+ --animate-update-glow: update-glow-spin 8s infinite, update-glow-fade 8s linear infinite;
--animate-accordion-down: accordion-down 150ms ease-out;
--animate-accordion-up: accordion-up 150ms ease-out;
@@ -1306,6 +1308,18 @@ html[data-touch-device='true'] :is(
}
/* Ported from opencode's `--animate-pulse-scale` (github.com/sst/opencode, MIT © 2025 opencode). */
+/* easeInOutCubic: the laps start slow, speed up, and slow down into the end. */
+@keyframes update-glow-spin {
+ 0% { transform: rotate(0deg); animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
+ 35%, 100% { transform: rotate(720deg); }
+}
+
+@keyframes update-glow-fade {
+ 0% { opacity: 0; }
+ 3%, 31% { opacity: 1; }
+ 35%, 100% { opacity: 0; }
+}
+
@keyframes todo-pulse {
0%, 100% { transform: scale(1); opacity: 1; }
50% { transform: scale(0.6); opacity: 0.5; }
diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsx
index 7a290ae61d..c91c5853b8 100644
--- a/apps/web/src/index.tsx
+++ b/apps/web/src/index.tsx
@@ -10,13 +10,11 @@ import { initializeLexical } from '@core/component/LexicalMarkdown/init';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { getPlatform, isTauri } from '@core/util/platform';
import { platformFetch } from '@core/util/platformFetch';
+import { promptReloadForFailedLoad } from '@core/util/reloadForNewerBuild';
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 { registerServiceWorker } from './lib/service-worker/register';
import { Root } from './routes/Root';
// Override global fetch with platformFetch for Tauri compatibility
@@ -100,14 +98,9 @@ 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', (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');
+ // The rail's update button offers the reload (a toast on touch layouts).
+ window.addEventListener('vite:preloadError', () => {
+ promptReloadForFailedLoad();
});
}
diff --git a/apps/web/src/lib/core/component/AI/signal/globalAttachments.tsx b/apps/web/src/lib/core/component/AI/signal/globalAttachments.tsx
index a760d48826..8726671e5b 100644
--- a/apps/web/src/lib/core/component/AI/signal/globalAttachments.tsx
+++ b/apps/web/src/lib/core/component/AI/signal/globalAttachments.tsx
@@ -2,7 +2,7 @@ import { SUPPORTED_CHAT_ATTACHMENT_BLOCKS } from '@core/component/AI/constant/fi
import { getItemBlockName } from '@core/util/getItemBlockName';
import type { HistoryItem } from '@queries/history/history';
import { useHistoryQuery } from '@queries/history/history';
-import { createEffect, createMemo, createSignal, Suspense } from 'solid-js';
+import { createEffect, createMemo, createSignal } from 'solid-js';
// ---- Global signals ----
@@ -12,13 +12,13 @@ const [globalAttachableHistory, setGlobalAttachableHistory] = createSignal<
export { globalAttachableHistory };
-// ---- Init component (mount once at app root) ----
-
-function GlobalAttachmentsInner() {
+/** Keeps `globalAttachableHistory` current; call once where the app's state lives. */
+export function useGlobalAttachableHistory(): void {
const historyQuery = useHistoryQuery();
const attachableHistory = createMemo(() => {
- return (historyQuery.data ?? []).filter((item) => {
+ const history = historyQuery.isSuccess ? historyQuery.data : [];
+ return history.filter((item) => {
const blockName = getItemBlockName(item, true);
return SUPPORTED_CHAT_ATTACHMENT_BLOCKS.includes(blockName);
});
@@ -27,14 +27,4 @@ function GlobalAttachmentsInner() {
createEffect(() => {
setGlobalAttachableHistory(attachableHistory());
});
-
- return null;
-}
-
-export function ChatAttachmentsInit() {
- return (
- <Suspense>
- <GlobalAttachmentsInner />
- </Suspense>
- );
}
diff --git a/apps/web/src/lib/core/context/team.tsx b/apps/web/src/lib/core/context/team.tsx
index 1b0ade8d3e..fbbae4f858 100644
--- a/apps/web/src/lib/core/context/team.tsx
+++ b/apps/web/src/lib/core/context/team.tsx
@@ -11,8 +11,11 @@ type TeamContextValue = {
export const [TeamContextProvider, useTeamContext] =
createAssertedContextProvider('TeamContext', (): TeamContextValue => {
const currentTeam = useCurrentTeamQuery();
+ // Guarded: `data` suspends while the team query waits on sign-in, and this
+ // provider wraps the whole app.
const isMacroTeam = createMemo(
- () => currentTeam.data?.team.slug === MACRO_TEAM_SLUG
+ () =>
+ currentTeam.isSuccess && currentTeam.data?.team.slug === MACRO_TEAM_SLUG
);
return {
diff --git a/apps/web/src/lib/core/util/reloadForNewerBuild.test.ts b/apps/web/src/lib/core/util/reloadForNewerBuild.test.ts
index 9e8d8b787d..32a12954e1 100644
--- a/apps/web/src/lib/core/util/reloadForNewerBuild.test.ts
+++ b/apps/web/src/lib/core/util/reloadForNewerBuild.test.ts
@@ -3,9 +3,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('@core/component/Toast/Toast', () => ({
toast: { custom: vi.fn() },
}));
+vi.mock('@core/mobile/isTouchDevice', () => ({ isTouchDevice: () => false }));
import {
holdAutomaticReload,
+ pendingWebUpdate,
+ promptReloadForFailedLoad,
type ReloadPage,
reloadForNewerBuild,
resetReloadForNewerBuildForTests,
@@ -136,3 +139,17 @@ describe('reloadForNewerBuild', () => {
expect(second.page.reload).not.toHaveBeenCalled();
});
});
+
+describe('promptReloadForFailedLoad', () => {
+ beforeEach(() => {
+ resetReloadForNewerBuildForTests();
+ });
+
+ it('offers the newer build and counts each failed load', () => {
+ promptReloadForFailedLoad();
+ promptReloadForFailedLoad();
+
+ expect(pendingWebUpdate()?.failedLoads).toBe(2);
+ expect(pendingWebUpdate()?.reload).toBeTypeOf('function');
+ });
+});
diff --git a/apps/web/src/lib/core/util/reloadForNewerBuild.ts b/apps/web/src/lib/core/util/reloadForNewerBuild.ts
index fc991bb0bb..c867998c5e 100644
--- a/apps/web/src/lib/core/util/reloadForNewerBuild.ts
+++ b/apps/web/src/lib/core/util/reloadForNewerBuild.ts
@@ -1,4 +1,6 @@
import { toast } from '@core/component/Toast/Toast';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import { createSignal } from 'solid-js';
import { deviceLooksOffline } from './connectivity';
import { isEditableInput } from './isEditableInput';
@@ -11,10 +13,24 @@ export interface ReloadPage {
reload(): void;
/** Runs `callback` each time the page is hidden or comes back online. */
onHiddenOrOnline(callback: () => void): void;
- /** Offers the user a reload now. */
- promptReload(reload: () => void): void;
+ /** Offers the user a reload now; `build` is the newer build, when known. */
+ promptReload(reload: () => void, build?: string): void;
}
+/** A newer web build this tab can reload into. */
+export type PendingWebUpdate = {
+ build?: string;
+ reload: () => void;
+ /** How many of this build's lazy chunks failed to load since it was found. */
+ failedLoads?: number;
+};
+
+const [pendingWebUpdate, setPendingWebUpdate] =
+ createSignal<PendingWebUpdate>();
+
+/** The newer web build waiting for a reload, which the rail's update button offers. */
+export { pendingWebUpdate };
+
const browserPage: ReloadPage = {
isHidden: () => document.visibilityState === 'hidden',
isOffline: deviceLooksOffline,
@@ -38,7 +54,10 @@ const browserPage: ReloadPage = {
});
window.addEventListener('online', later);
},
- promptReload(reload) {
+ promptReload(reload, build) {
+ setPendingWebUpdate({ build, reload });
+ // Touch layouts have no rail to show the update button in.
+ if (!isTouchDevice()) return;
toast.custom(
{
title: 'A new version of Macro is ready',
@@ -78,7 +97,10 @@ export function holdAutomaticReload(): () => void {
* written. Otherwise it tries again the next time it is hidden or comes back
* online.
*/
-export function reloadForNewerBuild(page: ReloadPage = browserPage): void {
+export function reloadForNewerBuild(
+ page: ReloadPage = browserPage,
+ build?: string
+): void {
if (scheduled) return;
scheduled = true;
const reloadIfIdle = () => {
@@ -92,10 +114,26 @@ export function reloadForNewerBuild(page: ReloadPage = browserPage): void {
}
};
page.onHiddenOrOnline(reloadIfIdle);
- page.promptReload(() => page.reload());
+ page.promptReload(() => page.reload(), build);
reloadIfIdle();
}
+/**
+ * A lazy chunk of this build failed to load, which after a deploy means a newer
+ * build replaced it. Offers the reload the same way as a newer build, and opens
+ * the offer again even if it was dismissed, since something the user opened
+ * just failed.
+ */
+export function promptReloadForFailedLoad(): void {
+ reloadForNewerBuild();
+ const current = pendingWebUpdate();
+ setPendingWebUpdate({
+ reload: current?.reload ?? (() => window.location.reload()),
+ build: current?.build,
+ failedLoads: (current?.failedLoads ?? 0) + 1,
+ });
+}
+
/** Test seam: forget the scheduled reload and every hold. */
export function resetReloadForNewerBuildForTests(): void {
scheduled = false;
diff --git a/apps/web/src/lib/queries/calendar/graphql/use-calendar-cache.ts b/apps/web/src/lib/queries/calendar/graphql/use-calendar-cache.ts
index 4eade79410..ceb7fddab5 100644
--- a/apps/web/src/lib/queries/calendar/graphql/use-calendar-cache.ts
+++ b/apps/web/src/lib/queries/calendar/graphql/use-calendar-cache.ts
@@ -3,7 +3,7 @@ import { queryClient } from '@queries/client';
import { CalendarSyncStatus } from '@service-storage/generated/schemas/calendarSyncStatus';
import { subscribeGraphqlSoupReconnected } from '@service-storage/graphql-soup';
import { makeEventListener } from '@solid-primitives/event-listener';
-import { createEffect, createSignal, onCleanup } from 'solid-js';
+import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js';
import { calendarKeys } from '../keys';
import { createCalendarOccurrenceQueryRange } from '../occurrences';
import { runCalendarBackfill } from './backfill';
@@ -49,14 +49,15 @@ async function refreshSyncStatus(): Promise<void> {
* server is still syncing. The cross-tab leader also widens coverage in the
* background.
*/
-export function useCalendarCache(): void {
+/** Keeps the calendar cache in sync while `active`, i.e. once a user is signed in. */
+export function useCalendarCache(active: Accessor<boolean>): void {
const host = useGraphqlCalendarHost();
const isLeader = createTabLeaderSignal('graphql-calendar-backfill:v1');
const [generation, setGeneration] = createSignal(0);
createEffect(() => {
const cacheHost = host();
- if (!cacheHost) return;
+ if (!cacheHost || !active()) return;
const controller = new CalendarSyncController(cacheHost);
setActiveCalendarSyncController(controller);
controller.markStale('start');
@@ -103,7 +104,7 @@ export function useCalendarCache(): void {
createEffect(() => {
const cacheHost = host();
- if (!cacheHost || !isLeader()) return;
+ if (!cacheHost || !active() || !isLeader()) return;
generation();
const abort = new AbortController();
runCalendarBackfill(cacheHost, { signal: abort.signal }).catch((error) => {
diff --git a/apps/web/src/lib/queries/soup/backfill.test.tsx b/apps/web/src/lib/queries/soup/backfill.test.tsx
index a631c37391..97d4af4617 100644
--- a/apps/web/src/lib/queries/soup/backfill.test.tsx
+++ b/apps/web/src/lib/queries/soup/backfill.test.tsx
@@ -116,7 +116,7 @@ const recencyTree = (signal: boolean, gte: string) => ({
});
function BackfillRunner(props: { userId: string }) {
- useSoupBackfills(props.userId);
+ useSoupBackfills(() => props.userId);
return null;
}
diff --git a/apps/web/src/lib/queries/soup/backfill.ts b/apps/web/src/lib/queries/soup/backfill.ts
index 9033176cf6..e6e68065b4 100644
--- a/apps/web/src/lib/queries/soup/backfill.ts
+++ b/apps/web/src/lib/queries/soup/backfill.ts
@@ -23,7 +23,7 @@ import { createSharedMailBackfillFetcher } from '@service-storage/shared-mail-ba
import * as Effect from 'effect/Effect';
import * as Fiber from 'effect/Fiber';
import * as Schedule from 'effect/Schedule';
-import { createEffect, createSignal, onCleanup } from 'solid-js';
+import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js';
// Bump when a default backfill input or completion guarantee changes so
// persisted cursors cannot retain an older hydration contract.
@@ -686,7 +686,8 @@ const waitForGraphqlSoupCacheHost = Effect.suspend(() => {
* inter-page sleeps. Engine handoffs resume durable checkpoints; only loss of
* stored cache data resets cursors so they cannot point past wiped records.
*/
-export function useSoupBackfills(userId: string): void {
+/** Runs the signed-in user's soup backfills; waits while `userId` is unknown. */
+export function useSoupBackfills(userId: Accessor<string | undefined>): void {
const graphqlSoupFlag = useFeatureFlag(enableGraphqlSoup);
const isLeader = createTabLeaderSignal(
`graphql-soup-backfill:v${BACKFILL_VERSION}:coordinator`
@@ -723,11 +724,12 @@ export function useSoupBackfills(userId: string): void {
createEffect(() => {
const host = cacheHost();
- if (!host) return;
+ const id = userId();
+ if (!host || !id) return;
cacheGeneration();
const fiber = Effect.runFork(
- runSoupBackfills(userId, host).pipe(Effect.ignore)
+ runSoupBackfills(id, host).pipe(Effect.ignore)
);
onCleanup(() => {
Effect.runFork(Fiber.interrupt(fiber));
diff --git a/apps/web/src/lib/queries/sync/SyncProvider.tsx b/apps/web/src/lib/queries/sync/use-query-sync.ts
similarity index 96%
rename from apps/web/src/lib/queries/sync/SyncProvider.tsx
rename to apps/web/src/lib/queries/sync/use-query-sync.ts
index 3795494710..779e16b25e 100644
--- a/apps/web/src/lib/queries/sync/SyncProvider.tsx
+++ b/apps/web/src/lib/queries/sync/use-query-sync.ts
@@ -57,13 +57,9 @@ import {
parseWebsocketPayload,
ws,
} from '@service-connection/websocket';
-import { type Accessor, onCleanup, type ParentProps } from 'solid-js';
+import { type Accessor, onCleanup } from 'solid-js';
import { match } from 'ts-pattern';
-type SyncProviderProps = ParentProps<{
- userId: Accessor<string | undefined>;
-}>;
-
function withParsedWebsocketPayload<T>(
type: string,
payload: unknown,
@@ -75,7 +71,8 @@ function withParsedWebsocketPayload<T>(
handle(parsedPayload);
}
-export function QuerySyncProvider(props: SyncProviderProps) {
+/** Keeps queries in sync with the connection websocket's updates for `userId`. */
+export function useQuerySync(userId: Accessor<string | undefined>): void {
ws.addEventListener(WebsocketEvent.Open, invalidateChannelPictures);
onCleanup(() =>
ws.removeEventListener(WebsocketEvent.Open, invalidateChannelPictures)
@@ -118,7 +115,7 @@ export function QuerySyncProvider(props: SyncProviderProps) {
withParsedWebsocketPayload<Parameters<typeof handleMessageEvent>[0]>(
data.type,
data.data,
- (event) => handleMessageEvent(event, props.userId())
+ (event) => handleMessageEvent(event, userId())
);
})
.with({ type: 'comms_channel_picture' }, () => {
@@ -214,6 +211,4 @@ export function QuerySyncProvider(props: SyncProviderProps) {
})
.otherwise(() => {});
});
-
- return props.children;
}
diff --git a/apps/web/src/lib/service-worker/register.ts b/apps/web/src/lib/service-worker/register.ts
index c522d7a165..f2ecbc30c8 100644
--- a/apps/web/src/lib/service-worker/register.ts
+++ b/apps/web/src/lib/service-worker/register.ts
@@ -10,7 +10,6 @@ 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. */
@@ -52,20 +51,11 @@ function onWorkerMessage(event: MessageEvent<unknown>): void {
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;
+ reloadForNewerBuild(undefined, String(data.build));
}
/**
diff --git a/apps/web/src/lib/split-router/routes/queries.ts b/apps/web/src/lib/split-router/routes/queries.ts
index 1e59edd2e0..0e2b250786 100644
--- a/apps/web/src/lib/split-router/routes/queries.ts
+++ b/apps/web/src/lib/split-router/routes/queries.ts
@@ -207,6 +207,8 @@ export function firstChangedDepth(
export type OutletMatch = {
component: unknown;
+ /** The route's own loading view, shown while `component` suspends. */
+ loading?: unknown;
key: string;
/** Depth the next nested outlet starts from. */
depth: number;
@@ -224,9 +226,9 @@ export function outletAt(
const branch = resolveBranch(routes, entry.location.route);
for (let depth = start; depth < branch.length; depth += 1) {
- const component = branch[depth]!.definition.component;
+ const { component, loading } = branch[depth]!.definition;
if (typeof component !== 'function') continue;
- return { component, key: keys[depth]!, depth: depth + 1 };
+ return { component, loading, key: keys[depth]!, depth: depth + 1 };
}
}
diff --git a/apps/web/src/lib/split-router/routes/types.ts b/apps/web/src/lib/split-router/routes/types.ts
index 50d2897a19..79d18a5932 100644
--- a/apps/web/src/lib/split-router/routes/types.ts
+++ b/apps/web/src/lib/split-router/routes/types.ts
@@ -110,6 +110,8 @@ export type SplitRouteDefinition<
path?: string;
aliases?: readonly string[];
component?: TComponent;
+ /** Shown in place of `component` while it suspends, such as while its lazy chunk loads. */
+ loading?: TComponent;
children?: readonly SplitRouteDefinition<TComponent>[];
params?: TParamsSchema;
state?: StandardSchemaV1;
diff --git a/apps/web/src/lib/split-router/solid/outlet.tsx b/apps/web/src/lib/split-router/solid/outlet.tsx
index 75da94a1b4..f742d6672a 100644
--- a/apps/web/src/lib/split-router/solid/outlet.tsx
+++ b/apps/web/src/lib/split-router/solid/outlet.tsx
@@ -3,6 +3,7 @@ import {
createMemo,
type JSX,
Show,
+ Suspense,
useContext,
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
@@ -52,7 +53,18 @@ function RouteOutlet(props: { fallback?: OutletFallback }) {
<Show keyed when={match()} fallback={fallback()}>
{(resolved) => (
<PaneContext.Provider value={context}>
- <Dynamic component={resolved.component as Component} />
+ {/* Only routes with their own loading view get a boundary, so the
+ rest suspend to their enclosing boundary as before. */}
+ <Show
+ when={resolved.loading as Component | undefined}
+ fallback={<Dynamic component={resolved.component as Component} />}
+ >
+ {(loading) => (
+ <Suspense fallback={<Dynamic component={loading()} />}>
+ <Dynamic component={resolved.component as Component} />
+ </Suspense>
+ )}
+ </Show>
</PaneContext.Provider>
)}
</Show>
diff --git a/apps/web/src/lib/split-router/solid/route.tsx b/apps/web/src/lib/split-router/solid/route.tsx
index 6b549abeee..3f4d38505a 100644
--- a/apps/web/src/lib/split-router/solid/route.tsx
+++ b/apps/web/src/lib/split-router/solid/route.tsx
@@ -2,12 +2,15 @@ import { type Component, type JSX, untrack } from 'solid-js';
import type { SplitRouteDefinition } from '../routes/types';
export type RouteProps = {
- /** Its children and component come from this element, not the definition. */
+ /** Its children, component, and loading come from this element, not the definition. */
definition: SplitRouteDefinition & {
children?: undefined;
component?: undefined;
+ loading?: undefined;
};
component?: Component<object>;
+ /** Shown while `component` suspends, such as while its lazy chunk loads. */
+ loading?: Component<object>;
children?: JSX.Element;
};
@@ -39,11 +42,11 @@ function resolveChildren(children: unknown): unknown[] {
}
function definitionOf(props: RouteProps): SplitRouteDefinition {
- const { definition, component } = props;
+ const { definition, component, loading } = props;
- if (definition.children || definition.component) {
+ if (definition.children || definition.component || definition.loading) {
throw new Error(
- `Split route "${definition.id}" is declared with <SplitRouter.Route>, so its definition must not set children or component`
+ `Split route "${definition.id}" is declared with <SplitRouter.Route>, so its definition must not set children, component, or loading`
);
}
@@ -52,6 +55,7 @@ function definitionOf(props: RouteProps): SplitRouteDefinition {
return {
...definition,
...(component ? { component } : {}),
+ ...(loading ? { loading } : {}),
...(children.length ? { children } : {}),
};
}
diff --git a/apps/web/src/lib/split-router/tests/solid.test.tsx b/apps/web/src/lib/split-router/tests/solid.test.tsx
index 1cda67a5f0..a743e0f899 100644
--- a/apps/web/src/lib/split-router/tests/solid.test.tsx
+++ b/apps/web/src/lib/split-router/tests/solid.test.tsx
@@ -1,5 +1,12 @@
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
-import { createEffect, For, type JSX, onCleanup, onMount } from 'solid-js';
+import {
+ createEffect,
+ For,
+ type JSX,
+ lazy,
+ onCleanup,
+ onMount,
+} from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { z } from 'zod';
import { createMemoryHistory, type MemoryHistory } from '../history/memory';
@@ -449,6 +456,38 @@ describe('<SplitRouter.Router>', () => {
expect(history.read().path).toBe('/login');
});
+ it('shows a route’s loading view while its lazy component loads', async () => {
+ let resolveInbox!: () => void;
+ const InboxView = lazy(
+ () =>
+ new Promise<{ default: () => JSX.Element }>((resolve) => {
+ resolveInbox = () => resolve({ default: () => <p>inbox</p> });
+ })
+ );
+ render(() => (
+ <Router
+ history={createMemoryHistory('/inbox')}
+ paneStore={createMemoryPaneStore()}
+ policy={createTestPolicy().policy}
+ defaultRoute={defaultRoute}
+ >
+ <Route definition={app} component={AppLayout}>
+ <Route definition={home} component={() => <p>home</p>} />
+ <Route
+ definition={inbox}
+ component={InboxView}
+ loading={() => <p>inbox skeleton</p>}
+ />
+ </Route>
+ </Router>
+ ));
+
+ expect(screen.getByText('inbox skeleton')).toBeTruthy();
+ resolveInbox();
+ expect(await screen.findByText('inbox')).toBeTruthy();
+ expect(screen.queryByText('inbox skeleton')).toBeNull();
+ });
+
it('reads routes from arrays and drops false children', () => {
const extra = [inbox].map((definition) => (
<Route definition={definition} component={() => <p>inbox</p>} />
@@ -511,7 +550,7 @@ describe('<SplitRouter.Router>', () => {
<Route definition={withComponent} />
</Router>
))
- ).toThrow(/must not set children or component/);
+ ).toThrow(/must not set children, component, or loading/);
expect(() =>
render(() => (
<Router {...options}>
diff --git a/apps/web/src/routes/BasePath.tsx b/apps/web/src/routes/BasePath.tsx
index 0dd9ccdb5c..6c6a785d5e 100644
--- a/apps/web/src/routes/BasePath.tsx
+++ b/apps/web/src/routes/BasePath.tsx
@@ -1,35 +1,17 @@
import { DEFAULT_ROUTE } from '@app/constants/defaultRoute';
import { useCheckoutCompletionListener } from '@app/features/paywall/use-checkout-completion-listener';
-import { clearLocalAuthSession } from '@core/auth/logout';
+import {
+ getCurrentQueryString,
+ SessionExpiredRedirect,
+} from '@components/app/SessionExpiredRedirect';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { hasLoginCookie } from '@core/util/cookies';
-import { confirmSessionExpired } from '@core/util/fetchWithToken';
import { consumePostLoginRedirect } from '@core/util/postLoginRedirect';
import { thrownResultErrorHasCode } from '@core/util/result';
-import {
- authKeys,
- invalidateUserInfo,
- useUserInfoQuery,
-} from '@queries/auth/user-info';
-import { queryClient } from '@queries/client';
+import { useUserInfoQuery } from '@queries/auth/user-info';
import { Navigate, useLocation, useSearchParams } from '@solidjs/router';
import { Button } from '@ui';
-import {
- createEffect,
- createResource,
- createSignal,
- Match,
- on,
- Show,
- Switch,
-} from 'solid-js';
-
-function getCurrentQueryString(routerSearch: string) {
- const params = new URLSearchParams(
- isNativeMobilePlatform() ? routerSearch : window.location.search
- );
- return params.toString().length > 0 ? `?${params.toString()}` : '';
-}
+import { createEffect, createSignal, Match, on, Switch } from 'solid-js';
function shouldShowNativeSessionVerificationFallback(
userInfoQuery: ReturnType<typeof useUserInfoQuery>
@@ -72,34 +54,6 @@ function SessionVerificationFallback(props: {
);
}
-function SessionExpiredRedirect() {
- const location = useLocation();
- // The UNAUTHORIZED that got us here can come from a latched refresh failure
- // without the server ever being consulted, so confirm with a fresh refresh
- // before destroying local session state. If the session turns out to be
- // alive, refetch user-info instead and only treat a repeat 401 as real.
- const [expired] = createResource(async () => {
- if (!(await confirmSessionExpired())) {
- await invalidateUserInfo();
- const stillUnauthorized = thrownResultErrorHasCode(
- queryClient.getQueryState(authKeys.userInfo.queryKey)?.error,
- 'UNAUTHORIZED'
- );
- if (!stillUnauthorized) return false;
- }
- await clearLocalAuthSession().catch((error) => {
- console.error('Failed to clear local auth session', error);
- });
- return true;
- });
-
- return (
- <Show when={expired()}>
- <Navigate href={`/welcome${getCurrentQueryString(location.search)}`} />
- </Show>
- );
-}
-
function AuthenticatedDestination(props: { fallback: string }) {
const pending = isNativeMobilePlatform() ? consumePostLoginRedirect() : null;
return <Navigate href={pending ?? props.fallback} />;
diff --git a/apps/web/src/routes/Root.tsx b/apps/web/src/routes/Root.tsx
index f143a5862a..365a6286ed 100644
--- a/apps/web/src/routes/Root.tsx
+++ b/apps/web/src/routes/Root.tsx
@@ -1,49 +1,28 @@
import { ROUTER_BASE } from '@app/constants/routerBase';
import { usePendingInviteRedemption } from '@app/features/gtm-invite/usePendingInviteRedemption';
import { GlobalShareInboxConflictDialog } from '@app/features/inbox/ShareInboxConflictDialog';
-import { IncomingMeetingInvitationsProvider } from '@app/features/meetings/incoming-meeting-invitations';
import { MeetingSessionProvider } from '@app/features/meetings/meeting-session-provider';
-import { usePendingNotificationNavigationEffect } from '@app/features/notifications/PendingNotificationNavigationEffect';
-import { SearchProvider } from '@app/features/soup/search/context';
import {
AnalyticsContextProvider,
useAnalytics,
} from '@app/lib/analytics/analytics-context';
import { PosthogProvider, usePosthog } from '@app/lib/analytics/posthog';
import { trackSignupCompletion } from '@app/lib/analytics/signupCompletion';
-import { useCalendarCache } from '@app/lib/queries/calendar/graphql/use-calendar-cache';
-import { useInvalidateQueriesOnReconnect } from '@app/lib/queries/invalidate-on-reconnect';
-import { useSoupBackfills } from '@app/lib/queries/soup/backfill';
import { setHotkeyRoot } from '@app/signal/hotkeyRoot';
-import { globalSplitManager } from '@app/signal/splitLayout';
import { IncomingCallEvents } from '@block-call/sidebar/incoming-calls';
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';
-import { ChatAttachmentsInit } from '@core/component/AI/signal/globalAttachments';
+import { RootFrame } from '@components/app/Layout';
import { ToastRegion } from '@core/component/Toast/ToastRegion';
import { ChannelsContextProvider } from '@core/context/channels';
import { EmailLinksContextProvider } from '@core/context/emailLinks';
import { QuickAccessProvider } from '@core/context/quickAccess';
-import { TeamContextProvider } from '@core/context/team';
-import {
- UserContextProvider,
- useIsAuthenticated,
- useUserId,
- useUserInfo,
-} from '@core/context/user';
-import { initAndStartEmailSync } from '@core/email-link';
+import { UserContextProvider, useUserInfo } from '@core/context/user';
import { useHotKeyRoot } from '@core/hotkey/hotkeys';
import { IosPushNotificationModal } from '@core/mobile/IosPushNotificationModal';
import { IpadUnsupportedDialog } from '@core/mobile/IpadUnsupportedDialog';
-import { isMobile } from '@core/mobile/isMobile';
-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
-import { createBlockOrchestrator } from '@core/orchestrator';
import { formatTabTitle, tabTitleSignal } from '@core/signal/tabTitle';
import {
getLoginCookieOptions,
@@ -51,7 +30,6 @@ 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';
@@ -59,27 +37,12 @@ import { EntityProvider } from '@entity';
import { MaybeTauriProvider } from '@macro/tauri';
import { TauriRouteListener } from '@macro/tauri/TauriProvider';
import { Telemetry } from '@macro-inc/observability';
-import {
- BrowserNotificationModal,
- createNotificationSource,
- type UnifiedNotification,
- useNotificationUpdates,
- usePlatformNotificationState,
-} from '@notifications';
-import { maybeHandlePlatformNotification } from '@notifications/notification-platform';
+import { BrowserNotificationModal } from '@notifications';
import {
invalidateUserInfo,
prefetchUserInfo,
useUserInfoQuery,
} from '@queries/auth/user-info';
-import { useChatRenameWebsocketSync } from '@queries/chat';
-import { QuerySyncProvider } from '@queries/sync/SyncProvider';
-import { MutationUndoProvider } from '@queries/undo';
-import {
- useRefreshTrackedEntitiesOnFocus,
- useReopenTrackedEntitiesOnReconnect,
-} from '@service-connection/client';
-import { ws as connectionGatewayWebsocket } from '@service-connection/websocket';
import { MetaProvider, Title } from '@solidjs/meta';
import {
HashRouter,
@@ -88,7 +51,6 @@ import {
Router,
type RouterProps,
type RouteSectionProps,
- useLocation,
} from '@solidjs/router';
import {
applyTheme,
@@ -97,25 +59,8 @@ import {
systemThemeEffect,
} from '@theme/utils/themeUtils';
import { detect } from 'detect-browser';
-import {
- createEffect,
- createSignal,
- type JSX,
- on,
- onCleanup,
- onMount,
- type ParentProps,
- Show,
- Suspense,
-} from 'solid-js';
+import { createEffect, type JSX, on, onCleanup, onMount } from 'solid-js';
import { AppRouterView } from './app-router-view';
-import { usesFocusedShell } from './focused-shell';
-
-// 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() {
@@ -176,58 +121,8 @@ const ROUTES: RouteDefinition[] = [
{ path: '/*path', component: AppRouterView },
];
-function ConfiguredGlobalAppStateProvider(props: ParentProps) {
- // Initialize global notification helpers
- const notifInterface = usePlatformNotificationState();
- useChatRenameWebsocketSync();
- useReopenTrackedEntitiesOnReconnect();
- useRefreshTrackedEntitiesOnFocus();
-
- if (isNativeMobilePlatform()) {
- useInvalidateQueriesOnReconnect();
- }
-
- const onNotification = (notification: UnifiedNotification) => {
- if (notifInterface === 'not-supported') return;
- const layoutManager = globalSplitManager();
- if (!layoutManager) return;
- maybeHandlePlatformNotification(
- notification,
- notifInterface,
- layoutManager
- );
- };
- const notificationSource = createNotificationSource(
- connectionGatewayWebsocket,
- onNotification
- );
- useNotificationUpdates(notificationSource);
-
- const blockOrchestrator = createBlockOrchestrator();
- usePendingNotificationNavigationEffect(notificationSource);
-
- return (
- <GlobalAppStateProvider
- notificationSource={notificationSource}
- blockOrchestrator={blockOrchestrator}
- >
- {props.children}
- </GlobalAppStateProvider>
- );
-}
-
-function SoupBackfillSideEffect(props: { userId: string }) {
- useSoupBackfills(props.userId);
- return null;
-}
-
-function CalendarCacheSideEffect() {
- useCalendarCache();
- return null;
-}
-
-/** Sets user info for observability, analytics, and login cookie. Must be inside QueryClientProvider. */
-function UserInfoSideEffects() {
+/** Syncs the signed-in user to observability, analytics, and the login cookie. */
+function useUserInfoSideEffects() {
const analytics = useAnalytics();
const posthog = usePosthog();
@@ -282,17 +177,6 @@ function UserInfoSideEffects() {
trackSignupCompletion(analytics, { id: user.id });
})
);
-
- return (
- <Show when={userInfo()?.id} keyed>
- {(userId) => (
- <>
- <SoupBackfillSideEffect userId={userId} />
- <CalendarCacheSideEffect />
- </>
- )}
- </Show>
- );
}
const clearBodyInlineStyleColor = () => {
@@ -301,124 +185,21 @@ const clearBodyInlineStyleColor = () => {
document.body.style.backgroundColor = '';
};
-function QuerySyncProviderWithUserId() {
- const userId = useUserId();
- return <QuerySyncProvider userId={userId} />;
-}
-
-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() &&
- // Desktop first-run users go through /onboarding instead (Layout redirect).
- isMobile() &&
- !isNativeMobilePlatform() &&
- userInfoQuery.data?.authenticated === true &&
- (userInfoQuery.data.tutorialComplete === false || onboardingStarted());
-
- createEffect(() => {
- if (modalOpen()) {
- setOnboardingStarted(true);
- setHasOpened(true);
- }
- });
-
- // First-time users (tutorial not yet completed) reach the app without passing
- // through a login route that inits the email link — e.g. marketing SSO returns to
- // /app, not /login — so kick off email sync once here. Idempotent on the backend;
- // AlreadyInitialized is ignored. Keyed by user id (not a bare flag) so a native
- // mobile logout→login of a different user in the same session still inits.
- let emailInitForUserId: string | undefined;
- createEffect(() => {
- const data = userInfoQuery.data;
- if (data?.authenticated !== true || data.tutorialComplete !== false) return;
- if (emailInitForUserId === data.id) return;
- emailInitForUserId = data.id;
-
- void initAndStartEmailSync().match(
- () => {},
- (err) => {
- if (err.tag !== 'AlreadyInitialized') {
- console.error('Failed to init email link for new user', err);
- }
- }
- );
- });
-
- const handleOpenChange = (nextOpen: boolean) => {
- setOpen(nextOpen);
- if (!nextOpen) {
- setOnboardingStarted(false);
- }
- };
-
- return (
- <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. */
+/** Longest the boot shell waits for a shell to draw 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.
+ * The router's root: the frame every page shares. Each route's shell decides
+ * its own chrome and hands off from index.html's boot shell when it mounts;
+ * the cap keeps an outage from hiding the app's own error states.
*/
-function useBootShellHandoff(isPublicPath: () => boolean) {
- const isAuthenticated = useIsAuthenticated();
+function AppRouteFrame(props: RouteSectionProps) {
+ useUserInfoSideEffects();
onMount(() => {
const cap = setTimeout(dismissBootShell, BOOT_SHELL_MAX_WAIT_MS);
onCleanup(() => clearTimeout(cap));
});
- createEffect(() => {
- if (isPublicPath() || isAuthenticated() !== undefined) dismissBootShell();
- });
-}
-
-/** Public booking and form links use a focused shell and skip app onboarding. */
-function AppRouteLayout(props: RouteSectionProps) {
- const location = useLocation();
- const isAuthenticated = useIsAuthenticated();
- const isFocusedPath = () =>
- usesFocusedShell(location.pathname, isAuthenticated());
- useBootShellHandoff(
- () => isFocusedPath() || isMeetingPath(location.pathname)
- );
- return (
- <Show
- when={!isFocusedPath()}
- fallback={
- <div class="h-dvh overflow-y-auto bg-page text-ink">
- {props.children}
- </div>
- }
- >
- <IncomingMeetingInvitationsProvider>
- <Show
- when={!isMeetingPath(location.pathname)}
- fallback={props.children}
- >
- <Layout {...props} />
- <InitialInteractiveOnboardingModal />
- </Show>
- </IncomingMeetingInvitationsProvider>
- </Show>
- );
+ return <RootFrame>{props.children}</RootFrame>;
}
export function Root() {
@@ -454,45 +235,33 @@ export function Root() {
<IosPushNotificationModal />
<IpadUnsupportedDialog />
<GlobalShareInboxConflictDialog />
- <QuerySyncProviderWithUserId />
- <UserInfoSideEffects />
- <TeamContextProvider>
- <ConfiguredGlobalAppStateProvider>
- <MutationUndoProvider>
- <ChannelsContextProvider>
- <CallProvider>
- <CallKitSync />
- <CallStartedNotifier />
- <IncomingCallEvents />
- <QuickAccessProvider>
- <SearchProvider>
- <ChatAttachmentsInit />
- <ReactiveFavicon />
- <Title>{tabTitle()}</Title>
- <MeetingSessionProvider>
- {/* Loading boundaries belong inside Layout so
- a pending resource cannot detach the app shell. */}
- <IsomorphicRouter
- transformUrl={transformShortIdInUrlPathname}
- root={AppRouteLayout}
- rootPreload={rootPreload}
- base={ROUTER_BASE}
- >
- {{
- path: '/',
- component: TauriRouteListener,
- children: ROUTES,
- }}
- </IsomorphicRouter>
- </MeetingSessionProvider>
- <ToastRegion />
- </SearchProvider>
- </QuickAccessProvider>
- </CallProvider>
- </ChannelsContextProvider>
- </MutationUndoProvider>
- </ConfiguredGlobalAppStateProvider>
- </TeamContextProvider>
+ <ChannelsContextProvider>
+ <CallProvider>
+ <CallKitSync />
+ <CallStartedNotifier />
+ <IncomingCallEvents />
+ <QuickAccessProvider>
+ <Title>{tabTitle()}</Title>
+ <MeetingSessionProvider>
+ {/* Loading boundaries belong inside RootFrame so
+ a pending resource cannot detach the frame. */}
+ <IsomorphicRouter
+ transformUrl={transformShortIdInUrlPathname}
+ root={AppRouteFrame}
+ rootPreload={rootPreload}
+ base={ROUTER_BASE}
+ >
+ {{
+ path: '/',
+ component: TauriRouteListener,
+ children: ROUTES,
+ }}
+ </IsomorphicRouter>
+ </MeetingSessionProvider>
+ <ToastRegion />
+ </QuickAccessProvider>
+ </CallProvider>
+ </ChannelsContextProvider>
</EmailLinksContextProvider>
</UserContextProvider>
</EntityProvider>
diff --git a/apps/web/src/routes/app-router-view.tsx b/apps/web/src/routes/app-router-view.tsx
index 810629d350..405cbe4efd 100644
--- a/apps/web/src/routes/app-router-view.tsx
+++ b/apps/web/src/routes/app-router-view.tsx
@@ -1,16 +1,27 @@
import { ROUTER_BASE } from '@app/constants/routerBase';
+import { AgentsViewSkeleton } from '@app/features/agents-view/agents-view-skeleton';
+import { MobileWebSignup } from '@app/features/auth/auth';
+import { CalendarViewSkeleton } from '@app/features/calendar-view/calendar-view-skeleton';
+import { ChannelInviteAcceptance } from '@app/features/channel-invitations/ChannelInviteAcceptance';
+import { ChannelsViewSkeleton } from '@app/features/channels-view/channels-view-skeleton';
+import { DriveViewSkeleton } from '@app/features/drive-view/drive-view-skeleton';
+import { EmailViewSkeleton } from '@app/features/email-view/email-view-skeleton';
+import { InviteLinksPortal } from '@app/features/gtm-invite/InviteLinksPortal';
+import { InviteWelcome } from '@app/features/gtm-invite/InviteWelcome';
import {
HomeCalendarRouteView,
HomeDetailRouteView,
} from '@app/features/home/home-view';
import { HomeRouteView } from '@app/features/home/route-views';
+import { ReviewsViewSkeleton } from '@app/features/reviews-view/reviews-view-skeleton';
+import { TasksViewSkeleton } from '@app/features/tasks-view/tasks-view-skeleton';
+import { TeamInviteAcceptance } from '@app/features/team-invitations/TeamInviteAcceptance';
import {
createMemoryPaneStore,
SplitRouter,
useSolidRouterHistory,
} from '@app/lib/split-router';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { SplitLayout } from '@components/app/split-layout/SplitLayout';
import { createAppSplitRouterMiddleware } from '@components/app/split-layout/split-router/app-middleware';
import { createAppPanePolicy } from '@components/app/split-layout/split-router/app-pane-policy';
import {
@@ -19,18 +30,61 @@ import {
} from '@components/app/split-layout/split-router/legacy-route';
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, onMount } from 'solid-js';
+import { lazy } from 'solid-js';
import { paneRoute } from './app-route';
import { BasePathComponent } from './BasePath';
+import {
+ ActivityRouteView,
+ AgentsRouteView,
+ CalendarRouteView,
+ CallDetailRouteView,
+ CallsRouteView,
+ ChannelDetailRouteView,
+ ChannelsRouteView,
+ CompaniesRouteView,
+ DriveCallRouteView,
+ DriveDetailView,
+ DriveRouteView,
+ EmailDetailRouteView,
+ FoldersRouteView,
+ FormRespondRoutePage,
+ HomeEntityDetailRouteView,
+ MailRouteView,
+ MeetingRouter,
+ NotFound,
+ PrDetailRouteView,
+ ProjectDetailRouteView,
+ ProjectTaskRouteView,
+ RecentRouteView,
+ ReviewsPrDetailRouteView,
+ ReviewsRouteView,
+ RoutineCreateRouteView,
+ SearchRouteView,
+ SettingsRouteView,
+ TasksDetailRouteView,
+ TasksRouteView,
+} from './lazy-route-views';
+import {
+ BookingReceiptRoutePage,
+ EmailCallback,
+ EmailLinkCallback,
+ LoginPage,
+ LoginPopupSuccess,
+ OnboardingPage,
+ PublicBookingRoutePage,
+ SignupPage,
+ TaskSlugPage,
+ WelcomePage,
+} from './pages';
import {
activityRoute,
agentChatsRoute,
agentsRoute,
agentsViewRoute,
appRoute,
+ authRoute,
baseRoute,
bookingReceiptRoute,
calendarSplitRoute,
@@ -73,6 +127,7 @@ import {
projectDetailRoute,
projectTaskRoute,
publicBookingRoute,
+ publicRoute,
recentRoute,
reviewsPrRoute,
reviewsSplitRoute,
@@ -89,171 +144,18 @@ import {
teamInviteRoute,
welcomeRoute,
} from './routes';
+import {
+ AppShell,
+ AuthShell,
+ FocusedShell,
+ withFormRespondShell,
+ withMeetingShell,
+} from './shells';
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 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 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 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 FormRespondRoutePage = lazyNamed(
- () => import('./pages'),
- 'FormRespondRoutePage'
-);
-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')
-);
+// Views under appRoute load lazily (lazy-route-views.ts); auth and booking
+// pages render outside it and load with the app.
/** Debug views stay behind the registry's lazy import. */
function debugView(componentId: string) {
@@ -265,46 +167,7 @@ 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)} />
));
@@ -333,44 +196,64 @@ export function AppRouterView() {
defaultRoute={() => ({ matches: [{ id: baseRoute.id, params: {} }] })}
>
<Route definition={baseRoute} component={BasePathComponent} />
+ <Route definition={publicRoute} component={FocusedShell}>
+ <Route
+ definition={publicBookingRoute}
+ component={PublicBookingRoutePage}
+ />
+ <Route
+ definition={bookingReceiptRoute}
+ component={BookingReceiptRoutePage}
+ />
+ </Route>
<Route
- definition={publicBookingRoute}
- component={PublicBookingRoutePage}
- />
- <Route
- definition={bookingReceiptRoute}
- component={BookingReceiptRoutePage}
- />
- <Route definition={formRespondRoute} component={FormRespondRoutePage} />
- <Route definition={meetRoute} component={MeetingRouter} />
- <Route definition={taskSlugRoute} component={TaskSlugPage} />
- <Route definition={signupRoute} component={SignupPage} />
- <Route definition={emailSignupCallbackRoute} component={EmailCallback} />
- <Route
- definition={inboxLinkCallbackRoute}
- component={EmailLinkCallback}
- />
- <Route
- definition={loginPopupSuccessRoute}
- component={LoginPopupSuccess}
- />
- <Route definition={loginRoute} component={LoginPage} />
- <Route definition={welcomeRoute} component={WelcomePage} />
- <Route definition={mobileEmailSignupRoute} component={MobileWebSignup} />
- <Route definition={onboardingRoute} component={OnboardingPage} />
- <Route definition={inviteRoute} component={InviteWelcome} />
- <Route
- definition={internalInviteLinksRoute}
- component={InviteLinksPortal}
+ definition={formRespondRoute}
+ component={withFormRespondShell(FormRespondRoutePage)}
/>
- <Route definition={teamInviteRoute} component={TeamInviteAcceptance} />
<Route
- definition={channelInviteRoute}
- component={ChannelInviteAcceptance}
+ definition={meetRoute}
+ component={withMeetingShell(MeetingRouter)}
/>
+ <Route definition={authRoute} component={AuthShell}>
+ <Route definition={taskSlugRoute} component={TaskSlugPage} />
+ <Route definition={signupRoute} component={SignupPage} />
+ <Route
+ definition={emailSignupCallbackRoute}
+ component={EmailCallback}
+ />
+ <Route
+ definition={inboxLinkCallbackRoute}
+ component={EmailLinkCallback}
+ />
+ <Route
+ definition={loginPopupSuccessRoute}
+ component={LoginPopupSuccess}
+ />
+ <Route definition={loginRoute} component={LoginPage} />
+ <Route definition={welcomeRoute} component={WelcomePage} />
+ <Route
+ definition={mobileEmailSignupRoute}
+ component={MobileWebSignup}
+ />
+ <Route definition={onboardingRoute} component={OnboardingPage} />
+ <Route definition={inviteRoute} component={InviteWelcome} />
+ <Route
+ definition={internalInviteLinksRoute}
+ component={InviteLinksPortal}
+ />
+ <Route definition={teamInviteRoute} component={TeamInviteAcceptance} />
+ <Route
+ definition={channelInviteRoute}
+ component={ChannelInviteAcceptance}
+ />
+ </Route>
- <Route definition={appRoute} component={SplitLayout}>
- <Route definition={driveSplitRoute} component={DriveRouteView}>
+ <Route definition={appRoute} component={AppShell}>
+ <Route
+ definition={driveSplitRoute}
+ component={DriveRouteView}
+ loading={DriveViewSkeleton}
+ >
<Route definition={driveFolderRoute}>
<Route
definition={driveFolderDocumentRoute}
@@ -394,11 +277,31 @@ export function AppRouterView() {
definition={routineCreateRoute}
component={RoutineCreateRouteView}
/>
- <Route definition={routineDetailRoute} component={AgentsRouteView} />
- <Route definition={routinesRoute} component={AgentsRouteView} />
- <Route definition={agentsRoute} component={AgentsRouteView} />
- <Route definition={codersRoute} component={AgentsRouteView} />
- <Route definition={agentChatsRoute} component={AgentsRouteView} />
+ <Route
+ definition={routineDetailRoute}
+ component={AgentsRouteView}
+ loading={AgentsViewSkeleton}
+ />
+ <Route
+ definition={routinesRoute}
+ component={AgentsRouteView}
+ loading={AgentsViewSkeleton}
+ />
+ <Route
+ definition={agentsRoute}
+ component={AgentsRouteView}
+ loading={AgentsViewSkeleton}
+ />
+ <Route
+ definition={codersRoute}
+ component={AgentsRouteView}
+ loading={AgentsViewSkeleton}
+ />
+ <Route
+ definition={agentChatsRoute}
+ component={AgentsRouteView}
+ loading={AgentsViewSkeleton}
+ />
<Route definition={homeSplitRoute} component={HomeRouteView}>
{/* The period path is matched before the block pattern can claim `calendar`. */}
<Route
@@ -420,14 +323,26 @@ export function AppRouterView() {
</Route>
<Route definition={recentRoute} component={RecentRouteView} />
<Route definition={activityRoute} component={ActivityRouteView} />
- <Route definition={agentsViewRoute} component={AgentsRouteView} />
- <Route definition={emailSplitRoute} component={MailRouteView}>
+ <Route
+ definition={agentsViewRoute}
+ component={AgentsRouteView}
+ loading={AgentsViewSkeleton}
+ />
+ <Route
+ definition={emailSplitRoute}
+ component={MailRouteView}
+ loading={EmailViewSkeleton}
+ >
<Route
definition={emailThreadRoute}
component={EmailDetailRouteView}
/>
</Route>
- <Route definition={tasksSplitRoute} component={TasksRouteView}>
+ <Route
+ definition={tasksSplitRoute}
+ component={TasksRouteView}
+ loading={TasksViewSkeleton}
+ >
<Route
definition={projectDetailRoute}
component={ProjectDetailRouteView}
@@ -443,14 +358,26 @@ export function AppRouterView() {
component={TasksDetailRouteView}
/>
</Route>
- <Route definition={reviewsSplitRoute} component={ReviewsRouteView}>
+ <Route
+ definition={reviewsSplitRoute}
+ component={ReviewsRouteView}
+ loading={ReviewsViewSkeleton}
+ >
<Route
definition={reviewsPrRoute}
component={ReviewsPrDetailRouteView}
/>
</Route>
- <Route definition={calendarSplitRoute} component={CalendarRouteView} />
- <Route definition={channelsSplitRoute} component={ChannelsRouteView}>
+ <Route
+ definition={calendarSplitRoute}
+ component={CalendarRouteView}
+ loading={CalendarViewSkeleton}
+ />
+ <Route
+ definition={channelsSplitRoute}
+ component={ChannelsRouteView}
+ loading={ChannelsViewSkeleton}
+ >
<Route
definition={channelDetailRoute}
component={ChannelDetailRouteView}
diff --git a/apps/web/src/routes/focused-shell.test.ts b/apps/web/src/routes/focused-shell.test.ts
deleted file mode 100644
index 71b86e4b88..0000000000
--- a/apps/web/src/routes/focused-shell.test.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import { usesFocusedShell } from './focused-shell';
-
-describe('usesFocusedShell', () => {
- it('keeps booking links focused for everyone', () => {
- expect(usesFocusedShell('/app/book/ada/intro', true)).toBe(true);
- expect(usesFocusedShell('/app/booking/receipt-1', false)).toBe(true);
- });
-
- it('renders a form’s respond link focused for anonymous visitors, inside the app shell once signed in', () => {
- expect(usesFocusedShell('/app/form/form-1/respond', false)).toBe(true);
- expect(usesFocusedShell('/app/form/form-1/respond', true)).toBe(false);
- });
-
- it('leaves app routes, the form block included, in the app shell', () => {
- expect(usesFocusedShell('/app/form/form-1', false)).toBe(false);
- expect(usesFocusedShell('/app/home', true)).toBe(false);
- });
-});
diff --git a/apps/web/src/routes/focused-shell.ts b/apps/web/src/routes/focused-shell.ts
deleted file mode 100644
index e381634680..0000000000
--- a/apps/web/src/routes/focused-shell.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';
-
-/** A form's respond link: `/form/<id>/respond`. */
-function isFormRespondPath(pathname: string) {
- return /^\/form\/[^/]+\/respond\/?$/.test(
- pathname.slice(ROUTER_BASE_CONCAT.length - 1)
- );
-}
-
-/**
- * Whether a page renders in the focused shell, without the app's chrome:
- * booking links always; a form's respond link only for anonymous visitors,
- * so a public form never hits login while signed-in respondents keep the
- * app shell around the same page (RFC 02 §4). While sign-in is unknown the
- * focused shell shows.
- */
-export function usesFocusedShell(
- pathname: string,
- authenticated: boolean | undefined
-) {
- if (
- pathname.startsWith(`${ROUTER_BASE_CONCAT}book/`) ||
- pathname.startsWith(`${ROUTER_BASE_CONCAT}booking/`)
- )
- return true;
- return isFormRespondPath(pathname) && authenticated !== true;
-}
diff --git a/apps/web/src/routes/lazy-route-views.ts b/apps/web/src/routes/lazy-route-views.ts
new file mode 100644
index 0000000000..b450ac68f6
--- /dev/null
+++ b/apps/web/src/routes/lazy-route-views.ts
@@ -0,0 +1,140 @@
+import { lazyNamed } from '@core/util/lazyNamed';
+import { lazy } from 'solid-js';
+
+/**
+ * Every view except Home (the default landing) loads as its own chunk. The
+ * split router warms a route's chunks while it navigates, and `AppShell`
+ * fetches the likely-next ones once the first screen settles.
+ */
+export const ActivityRouteView = lazyNamed(
+ () => import('@app/features/activity/route-views'),
+ 'ActivityRouteView'
+);
+export const AgentsRouteView = lazyNamed(
+ () => import('@app/features/agents-view/route-views'),
+ 'AgentsRouteView'
+);
+export const CallDetailRouteView = lazyNamed(
+ () => import('@app/features/block-call/route-views'),
+ 'CallDetailRouteView'
+);
+export const PrDetailRouteView = lazyNamed(
+ () => import('@app/features/block-pr/route-views'),
+ 'PrDetailRouteView'
+);
+export const CalendarRouteView = lazyNamed(
+ () => import('@app/features/calendar-view/route-views'),
+ 'CalendarRouteView'
+);
+export const ChannelDetailRouteView = lazyNamed(
+ () => import('@app/features/channels-view/channels-view'),
+ 'ChannelDetailRouteView'
+);
+export const ChannelsRouteView = lazyNamed(
+ () => import('@app/features/channels-view/route-views'),
+ 'ChannelsRouteView'
+);
+export const CompaniesRouteView = lazyNamed(
+ () => import('@app/features/crm/route-views'),
+ 'CompaniesRouteView'
+);
+export const DriveDetailView = lazyNamed(
+ () => import('@app/features/drive-view/components/DriveDetailView'),
+ 'DriveDetailView'
+);
+export const DriveCallRouteView = lazyNamed(
+ () => import('@app/features/drive-view/route-views'),
+ 'DriveCallRouteView'
+);
+export const DriveRouteView = lazyNamed(
+ () => import('@app/features/drive-view/route-views'),
+ 'DriveRouteView'
+);
+export const EmailDetailRouteView = lazyNamed(
+ () => import('@app/features/email-view/components/EmailDetailView'),
+ 'EmailDetailRouteView'
+);
+export const MailRouteView = lazyNamed(
+ () => import('@app/features/email-view/route-views'),
+ 'MailRouteView'
+);
+export const HomeEntityDetailRouteView = lazyNamed(
+ () => import('@app/features/home/components/HomeEntityDetailRouteView'),
+ 'HomeEntityDetailRouteView'
+);
+export const MeetingRouter = lazyNamed(
+ () => import('@app/features/meetings/meeting-router'),
+ 'MeetingRouter'
+);
+export const CallsRouteView = lazyNamed(
+ () => import('@app/features/next-soup/route-views'),
+ 'CallsRouteView'
+);
+export const FoldersRouteView = lazyNamed(
+ () => import('@app/features/next-soup/route-views'),
+ 'FoldersRouteView'
+);
+export const RecentRouteView = lazyNamed(
+ () => import('@app/features/next-soup/route-views'),
+ 'RecentRouteView'
+);
+export const SearchRouteView = lazyNamed(
+ () => import('@app/features/next-soup/route-views'),
+ 'SearchRouteView'
+);
+export const ReviewsPrDetailRouteView = lazyNamed(
+ () => import('@app/features/reviews-view/route-views'),
+ 'ReviewsPrDetailRouteView'
+);
+export const ReviewsRouteView = lazyNamed(
+ () => import('@app/features/reviews-view/route-views'),
+ 'ReviewsRouteView'
+);
+export const RoutineCreateRouteView = lazyNamed(
+ () => import('@app/features/routines/route-views'),
+ 'RoutineCreateRouteView'
+);
+export const SettingsRouteView = lazyNamed(
+ () => import('@app/features/settings/route-views'),
+ 'SettingsRouteView'
+);
+export const TasksDetailRouteView = lazyNamed(
+ () => import('@app/features/tasks-view/components/TasksDetailView'),
+ 'TasksDetailRouteView'
+);
+export const ProjectDetailRouteView = lazyNamed(
+ () => import('@app/features/tasks-view/route-views'),
+ 'ProjectDetailRouteView'
+);
+export const ProjectTaskRouteView = lazyNamed(
+ () => import('@app/features/tasks-view/route-views'),
+ 'ProjectTaskRouteView'
+);
+export const TasksRouteView = lazyNamed(
+ () => import('@app/features/tasks-view/route-views'),
+ 'TasksRouteView'
+);
+export const FormRespondRoutePage = lazyNamed(
+ () => import('./pages'),
+ 'FormRespondRoutePage'
+);
+export const NotFound = lazy(
+ () => import('@core/component/AccessErrorViews/NotFound')
+);
+
+/**
+ * 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.
+ */
+export const LIKELY_NEXT_VIEWS = [
+ HomeEntityDetailRouteView,
+ ChannelsRouteView,
+ ChannelDetailRouteView,
+ MailRouteView,
+ EmailDetailRouteView,
+ DriveRouteView,
+ DriveDetailView,
+ TasksRouteView,
+ AgentsRouteView,
+ CalendarRouteView,
+];
diff --git a/apps/web/src/routes/routes.ts b/apps/web/src/routes/routes.ts
index 3136ce5786..8708698a50 100644
--- a/apps/web/src/routes/routes.ts
+++ b/apps/web/src/routes/routes.ts
@@ -166,6 +166,12 @@ export const channelInviteRoute = defineRoute({
externalSearch: '*',
});
+/** Sign-in, onboarding, invite, and handoff pages, without the app's chrome. */
+export const authRoute = defineRoute({ id: 'auth' });
+
+/** Booking pages a visitor opens from a shared link, in the focused shell. */
+export const publicRoute = defineRoute({ id: 'public' });
+
/** The split layout; its children are the pane routes. */
export const appRoute = defineRoute({ id: APP_ROUTE_ID });
diff --git a/apps/web/src/routes/shells.tsx b/apps/web/src/routes/shells.tsx
new file mode 100644
index 0000000000..d7d8e53c5d
--- /dev/null
+++ b/apps/web/src/routes/shells.tsx
@@ -0,0 +1,139 @@
+import { SplitRouter } from '@app/lib/split-router';
+import { dismissBootShell } from '@components/app/boot-shell';
+import { AppChrome, PageContent } from '@components/app/Layout';
+import { SplitLayout } from '@components/app/split-layout/SplitLayout';
+import { useIsAuthenticated } from '@core/auth';
+import { type JSX, onCleanup, onMount, type ParentProps, Show } from 'solid-js';
+import { LIKELY_NEXT_VIEWS } from './lazy-route-views';
+
+/** Takes over from index.html's boot shell once this shell has drawn. */
+function useDismissBootShell() {
+ onMount(dismissBootShell);
+}
+
+/** Sign-in, onboarding, invite, and handoff pages: the page alone. */
+export function AuthShell(): JSX.Element {
+ useDismissBootShell();
+ return (
+ <PageContent>
+ <SplitRouter.Outlet />
+ </PageContent>
+ );
+}
+
+function FocusedPage(props: ParentProps) {
+ useDismissBootShell();
+ return (
+ <div class="min-h-0 flex-1 overflow-y-auto bg-page text-ink">
+ {props.children}
+ </div>
+ );
+}
+
+/** Booking links: a scrolling page on the page background, without app chrome. */
+export function FocusedShell(): JSX.Element {
+ return (
+ <FocusedPage>
+ <SplitRouter.Outlet />
+ </FocusedPage>
+ );
+}
+
+/**
+ * A form's respond page: anonymous visitors get the focused shell, so a public
+ * form never hits login; signed-in respondents keep the app chrome around it.
+ * While sign-in is unknown the focused shell shows.
+ */
+export function withFormRespondShell(Page: () => JSX.Element) {
+ return function FormRespondShell(): JSX.Element {
+ const isAuthenticated = useIsAuthenticated();
+ return (
+ <Show
+ when={isAuthenticated() === true}
+ fallback={
+ <FocusedPage>
+ <Page />
+ </FocusedPage>
+ }
+ >
+ <AppPage>
+ <Page />
+ </AppPage>
+ </Show>
+ );
+ };
+}
+
+/** A call: full screen, without app chrome. */
+export function withMeetingShell(Page: () => JSX.Element) {
+ return function MeetingShell(): JSX.Element {
+ useDismissBootShell();
+ return (
+ <PageContent>
+ <Page />
+ </PageContent>
+ );
+ };
+}
+
+function AppPage(props: ParentProps) {
+ useDismissBootShell();
+ return <AppChrome>{props.children}</AppChrome>;
+}
+
+type PreloadableView = { preload: () => Promise<unknown> };
+type NetworkInformation = { saveData?: boolean };
+
+/**
+ * Warms the likely-next view chunks one at a time while the app is open,
+ * leaving startup and hidden tabs alone and skipping Save-Data connections.
+ */
+function warmRouteViews(views: readonly PreloadableView[]): void {
+ const connection = (
+ navigator as Navigator & { connection?: NetworkInformation }
+ ).connection;
+ if (connection?.saveData) return;
+
+ const queue = [...views];
+ let disposed = false;
+ let timer: ReturnType<typeof setTimeout> | undefined;
+
+ const next = () => {
+ const view = disposed ? undefined : queue.shift();
+ if (!view) return;
+ void view
+ .preload()
+ .catch(() => {})
+ .finally(schedule);
+ };
+ function schedule() {
+ if (disposed || queue.length === 0) return;
+ if (document.visibilityState !== 'visible') {
+ document.addEventListener('visibilitychange', schedule, { once: true });
+ return;
+ }
+ if ('requestIdleCallback' in window) {
+ window.requestIdleCallback(next, { timeout: 5000 });
+ } else {
+ timer = setTimeout(next, 1000);
+ }
+ }
+
+ // Leave the first seconds to the landing view's own data and chunks.
+ timer = setTimeout(schedule, 2500);
+ onCleanup(() => {
+ disposed = true;
+ clearTimeout(timer);
+ document.removeEventListener('visibilitychange', schedule);
+ });
+}
+
+/** The app: its chrome around the split layout, which renders every pane. */
+export function AppShell(): JSX.Element {
+ warmRouteViews(LIKELY_NEXT_VIEWS);
+ return (
+ <AppPage>
+ <SplitLayout />
+ </AppPage>
+ );
+}
diff --git a/apps/web/vite.base.ts b/apps/web/vite.base.ts
index 601b538077..e486499a91 100644
--- a/apps/web/vite.base.ts
+++ b/apps/web/vite.base.ts
@@ -130,6 +130,83 @@ function cloudFrontCompressionLimit(): Plugin {
};
}
+/**
+ * loro-crdt's `browser` export downloads its 3 MB WASM with a synchronous
+ * XMLHttpRequest and compiles it on the main thread, freezing startup for the
+ * whole download. Builds use the `bundler` export that dev already resolves
+ * through the `development` condition: vite-plugin-wasm streams and compiles it
+ * off the main thread (htmlPreloads starts its download with the HTML).
+ */
+function loroAsyncWasm(): Plugin {
+ return {
+ name: 'loro-async-wasm',
+ apply: 'build',
+ enforce: 'pre',
+ resolveId(source, importer, options) {
+ if (source !== 'loro-crdt') return null;
+ return this.resolve('loro-crdt/bundler', importer, {
+ ...options,
+ skipSelf: true,
+ });
+ },
+ };
+}
+
+/** Hashed assets the first screen needs; index.html requests them while it parses. */
+const HTML_PRELOADS = [
+ // The app waits for Loro to initialize before rendering.
+ {
+ file: /(^|\/)loro_wasm_bg-[\w-]+\.wasm$/,
+ as: 'fetch',
+ type: 'application/wasm',
+ },
+ // The UI font; otherwise it starts downloading only once text renders.
+ {
+ file: /(^|\/)inter-latin-wght-normal-[\w-]+\.woff2$/,
+ as: 'font',
+ type: 'font/woff2',
+ },
+] as const;
+
+/**
+ * Adds `<link rel="preload">` for HTML_PRELOADS, so their downloads start with
+ * the HTML instead of after the entry runs. The service worker caches preloads
+ * with the shell.
+ */
+function htmlPreloads(): Plugin {
+ let base = '/';
+ return {
+ name: 'html-preloads',
+ apply: 'build',
+ configResolved(config) {
+ base = config.base.endsWith('/') ? config.base : `${config.base}/`;
+ },
+ transformIndexHtml: {
+ order: 'post',
+ handler(_html, ctx) {
+ const files = Object.keys(ctx.bundle ?? {});
+ return HTML_PRELOADS.flatMap((preload) => {
+ const file = files.find((fileName) => preload.file.test(fileName));
+ if (!file) return [];
+ return [
+ {
+ tag: 'link',
+ attrs: {
+ rel: 'preload',
+ href: `${base}${file}`,
+ as: preload.as,
+ type: preload.type,
+ crossorigin: '',
+ },
+ injectTo: 'head' as const,
+ },
+ ];
+ });
+ },
+ },
+ };
+}
+
export const createAppViteConfig = (): UserConfigFn => {
return ({ command, mode }) => {
const ENV_MODE = process.env.MODE ?? mode;
@@ -152,6 +229,8 @@ export const createAppViteConfig = (): UserConfigFn => {
pureGeneratedZodSchemas(),
solid(),
wasm(),
+ loroAsyncWasm(),
+ htmlPreloads(),
tailwind(),
solidSvg({ defaultAsComponent: true }),
tsconfigpaths({
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index b128c1d804..1be2f0c263 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -2343,12 +2343,23 @@ Section headings and controls share a white surface in light mode and the
composer border in dark mode, with subtle row separators. The compact sidebar
uses the shared workspace width.
+When a newer version is ready, an **Update available** button (a download icon
+in a subtle accent circle that a glowing comet periodically circles) appears in
+the sidebar rail above the mobile-app and settings icons. Its popover (a title,
+a short description, and one action) opens by itself once per update until
+dismissed (click outside or Escape); the button stays until the update is
+applied. Its wording and action depend on the update: **New version available**
+/ **Reload** for a newer web build, **Update ready** / **Update** for a
+downloaded bundle in the desktop app, and **Desktop app update ready** /
+**Restart and update** for a native desktop update. When part of the app fails
+to load because a newer web build replaced it, the same button appears and its
+popover opens again (even if dismissed) with **Reload**; there is no blocking
+alert. Touch layouts have no rail, so a newer web build shows a **Reload** toast
+there instead.
+
On desktop release builds, **Account → Desktop app update** shows native update
-progress. When a verified update is ready, an **Update available** arrow icon
-appears in the sidebar above the mobile-app and settings icons. Click it to open
-**Update Macro**, then choose **Restart and update** or **Later**. Dismissing the
-modal leaves the sidebar notification available. While preparing to restart,
-the modal disables its actions. Restart waits for pending canvas/PDF saves and
+progress. While preparing to restart, the popover can't be dismissed and its
+action is disabled. Restart waits for pending canvas/PDF saves and
local persistence; active calls, uploads, and imports must finish first. A ready
update also installs on normal app quit. Closing a window only triggers
installation if it exits the app. Browser, mobile, and development builds do not