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(check): report the open-project count with the install counter

review0f9748a10555
diff --git a/src/core/check.test.ts b/src/core/check.test.ts
index 3ce4969a8..5f6837394 100644
--- a/src/core/check.test.ts
+++ b/src/core/check.test.ts
@@ -42,7 +42,9 @@ describe('fetchCheck — reports the plan', () => {
status: 200,
headers: { 'content-type': 'application/json' }
})
- const planOf = (call: number) => new URL(String(fetchMock.mock.calls[call][0])).searchParams.get('plan')
+ const paramsOf = (call: number) => new URL(String(fetchMock.mock.calls[call][0])).searchParams
+ const param = (call: number, key: string) => paramsOf(call).get(key)
+ const planOf = (call: number) => param(call, 'plan')
// A fresh module graph per load (the cache is module state), so the platform must be set on the
// SAME instance check.ts will import.
const loadCheck = async () => {
@@ -100,4 +102,70 @@ describe('fetchCheck — reports the plan', () => {
premium.value = true
expect(await fetchCheck()).toEqual({ messages: [], update: { minSupported: '0.5.0', mandatory: false } })
})
+
+ // The open-project count rides the same call, but — unlike the install count above — only while
+ // the Settings → Privacy telemetry toggle is on, and only as a bare number. Its server side keeps
+ // the per-install maximum (the data the project-limit allowance is computed from).
+ describe('openProjects', () => {
+ beforeEach(() => fetchMock.mockResolvedValue(feed('x')))
+
+ it('sends openProjects when telemetry is on and the count is known', async () => {
+ const m = await loadCheck()
+ m.configureCheck({ openProjects: () => 7, telemetryEnabled: () => true })
+ await m.fetchCheck()
+ expect(param(0, 'openProjects')).toBe('7')
+ })
+
+ it('omits it when telemetry is off', async () => {
+ const m = await loadCheck()
+ m.configureCheck({ openProjects: () => 7, telemetryEnabled: () => false })
+ await m.fetchCheck()
+ expect(param(0, 'openProjects')).toBeNull()
+ })
+
+ it('omits it before the index is loaded', async () => {
+ const m = await loadCheck()
+ m.configureCheck({ openProjects: () => undefined, telemetryEnabled: () => true })
+ await m.fetchCheck()
+ expect(param(0, 'openProjects')).toBeNull()
+ })
+
+ it('omits it when never configured', async () => {
+ const m = await loadCheck()
+ await m.fetchCheck()
+ expect(param(0, 'openProjects')).toBeNull()
+ })
+
+ it('omits a count that is not a non-negative integer', async () => {
+ for (const n of [-1, 2.5, Number.NaN, Number.POSITIVE_INFINITY]) {
+ fetchMock.mockClear()
+ const m = await loadCheck()
+ m.configureCheck({ openProjects: () => n, telemetryEnabled: () => true })
+ await m.fetchCheck()
+ expect(param(0, 'openProjects')).toBeNull()
+ }
+ })
+
+ it('sends a count of zero', async () => {
+ const m = await loadCheck()
+ m.configureCheck({ openProjects: () => 0, telemetryEnabled: () => true })
+ await m.fetchCheck()
+ expect(param(0, 'openProjects')).toBe('0')
+ })
+
+ it('sends nothing else new', async () => {
+ const m = await loadCheck()
+ m.configureCheck({ openProjects: () => 7, telemetryEnabled: () => true })
+ await m.fetchCheck()
+ expect([...paramsOf(0).keys()].sort()).toEqual([
+ 'arch',
+ 'channel',
+ 'deviceId',
+ 'openProjects',
+ 'os',
+ 'plan',
+ 'version'
+ ])
+ })
+ })
})
diff --git a/src/core/check.ts b/src/core/check.ts
index b163c8491..5e27a2123 100644
--- a/src/core/check.ts
+++ b/src/core/check.ts
@@ -5,6 +5,9 @@
// passive active-install counter — so the version distribution reflects EVERY install, not only
// the (few) that also opt into the telemetry ping. It also states the plan (`pro` | `free`) so a
// message can be aimed at paid or free users; the backend matches on it and does not store it.
+// While the Settings → Privacy telemetry toggle is on it also carries the open-project count
+// (`openProjects`, a bare number — never names, paths or hosts); the backend keeps the per-install
+// maximum, the data the project-limit allowance is computed from. See `configureCheck`.
// 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 { platform } from './platform'
@@ -26,7 +29,7 @@ const EMPTY: CheckResult = { messages: [], update: { minSupported: null, mandato
// server is targeted explicitly. Deliberately NOT gated on the in-app telemetry toggle: this
// call always runs (content delivery + the anonymous install count), so an install still counts
// even if the user never opts into the detailed telemetry ping. The env kill-switches above are
-// the hard off.
+// the hard off. The one field that IS gated on the toggle is `openProjects` (`openProjectsParam`).
function allowed(): boolean {
if (process.env.DO_NOT_TRACK || process.env.NODETERM_TELEMETRY_DISABLED) return false
if (!platform().isPackaged && !process.env.NODETERM_API_BASE) return false
@@ -66,6 +69,30 @@ const NOTES_MAX = 16 * 1024
/** Test seam: the sanitizer is the whole contract with the feed's shape. */
export const sanitizeCheckForTest = sanitize
+export interface CheckDeps {
+ /** Open projects in the workspace index (`WorkspaceStore.openProjectCount`); undefined = unknown
+ * (index not loaded yet, or never saved in v3 form), and an unknown count is never sent. */
+ openProjects: () => number | undefined
+ /** `settings.telemetryEnabled` — the count is sent only while it is exactly true. */
+ telemetryEnabled: () => boolean
+}
+
+// Set once by the shell at boot; read per call, so a toggle flip or a project open/close takes
+// effect on the next uncached fetch. Never configured = the count is never sent.
+let deps: CheckDeps | null = null
+
+export function configureCheck(next: CheckDeps): void {
+ deps = next
+}
+
+// `openProjects=<n>` only when configured, the telemetry toggle is on and `n` is a non-negative
+// integer. Nothing else is added.
+function openProjectsParam(): Record<string, string> {
+ if (!deps || deps.telemetryEnabled() !== true) return {}
+ const n = deps.openProjects()
+ return typeof n === 'number' && Number.isInteger(n) && n >= 0 ? { openProjects: String(n) } : {}
+}
+
type Plan = 'pro' | 'free'
// The plan the response was fetched for. The backend aims messages at paid or free users by the
@@ -90,7 +117,8 @@ export async function fetchCheck(): Promise<CheckResult> {
os: process.platform,
arch: process.arch,
channel: 'stable',
- plan
+ plan,
+ ...openProjectsParam()
})
const ctrl = new AbortController()
const t = setTimeout(() => ctrl.abort(), 8000)
diff --git a/src/main/index.ts b/src/main/index.ts
index ab0f75f51..e68310ab8 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -177,7 +177,7 @@ import {
} from '../core/commit-message'
import { initUpdater, type UpdaterHandle } from './updater'
import { requestRendererFlush } from './renderer-flush'
-import { fetchCheck } from '../core/check'
+import { configureCheck, fetchCheck } from '../core/check'
import {
hookServer,
OPEN_PROJECT_CONTROL_REFUSAL,
@@ -2054,6 +2054,12 @@ app.whenReady().then(async () => {
if (target) void shell.openExternal(target)
})
+ // The open-project count rides /v1/check only while the Settings → Privacy telemetry toggle is
+ // on, and only once the workspace index is known (core/check.ts). Both read per call.
+ configureCheck({
+ openProjects: () => workspaceStore.openProjectCount(),
+ telemetryEnabled: () => settingsStore.get().telemetryEnabled
+ })
ipcMain.handle(IPC.announcementsFetch, async () => (await fetchCheck()).messages)
ipcMain.handle(IPC.appUpdatePolicy, async () => (await fetchCheck()).update)
diff --git a/src/renderer/components/settings/sections/PrivacySection.test.tsx b/src/renderer/components/settings/sections/PrivacySection.test.tsx
new file mode 100644
index 000000000..de6c75331
--- /dev/null
+++ b/src/renderer/components/settings/sections/PrivacySection.test.tsx
@@ -0,0 +1,43 @@
+// @vitest-environment jsdom
+//
+// Settings → Privacy is where the user learns what the telemetry toggle sends. The open-project
+// count rides /v1/check only while this toggle is on (core/check.ts), so the row must say so —
+// and say it is a number only — before the first count is ever sent (spec §9).
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+let root: Root
+let host: HTMLElement
+
+beforeEach(() => {
+ vi.resetModules()
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+})
+
+afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+})
+
+async function renderSection(): Promise<string> {
+ const { PrivacySection } = await import('./PrivacySection')
+ act(() => root.render(<PrivacySection isActive />))
+ return host.textContent ?? ''
+}
+
+describe('Privacy → telemetry row', () => {
+ it('names the open-project count in its label', async () => {
+ expect(await renderSection()).toContain('Send anonymous usage data (version/OS, open-project count)')
+ })
+
+ it('says the count is a number only, and how to fully disable', async () => {
+ expect(await renderSection()).toContain(
+ 'No personal data; client IP is never stored. Used to see which versions are in use and how many projects people keep open (a number only — never names, paths or hosts). A lighter anonymous install count runs regardless; fully disable with the DO_NOT_TRACK environment variable.'
+ )
+ })
+})
diff --git a/src/renderer/components/settings/sections/PrivacySection.tsx b/src/renderer/components/settings/sections/PrivacySection.tsx
index ee2b09b25..066158f27 100644
--- a/src/renderer/components/settings/sections/PrivacySection.tsx
+++ b/src/renderer/components/settings/sections/PrivacySection.tsx
@@ -19,8 +19,8 @@ export function PrivacySection({ isActive }: { isActive: boolean }): React.JSX.E
<SettingsSection id="privacy" title="Privacy" isActive={isActive} searchEntries={ENTRIES}>
<SearchableRow {...ROWS.telemetry}>
<FieldRow
- label="Send anonymous usage data (version/OS)"
- description="No personal data; client IP is never stored. Used only to see which versions are in use. A lighter anonymous install count runs regardless; fully disable with the DO_NOT_TRACK environment variable."
+ label="Send anonymous usage data (version/OS, open-project count)"
+ description="No personal data; client IP is never stored. Used to see which versions are in use and how many projects people keep open (a number only — never names, paths or hosts). A lighter anonymous install count runs regardless; fully disable with the DO_NOT_TRACK environment variable."
control={
<Switch
checked={telemetryEnabled}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index ff6ecce2f..a90e9e402 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -2353,8 +2353,9 @@ export interface Settings {
* footprint across restarts. Independent of manual "Pause session", which always persists this
* way regardless of this setting. */
agentHibernationPersistAcrossRestart: boolean
- /** Send anonymous usage data (version/OS) to the telemetry backend. Opt-OUT (default on):
- * version/OS only, nothing personal, client IP never stored. Turn it off in Settings → Privacy
+ /** Send anonymous usage data: the version/OS telemetry ping, and the open-project count on the
+ * /v1/check call (`openProjects`, a number only — never names, paths or hosts). Opt-OUT
+ * (default on): nothing personal, client IP never stored. Turn it off in Settings → Privacy
* (or hard-disable with DO_NOT_TRACK / NODETERM_TELEMETRY_DISABLED). Note: a lighter anonymous
* install count also rides the /v1/check call and is NOT gated on this toggle — see core/check.ts. */
telemetryEnabled: boolean