Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(block-pr): load GitHub description images through the proxy (#8927)
Wolf Mermelstein2d0985d8c492
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex d4b93438df..ba53ac0411 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -308,6 +308,7 @@ resolved session ID; keep the existing `AgentSessionProvider` subscription to- Keep desktop headers on the shared `ListHeader` / `HeaderActionGroup` pattern: view `Tabs` as pills after the title, `sm`/`icon-sm` semantic islands (28px controls) with 8px gaps on the right, fully rounded frames, New then expandable Search; retain `md` sizing for Tabs, New, and Search. Drive and Tasks list-header filter, layout, sort, and grouping islands use `md`/`icon-md` (32px) to match New and Search. Preserve touch layouts. Compose ButtonGroup actions with explicit `ButtonGroup.Button` segments; use `variant="secondary" finish="raised"` on action frames. Standalone Buttons do not inherit group styling. Pick each control by role from the [design system rule](../../.agents/rules/web/design-system.md); see [UI conventions](../../docs/agent-guide/ui-conventions.md#top-bars). Never use recessed/inset backgrounds in headers.- Keep desktop model and effort controls separate: the model selector opens the catalog and the speedometer opens the runtime's advertised slider stops; retain the mobile effort sheet.- Passive PR mentions must not retry initial GitHub status failures on remount; preserve confirmed status through refetch errors and keep pending data reads out of their parent Suspense boundary.+- PR description and comment images are remote URL images: rewrite GitHub blob/`raw` links to `raw.githubusercontent.com` and load them through the image proxy so COEP does not block github.com.- Keep native booking exit navigation in the route shell, outside page loading boundaries, and use the router so the native hash route stays intact.- Diagnose native full reloads with `native_webview_started`, `native_diagnostic_recovered`, and the shared `frontend_instance_id`; use `reloadApp(reason)` for frontend reloads and keep breadcrumbs content-free. Treat `previous_document_*` checkpoints as last-observed lifecycle evidence, never a crash verdict; clear them on logout. `previous_document_last_*` comes from the native navigation breadcrumb (route and entity type, never ids). See [frontend checkpoints](docs/native-reload-diagnostics.md) and `tauri/src-tauri/README.md`.- Pass `$APPLOCALDATA` (Application Support on Apple platforms) as the native HTTP cookie storage directory; the plugin owns the `.cookies` filename. Never use purgeable caches. The location change intentionally requires one new sign-in, without migration. See `tauri/src-tauri/README.md#native-authentication-cookies`.diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.test.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.test.tsxindex 0e442e87b4..938f156c1d 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.test.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.test.tsx@@ -23,6 +23,8 @@ vi.mock('@core/component/Toast/Toast', () => ({toast: { failure: vi.fn() },}));+import { SERVER_HOSTS } from '@core/constant/servers';+import { displayImageUrl } from '@core/util/imageProxy';import { MarkdownImage } from './MarkdownImage';import { MarkdownVideo } from './MarkdownVideo';@@ -35,6 +37,24 @@ const unsetMedia = {} as const;describe('markdown media loading', () => {+ it('loads a GitHub blob screenshot through the image proxy', () => {+ const src =+ 'https://github.com/macro-inc/macro/blob/pr-assets/time-range-timeline/typed-1-all-day.png?raw=true';+ const view = render(() => (+ <MarkdownImage {...unsetMedia} key="github-shot" url={src} alt="Picker" />+ ));+ const image = view.container.querySelector('img')!;+ expect(image.getAttribute('src')).toBe(displayImageUrl(src));+ expect(image.getAttribute('src')).toContain(+ `${SERVER_HOSTS['image-proxy-service']}/proxy?url=`+ );+ expect(image.getAttribute('src')).toContain(+ encodeURIComponent(+ 'https://raw.githubusercontent.com/macro-inc/macro/pr-assets/time-range-timeline/typed-1-all-day.png'+ )+ );+ });+it('shows a reserved image card while the file has no size yet', () => {render(() => (<MarkdownImagediff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsxindex 4dd3e04ad9..b2f2b4d7ac 100644--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx@@ -5,6 +5,7 @@ false && internalDrag;import { Lightbox } from '@core/component/Lightbox';import { toast } from '@core/component/Toast/Toast';import { fireAndForget } from '@core/util/fireAndForget';+import { displayImageUrl } from '@core/util/imageProxy';import ImageIcon from '@icon/system/regular/image-broken.svg';import LoadingSpinner from '@icon/system/regular/spinner.svg';import { Dialog } from '@kobalte/core/dialog';@@ -104,7 +105,10 @@ export function MarkdownImage(props: ImageDecoratorProps) {return;}if (props.srcType === 'url') {- setImageUrl(props.url);+ // External hosts (GitHub blob screenshots, GIFs) need the image proxy+ // under COEP; GitHub blob/`raw` links are rewritten to the raw file host+ // first so the proxy fetches bytes, not an HTML redirect page.+ setImageUrl(displayImageUrl(props.url));return;}fireAndForget(diff --git a/apps/web/src/lib/core/util/imageProxy.test.ts b/apps/web/src/lib/core/util/imageProxy.test.tsnew file mode 100644index 0000000000..b3055002a3--- /dev/null+++ b/apps/web/src/lib/core/util/imageProxy.test.ts@@ -0,0 +1,56 @@+import { describe, expect, it } from 'vitest';+import { SERVER_HOSTS } from '../constant/servers';+import {+ displayImageUrl,+ githubRawImageUrl,+ proxyImageUrl,+} from './imageProxy';++describe('githubRawImageUrl', () => {+ it('rewrites a blob link with ?raw=true to the raw file host', () => {+ expect(+ githubRawImageUrl(+ 'https://github.com/macro-inc/macro/blob/pr-assets/time-range-timeline/typed-1-all-day.png?raw=true'+ )+ ).toBe(+ 'https://raw.githubusercontent.com/macro-inc/macro/pr-assets/time-range-timeline/typed-1-all-day.png'+ );+ });++ it('strips refs/heads from a /raw/ redirect', () => {+ expect(+ githubRawImageUrl(+ 'https://github.com/macro-inc/macro/raw/refs/heads/pr-assets/time-range-timeline/typed-1-all-day.png'+ )+ ).toBe(+ 'https://raw.githubusercontent.com/macro-inc/macro/pr-assets/time-range-timeline/typed-1-all-day.png'+ );+ });++ it('leaves user-attachment and already-raw URLs alone', () => {+ const attachment =+ 'https://github.com/user-attachments/assets/1ac88ed4-ef69-4b5f-847b-02bd105ffdd4';+ const raw =+ 'https://raw.githubusercontent.com/macro-inc/macro/pr-assets/shot.png';+ expect(githubRawImageUrl(attachment)).toBe(attachment);+ expect(githubRawImageUrl(raw)).toBe(raw);+ });+});++describe('displayImageUrl', () => {+ it('proxies a rewritten GitHub blob image', () => {+ const src =+ 'https://github.com/macro-inc/macro/blob/pr-assets/shot.png?raw=true';+ expect(displayImageUrl(src)).toBe(+ `${SERVER_HOSTS['image-proxy-service']}/proxy?url=${encodeURIComponent(+ 'https://raw.githubusercontent.com/macro-inc/macro/pr-assets/shot.png'+ )}`+ );+ });++ it('leaves data URLs unchanged', () => {+ expect(proxyImageUrl('data:image/png;base64,AAAA')).toBe(+ 'data:image/png;base64,AAAA'+ );+ });+});diff --git a/apps/web/src/lib/core/util/imageProxy.ts b/apps/web/src/lib/core/util/imageProxy.tsindex 6ef6d652c3..9ff39dc001 100644--- a/apps/web/src/lib/core/util/imageProxy.ts+++ b/apps/web/src/lib/core/util/imageProxy.ts@@ -1,5 +1,37 @@import { SERVER_HOSTS } from '../constant/servers';+/**+ * GitHub blob and `/raw/` links are HTML redirect pages, not image bytes.+ * Markdown `` is the usual+ * form in PR descriptions; the browser's COEP + `crossorigin` check fails on+ * the github.com 302 (no CORS), so the image never loads. Point at the raw+ * file host instead.+ */+export function githubRawImageUrl(src: string): string {+ let url: URL;+ try {+ url = new URL(src);+ } catch {+ return src;+ }+ if (url.hostname !== 'github.com' && url.hostname !== 'www.github.com') {+ return src;+ }++ const parts = url.pathname.split('/').filter(Boolean);+ if (parts.length < 4) return src;+ const [owner, repo, kind, ...rest] = parts;+ if (kind !== 'blob' && kind !== 'raw') return src;+ if (rest.length === 0) return src;++ if (rest[0] === 'refs' && (rest[1] === 'heads' || rest[1] === 'tags')) {+ rest.splice(0, 2);+ if (rest.length === 0) return src;+ }++ return `https://raw.githubusercontent.com/${owner}/${repo}/${rest.join('/')}`;+}+/*** Rewrite an external image URL to load through the image proxy service.*@@ -13,3 +45,8 @@ export function proxyImageUrl(src: string): string {if (!src.startsWith('http://') && !src.startsWith('https://')) return src;return `${SERVER_HOSTS['image-proxy-service']}/proxy?url=${encodeURIComponent(src)}`;}++/** URL to put on an `<img>` for a remote markdown image. */+export function displayImageUrl(src: string): string {+ return proxyImageUrl(githubRawImageUrl(src));+}diff --git a/docs/agent-guide/pull-requests.md b/docs/agent-guide/pull-requests.mdindex 948b1d8da7..93135ea4cc 100644--- a/docs/agent-guide/pull-requests.md+++ b/docs/agent-guide/pull-requests.md@@ -92,6 +92,8 @@ Old `/app/pr/<foreignEntityId>` links redirect to Reviews. Check a copied link,a PR opened from a list or agent session, a second split, breadcrumb return,side-panel toggle, and phone layout. If no GitHub data loads, the detail showsan error banner with a Retry button; pressing it refetches the PR in place.+Description screenshots hosted on GitHub (including `blob/…?raw=true` links)+render in the body; they must not show "This image could not be found."PR metadata changes should update an already loaded Reviews list row and thelinked agent session's PR status without reloading the page. To verify, keep