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.

fix(announcements): a missing picture passes the popup over

reviewaee07b16c659
diff --git a/src/renderer/components/AnnouncementPopup.test.tsx b/src/renderer/components/AnnouncementPopup.test.tsx
index c6a60c5d6..3b9990bcf 100644
--- a/src/renderer/components/AnnouncementPopup.test.tsx
+++ b/src/renderer/components/AnnouncementPopup.test.tsx
@@ -308,6 +308,24 @@ it('waits for a picture it could not fetch, and tries again on the next read', a
expect(dialog()?.querySelector('img')?.getAttribute('src')).toBe(IMAGE_URL)
})
+it('lets the next popup take its turn when a picture cannot be had', async () => {
+ setFeed([pop('pictured', { image: HASH }), pop('plain')])
+ popupImage.mockResolvedValueOnce(null)
+ await mount()
+ expect(dialog()?.textContent).toContain('Title plain')
+ expect(loadSeenPopups().has('pictured')).toBe(false)
+})
+
+// The re-read while one waits: a newer popup's failed picture must not cost the one already waiting.
+it('keeps the popup that is waiting when a newer one has no picture yet', async () => {
+ setFeed([pop('plain')], [pop('pictured', { image: HASH }), pop('plain')])
+ popupImage.mockResolvedValue(null)
+ await mount(true)
+ await act(async () => vi.advanceTimersByTime(PENDING_RECHECK_MS))
+ await rerender(false)
+ expect(dialog()?.textContent).toContain('Title plain')
+})
+
it('treats a rejected picture fetch like a missing one', async () => {
setFeed([pop('a', { image: HASH })])
popupImage.mockRejectedValueOnce(new Error('no handler'))
diff --git a/src/renderer/components/AnnouncementPopup.tsx b/src/renderer/components/AnnouncementPopup.tsx
index 27bf29219..fbfedca36 100644
--- a/src/renderer/components/AnnouncementPopup.tsx
+++ b/src/renderer/components/AnnouncementPopup.tsx
@@ -21,6 +21,18 @@ const RETRY_MS = 1000
/** A popup ready to show: its picture, if it has one, is in hand. */
type ReadyPopup = PopupAnnouncement & { imageUrl?: string }
+/**
+ * `pickPopup`, with the picture fetched. A popup shows only once and was written around its picture,
+ * so it never goes up without it: it is passed over, unrecorded, for the next read to try again, and
+ * the next one in the feed takes its turn rather than waiting behind it.
+ */
+async function readyPopup(items: PopupAnnouncement[], isPremium: boolean): Promise<ReadyPopup | null> {
+ const next = pickPopup(items, loadSeenPopups(), isPremium)
+ if (!next?.image) return next
+ const imageUrl = await window.nodeTerminal.announcements.popupImage(next.image)
+ return imageUrl ? { ...next, imageUrl } : readyPopup(items.filter((p) => p !== next), isPremium)
+}
+
/**
* 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.
@@ -54,13 +66,7 @@ export function AnnouncementPopup({ blocked }: { blocked: boolean }): React.JSX.
try {
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
- }
+ next = await readyPopup(items, premiumRef.current)
} catch {
return
}