A desktop coding agent with free access to frontier models.
TypeScript
feat: buildathon promo and updates feed
Samrat Talukdarfdbf201eed92
diff --git a/apps/app/src/app/lib/buildathon.ts b/apps/app/src/app/lib/buildathon.tsindex 06ddc6fb..7217d845 100644--- a/apps/app/src/app/lib/buildathon.ts+++ b/apps/app/src/app/lib/buildathon.ts@@ -1,13 +1,16 @@// Buildathon, renderer side. The Electron main process reads-// GET /me/buildathon (apps/desktop/electron/buildathon.mjs) and answers null-// for anyone not enrolled, offline or on any error; everything here then-// renders nothing. Nothing in this file is awaited on the way to the first+// GET /me/buildathon (apps/desktop/electron/buildathon.mjs) and answers a+// participant's status, a non-participant's promo, or null (no promo,+// offline, any error); with null everything here renders nothing. Nothing in this file is awaited on the way to the first// screen.import { create } from "zustand";import type {+ OmniRushBuildathonAnnouncement,+ OmniRushBuildathonAnswer,OmniRushBuildathonEvent,+ OmniRushBuildathonPromo,OmniRushBuildathonSession,OmniRushBuildathonStatus,OmniRushBuildathonTagResult,@@ -18,12 +21,25 @@ export type BuildathonStatus = OmniRushBuildathonStatus;export type BuildathonEvent = OmniRushBuildathonEvent;export type BuildathonSession = OmniRushBuildathonSession;export type BuildathonTrack = OmniRushBuildathonTrack;+export type BuildathonPromo = OmniRushBuildathonPromo;+export type BuildathonAnnouncement = OmniRushBuildathonAnnouncement;+export type BuildathonAnswer = OmniRushBuildathonAnswer;export const BUILDATHON_REFRESH_MS = 10 * 60_000;+/** After the join page opens: re-read every 30 s (and on focus) for 10 minutes. */+export const JOIN_WATCH_REFRESH_MS = 30_000;+export const JOIN_WATCH_MS = 10 * 60_000;export const ONLY_TOOL_RULE = "OmniRush must be the only generative AI tool you use.";export const BUILDATHON_TRACKS_STORAGE_KEY = "omnirush.buildathon.tracks.v1";export const BUILDATHON_TAGGED_STORAGE_KEY = "omnirush.buildathon.tagged.v1";export const BUILDATHON_REMINDERS_STORAGE_KEY = "omnirush.buildathon.reminders.v1";+/** Promo ids: `dismissed` (banner closed, or the card's close), `card` (the one-time home card was shown). */+export const BUILDATHON_PROMO_STORAGE_KEY = "omnirush.buildathon.promo.v1";+/** Announcement ids: `notified` (toast + notification shown), `read` (seen in My Buildathon). */+export const BUILDATHON_ANNOUNCEMENTS_STORAGE_KEY = "omnirush.buildathon.announcements.v1";+/** At most this many announcements pop up one by one; the rest are one summary toast. */+export const ANNOUNCEMENT_TOAST_LIMIT = 3;+const MAX_IDS_REMEMBERED = 200;const MAX_TAGGED_REMEMBERED = 500;const HOUR_MS = 3_600_000;@@ -274,6 +290,72 @@ export function rememberShownReminders(keys: string[], storage: KeyValueStore |writeJson(BUILDATHON_REMINDERS_STORAGE_KEY, [...shown].slice(-50), storage);}+// --- Promo (non-participants) -------------------------------------------------++type IdLists = Record<string, string[]>;++function readIdLists(key: string, storage: KeyValueStore | null): IdLists {+ const value = readJson<Record<string, unknown>>(key, {}, storage);+ const lists: IdLists = {};+ for (const [name, ids] of Object.entries(value)) {+ if (Array.isArray(ids)) lists[name] = ids.filter((id): id is string => typeof id === "string");+ }+ return lists;+}++function addIds(key: string, list: string, ids: string[], storage: KeyValueStore | null): void {+ if (!ids.length) return;+ const lists = readIdLists(key, storage);+ const next = (lists[list] ?? []).filter((id) => !ids.includes(id));+ next.push(...ids);+ lists[list] = next.slice(-MAX_IDS_REMEMBERED);+ writeJson(key, lists, storage);+}++export function readPromoIds(list: "dismissed" | "card", storage: KeyValueStore | null = defaultStorage()): Set<string> {+ return new Set(readIdLists(BUILDATHON_PROMO_STORAGE_KEY, storage)[list] ?? []);+}++export function rememberPromoId(list: "dismissed" | "card", id: string, storage: KeyValueStore | null = defaultStorage()): void {+ addIds(BUILDATHON_PROMO_STORAGE_KEY, list, [id], storage);+}++/** Whether the promo is still on: not dismissed under its id and before its end (server clock). */+export function promoActive(promo: BuildathonPromo | null, nowMs: number, dismissed: ReadonlySet<string>): promo is BuildathonPromo {+ if (!promo || dismissed.has(promo.id)) return false;+ const ends = promo.endsAt ? Date.parse(promo.endsAt) : Number.NaN;+ return !(Number.isFinite(ends) && ends <= nowMs);+}++// --- Announcements (participants) ----------------------------------------------++export function readAnnouncementIds(list: "notified" | "read", storage: KeyValueStore | null = defaultStorage()): Set<string> {+ return new Set(readIdLists(BUILDATHON_ANNOUNCEMENTS_STORAGE_KEY, storage)[list] ?? []);+}++export function rememberAnnouncementIds(list: "notified" | "read", ids: string[], storage: KeyValueStore | null = defaultStorage()): void {+ addIds(BUILDATHON_ANNOUNCEMENTS_STORAGE_KEY, list, ids, storage);+}++/**+ * The announcements to pop up now: those never shown, oldest first so the+ * newest ends on top. Past the limit only the newest pop up and the rest are+ * counted (one summary).+ */+export function announcementsToNotify(+ announcements: BuildathonAnnouncement[],+ notified: ReadonlySet<string>,+ limit = ANNOUNCEMENT_TOAST_LIMIT,+): { show: BuildathonAnnouncement[]; more: number; ids: string[] } {+ const fresh = announcements.filter((announcement) => !notified.has(announcement.id));+ const show = fresh.slice(0, limit).reverse();+ return { show, more: Math.max(0, fresh.length - limit), ids: fresh.map((announcement) => announcement.id) };+}++export function unreadAnnouncementIds(announcements: BuildathonAnnouncement[], read: ReadonlySet<string>): string[] {+ return announcements.filter((announcement) => !read.has(announcement.id)).map((announcement) => announcement.id);+}+// --- Which sessions to tag ---------------------------------------------------export type BuildathonProject = {@@ -319,6 +401,14 @@ export function sessionsToTag(type BuildathonStore = {status: BuildathonStatus | null;+ /** A non-participant's promo (null for participants and when there is none). */+ promo: BuildathonPromo | null;+ /** Bumped when a promo is dismissed or an announcement read, so views re-read storage. */+ seenVersion: number;+ /** Until when (local ms) the app re-reads often, after opening the join page. */+ joinWatchUntil: number;+ /** Set when this run saw the account go from the promo to enrolled (the "You're in" moment). */+ joinedAt: number | null;/** Server clock minus local clock, from the latest answer. */offsetMs: number;panelOpen: boolean;@@ -330,6 +420,11 @@ type BuildathonStore = {/** Bumped on every track change so pickers re-read storage. */tracksVersion: number;setStatus: (status: BuildathonStatus | null, receivedAtMs?: number) => void;+ /** Either a participant's status or a promo (or neither): one answer of GET /me/buildathon. */+ setAnswer: (answer: BuildathonAnswer, receivedAtMs?: number) => void;+ bumpSeen: () => void;+ startJoinWatch: (nowMs?: number) => void;+ clearJoined: () => void;openPanel: () => void;closePanel: () => void;setProjects: (projects: BuildathonProject[], selectedProjectId?: string | null) => void;@@ -338,8 +433,17 @@ type BuildathonStore = {bumpTracks: () => void;};+/** Enrolled after showing the promo in this run: the join just happened (the watch ends). */+function joinedFrom(state: BuildathonStore, nowMs: number): Partial<BuildathonStore> {+ return state.promo && !state.status ? { joinedAt: nowMs, joinWatchUntil: 0 } : {};+}+export const useBuildathonStore = create<BuildathonStore>((set) => ({status: null,+ promo: null,+ seenVersion: 0,+ joinWatchUntil: 0,+ joinedAt: null,offsetMs: 0,panelOpen: false,projects: [],@@ -350,8 +454,23 @@ export const useBuildathonStore = create<BuildathonStore>((set) => ({set((state) => ({status,offsetMs: status ? clockOffsetMs(status.serverTime, receivedAtMs) : 0,+ promo: status ? null : state.promo,panelOpen: status ? state.panelOpen : false,+ ...(status ? joinedFrom(state, receivedAtMs) : {}),})),+ setAnswer: (answer, receivedAtMs = Date.now()) =>+ set((state) => {+ if (answer?.enrolled === true) {+ return { status: answer, promo: null, offsetMs: clockOffsetMs(answer.serverTime, receivedAtMs), panelOpen: state.panelOpen, ...joinedFrom(state, receivedAtMs) };+ }+ if (answer?.enrolled === false && answer.promo) {+ return { status: null, promo: answer.promo, offsetMs: clockOffsetMs(answer.serverTime, receivedAtMs), panelOpen: false };+ }+ return { status: null, promo: null, offsetMs: 0, panelOpen: false };+ }),+ bumpSeen: () => set((state) => ({ seenVersion: state.seenVersion + 1 })),+ startJoinWatch: (nowMs = Date.now()) => set({ joinWatchUntil: nowMs + JOIN_WATCH_MS }),+ clearJoined: () => set({ joinedAt: null }),openPanel: () => set({ panelOpen: true }),closePanel: () => set({ panelOpen: false }),setProjects: (projects, selectedProjectId = null) => set({ projects, selectedProjectId }),@@ -375,15 +494,14 @@ export function noteNewBuildathonProject(path: string | null | undefined, name?:let refreshing: Promise<void> | null = null;-/** One read of the event; any failure hides everything. Never throws. */-export function refreshBuildathon(read: () => Promise<BuildathonStatus | null>): Promise<void> {+/** One read of the event (a participant's status or a promo); any failure hides everything. Never throws. */+export function refreshBuildathon(read: () => Promise<BuildathonAnswer>): Promise<void> {if (refreshing) return refreshing;refreshing = (async () => {try {- const status = await read();- useBuildathonStore.getState().setStatus(status?.enrolled === true ? status : null);+ useBuildathonStore.getState().setAnswer(await read());} catch {- useBuildathonStore.getState().setStatus(null);+ useBuildathonStore.getState().setAnswer(null);} finally {refreshing = null;}diff --git a/apps/app/src/app/lib/desktop.ts b/apps/app/src/app/lib/desktop.tsindex 690740db..6c6ef3d8 100644--- a/apps/app/src/app/lib/desktop.ts+++ b/apps/app/src/app/lib/desktop.ts@@ -789,6 +789,7 @@ const {omnirushBuildathon,omnirushBuildathonSessions,omnirushBuildathonLink,+ omnirushBuildathonJoin,omnirushBuildathonTagSession,omnirushBuildathonChecklist,omnirushAccountConnect,@@ -860,6 +861,7 @@ export {omnirushBuildathon,omnirushBuildathonSessions,omnirushBuildathonLink,+ omnirushBuildathonJoin,omnirushBuildathonTagSession,omnirushBuildathonChecklist,omnirushAccountConnect,diff --git a/apps/app/src/react-app/domains/buildathon/buildathon-poster-thumb.webp b/apps/app/src/react-app/domains/buildathon/buildathon-poster-thumb.webpnew file mode 100644index 00000000..4a315fc8Binary files /dev/null and b/apps/app/src/react-app/domains/buildathon/buildathon-poster-thumb.webp differdiff --git a/apps/app/src/react-app/domains/buildathon/buildathon-promo.tsx b/apps/app/src/react-app/domains/buildathon/buildathon-promo.tsxnew file mode 100644index 00000000..25de3836--- /dev/null+++ b/apps/app/src/react-app/domains/buildathon/buildathon-promo.tsx@@ -0,0 +1,237 @@+/** @jsxImportSource react */+// The buildathon promo for accounts that are not enrolled (contract "Promo for+// non-participants"): a slim top banner until dismissed, and a one-time card on+// the home screen. Both come from the server's `promo` block, are keyed by its+// id, and are gone after its end time. The CTA joins in the app when the promo+// allows it, else opens the event page.++import { useEffect, useState, type ReactNode } from "react";+import { ArrowRight, Loader2, Rocket, X } from "lucide-react";++import { toast } from "@/components/ui/sonner";+import { cn } from "@/lib/utils";++import { omnirushBuildathonJoin, openDesktopUrl } from "../../../app/lib/desktop";+import {+ promoActive,+ readPromoIds,+ rememberPromoId,+ useBuildathonStore,+ type BuildathonPromo,+} from "../../../app/lib/buildathon";+import { BANNER_HEIGHT_PX, bannerShiftStyle } from "../../shell/update-gate";+import posterThumb from "./buildathon-poster-thumb.webp";++/** The event poster's colours (omnirush.ai/buildathon). */+const BLUE = "#3A2DF5";+const LIME = "#D8FC38";+const INK = "#0B0630";++/** The server clock (the promo answer's offset), re-read every `intervalMs`. */+function useServerNow(intervalMs: number): number {+ const offsetMs = useBuildathonStore((store) => store.offsetMs);+ const [now, setNow] = useState(() => Date.now());+ useEffect(() => {+ const timer = window.setInterval(() => setNow(Date.now()), intervalMs);+ return () => window.clearInterval(timer);+ }, [intervalMs]);+ return now + offsetMs;+}++/** The promo to show now, or null (none, dismissed under its id, or past its end). */+export function useActivePromo(): BuildathonPromo | null {+ const promo = useBuildathonStore((store) => store.promo);+ const seenVersion = useBuildathonStore((store) => store.seenVersion);+ const now = useServerNow(30_000);+ // seenVersion: re-read the dismissed ids after a dismissal.+ void seenVersion;+ return promoActive(promo, now, readPromoIds("dismissed")) ? promo : null;+}++export function dismissPromo(id: string): void {+ rememberPromoId("dismissed", id);+ useBuildathonStore.getState().bumpSeen();+}++let joining = false;++/**+ * The CTA. Open joining: the join page in the browser (it links GitHub),+ * then the app re-reads often until the account is enrolled and switches to+ * the participant UI ("You're in"). Without a join page: join in the app.+ * Otherwise: the event page.+ */+export async function runPromoCta(promo: BuildathonPromo, setBusy?: (busy: boolean) => void): Promise<void> {+ if (promo.join && promo.joinUrl) {+ await openDesktopUrl(promo.joinUrl).catch(() => undefined);+ useBuildathonStore.getState().startJoinWatch();+ toast.info("Finish joining in your browser", {+ description: "Link your GitHub account there. The app switches over as soon as you're in.",+ duration: 15_000,+ });+ return;+ }+ if (!promo.join) {+ if (promo.ctaUrl) await openDesktopUrl(promo.ctaUrl).catch(() => undefined);+ return;+ }+ if (joining) return;+ joining = true;+ setBusy?.(true);+ try {+ const result = await omnirushBuildathonJoin().catch(() => ({ ok: false as const, error: "Could not join right now. Try again in a moment." }));+ if (result.ok) {+ // The layer greets the new participant ("You're in") and opens My Buildathon.+ useBuildathonStore.getState().setStatus(result.status);+ return;+ }+ const pageUrl = promo.ctaUrl;+ toast.error(result.error, pageUrl+ ? { action: { label: "Open event page", onClick: () => void openDesktopUrl(pageUrl).catch(() => undefined) } }+ : undefined);+ } finally {+ joining = false;+ setBusy?.(false);+ }+}++function CtaButton(props: { promo: BuildathonPromo; size: "xs" | "sm"; testId: string }) {+ const [busy, setBusy] = useState(false);+ return (+ <button+ type="button"+ disabled={busy}+ onClick={() => void runPromoCta(props.promo, setBusy)}+ className={cn(+ "inline-flex shrink-0 items-center gap-1 rounded-full font-semibold transition-[filter] hover:brightness-95 disabled:opacity-70 mac:titlebar-no-drag",+ props.size === "xs" ? "h-6 px-2.5 text-[11.5px]" : "h-8 px-3.5 text-[12.5px]",+ )}+ style={{ backgroundColor: LIME, color: INK }}+ data-testid={props.testId}+ data-join={props.promo.join ? "true" : "false"}+ >+ {busy ? <Loader2 className="size-3.5 animate-spin" /> : null}+ {busy ? "Joining…" : props.promo.ctaLabel}+ {busy ? null : <ArrowRight className="size-3.5" />}+ </button>+ );+}++/** Whether the app is waiting for a join finished in the browser. */+function useJoinWatching(): boolean {+ const until = useBuildathonStore((store) => store.joinWatchUntil);+ const [now, setNow] = useState(() => Date.now());+ useEffect(() => {+ if (until <= Date.now()) return;+ setNow(Date.now());+ const timer = window.setTimeout(() => setNow(Date.now()), until - Date.now() + 50);+ return () => window.clearTimeout(timer);+ }, [until]);+ return until > now;+}++/** The slim top banner (the update banner's place and height, the poster's colours). */+export function BuildathonPromoBanner(props: { promo: BuildathonPromo }) {+ const { promo } = props;+ const watching = useJoinWatching();+ return (+ <div+ role="region"+ aria-label={promo.title}+ data-testid="buildathon-promo-banner"+ className="fixed inset-x-0 top-0 z-[70] flex items-center justify-center gap-3 border-b border-black/20 px-10 text-[12px] font-medium text-white mac:titlebar-drag mac:ps-20"+ style={{ height: BANNER_HEIGHT_PX, backgroundColor: BLUE }}+ >+ <Rocket className="size-3.5 shrink-0" style={{ color: LIME }} aria-hidden="true" />+ <span className="shrink-0 font-extrabold uppercase tracking-[0.04em]">{promo.title}</span>+ {watching ? (+ <span className="truncate text-white/80" data-testid="buildathon-promo-waiting">Finish joining in your browser; this updates by itself.</span>+ ) : promo.text ? <span className="hidden truncate text-white/80 md:inline">{promo.text}</span> : null}+ <CtaButton promo={promo} size="xs" testId="buildathon-promo-banner-cta" />+ <button+ type="button"+ aria-label="Dismiss"+ title="Dismiss"+ onClick={() => dismissPromo(promo.id)}+ className="absolute right-2 inline-flex size-6 items-center justify-center rounded-md text-white/70 hover:bg-white/10 hover:text-white mac:titlebar-no-drag"+ data-testid="buildathon-promo-dismiss"+ >+ <X className="size-3.5" />+ </button>+ </div>+ );+}++/** The banner over the app while a promo is on; the app shifts below it like the other top banners. */+export function BuildathonPromoGate({ children }: { children: ReactNode }) {+ const promo = useActivePromo();+ return (+ <>+ {promo ? <BuildathonPromoBanner promo={promo} /> : null}+ <div data-buildathon-promo-shifted={promo ? "" : undefined} style={bannerShiftStyle(Boolean(promo))}>+ {children}+ </div>+ </>+ );+}++/** The promo id whose home card this run shows (the card is shown in one run only). */+let cardThisRun: string | null = null;++/** Whether the home card shows: the first run that sees this promo id keeps it for the run. */+function useOneTimeCard(promo: BuildathonPromo | null): boolean {+ const [, rerender] = useState(0);+ useEffect(() => {+ if (!promo || cardThisRun === promo.id) return;+ if (readPromoIds("card").has(promo.id)) return;+ cardThisRun = promo.id;+ rememberPromoId("card", promo.id);+ rerender((value) => value + 1);+ }, [promo]);+ return Boolean(promo && cardThisRun === promo.id);+}++/** Test hook: forget which card this run showed. */+export function resetPromoCardRun(): void {+ cardThisRun = null;+}++/** The one-time home-screen card: poster, title, text, CTA. */+export function BuildathonPromoCard() {+ const promo = useActivePromo();+ const show = useOneTimeCard(promo);+ if (!promo || !show) return null;+ return (+ <div+ className="relative flex overflow-hidden rounded-2xl border border-black/10 text-white shadow-[var(--dls-card-shadow)]"+ style={{ backgroundColor: BLUE }}+ data-testid="buildathon-promo-card"+ >+ <img+ src={posterThumb}+ alt=""+ aria-hidden="true"+ draggable={false}+ className="w-[104px] shrink-0 object-cover object-top"+ />+ <div className="min-w-0 flex-1 space-y-1.5 p-4 pe-9">+ <div className="text-[10.5px] font-semibold uppercase tracking-[0.14em]" style={{ color: LIME }}>Online · Solo</div>+ <div className="text-[17px] font-extrabold uppercase leading-tight tracking-[-0.01em]">{promo.title}</div>+ {promo.text ? <div className="text-[12.5px] leading-snug text-white/85">{promo.text}</div> : null}+ <div className="flex items-center gap-2 pt-1">+ <CtaButton promo={promo} size="sm" testId="buildathon-promo-card-cta" />+ </div>+ </div>+ <button+ type="button"+ aria-label="Dismiss"+ title="Dismiss"+ onClick={() => dismissPromo(promo.id)}+ className="absolute right-2 top-2 inline-flex size-6 items-center justify-center rounded-md text-white/70 hover:bg-white/10 hover:text-white"+ data-testid="buildathon-promo-card-dismiss"+ >+ <X className="size-3.5" />+ </button>+ </div>+ );+}diff --git a/apps/app/src/react-app/domains/buildathon/buildathon.tsx b/apps/app/src/react-app/domains/buildathon/buildathon.tsxindex c11fa928..ff78f3b2 100644--- a/apps/app/src/react-app/domains/buildathon/buildathon.tsx+++ b/apps/app/src/react-app/domains/buildathon/buildathon.tsx@@ -20,6 +20,11 @@ import { createOmniRushServerClient } from "../../../app/lib/omnirush-server";import { resolveOmniRushConnection } from "../../shell/omnirush-connection";import {BUILDATHON_REFRESH_MS,+ JOIN_WATCH_REFRESH_MS,+ announcementsToNotify,+ readAnnouncementIds,+ rememberAnnouncementIds,+ unreadAnnouncementIds,buildathonChipText,buildathonCountdown,compactTokens,@@ -43,6 +48,7 @@ import {syncBuildathonServer,tagSessions,useBuildathonStore,+ type BuildathonAnnouncement,type BuildathonCountdown,type BuildathonProject,type BuildathonSession,@@ -68,10 +74,20 @@ function useCountdown(status: BuildathonStatus | null): BuildathonCountdown | nureturn status ? buildathonCountdown(status.event, now) : null;}-/** Header chip: "Buildathon · 5d 03h left", red in the last hour. Nothing unless enrolled. */+/** Ids of the announcements not yet read in My Buildathon. */+function useUnreadAnnouncements(status: BuildathonStatus | null): string[] {+ const seenVersion = useBuildathonStore((store) => store.seenVersion);+ return useMemo(+ () => (status ? unreadAnnouncementIds(status.announcements, readAnnouncementIds("read")) : []),+ [status, seenVersion],+ );+}++/** Header chip: "Buildathon · 5d 03h left", red in the last hour, a dot for unread updates. Nothing unless enrolled. */export function BuildathonChip() {const status = useBuildathonStore((store) => store.status);const countdown = useCountdown(status);+ const unread = useUnreadAnnouncements(status);if (!status || !countdown) return null;return (<button@@ -91,6 +107,13 @@ export function BuildathonChip() {><Trophy className="size-3.5" /><span>{buildathonChipText(countdown)}</span>+ {unread.length ? (+ <span+ className="size-1.5 rounded-full bg-[#3A2DF5] dark:bg-[#D8FC38]"+ aria-label={`${unread.length} new update${unread.length === 1 ? "" : "s"}`}+ data-testid="buildathon-chip-unread"+ />+ ) : null}</button>);}@@ -340,11 +363,103 @@ function ChecklistSection(props: { status: BuildathonStatus }) {);}-/** "My Buildathon": countdown, tokens, rules, sessions, submission, link code. */+/** Plain text with its http(s) links clickable (opened in the browser). */+function LinkedText(props: { text: string }) {+ // A link ends before trailing punctuation ("see https://x.example/a." keeps the full stop as text).+ const parts = props.text.split(/(https?:\/\/[^\s<>"']*[^\s<>"'.,;:!?)\]])/g);+ return (+ <>+ {parts.map((part, index) =>+ index % 2 === 1 ? (+ <button+ key={index}+ type="button"+ className="break-all text-primary hover:underline"+ onClick={() => void openDesktopUrl(part).catch(() => undefined)}+ >+ {part}+ </button>+ ) : (+ <span key={index}>{part}</span>+ ),+ )}+ </>+ );+}++function announcementTime(iso: string | null): string {+ if (!iso) return "";+ const date = new Date(iso);+ if (!Number.isFinite(date.getTime())) return "";+ return new Intl.DateTimeFormat(undefined, { day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" }).format(date);+}++/** The updates feed, newest first; a dot on each one not read before this panel opened. */+function UpdatesSection(props: { announcements: BuildathonAnnouncement[]; unread: ReadonlySet<string> }) {+ if (!props.announcements.length) return null;+ const count = props.announcements.filter((announcement) => props.unread.has(announcement.id)).length;+ return (+ <Section title={`Updates${count ? ` · ${count} new` : ""}`} testId="buildathon-updates">+ <ul className="flex flex-col gap-1.5">+ {props.announcements.map((announcement) => {+ const unread = props.unread.has(announcement.id);+ return (+ <li+ key={announcement.id}+ className={cn(+ "rounded-lg border px-3 py-2 text-xs",+ announcement.level === "important" ? "border-[#3A2DF5]/40 bg-[#3A2DF5]/5 dark:border-[#D8FC38]/40 dark:bg-[#D8FC38]/5" : "border-border",+ )}+ data-testid="buildathon-update"+ data-id={announcement.id}+ data-unread={unread ? "true" : "false"}+ >+ <div className="flex items-start gap-2">+ <span+ className={cn("mt-1.5 size-1.5 shrink-0 rounded-full", unread ? "bg-[#3A2DF5] dark:bg-[#D8FC38]" : "bg-transparent")}+ aria-label={unread ? "New" : undefined}+ />+ <div className="min-w-0 flex-1">+ <div className="flex items-baseline justify-between gap-2">+ <span className="font-medium">{announcement.title}</span>+ <span className="shrink-0 text-[10.5px] text-muted-foreground">{announcementTime(announcement.publishedAt)}</span>+ </div>+ {announcement.body ? (+ <div className="mt-0.5 whitespace-pre-wrap break-words text-muted-foreground"><LinkedText text={announcement.body} /></div>+ ) : null}+ {announcement.url ? (+ <button+ type="button"+ className="mt-1 inline-flex items-center gap-1 text-primary hover:underline"+ onClick={() => void openDesktopUrl(announcement.url!).catch(() => undefined)}+ >+ Open link <ExternalLink className="size-3" />+ </button>+ ) : null}+ </div>+ </div>+ </li>+ );+ })}+ </ul>+ </Section>+ );+}++/** "My Buildathon": countdown, tokens, updates, rules, sessions, submission, link code. */export function BuildathonPanel(props: { status: BuildathonStatus; onClose: () => void }) {const { event, participant, submission } = props.status;const countdown = useCountdown(props.status)!;const [sessions, setSessions] = useState<BuildathonSession[] | null | undefined>(undefined);+ // The unread ones as of opening keep their dots while the panel is open; they count as read from now on.+ const [unread] = useState(() => new Set(unreadAnnouncementIds(props.status.announcements, readAnnouncementIds("read"))));+ useEffect(() => {+ const ids = unreadAnnouncementIds(props.status.announcements, readAnnouncementIds("read"));+ if (!ids.length) return;+ rememberAnnouncementIds("read", ids);+ rememberAnnouncementIds("notified", ids);+ useBuildathonStore.getState().bumpSeen();+ }, [props.status.announcements]);useEffect(() => {let live = true;@@ -393,6 +508,27 @@ export function BuildathonPanel(props: { status: BuildathonStatus; onClose: () =</div></div>+ <UpdatesSection announcements={props.status.announcements} unread={unread} />++ <div className="flex items-center justify-between gap-2 rounded-lg border border-border px-3 py-2 text-xs" data-testid="buildathon-github">+ {props.status.github ? (+ <span>+ <span className="text-muted-foreground">GitHub</span>{" "}+ <span className="font-medium" data-testid="buildathon-github-login">@{props.status.github.login}</span>+ <span className="text-muted-foreground"> · your submission repo must be under this account</span>+ </span>+ ) : (+ <>+ <span className="text-muted-foreground">Link your GitHub account before you submit.</span>+ {submitUrl ? (+ <Button size="xs" variant="outline" onClick={() => void openDesktopUrl(submitUrl).catch(() => undefined)}>+ Link GitHub <ExternalLink className="size-3" />+ </Button>+ ) : null}+ </>+ )}+ </div>+<Section title="Submission" testId="buildathon-submission">{submission ? (<div className="space-y-1.5 rounded-lg border border-border px-3 py-2 text-xs">@@ -492,6 +628,62 @@ export function BuildathonLayer() {void desktopNotificationShow({ title: status.event.name, body: due.text }).catch(() => undefined);}, [status, now]);+ // After the join page opened: re-read every 30 s and whenever the window comes back, for 10 minutes.+ const joinWatchUntil = useBuildathonStore((store) => store.joinWatchUntil);+ useEffect(() => {+ if (joinWatchUntil <= Date.now()) return;+ const check = () => {+ if (Date.now() > useBuildathonStore.getState().joinWatchUntil) return;+ void refreshBuildathon(readStatus);+ };+ const timer = window.setInterval(check, JOIN_WATCH_REFRESH_MS);+ const stop = window.setTimeout(() => window.clearInterval(timer), joinWatchUntil - Date.now() + 1_000);+ const onVisible = () => { if (document.visibilityState === "visible") check(); };+ window.addEventListener("focus", check);+ document.addEventListener("visibilitychange", onVisible);+ return () => {+ window.clearInterval(timer);+ window.clearTimeout(stop);+ window.removeEventListener("focus", check);+ document.removeEventListener("visibilitychange", onVisible);+ };+ }, [joinWatchUntil]);++ // Just joined (from the promo, in this run): greet once and open My Buildathon.+ const joinedAt = useBuildathonStore((store) => store.joinedAt);+ useEffect(() => {+ if (!joinedAt || !status) return;+ const store = useBuildathonStore.getState();+ store.clearJoined();+ // The updates so far are listed (with dots) in the panel that opens now, not popped up one by one.+ rememberAnnouncementIds("notified", status.announcements.map((announcement) => announcement.id));+ store.openPanel();+ const tokens = status.participant?.tokensGranted ? `${compactTokens(status.participant.tokensGranted)} event tokens are on your account. ` : "";+ const body = `${tokens}Pick a track for your project to get started.`;+ toast.success(`You're in: ${status.event.name}`, { description: body, duration: 15_000 });+ void desktopNotificationShow({ title: `You're in: ${status.event.name}`, body }).catch(() => undefined);+ }, [joinedAt, status]);++ // Updates: each one never shown pops up once (toast + desktop notification); a burst is capped.+ useEffect(() => {+ if (!status?.announcements.length) return;+ const due = announcementsToNotify(status.announcements, readAnnouncementIds("notified"));+ if (!due.ids.length) return;+ rememberAnnouncementIds("notified", due.ids);+ const view = { label: "View", onClick: () => useBuildathonStore.getState().openPanel() };+ for (const announcement of due.show) {+ const body = announcement.body.length > 220 ? `${announcement.body.slice(0, 219).trimEnd()}…` : announcement.body;+ const show = announcement.level === "important" ? toast.warning : toast.info;+ show(announcement.title, { description: body || undefined, duration: 20_000, action: view });+ void desktopNotificationShow({ title: `${status.event.name}: ${announcement.title}`, body: body || undefined }).catch(() => undefined);+ }+ if (due.more) {+ const text = `${due.more} more update${due.more === 1 ? "" : "s"} in My Buildathon`;+ toast.info(text, { duration: 20_000, action: view });+ void desktopNotificationShow({ title: status.event.name, body: text }).catch(() => undefined);+ }+ }, [status]);+// Tell the server each event session's track (fire-and-forget).useEffect(() => {if (!status) return;diff --git a/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsx b/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsxindex 8d34b1a3..5384437a 100644--- a/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsx+++ b/apps/app/src/react-app/domains/session/chat/session-empty-hero.tsx@@ -5,6 +5,7 @@ import { Zap } from "lucide-react";import type { ComposerAttachment } from "@/app/types";import { CODING_STARTER_CARDS, resolveOrganizationPromptCardContent } from "@/components/chat/task-suggestions";import { useCheckDesktopRestriction, useOrgRestrictions } from "@/react-app/domains/cloud/desktop-config-provider";+import { BuildathonPromoCard } from "@/react-app/domains/buildathon/buildathon-promo";import {NewTaskComposer,type NewTaskComposerContext,@@ -168,6 +169,8 @@ export function SessionEmptyHero(props: SessionEmptyHeroProps) {</button>))}</div>++ <BuildathonPromoCard /></div>);}diff --git a/apps/app/src/react-app/shell/app-root.tsx b/apps/app/src/react-app/shell/app-root.tsxindex d5b41989..a55e1758 100644--- a/apps/app/src/react-app/shell/app-root.tsx+++ b/apps/app/src/react-app/shell/app-root.tsx@@ -50,6 +50,7 @@ import { SyncRestartGate } from "./sync-restart-banner";import { UpdateGate } from "./update-gate";import { QualityRewards } from "../domains/quality/quality-notice";import { BuildathonLayer } from "../domains/buildathon/buildathon";+import { BuildathonPromoGate } from "../domains/buildathon/buildathon-promo";import { TurnRunningSync } from "../domains/quality/good-session";import { SettingsRoute } from "./settings-route";import { ShellConfigProvider } from "./shell-config";@@ -388,6 +389,7 @@ export function AppRoot() {<DesktopUpdaterProvider><UpdateGate><SyncRestartGate>+ <BuildathonPromoGate><ShellConfigProvider><AppMenuProvider><OmniRushControlProvider>@@ -527,6 +529,7 @@ export function AppRoot() {</OmniRushControlProvider></AppMenuProvider></ShellConfigProvider>+ </BuildathonPromoGate></SyncRestartGate></UpdateGate></DesktopUpdaterProvider>diff --git a/apps/app/tests/buildathon.test.ts b/apps/app/tests/buildathon.test.tsindex b1861e78..b01e4b32 100644--- a/apps/app/tests/buildathon.test.ts+++ b/apps/app/tests/buildathon.test.ts@@ -1,6 +1,15 @@import { describe, expect, test } from "bun:test";import {+ announcementsToNotify,+ promoActive,+ readAnnouncementIds,+ readPromoIds,+ rememberAnnouncementIds,+ rememberPromoId,+ unreadAnnouncementIds,+ type BuildathonAnnouncement,+ type BuildathonPromo,buildathonChipText,buildathonCountdown,buildathonProjectPaths,@@ -168,7 +177,7 @@ test("the only-tool rule comes first", () => {});describe("refresh", () => {- const status: BuildathonStatus = { enrolled: true, serverTime: null, event: EVENT, participant: null, submission: null, repro: { box: "on", agentRules: "", checklist: [] } };+ const status: BuildathonStatus = { enrolled: true, serverTime: null, event: EVENT, participant: null, submission: null, repro: { box: "on", agentRules: "", checklist: [] }, announcements: [], github: null };test("enrolled shows, anything else hides", async () => {await refreshBuildathon(async () => status);@@ -213,6 +222,8 @@ describe("reproducibility mode: buildathon projects", () => {const status: BuildathonStatus = {enrolled: true, serverTime: null, event: EVENT, participant: null, submission: null,repro: { box: "on", agentRules: "Rules.", checklist: [] },+ announcements: [],+ github: null,};const storage = memoryStorage();writeProjectTrack("/p/app", "agents", storage, inside);@@ -227,3 +238,75 @@ describe("reproducibility mode: buildathon projects", () => {expect(sent.length).toBe(1);});});++describe("promo (non-participants)", () => {+ const promo: BuildathonPromo = {+ id: "frontier-2026-reg", title: "Frontier Buildathon 2026", text: "$300 prize pool", ctaLabel: "Join the Buildathon",+ ctaUrl: "https://omnirush.ai/buildathon", endsAt: "2026-10-19T18:29:59Z", join: false, joinUrl: null,+ };+ const before = Date.parse("2026-10-15T00:00:00Z");++ test("on until dismissed under its id, and never after its end", () => {+ const storage = memoryStorage();+ expect(promoActive(promo, before, readPromoIds("dismissed", storage))).toBe(true);+ expect(promoActive(promo, Date.parse("2026-10-19T18:30:00Z"), new Set())).toBe(false);+ expect(promoActive({ ...promo, endsAt: null }, Date.parse("2027-01-01T00:00:00Z"), new Set())).toBe(true);+ expect(promoActive(null, before, new Set())).toBe(false);+ rememberPromoId("dismissed", promo.id, storage);+ expect(promoActive(promo, before, readPromoIds("dismissed", storage))).toBe(false);+ // A new id shows again.+ expect(promoActive({ ...promo, id: "frontier-2026-last-call" }, before, readPromoIds("dismissed", storage))).toBe(true);+ expect(readPromoIds("card", storage).size).toBe(0);+ });++ test("the store takes a promo or a status, never both", async () => {+ const status: BuildathonStatus = { enrolled: true, serverTime: null, event: EVENT, participant: null, submission: null, repro: { box: "on", agentRules: "", checklist: [] }, announcements: [], github: null };+ await refreshBuildathon(async () => ({ enrolled: false, serverTime: null, promo }));+ expect(useBuildathonStore.getState().promo?.id).toBe(promo.id);+ expect(useBuildathonStore.getState().status).toBeNull();+ // Joining on the web: the watch re-reads; the first enrolled answer replaces the promo at once.+ useBuildathonStore.getState().startJoinWatch(1_000);+ expect(useBuildathonStore.getState().joinWatchUntil).toBe(1_000 + 10 * 60_000);+ await refreshBuildathon(async () => status);+ expect(useBuildathonStore.getState().promo).toBeNull();+ expect(useBuildathonStore.getState().status?.event.id).toBe("frontier-2026");+ expect(useBuildathonStore.getState().joinedAt).not.toBeNull();+ expect(useBuildathonStore.getState().joinWatchUntil).toBe(0);+ useBuildathonStore.getState().clearJoined();+ // A participant's later reads are not a new join.+ await refreshBuildathon(async () => status);+ expect(useBuildathonStore.getState().joinedAt).toBeNull();+ await refreshBuildathon(async () => ({ enrolled: false, serverTime: null, promo }));+ await refreshBuildathon(async () => null);+ expect(useBuildathonStore.getState().promo).toBeNull();+ expect(useBuildathonStore.getState().status).toBeNull();+ });+});++describe("announcements (participants)", () => {+ const item = (id: string, title = id): BuildathonAnnouncement => ({ id, title, body: "", url: null, level: "info", publishedAt: null });+ const feed = [item("a_5"), item("a_4"), item("a_3"), item("a_2"), item("a_1")]; // newest first++ test("each once; a burst shows the newest few (newest last) and counts the rest", () => {+ const storage = memoryStorage();+ const first = announcementsToNotify(feed, readAnnouncementIds("notified", storage));+ expect(first.show.map((a) => a.id)).toEqual(["a_3", "a_4", "a_5"]);+ expect(first.more).toBe(2);+ expect(first.ids.length).toBe(5);+ rememberAnnouncementIds("notified", first.ids, storage);+ expect(announcementsToNotify(feed, readAnnouncementIds("notified", storage)).ids).toEqual([]);+ const next = announcementsToNotify([item("a_6"), ...feed], readAnnouncementIds("notified", storage));+ expect(next.show.map((a) => a.id)).toEqual(["a_6"]);+ expect(next.more).toBe(0);+ });++ test("unread until read in My Buildathon; ids persist and are bounded", () => {+ const storage = memoryStorage();+ expect(unreadAnnouncementIds(feed, readAnnouncementIds("read", storage)).length).toBe(5);+ rememberAnnouncementIds("read", ["a_5", "a_4"], storage);+ expect(unreadAnnouncementIds(feed, readAnnouncementIds("read", storage))).toEqual(["a_3", "a_2", "a_1"]);+ rememberAnnouncementIds("read", Array.from({ length: 300 }, (_, index) => `x_${index}`), storage);+ expect(readAnnouncementIds("read", storage).size).toBe(200);+ expect(readAnnouncementIds("notified", storage).size).toBe(0);+ });+});diff --git a/apps/desktop/electron/buildathon.mjs b/apps/desktop/electron/buildathon.mjsindex 36352ae9..f6dcf7da 100644--- a/apps/desktop/electron/buildathon.mjs+++ b/apps/desktop/electron/buildathon.mjs@@ -172,8 +172,74 @@ export function parseBuildathonRepro(value) {};}+const PROMO_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,79}$/;+const ANNOUNCEMENT_LEVELS = ["info", "important"];++function clip(value, max) {+ const raw = text(value);+ return raw ? (raw.length > max ? `${raw.slice(0, max - 1).trimEnd()}…` : raw) : null;+}++/**+ * The `promo` block of a non-participant's answer (contract "Promo for+ * non-participants"). Null when absent or unusable: no id, no title, or no+ * way to act on it (neither in-app joining nor an https page).+ * @returns {import("@omnirush/types/desktop-ipc").OmniRushBuildathonPromo | null}+ */+export function parseBuildathonPromo(value) {+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;+ const id = text(value.id);+ const title = clip(value.title, 120);+ if (!id || !PROMO_ID.test(id) || !title) return null;+ const join = value.join === true;+ const ctaUrl = httpsUrl(value.cta_url);+ const joinUrl = join ? httpsUrl(value.join_url) : null;+ if (!join && !ctaUrl) return null;+ return {+ id,+ title,+ text: clip(value.text, 280),+ ctaLabel: clip(value.cta_label, 40) ?? "Join the Buildathon",+ ctaUrl,+ endsAt: isoTime(value.ends_at),+ join,+ joinUrl,+ };+}+/**- * GET /me/buildathon (or the link answer): null unless the account is+ * The participants' updates feed: newest first, at most 20, each with an id+ * and a title or a body.+ * @returns {import("@omnirush/types/desktop-ipc").OmniRushBuildathonAnnouncement[]}+ */+export function parseBuildathonAnnouncements(value) {+ if (!Array.isArray(value)) return [];+ const seen = new Set();+ const out = [];+ for (const entry of value) {+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;+ const id = text(entry.id);+ if (!id || id.length > 120 || seen.has(id)) continue;+ const title = clip(entry.title, 160);+ const body = clip(entry.body, 4_000);+ if (!title && !body) continue;+ seen.add(id);+ out.push({+ id,+ title: title ?? "Update",+ body: body ?? "",+ url: httpsUrl(entry.url),+ level: ANNOUNCEMENT_LEVELS.includes(entry.level) ? entry.level : "info",+ publishedAt: isoTime(entry.published_at),+ });+ }+ // Newest first (the server's order; a stable sort keeps it for equal or missing times).+ out.sort((left, right) => (Date.parse(right.publishedAt ?? "") || 0) - (Date.parse(left.publishedAt ?? "") || 0));+ return out.slice(0, 20);+}++/**+ * GET /me/buildathon (or the link/join answer): null unless the account is* enrolled and the event names a deadline.* @returns {BuildathonStatus | null}*/@@ -188,9 +254,52 @@ export function parseBuildathonStatus(value) {participant: parseParticipant(value.participant),submission: parseBuildathonSubmission(value.submission),repro: parseBuildathonRepro(value.repro),+ announcements: parseBuildathonAnnouncements(value.announcements),+ github: parseBuildathonGithub(value.github ?? value.participant?.github),};}+/** The linked GitHub account (`github` of the enrolled body); null when none is linked. */+export function parseBuildathonGithub(value) {+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;+ const login = text(value.login);+ if (!login || !/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(login)) return null;+ return { login, linkedAt: isoTime(value.linked_at) };+}++/**+ * GET /me/buildathon as the app reads it: the participant's status, a+ * non-participant's promo (`enrolled: false` with a usable `promo`), or null+ * (nothing to show).+ * @returns {import("@omnirush/types/desktop-ipc").OmniRushBuildathonAnswer}+ */+export function parseBuildathonAnswer(value) {+ const status = parseBuildathonStatus(value);+ if (status) return status;+ if (!value || typeof value !== "object" || Array.isArray(value) || value.enrolled !== false) return null;+ const promo = parseBuildathonPromo(value.promo);+ return promo ? { enrolled: false, serverTime: isoTime(value.server_time), promo } : null;+}++const JOIN_ERRORS = {+ join_closed: "Joining is closed right now.",+ github_required: "Link your GitHub account on omnirush.ai to join.",+ github_too_new: "Your GitHub account must be at least 30 days old to join.",+ github_inactive: "Your GitHub account needs some public activity in the last year (a public repo or contribution) to join.",+ github_in_use: "That GitHub account is already linked to another OmniRush account.",+ already_enrolled: "This account is already enrolled.",+ not_available: "Joining is not available right now.",+};++/** A refused join as a sentence. */+export function buildathonJoinError(payload, status) {+ const code = payload && typeof payload === "object" ? text(payload.error) : null;+ if (code && Object.hasOwn(JOIN_ERRORS, code)) return JOIN_ERRORS[code];+ if (status === 403) return JOIN_ERRORS.join_closed;+ if (status === 401) return "Sign in to join.";+ return "Could not join right now. Try again in a moment.";+}+/*** GET /me/buildathon/sessions; null on a malformed body.* @returns {BuildathonSession[] | null}diff --git a/apps/desktop/electron/buildathon.test.mjs b/apps/desktop/electron/buildathon.test.mjsindex 78e71eea..1cd12530 100644--- a/apps/desktop/electron/buildathon.test.mjs+++ b/apps/desktop/electron/buildathon.test.mjs@@ -10,6 +10,9 @@ import {DEFAULT_AGENT_RULES,buildathonLinkCode,buildathonTrackId,+ parseBuildathonAnnouncements,+ parseBuildathonAnswer,+ parseBuildathonPromo,parseBuildathonRepro,parseBuildathonSessions,parseBuildathonStatus,@@ -154,7 +157,7 @@ test("buildathon store: GET /me/buildathon with the device credential; null forseen.push({ path: new URL(url).pathname, authorization: new Headers(init.headers).get("authorization"), signal: init.signal instanceof AbortSignal });return Response.json(ENROLLED);});- assert.equal((await store.buildathonStatus()).event.id, "frontier-2026");+ assert.equal(/** @type {any} */ (await store.buildathonStatus()).event.id, "frontier-2026");assert.deepEqual(seen, [{ path: "/omnirush/me/buildathon", authorization: "Bearer access-1", signal: true }]);for (const fetchImpl of [@@ -274,3 +277,117 @@ test("checklist IPC: an existing project folder only, never home, a root or a reassert.equal(projectChecklist({ path: path.join(dir, "missing") }), null);assert.equal(projectChecklist({}), null);});++const PROMO = {+ id: "frontier-2026-reg",+ title: "Frontier Buildathon 2026",+ text: "$300 prize pool · $300 of GPT-6 tokens each · solo · 6 days",+ cta_label: "Join the Buildathon",+ cta_url: "https://omnirush.ai/buildathon",+ ends_at: "2026-10-19T18:29:59Z",+ join: false,+};++test("promo: a non-participant's promo block, cleaned", () => {+ assert.deepEqual(parseBuildathonPromo(PROMO), {+ id: "frontier-2026-reg",+ title: "Frontier Buildathon 2026",+ text: "$300 prize pool · $300 of GPT-6 tokens each · solo · 6 days",+ ctaLabel: "Join the Buildathon",+ ctaUrl: "https://omnirush.ai/buildathon",+ endsAt: "2026-10-19T18:29:59Z",+ join: false,+ joinUrl: null,+ });+ // Open joining on the web.+ const open = parseBuildathonPromo({ ...PROMO, join: true, join_url: "https://omnirush.ai/console/buildathon?join=1" });+ assert.equal(open.joinUrl, "https://omnirush.ai/console/buildathon?join=1");+ assert.equal(parseBuildathonPromo({ ...PROMO, join_url: "https://omnirush.ai/console/buildathon?join=1" }).joinUrl, null, "no join_url unless join is on");+ assert.equal(parseBuildathonPromo({ ...PROMO, join: true, join_url: "http://omnirush.ai/x" }).joinUrl, null);+ // Defaults and cleaning.+ const bare = parseBuildathonPromo({ id: "p1", title: "T", cta_url: "https://x.example/" , join: "yes" });+ assert.equal(bare.ctaLabel, "Join the Buildathon");+ assert.equal(bare.join, false, "only a literal true joins in the app");+ assert.equal(bare.text, null);+ assert.equal(bare.endsAt, null);+ // In-app join needs no page.+ assert.equal(parseBuildathonPromo({ id: "p1", title: "T", join: true }).join, true);+ // Unusable: no id, a bad id, no title, no way to act (no join, no https page).+ for (const bad of [null, [], { ...PROMO, id: "" }, { ...PROMO, id: "has space" }, { ...PROMO, title: " " },+ { ...PROMO, cta_url: "http://omnirush.ai/buildathon" }, { ...PROMO, cta_url: "javascript:alert(1)" }]) {+ assert.equal(parseBuildathonPromo(bad), null, JSON.stringify(bad));+ }+});++test("promo: GET /me/buildathon reads as status, promo or nothing", () => {+ assert.equal(parseBuildathonAnswer({ enrolled: false }), null, "no promo: nothing, as before");+ assert.equal(parseBuildathonAnswer({ enrolled: false, promo: { id: "x" } }), null);+ assert.deepEqual(parseBuildathonAnswer({ enrolled: false, promo: PROMO, server_time: "2026-10-15T10:00:00Z" }), {+ enrolled: false,+ serverTime: "2026-10-15T10:00:00Z",+ promo: parseBuildathonPromo(PROMO),+ });+ assert.equal(parseBuildathonAnswer({ promo: PROMO }), null, "enrolled must be false, not missing");+ const status = parseBuildathonAnswer({ ...ENROLLED, promo: PROMO });+ assert.equal(status.enrolled, true);+ assert.equal("promo" in status, false, "participants never get the promo");+});++test("announcements: newest first, at most 20, cleaned", () => {+ const list = parseBuildathonAnnouncements([+ { id: "a_1", title: "Old", body: "first", url: null, level: "info", published_at: "2026-10-14T10:00:00Z" },+ { id: "a_2", title: "New", body: "see https://omnirush.ai/x", url: "https://omnirush.ai/x", level: "important", published_at: "2026-10-15T10:00:00Z" },+ { id: "a_2", title: "dup", body: "dup" },+ { id: "a_3", body: "body only", url: "http://insecure.example", level: "loud" },+ { id: "", title: "no id" },+ { id: "a_4" },+ "junk",+ ]);+ assert.deepEqual(list.map((a) => a.id), ["a_2", "a_1", "a_3"]);+ assert.equal(list[0].level, "important");+ assert.equal(list[0].url, "https://omnirush.ai/x");+ assert.equal(list[2].title, "Update");+ assert.equal(list[2].url, null);+ assert.equal(list[2].level, "info");+ const many = Array.from({ length: 30 }, (_, index) => ({ id: `a_${index}`, title: `t${index}`, published_at: new Date(Date.UTC(2026, 9, 14, index % 24, index)).toISOString() }));+ assert.equal(parseBuildathonAnnouncements(many).length, 20);+ assert.deepEqual(parseBuildathonAnnouncements(undefined), []);+ assert.deepEqual(parseBuildathonStatus(ENROLLED).announcements, []);+ assert.equal(parseBuildathonStatus(ENROLLED).github, null);+ assert.deepEqual(parseBuildathonStatus({ ...ENROLLED, github: { login: "octo-cat", linked_at: "2026-10-14T19:30:00Z" } }).github, { login: "octo-cat", linkedAt: "2026-10-14T19:30:00Z" });+ assert.equal(parseBuildathonStatus({ ...ENROLLED, github: { login: "bad login!" } }).github, null);+ assert.equal(parseBuildathonStatus({ ...ENROLLED, announcements: [{ id: "a_1", title: "Hi" }] }).announcements[0].title, "Hi");+});++test("buildathon store: the promo comes through GET /me/buildathon", async () => {+ const store = await signedInStore(async () => Response.json({ enrolled: false, promo: PROMO }));+ const answer = await store.buildathonStatus();+ assert.equal(answer.enrolled, false);+ assert.equal(answer.promo.id, "frontier-2026-reg");+});++test("buildathon store: join; the enrolled status, or the refusal in words", async () => {+ const seen = [];+ const store = await signedInStore(async (url, init) => {+ seen.push({ path: new URL(url).pathname, method: init.method, authorization: new Headers(init.headers).get("authorization") });+ return Response.json({ ...ENROLLED, announcements: [{ id: "a_1", title: "Welcome" }] });+ });+ const joined = await store.buildathonJoin();+ assert.equal(joined.ok, true);+ assert.equal(joined.status.event.id, "frontier-2026");+ assert.equal(joined.status.announcements[0].id, "a_1");+ assert.deepEqual(seen, [{ path: "/omnirush/me/buildathon/join", method: "POST", authorization: "Bearer access-1" }]);++ const closed = await signedInStore(async () => Response.json({ error: "join_closed" }, { status: 403 }));+ assert.deepEqual(await closed.buildathonJoin(), { ok: false, error: "Joining is closed right now.", closed: true });+ for (const [code, words] of /** @type {Array<[string, RegExp]>} */ ([["github_required", /Link your GitHub/], ["github_too_new", /30 days/], ["github_inactive", /public activity/], ["github_in_use", /another OmniRush account/]])) {+ const refused = await signedInStore(async () => Response.json({ error: code }, { status: 403 }));+ assert.match(/** @type {any} */ (await refused.buildathonJoin()).error, words, code);+ }+ const odd = await signedInStore(async () => Response.json({ enrolled: false }));+ assert.equal((await odd.buildathonJoin()).ok, false);+ const down = await signedInStore(async () => new Response("down", { status: 502 }));+ assert.match(/** @type {any} */ (await down.buildathonJoin()).error, /Try again/);+ const offline = await signedInStore(async () => { throw new TypeError("fetch failed"); });+ assert.equal((await offline.buildathonJoin()).ok, false);+});diff --git a/apps/desktop/electron/main.mjs b/apps/desktop/electron/main.mjsindex e5dafedf..7cdc17d4 100644--- a/apps/desktop/electron/main.mjs+++ b/apps/desktop/electron/main.mjs@@ -2208,6 +2208,10 @@ const desktopCommandHandlers = {const input = args[0] && typeof args[0] === "object" ? args[0] : {};return omnirushAccountStore.buildathonLink({ code: input.code });},+ // Join from the promo (only offered when the server's promo says so).+ "omnirushBuildathonJoin": async (event) => {+ return omnirushAccountStore.buildathonJoin();+ },// The rebuild checklist of one buildathon project, checked in its folder (cheap file checks)."omnirushBuildathonChecklist": async (event, ...args) => {const input = args[0] && typeof args[0] === "object" ? args[0] : {};diff --git a/apps/desktop/electron/omnirush-account.mjs b/apps/desktop/electron/omnirush-account.mjsindex 147498e5..20e1c88e 100644--- a/apps/desktop/electron/omnirush-account.mjs+++ b/apps/desktop/electron/omnirush-account.mjs@@ -13,7 +13,7 @@ import {writePlaintextCredentialFile,} from "./plaintext-credential-file.mjs";import { CLIENT_HEADER, guiClientHeaderValue, parseClientUpdate } from "./update-gate.mjs";-import { buildathonLinkCode, buildathonLinkError, buildathonProjectName, buildathonTrackId, parseBuildathonSessions, parseBuildathonStatus } from "./buildathon.mjs";+import { buildathonJoinError, buildathonLinkCode, buildathonLinkError, buildathonProjectName, buildathonTrackId, parseBuildathonAnswer, parseBuildathonSessions, parseBuildathonStatus } from "./buildathon.mjs";import { parseAccountQuality, parseFailLabels, parseQualitySessions, parseSessionStatus, parseSpinHistory, profileSessionId, parseSpinResult, parseWheelSegments, spinIdempotencyKey, spinRefusal } from "./quality.mjs";const execFileAsync = promisify(execFile);@@ -1249,15 +1249,15 @@ export function createDesktopOmniRushAccountStore({}/**- * The buildathon block (GET /me/buildathon). Null for anyone not enrolled,- * while signed out, offline, slow or on a bad answer: the app then shows- * nothing about the event.+ * The buildathon block (GET /me/buildathon): a participant's status, a+ * non-participant's promo, or null (no promo, signed out, offline, slow or+ * a bad answer): the app then shows nothing about the event.*/async function buildathonStatus() {try {const response = await sendAuthorized("/me/buildathon", { method: "GET", signal: AbortSignal.timeout(BUILDATHON_TIMEOUT_MS) });if (!response?.ok) return null;- return parseBuildathonStatus(await response.json());+ return parseBuildathonAnswer(await response.json());} catch {return null;}@@ -1300,6 +1300,30 @@ export function createDesktopOmniRushAccountStore({return status ? { ok: true, status } : { ok: false, error: "That code is not linked to an event you can join." };}+ /**+ * Join the event from the app (POST /me/buildathon/join; only offered when+ * the promo says `join: true`). The answer is the enrolled status.+ * @returns {Promise<import("@omnirush/types/desktop-ipc").OmniRushBuildathonLinkResult>}+ */+ async function buildathonJoin() {+ let response;+ try {+ response = await sendAuthorized("/me/buildathon/join", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: "{}",+ signal: AbortSignal.timeout(BUILDATHON_TIMEOUT_MS),+ });+ } catch {+ return { ok: false, error: "Could not join right now. Try again in a moment." };+ }+ if (!response) return { ok: false, error: "Sign in to join." };+ const payload = await response.json().catch(() => null);+ if (!response.ok) return { ok: false, error: buildathonJoinError(payload, response.status), closed: response.status === 403 };+ const status = parseBuildathonStatus(payload);+ return status ? { ok: true, status } : { ok: false, error: "Could not join right now. Try again in a moment." };+ }+/*** Name the track of one session (PUT /me/sessions/{id}/buildathon), with* the folder's last name. 204 is done; 400/403/404/409 (unknown track, not@@ -1381,6 +1405,7 @@ export function createDesktopOmniRushAccountStore({buildathonStatus,buildathonSessions,buildathonLink,+ buildathonJoin,buildathonTagSession,};}diff --git a/packages/types/src/desktop-ipc.ts b/packages/types/src/desktop-ipc.tsindex 1ecb9125..0d22792b 100644--- a/packages/types/src/desktop-ipc.ts+++ b/packages/types/src/desktop-ipc.ts@@ -338,7 +338,37 @@ export type OmniRushBuildathonStatus = {participant: OmniRushBuildathonParticipant | null;submission: OmniRushBuildathonSubmission | null;repro: OmniRushBuildathonRepro;+ /** The updates feed, newest first (at most 20). */+ announcements: OmniRushBuildathonAnnouncement[];+ /** The linked GitHub account (needed to submit); null when none is linked. */+ github: { login: string; linkedAt: string | null } | null;};+export type OmniRushBuildathonAnnouncement = {+ id: string;+ title: string;+ /** Plain text; may contain URLs. */+ body: string;+ url: string | null;+ level: "info" | "important";+ publishedAt: string | null;+};+/** A non-participant's promo (GET /me/buildathon `enrolled: false` + `promo`). */+export type OmniRushBuildathonPromo = {+ /** The dismissal key: a new id shows the promo again. */+ id: string;+ title: string;+ text: string | null;+ ctaLabel: string;+ ctaUrl: string | null;+ /** Registration close: hidden after it. */+ endsAt: string | null;+ /** True: open joining (on the web at `joinUrl`, which links GitHub; without one, POST /me/buildathon/join). */+ join: boolean;+ joinUrl: string | null;+};+export type OmniRushBuildathonPromoStatus = { enrolled: false; serverTime: string | null; promo: OmniRushBuildathonPromo };+/** What the app reads from GET /me/buildathon: a participant, a promo, or nothing to show. */+export type OmniRushBuildathonAnswer = OmniRushBuildathonStatus | OmniRushBuildathonPromoStatus | null;export type OmniRushBuildathonSession = {sessionId: string;title: string | null;@@ -352,7 +382,7 @@ export type OmniRushBuildathonSession = {};export type OmniRushBuildathonLinkResult =| { ok: true; status: OmniRushBuildathonStatus }- | { ok: false; error: string };+ | { ok: false; error: string; closed?: boolean };export type OmniRushBuildathonTagResult = "tagged" | "refused" | "retry";export type OmniRushSessionStatus = {@@ -906,7 +936,8 @@ export type DesktopCommandMap = {args: [input: { idempotencyKey: string }];result: OmniRushQualitySpinOutcome;};- omnirushBuildathon: { args: []; result: OmniRushBuildathonStatus | null };+ omnirushBuildathon: { args: []; result: OmniRushBuildathonAnswer };+ omnirushBuildathonJoin: { args: []; result: OmniRushBuildathonLinkResult };omnirushBuildathonSessions: { args: []; result: OmniRushBuildathonSession[] | null };omnirushBuildathonLink: { args: [input: { code: string }]; result: OmniRushBuildathonLinkResult };omnirushBuildathonChecklist: {