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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(b2): client check.ts feed (messages + update policy) replacing announcements.json
enes26da9a6e88a1
diff --git a/src/main/announcements.ts b/src/main/announcements.tsdeleted file mode 100644index c94138b4a..000000000--- a/src/main/announcements.ts+++ /dev/null@@ -1,36 +0,0 @@-// Fetches the remote announcements feed from the website. Runs in the main process-// (Node) so the renderer's Content-Security-Policy stays locked to 'self' — the-// renderer asks for the data over IPC instead of making a cross-origin request.-import type { Announcement } from '../shared/types'--const FEED_URL = 'https://nodeterm.dev/announcements.json'-const TIMEOUT_MS = 8000--function isAnnouncement(x: unknown): x is Announcement {- if (!x || typeof x !== 'object') return false- const a = x as Record<string, unknown>- return typeof a.id === 'string' && typeof a.title === 'string'-}--export async function fetchAnnouncements(): Promise<Announcement[]> {- try {- const ctrl = new AbortController()- const t = setTimeout(() => ctrl.abort(), TIMEOUT_MS)- const res = await fetch(FEED_URL, { signal: ctrl.signal, cache: 'no-cache' }).finally(() =>- clearTimeout(t)- )- if (!res.ok) return []- const data = await res.json()- if (!Array.isArray(data)) return []- // Keep only well-formed items and sanitize the optional link scheme.- return data.filter(isAnnouncement).map((a) => ({- id: a.id,- title: a.title,- body: typeof a.body === 'string' ? a.body : undefined,- url: typeof a.url === 'string' && /^https?:\/\//.test(a.url) ? a.url : undefined,- level: a.level === 'success' || a.level === 'warning' ? a.level : 'info'- }))- } catch {- return []- }-}diff --git a/src/main/check.ts b/src/main/check.tsnew file mode 100644index 000000000..9a657dc94--- /dev/null+++ b/src/main/check.ts@@ -0,0 +1,73 @@+// Polls the backend /v1/check feed from the main process (so the renderer CSP stays 'self').+// Successor to the static announcements.json: returns targeted messages for the announcement+// banner AND the mandatory-update policy for the Update Card. Persists nothing server-side.+import { app } from 'electron'+import type { Announcement, UpdatePolicy } from '../shared/types'++const API_BASE = process.env.NODETERM_API_BASE || 'https://api.nodeterm.dev'+const CACHE_MS = 5 * 60 * 1000++export interface CheckResult {+ messages: Announcement[]+ update: UpdatePolicy+}++const EMPTY: CheckResult = { messages: [], update: { minSupported: null, mandatory: false } }++// Same build + DO_NOT_TRACK gate as telemetry: dev never hits the prod API unless a local+// server is targeted explicitly. Not gated on the telemetry opt-out — this is content delivery+// (the old announcements feed always ran) and /v1/check stores nothing.+function allowed(): boolean {+ if (process.env.DO_NOT_TRACK || process.env.NODETERM_TELEMETRY_DISABLED) return false+ if (!app.isPackaged && !process.env.NODETERM_API_BASE) return false+ return true+}++function sanitize(data: unknown): CheckResult {+ if (!data || typeof data !== 'object') return EMPTY+ const d = data as Record<string, unknown>+ const rawMessages = Array.isArray(d.messages) ? d.messages : []+ const messages: Announcement[] = rawMessages+ .filter((m): m is Record<string, unknown> => !!m && typeof m === 'object')+ .filter((m) => typeof m.id === 'string' && typeof m.title === 'string')+ .map((m) => ({+ id: m.id as string,+ title: m.title as string,+ body: typeof m.body === 'string' ? m.body : undefined,+ url: typeof m.url === 'string' && /^https?:\/\//.test(m.url) ? m.url : undefined,+ level: m.level === 'success' || m.level === 'warning' ? m.level : 'info'+ }))+ const u = (d.update ?? {}) as Record<string, unknown>+ const update: UpdatePolicy = {+ minSupported: typeof u.minSupported === 'string' ? u.minSupported : null,+ mandatory: u.mandatory === true+ }+ return { messages, update }+}++let cache: { at: number; data: CheckResult } | null = null++export async function fetchCheck(): Promise<CheckResult> {+ if (!allowed()) return EMPTY+ const now = Date.now()+ if (cache && now - cache.at < CACHE_MS) return cache.data+ try {+ const q = new URLSearchParams({+ version: app.getVersion(),+ os: process.platform,+ channel: 'stable'+ })+ const ctrl = new AbortController()+ const t = setTimeout(() => ctrl.abort(), 8000)+ const res = await fetch(`${API_BASE}/v1/check?${q.toString()}`, {+ signal: ctrl.signal,+ cache: 'no-cache'+ }).finally(() => clearTimeout(t))+ if (!res.ok) return cache?.data ?? EMPTY+ const data = sanitize(await res.json())+ cache = { at: now, data }+ return data+ } catch {+ return cache?.data ?? EMPTY+ }+}diff --git a/src/main/index.ts b/src/main/index.tsindex 70f6e305c..570b594a2 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -10,7 +10,7 @@ import { SettingsStore } from './settings-store'import { GitService } from './git-service'import { generateCommitMessage, generateTerminalName } from './commit-message'import { initUpdater } from './updater'-import { fetchAnnouncements } from './announcements'+import { fetchCheck } from './check'import { initClaudeHooks } from './claude-hooks'import { initBridge } from './bridge'import { initTelemetry } from './telemetry'@@ -145,7 +145,8 @@ app.whenReady().then(() => {})- ipcMain.handle(IPC.announcementsFetch, () => fetchAnnouncements())+ ipcMain.handle(IPC.announcementsFetch, async () => (await fetchCheck()).messages)+ ipcMain.handle(IPC.appUpdatePolicy, async () => (await fetchCheck()).update)ipcMain.on(IPC.shellReveal, (_e, p: string) => {if (p) shell.showItemInFolder(p)diff --git a/src/preload/index.ts b/src/preload/index.tsindex 19e891a83..41942cec8 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -106,6 +106,7 @@ const api: NodeTerminalApi = {},check: () => ipcRenderer.send(IPC.appCheckForUpdates),getVersion: () => ipcRenderer.invoke(IPC.appGetVersion),+ getPolicy: () => ipcRenderer.invoke(IPC.appUpdatePolicy),restart: () => ipcRenderer.send(IPC.appRestartToUpdate)},announcements: {diff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex dd1bec976..bd67f12ce 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -28,6 +28,7 @@ export const IPC = {appUpdateNotAvailable: 'app:update-not-available',appCheckForUpdates: 'app:check-for-updates',appGetVersion: 'app:get-version',+ appUpdatePolicy: 'app:update-policy',appRestartToUpdate: 'app:restart-to-update',announcementsFetch: 'announcements:fetch',usageFetch: 'usage:fetch',diff --git a/src/shared/types.ts b/src/shared/types.tsindex b9c424892..fdda4bfac 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -285,6 +285,13 @@ export interface UpdateInfo {notes?: string}+export interface UpdatePolicy {+ /** Minimum supported version for the device's channel (or null when no policy). */+ minSupported: string | null+ /** True when the running version is below the minimum supported version. */+ mandatory: boolean+}+export interface UpdateProgress {/** 0–100. */percent: number@@ -308,6 +315,8 @@ export interface UpdateApi {check(): void/** The running app version. */getVersion(): Promise<string>+ /** The channel's mandatory-update policy for the running version (from /v1/check). */+ getPolicy(): Promise<UpdatePolicy>/** Quit and install the staged update. */restart(): void}