Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore: ios js entry observability (#4345)
Peter Chinman264ea2d616b4
diff --git a/js/app/packages/app/component/settings/Account.tsx b/js/app/packages/app/component/settings/Account.tsxindex fc0954fd72..b4a43c41ff 100644--- a/js/app/packages/app/component/settings/Account.tsx+++ b/js/app/packages/app/component/settings/Account.tsx@@ -6,7 +6,7 @@ import { toast } from '@core/component/Toast/Toast';import { staticFileIdEndpoint } from '@core/constant/servers';import { createStaticFile } from '@core/util/create';import { openFilePicker } from '@core/util/upload';-import { Dialog, Button, Panel, Tooltip, ToggleSwitch, Dropdown } from '@ui';+import { Dialog, Button, Panel, Tooltip, ToggleSwitch, Dropdown, cn } from '@ui';import { SettingsCard, SettingsPage, SettingsSection } from './primitives';import {blockNameToFileExtensions,@@ -50,6 +50,7 @@ import { useAnalytics } from '@app/component/analytics-context';import { useTauri, type BundleUpdateStatus } from '@macro/tauri';import { invoke } from '@tauri-apps/api/core';import { Transition } from 'solid-transition-group';+import { formatAssetUrl, loadEntryAssetInfo } from './entryAssetInfo';// 16 megabytesconst MAX_PROFILE_PICTURE_SIZE = 16 * 1000 * 1000;@@ -666,22 +667,120 @@ type BundleDebugInfo = {function BundleVersionRow() {if (!isNativeMobilePlatform()) return null;+ const [showBuildInfo, setShowBuildInfo] = createSignal(false);const [bundleDebugInfo] = createResource(() =>invoke<BundleDebugInfo>('get_bundle_debug_info').catch((error) => {console.error('[bundle-update] get_bundle_debug_info failed', error);return null;}));+ const [entryAssetInfo] = createResource(showBuildInfo, (open) =>+ open ? loadEntryAssetInfo() : null+ );+return (<Show when={bundleDebugInfo()}>{(info) => (- <Row label="Version">- <span class="text-sm text-ink-muted">- {info().bundleBuild} ({info().source === 'embedded' ? 'app' : 'ota'})- {' '}- - {info().nativeBuild}- </span>- </Row>+ <>+ <Row label="Version">+ <button+ type="button"+ class="appearance-none rounded-sm border-0 bg-transparent p-0 text-right text-sm text-ink-muted hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"+ onClick={() => setShowBuildInfo(true)}+ >+ {info().bundleBuild}{' '}+ ({info().source === 'embedded' ? 'app' : 'ota'}) -{' '}+ {info().nativeBuild}+ </button>+ </Row>+ <Dialog+ open={showBuildInfo()}+ onOpenChange={setShowBuildInfo}+ position="center"+ class="w-120"+ >+ <Panel active depth={2} class="rounded-xl">+ <Panel.Header class="px-6">+ <Dialog.Title class="text-ink text-sm font-semibold">+ App Debug Info+ </Dialog.Title>+ </Panel.Header>+ <Panel.Body class="p-6 font-sans flex flex-col gap-4">+ <div class="grid gap-2 text-sm">+ <div class="flex items-center justify-between gap-4">+ <span class="text-ink-muted">Selected bundle</span>+ <span class="text-ink">+ {info().bundleBuild}{' '}+ ({info().source === 'embedded' ? 'app' : 'ota'})+ </span>+ </div>+ <div class="flex items-center justify-between gap-4">+ <span class="text-ink-muted">Native build</span>+ <span class="text-ink">{info().nativeBuild}</span>+ </div>+ <div class="flex items-center justify-between gap-4">+ <span class="text-ink-muted">Runtime entry</span>+ <span+ class={cn(+ 'text-right break-all',+ entryAssetInfo()?.matches === false+ ? 'text-failure'+ : 'text-ink'+ )}+ >+ {entryAssetInfo.loading+ ? 'Loading...'+ : formatAssetUrl(entryAssetInfo()?.loadedEntryUrl)}+ </span>+ </div>+ <div class="flex items-center justify-between gap-4">+ <span class="text-ink-muted">Fresh index entry</span>+ <span+ class={cn(+ 'text-right break-all',+ entryAssetInfo()?.matches === false+ ? 'text-failure'+ : 'text-ink'+ )}+ >+ {entryAssetInfo.loading+ ? 'Loading...'+ : formatAssetUrl(entryAssetInfo()?.freshIndexEntryUrl)}+ </span>+ </div>+ <div class="flex items-center justify-between gap-4">+ <span class="text-ink-muted">Matches</span>+ <span+ class={cn(+ entryAssetInfo()?.matches === false+ ? 'text-failure'+ : 'text-ink'+ )}+ >+ {entryAssetInfo.loading+ ? 'Loading...'+ : entryAssetInfo()?.matches == null+ ? 'unknown'+ : entryAssetInfo()?.matches+ ? 'true'+ : 'false'}+ </span>+ </div>+ <Show when={entryAssetInfo()?.error}>+ {(error) => (+ <div class="flex items-center justify-between gap-4">+ <span class="text-ink-muted">Error</span>+ <span class="text-right text-failure break-all">+ {error()}+ </span>+ </div>+ )}+ </Show>+ </div>+ </Panel.Body>+ </Panel>+ </Dialog>+ </>)}</Show>);diff --git a/js/app/packages/app/component/settings/entryAssetInfo.ts b/js/app/packages/app/component/settings/entryAssetInfo.tsnew file mode 100644index 0000000000..8a6b3e05f0--- /dev/null+++ b/js/app/packages/app/component/settings/entryAssetInfo.ts@@ -0,0 +1,73 @@+export type EntryAssetInfo = {+ freshIndexEntryUrl: string | null;+ loadedEntryUrl: string | null;+ matches: boolean | null;+ error?: string;+};++function normalizeAssetUrl(value: string): string {+ const url = new URL(value, window.location.href);+ url.hash = '';+ url.search = '';+ return url.href;+}++export function formatAssetUrl(value: string | null | undefined): string {+ if (!value) return 'Unavailable';+ try {+ const path = new URL(value, window.location.href).pathname;+ return path.split('/').filter(Boolean).at(-1) ?? value;+ } catch {+ return value;+ }+}++function extractEntryScriptUrl(html: string, indexUrl: string): string | null {+ const document = new DOMParser().parseFromString(html, 'text/html');+ const entryScript = document.querySelector<HTMLScriptElement>(+ 'script[type="module"][src]'+ );+ const src = entryScript?.getAttribute('src');+ return src ? new URL(src, indexUrl).href : null;+}++export async function loadEntryAssetInfo(): Promise<EntryAssetInfo> {+ const loadedEntryUrl = window.__MACRO_RUNTIME_ENTRY_URL__ ?? null;+ if (!loadedEntryUrl) {+ return {+ freshIndexEntryUrl: null,+ loadedEntryUrl,+ matches: null,+ error: 'Runtime entry URL unavailable',+ };+ }++ try {+ const indexUrl = new URL('index.html', loadedEntryUrl);+ indexUrl.searchParams.set('__macro_bundle_probe', Date.now().toString());+ const browserFetch = window.__MACRO_BROWSER_FETCH__ ?? window.fetch.bind(window);+ const response = await browserFetch(indexUrl.href, { cache: 'no-store' });+ if (!response.ok) {+ throw new Error(`Fresh index fetch failed with ${response.status}`);+ }+ const freshIndexEntryUrl = extractEntryScriptUrl(+ await response.text(),+ indexUrl.href+ );+ return {+ freshIndexEntryUrl,+ loadedEntryUrl,+ matches:+ freshIndexEntryUrl !== null &&+ normalizeAssetUrl(loadedEntryUrl) ===+ normalizeAssetUrl(freshIndexEntryUrl),+ };+ } catch (error) {+ return {+ freshIndexEntryUrl: null,+ loadedEntryUrl,+ matches: null,+ error: error instanceof Error ? error.message : String(error),+ };+ }+}diff --git a/js/app/packages/app/index.tsx b/js/app/packages/app/index.tsxindex 5f89260bf5..1a9c168950 100644--- a/js/app/packages/app/index.tsx+++ b/js/app/packages/app/index.tsx@@ -13,6 +13,16 @@ import { ErrorBoundary, render } from 'solid-js/web';import { FatalError } from './component/FatalError';import { Root } from './component/Root';+declare global {+ interface Window {+ __MACRO_BROWSER_FETCH__?: typeof window.fetch;+ __MACRO_RUNTIME_ENTRY_URL__?: string;+ }+}++window.__MACRO_BROWSER_FETCH__ = window.fetch.bind(window);+window.__MACRO_RUNTIME_ENTRY_URL__ = import.meta.url;+// Override global fetch with platformFetch for Tauri compatibility// Skip localhost requests (dev server) to avoid breaking HMRif (isTauri()) {