Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(announcements): show a popup's picture

reviewf62cabae95b9
diff --git a/CLAUDE.md b/CLAUDE.md
index 8cdce8258..839a4f8b0 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -10910,7 +10910,13 @@ tour, Settings, palette, dictation, …), and no key was pressed for 4 s. It the
— and takes Escape in the CAPTURE phase: xterm stops propagation of Escape, so a bubble listener
never hears it and the agent in the pane gets an ESC that interrupts its turn. Its button opens
`url`, or with `action: 'upgrade'` starts the Pro checkout — an upgrade popup is skipped for a Pro
-user, dropped the moment the plan flips, and closes when Pro arrives. Server Edition: the bridge answers `[]` (it does not read the feed). Mobile:
+user, dropped the moment the plan flips, and closes when Pro arrives. A popup may carry a picture
+(`image`, a SHA-256): `fetchPopupImage` in `core/check.ts` gets it from `API_BASE` by that hash, so
+the feed can name no URL, checks the hash and the magic bytes, caps the size while reading, and hands
+the renderer a `data:` URL because the CSP's `img-src` takes no network source. It is fetched as part
+of the feed read, and a popup whose picture cannot be had waits for the next read, unrecorded: it
+shows only once, and it was written around that picture. Never add HTML to these messages: a
+picture carries a design with no code in it. Server Edition: the bridge answers `[]` (it does not read the feed). Mobile:
N/A for v1 (follow-up in the iOS repo). The call no-ops under
`DO_NOT_TRACK`/`NODETERM_TELEMETRY_DISABLED` or in unpackaged builds (unless `NODETERM_API_BASE`
targets a local server). Schema example:
diff --git a/src/core/check-popup-image.test.ts b/src/core/check-popup-image.test.ts
new file mode 100644
index 000000000..94af8d43a
--- /dev/null
+++ b/src/core/check-popup-image.test.ts
@@ -0,0 +1,127 @@
+import { createHash } from 'node:crypto'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { fakePlatform } from './platform-fake'
+
+const PNG = Buffer.from(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
+ 'base64'
+)
+const JPEG = Buffer.from([0xff, 0xd8, 0xff, 0xe0, 1, 2, 3])
+const WEBP = Buffer.from([...Buffer.from('RIFF'), 0, 0, 0, 0, ...Buffer.from('WEBP'), 1, 2, 3])
+const sha = (b: Buffer | string) => createHash('sha256').update(b).digest('hex')
+
+describe('fetchPopupImage', () => {
+ let fetchMock: ReturnType<typeof vi.fn>
+
+ // A fresh module per load: API_BASE and the kept picture are module state.
+ const load = async () => {
+ vi.resetModules()
+ ;(await import('./platform')).initPlatform(fakePlatform())
+ return import('./check')
+ }
+
+ beforeEach(() => {
+ vi.doMock('./license', () => ({ isPremium: () => false }))
+ vi.doMock('./device-id', () => ({ getDeviceId: () => '33333333-3333-3333-3333-333333333333' }))
+ vi.stubEnv('NODETERM_API_BASE', 'http://api.test')
+ vi.stubEnv('DO_NOT_TRACK', '')
+ vi.stubEnv('NODETERM_TELEMETRY_DISABLED', '')
+ fetchMock = vi.fn()
+ vi.stubGlobal('fetch', fetchMock)
+ })
+
+ afterEach(() => {
+ vi.unstubAllGlobals()
+ vi.unstubAllEnvs()
+ vi.doUnmock('./license')
+ vi.doUnmock('./device-id')
+ })
+
+ it('fetches from our own API by hash, with no install id, and returns a data URL', async () => {
+ fetchMock.mockResolvedValue(new Response(PNG))
+ const { fetchPopupImage } = await load()
+ await expect(fetchPopupImage(sha(PNG))).resolves.toBe(`data:image/png;base64,${PNG.toString('base64')}`)
+ const [url, init] = fetchMock.mock.calls[0]
+ expect(url).toBe(`http://api.test/v1/message-image/${sha(PNG)}`)
+ expect(init.redirect).toBe('error')
+ })
+
+ it('names the type from the bytes, not the reply', async () => {
+ const { fetchPopupImage } = await load()
+ for (const [bytes, mime] of [
+ [JPEG, 'image/jpeg'],
+ [WEBP, 'image/webp']
+ ] as const) {
+ fetchMock.mockResolvedValueOnce(new Response(bytes, { headers: { 'content-type': 'text/html' } }))
+ await expect(fetchPopupImage(sha(bytes))).resolves.toMatch(new RegExp(`^data:${mime};base64,`))
+ }
+ })
+
+ it('refuses bytes that do not match the hash', async () => {
+ fetchMock.mockResolvedValue(new Response(PNG))
+ const { fetchPopupImage } = await load()
+ await expect(fetchPopupImage('a'.repeat(64))).resolves.toBeNull()
+ })
+
+ it('refuses a matching hash over bytes that are not an image', async () => {
+ const html = '<script>alert(1)</script>'
+ fetchMock.mockResolvedValue(new Response(html))
+ const { fetchPopupImage } = await load()
+ await expect(fetchPopupImage(sha(html))).resolves.toBeNull()
+ })
+
+ it('stops reading past the limit, whatever the reply claimed', async () => {
+ const chunk = Buffer.alloc(512 * 1024)
+ PNG.copy(chunk)
+ const cancel = vi.fn()
+ // A body that never ends: only the limit can stop this read.
+ const body = new ReadableStream<Uint8Array>({ pull: (c) => c.enqueue(chunk), cancel })
+ fetchMock.mockResolvedValue(new Response(body, { headers: { 'content-length': '10' } }))
+ const { fetchPopupImage } = await load()
+ await expect(fetchPopupImage('a'.repeat(64))).resolves.toBeNull()
+ expect(cancel).toHaveBeenCalled()
+ })
+
+ it('takes exactly the limit', async () => {
+ const full = Buffer.alloc(2 * 1024 * 1024)
+ PNG.copy(full)
+ fetchMock.mockResolvedValue(new Response(full))
+ const { fetchPopupImage } = await load()
+ await expect(fetchPopupImage(sha(full))).resolves.toMatch(/^data:image\/png/)
+ })
+
+ it('never asks for something that is not a hash', async () => {
+ const { fetchPopupImage } = await load()
+ for (const bad of ['', 'A'.repeat(64), `../../${'a'.repeat(58)}`, `${'a'.repeat(64)}/x`, `https://evil.test/${'a'.repeat(46)}`]) {
+ await expect(fetchPopupImage(bad)).resolves.toBeNull()
+ }
+ expect(fetchMock).not.toHaveBeenCalled()
+ })
+
+ it('honours the same opt-outs as the feed', async () => {
+ vi.stubEnv('DO_NOT_TRACK', '1')
+ const { fetchPopupImage } = await load()
+ await expect(fetchPopupImage(sha(PNG))).resolves.toBeNull()
+ expect(fetchMock).not.toHaveBeenCalled()
+ })
+
+ it('answers null on a failed read, and tries again next time', async () => {
+ fetchMock
+ .mockRejectedValueOnce(new Error('offline'))
+ .mockResolvedValueOnce(new Response('gone', { status: 404 }))
+ .mockResolvedValue(new Response(PNG))
+ const { fetchPopupImage } = await load()
+ await expect(fetchPopupImage(sha(PNG))).resolves.toBeNull()
+ await expect(fetchPopupImage(sha(PNG))).resolves.toBeNull()
+ await expect(fetchPopupImage(sha(PNG))).resolves.toMatch(/^data:image\/png/)
+ })
+
+ // A popup waiting its turn re-reads the feed every five minutes.
+ it('fetches a picture once', async () => {
+ fetchMock.mockImplementation(async () => new Response(PNG))
+ const { fetchPopupImage } = await load()
+ const first = await fetchPopupImage(sha(PNG))
+ await expect(fetchPopupImage(sha(PNG))).resolves.toBe(first)
+ expect(fetchMock).toHaveBeenCalledTimes(1)
+ })
+})
diff --git a/src/core/check.test.ts b/src/core/check.test.ts
index cd7d2806b..832c4008c 100644
--- a/src/core/check.test.ts
+++ b/src/core/check.test.ts
@@ -136,6 +136,21 @@ describe('/v1/check sanitize — popups', () => {
])
})
+ it('keeps a picture only as a hash: the feed names no URL', () => {
+ const hash = 'a'.repeat(64)
+ const r = sanitize({
+ popups: [
+ { id: 'ok', title: 'A', image: hash },
+ { id: 'url', title: 'B', image: `https://evil.test/${hash}` },
+ { id: 'path', title: 'C', image: `../${hash}` },
+ { id: 'num', title: 'D', image: 7 }
+ ],
+ update: {}
+ })
+ expect(r.popups.map((p) => p.image)).toEqual([hash, undefined, undefined, undefined])
+ expect(r.popups.slice(1).every((p) => !('image' in p))).toBe(true)
+ })
+
it('drops what it cannot show and never guesses an action', () => {
const r = sanitize({
popups: [
diff --git a/src/core/check.ts b/src/core/check.ts
index c0d15e911..5b9794c60 100644
--- a/src/core/check.ts
+++ b/src/core/check.ts
@@ -12,6 +12,7 @@
// only while it is); that answer reaches core through `onCheckAnswer`, not through CheckResult.
// Nothing personal is sent and the client IP is never stored server-side; a hard opt-out is still
// DO_NOT_TRACK / NODETERM_TELEMETRY_DISABLED.
+import { createHash } from 'node:crypto'
import { platform } from './platform'
import { getDeviceId } from './device-id'
import { isPremium } from './license'
@@ -62,6 +63,7 @@ function sanitize(data: unknown): CheckResult {
if (label) p.ctaLabel = label.slice(0, CTA_LABEL_MAX)
// A closed set: an action this build does not know is no action, never a guess at one.
if (m.action === 'upgrade') p.action = 'upgrade'
+ if (typeof m.image === 'string' && IMAGE_HASH.test(m.image)) p.image = m.image
return p
})
const u = (d.update ?? {}) as Record<string, unknown>
@@ -80,6 +82,10 @@ function sanitize(data: unknown): CheckResult {
const NOTES_MAX = 16 * 1024
const CTA_LABEL_MAX = 40
+const IMAGE_HASH = /^[0-9a-f]{64}$/
+/** The largest popup picture this build takes; the admin console refuses more on upload. */
+const IMAGE_MAX_BYTES = 2 * 1024 * 1024
+const IMAGE_TIMEOUT_MS = 20_000
/** Test seam: the sanitizer is the whole contract with the feed's shape. */
export const sanitizeCheckForTest = sanitize
@@ -239,3 +245,58 @@ export async function fetchCheck(): Promise<CheckResult> {
return fallback()
}
}
+
+/** The type the bytes say. A closed set, so nothing else can reach a `data:` URL. */
+function imageMime(b: Uint8Array): string | null {
+ const starts = (at: number, sig: number[]): boolean => sig.every((x, i) => b[at + i] === x)
+ if (starts(0, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])) return 'image/png'
+ if (starts(0, [0xff, 0xd8, 0xff])) return 'image/jpeg'
+ if (starts(0, [0x52, 0x49, 0x46, 0x46]) && starts(8, [0x57, 0x45, 0x42, 0x50])) return 'image/webp'
+ return null
+}
+
+/** The body up to `max` bytes, or null past it. Read in chunks: `content-length` is only a claim. */
+async function readCapped(body: ReadableStream<Uint8Array>, max: number): Promise<Buffer | null> {
+ const reader = body.getReader()
+ const chunks: Uint8Array[] = []
+ let size = 0
+ for (;;) {
+ const { done, value } = await reader.read()
+ if (done) return Buffer.concat(chunks)
+ size += value.length
+ if (size > max) {
+ await reader.cancel()
+ return null
+ }
+ chunks.push(value)
+ }
+}
+
+let lastImage: { sha256: string; url: string } | null = null
+
+/**
+ * A popup's picture as a `data:` URL (the renderer CSP's `img-src` takes no network source), or null
+ * when it cannot be had. The feed only ever names a hash, never a URL, so it cannot point this at
+ * another host; the bytes must match that hash and be an image. No install id goes with it.
+ * The latest is kept: a popup waiting its turn asks again every few minutes.
+ */
+export async function fetchPopupImage(sha256: string): Promise<string | null> {
+ if (!IMAGE_HASH.test(sha256) || !allowed()) return null
+ if (lastImage?.sha256 === sha256) return lastImage.url
+ const ctrl = new AbortController()
+ const t = setTimeout(() => ctrl.abort(), IMAGE_TIMEOUT_MS)
+ try {
+ const res = await fetch(`${API_BASE}/v1/message-image/${sha256}`, { signal: ctrl.signal, redirect: 'error' })
+ if (!res.ok || !res.body) return null
+ const bytes = await readCapped(res.body, IMAGE_MAX_BYTES)
+ if (!bytes || createHash('sha256').update(bytes).digest('hex') !== sha256) return null
+ const mime = imageMime(bytes)
+ if (!mime) return null
+ lastImage = { sha256, url: `data:${mime};base64,${bytes.toString('base64')}` }
+ return lastImage.url
+ } catch {
+ return null
+ } finally {
+ clearTimeout(t)
+ }
+}
diff --git a/src/main/index.ts b/src/main/index.ts
index e5dc9d6e5..7af9e3295 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -178,7 +178,7 @@ import {
} from '../core/commit-message'
import { initUpdater, type UpdaterHandle } from './updater'
import { requestRendererFlush } from './renderer-flush'
-import { configureCheck, fetchCheck } from '../core/check'
+import { configureCheck, fetchCheck, fetchPopupImage } from '../core/check'
import {
hookServer,
OPEN_PROJECT_CONTROL_REFUSAL,
@@ -2065,6 +2065,7 @@ app.whenReady().then(async () => {
})
ipcMain.handle(IPC.announcementsFetch, async () => (await fetchCheck()).messages)
ipcMain.handle(IPC.announcementsPopups, async () => (await fetchCheck()).popups)
+ ipcMain.handle(IPC.announcementsPopupImage, (_e, sha256: string) => fetchPopupImage(String(sha256)))
ipcMain.handle(IPC.appUpdatePolicy, async () => (await fetchCheck()).update)
// Writable base dir for app-managed files (e.g. default git worktree location). On the platform:
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 9e1d3a87f..be706b38f 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -566,7 +566,8 @@ const api: NodeTerminalApi = {
},
announcements: {
fetch: () => ipcRenderer.invoke(IPC.announcementsFetch),
- popups: () => ipcRenderer.invoke(IPC.announcementsPopups)
+ popups: () => ipcRenderer.invoke(IPC.announcementsPopups),
+ popupImage: (sha256: string) => ipcRenderer.invoke(IPC.announcementsPopupImage, sha256)
},
usage: {
fetch: (accountId?: string) => ipcRenderer.invoke(IPC.usageFetch, accountId),
diff --git a/src/renderer/bridge/stubs.test.ts b/src/renderer/bridge/stubs.test.ts
index 6706fe4ac..f07eb04c5 100644
--- a/src/renderer/bridge/stubs.test.ts
+++ b/src/renderer/bridge/stubs.test.ts
@@ -84,6 +84,7 @@ describe('bridge stubs', () => {
const s = buildStubApi()
await expect(s.announcements.fetch()).resolves.toEqual([])
await expect(s.announcements.popups()).resolves.toEqual([])
+ await expect(s.announcements.popupImage('a'.repeat(64))).resolves.toBeNull()
// UpdateCard reads `p.mandatory` with no null guard, so the stub must return a real
// UpdatePolicy — a `null` here was a TypeError on every Server Edition page load.
await expect(s.updates.getPolicy()).resolves.toEqual({ minSupported: null, mandatory: false })
diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.ts
index aac750856..86b9efbb1 100644
--- a/src/renderer/bridge/stubs.ts
+++ b/src/renderer/bridge/stubs.ts
@@ -273,7 +273,8 @@ export function buildStubApi(): Omit<
announcements: {
fetch: () => Promise.resolve([]),
// The Server Edition does not read the check feed, so there is never a popup to show.
- popups: () => Promise.resolve([])
+ popups: () => Promise.resolve([]),
+ popupImage: () => Promise.resolve(null)
},
license: {
upgrade: U('license.upgrade'),
diff --git a/src/renderer/components/AnnouncementPopup.test.tsx b/src/renderer/components/AnnouncementPopup.test.tsx
index 3b9c81c4e..c6a60c5d6 100644
--- a/src/renderer/components/AnnouncementPopup.test.tsx
+++ b/src/renderer/components/AnnouncementPopup.test.tsx
@@ -18,6 +18,8 @@ vi.mock('../state/entitlement', async () => {
})
const SIX_HOURS = 6 * 60 * 60 * 1000
+const IMAGE_URL = 'data:image/png;base64,AAAA'
+const HASH = 'a'.repeat(64)
const pop = (id: string, extra: Partial<PopupAnnouncement> = {}): PopupAnnouncement => ({
id,
@@ -29,12 +31,14 @@ const pop = (id: string, extra: Partial<PopupAnnouncement> = {}): PopupAnnouncem
let root: Root | null = null
let popups: ReturnType<typeof vi.fn>
+let popupImage: ReturnType<typeof vi.fn>
function setFeed(...reads: PopupAnnouncement[][]): void {
popups = vi.fn()
for (const r of reads) popups.mockResolvedValueOnce(r)
popups.mockResolvedValue(reads[reads.length - 1] ?? [])
- ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = { announcements: { popups } }
+ popupImage = vi.fn().mockResolvedValue(IMAGE_URL)
+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = { announcements: { popups, popupImage } }
}
async function mount(blocked = false): Promise<void> {
@@ -276,6 +280,56 @@ it('never shows a Pro user an upgrade popup, and keeps it for a lapse', async ()
expect(loadSeenPopups().has('upsell')).toBe(false)
})
+it('shows its picture, fetched before it goes up', async () => {
+ setFeed([pop('a', { image: HASH })])
+ await mount()
+ expect(popupImage).toHaveBeenCalledWith(HASH)
+ expect(dialog()?.querySelector('img')?.getAttribute('src')).toBe(IMAGE_URL)
+ expect(loadSeenPopups().has('a')).toBe(true)
+})
+
+it('asks for no picture when it has none', async () => {
+ setFeed([pop('a')])
+ await mount()
+ expect(popupImage).not.toHaveBeenCalled()
+ expect(dialog()?.querySelector('img')).toBeNull()
+})
+
+// Once only, and written around the picture: without it, it waits for the next read, unrecorded.
+it('waits for a picture it could not fetch, and tries again on the next read', async () => {
+ setFeed([pop('a', { image: HASH })])
+ popupImage.mockResolvedValueOnce(null)
+ await mount()
+ await act(async () => vi.advanceTimersByTime(10_000))
+ expect(dialog()).toBeNull()
+ expect(loadSeenPopups().has('a')).toBe(false)
+
+ await act(async () => vi.advanceTimersByTime(SIX_HOURS))
+ expect(dialog()?.querySelector('img')?.getAttribute('src')).toBe(IMAGE_URL)
+})
+
+it('treats a rejected picture fetch like a missing one', async () => {
+ setFeed([pop('a', { image: HASH })])
+ popupImage.mockRejectedValueOnce(new Error('no handler'))
+ await mount()
+ await act(async () => vi.advanceTimersByTime(10_000))
+ expect(dialog()).toBeNull()
+ expect(loadSeenPopups().has('a')).toBe(false)
+})
+
+it('lets no slow picture land after the plan changed', async () => {
+ setFeed([pop('upsell', { action: 'upgrade', image: HASH })])
+ let answer: (url: string) => void = () => {}
+ popupImage.mockReturnValueOnce(new Promise<string>((r) => (answer = r)))
+ await mount()
+ // The purchase lands while the picture is on its way; the next read finds the popup skipped.
+ await act(async () => useEntitlement.setState({ isPremium: true }))
+ await act(async () => answer(IMAGE_URL))
+ await act(async () => vi.advanceTimersByTime(10_000))
+ expect(dialog()).toBeNull()
+ expect(loadSeenPopups().has('upsell')).toBe(false)
+})
+
it('shows nothing when the feed cannot be read', async () => {
;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {
announcements: { popups: vi.fn().mockRejectedValue(new Error('offline')) }
diff --git a/src/renderer/components/AnnouncementPopup.tsx b/src/renderer/components/AnnouncementPopup.tsx
index baeac7eb8..27bf29219 100644
--- a/src/renderer/components/AnnouncementPopup.tsx
+++ b/src/renderer/components/AnnouncementPopup.tsx
@@ -18,6 +18,9 @@ import { openDialogCount, useDialogStack } from './dialog-stack'
const SIX_HOURS = 6 * 60 * 60 * 1000
const RETRY_MS = 1000
+/** A popup ready to show: its picture, if it has one, is in hand. */
+type ReadyPopup = PopupAnnouncement & { imageUrl?: string }
+
/**
* A one-time popup from the check feed (lib/announcementPopup.ts): the admin console's "popup
* (once)" messages, aimed like banners (plan, OS, channel, version). Mounted once, in Canvas.
@@ -36,8 +39,8 @@ export function AnnouncementPopup({ blocked }: { blocked: boolean }): React.JSX.
const licenseKnown = useEntitlement((s) => s.known)
const settingsKnown = useSettings((s) => s.hydrated)
const upgradeOpen = useUpgradeGate((s) => s.open)
- const [pending, setPending] = useState<PopupAnnouncement | null>(null)
- const [shown, setShown] = useState<PopupAnnouncement | null>(null)
+ const [pending, setPending] = useState<ReadyPopup | null>(null)
+ const [shown, setShown] = useState<ReadyPopup | null>(null)
const lastKeyAt = useRef(0)
// Only the latest read may set `pending`: a slow read for the plan this install just left must
// not land after the one for the plan it is on now.
@@ -47,14 +50,22 @@ export function AnnouncementPopup({ blocked }: { blocked: boolean }): React.JSX.
const read = useCallback(async (): Promise<void> => {
const seq = ++readSeq.current
- let items: PopupAnnouncement[]
+ let next: ReadyPopup | null
try {
- items = await window.nodeTerminal.announcements.popups()
+ const items = await window.nodeTerminal.announcements.popups()
+ if (seq !== readSeq.current) return
+ next = pickPopup(items, loadSeenPopups(), premiumRef.current)
+ // It shows only once and was written around its picture, so it never goes up without it. Not
+ // shown means not recorded: the next read tries again.
+ if (next?.image) {
+ const imageUrl = await window.nodeTerminal.announcements.popupImage(next.image)
+ next = imageUrl ? { ...next, imageUrl } : null
+ }
} catch {
return
}
if (seq !== readSeq.current) return
- setPending(pickPopup(items, loadSeenPopups(), premiumRef.current))
+ setPending(next)
}, [])
// Main asks the feed with the current plan, so a plan change re-asks — and drops what is waiting
@@ -119,7 +130,7 @@ export function AnnouncementPopup({ blocked }: { blocked: boolean }): React.JSX.
return <PopupDialog key={shown.id} popup={shown} onClose={close} />
}
-function PopupDialog({ popup, onClose }: { popup: PopupAnnouncement; onClose(): void }): React.JSX.Element {
+function PopupDialog({ popup, onClose }: { popup: ReadyPopup; onClose(): void }): React.JSX.Element {
const isTop = useDialogStack()
const boxRef = useRef<HTMLDivElement>(null)
const shownAtRef = useRef(Date.now())
@@ -177,6 +188,7 @@ function PopupDialog({ popup, onClose }: { popup: PopupAnnouncement; onClose():
tabIndex={-1}
onClick={(e) => e.stopPropagation()}
>
+ {popup.imageUrl && <img className="announce-popup__image" src={popup.imageUrl} alt="" />}
<h2 className="announce-popup__title" id={titleId}>
{popup.title}
</h2>
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 3f5bb6498..7651b9254 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -7321,6 +7321,18 @@ body,
border-top-color: var(--warn);
}
+/* Edge to edge at the top of the box, and never cropped: it can be a design with words in it. The
+ admin console's preview draws it with the same numbers. */
+.announce-popup__image {
+ display: block;
+ flex: none;
+ width: calc(100% + 36px); /* the box's 18px padding, both sides */
+ max-height: min(320px, 40vh);
+ object-fit: contain;
+ margin: -18px -18px 14px;
+ border-radius: 11px 11px 0 0; /* the box's 14px, less its 3px top border */
+}
+
.announce-popup__title {
margin: 0 0 10px;
font-size: 15px;
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index ec576a111..e0828a3e2 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -387,6 +387,7 @@ export const IPC = {
appRestartToUpdate: 'app:restart-to-update',
announcementsFetch: 'announcements:fetch',
announcementsPopups: 'announcements:popups',
+ announcementsPopupImage: 'announcements:popup-image',
usageFetch: 'usage:fetch',
usageRefresh: 'usage:refresh',
usageUpdate: 'usage:update',
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 913aa98cb..f74f15a02 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -3088,6 +3088,8 @@ export interface PopupAnnouncement extends Announcement {
ctaLabel?: string
/** 'upgrade' = the button starts the app's own Pro checkout instead of opening `url`. */
action?: 'upgrade'
+ /** The SHA-256 naming its picture, fetched with `AnnouncementsApi.popupImage`. */
+ image?: string
}
export interface AnnouncementsApi {
@@ -3096,6 +3098,8 @@ export interface AnnouncementsApi {
/** The feed's one-time popups ([] on any failure, and on the Server Edition, which does not read
* the feed). Which of them were already shown is the renderer's record, not the feed's. */
popups(): Promise<PopupAnnouncement[]>
+ /** A popup's picture as a `data:` URL, or null when it cannot be had. */
+ popupImage(sha256: string): Promise<string | null>
}
export interface NotifyPayload {