The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): feature-flags resolver — canary builds preview local models
ethernet3323bea86860
diff --git a/apps/desktop/electron/feature-flags.test.ts b/apps/desktop/electron/feature-flags.test.tsnew file mode 100644index 00000000000..8263a7458a7--- /dev/null+++ b/apps/desktop/electron/feature-flags.test.ts@@ -0,0 +1,32 @@+// feature-flags.ts is the single resolver for which gated surfaces are on in+// this artifact. These tests pin the flag table: launch argv opts in on any+// channel, canary builds ride along by default, stable builds stay strict.+import assert from 'node:assert/strict'++import { test } from 'vitest'++import { isCanaryTag, resolveFeatureFlags } from './feature-flags'++test('stable builds need the --local launch flag for local models', () => {+ assert.deepEqual(resolveFeatureFlags({ argv: [], canary: false }), { localModels: false })+ assert.deepEqual(resolveFeatureFlags({ argv: ['Hermes.exe'], canary: false }), { localModels: false })+})++test('--local in argv opts into local models on any channel', () => {+ assert.deepEqual(resolveFeatureFlags({ argv: ['Hermes.exe', '--local'], canary: false }), { localModels: true })+ assert.deepEqual(resolveFeatureFlags({ argv: ['--local'], canary: true }), { localModels: true })+})++test('canary builds get local models by default, no flag needed', () => {+ assert.deepEqual(resolveFeatureFlags({ argv: [], canary: true }), { localModels: true })+ assert.deepEqual(resolveFeatureFlags({ argv: ['Hermes.exe'], canary: true }), { localModels: true })+})++test('isCanaryTag recognizes canary stamps and rejects stable/dev tags', () => {+ assert.equal(isCanaryTag('v0.28.0-canary.20260818'), true)+ assert.equal(isCanaryTag('v0.28.0-canary.20260818123456'), true)+ assert.equal(isCanaryTag('v0.28.0'), false)+ assert.equal(isCanaryTag(''), false)+ assert.equal(isCanaryTag(null), false)+ assert.equal(isCanaryTag(undefined), false)+})diff --git a/apps/desktop/electron/feature-flags.ts b/apps/desktop/electron/feature-flags.tsnew file mode 100644index 00000000000..22b3731abf0--- /dev/null+++ b/apps/desktop/electron/feature-flags.ts@@ -0,0 +1,36 @@+// feature-flags.ts — the desktop's feature-flag resolver.+//+// One place that decides which gated surfaces are on for this artifact.+// Flags resolve from two inputs:+// - launch argv (e.g. `--local` on Hermes.exe, or `hermes desktop --local`)+// - the release channel of the artifact (canary builds preview features)+// The verdict is static for the process lifetime; the renderer reads it+// once via the preload bridge (`hermes:feature-flags`).++export interface FeatureFlags {+ /** Local-models GUI surfaces (settings pane, pickers, statusbar, tips). */+ localModels: boolean+}++/** True when a baked install tag names a canary-channel build. */+export function isCanaryTag(tag: string | null | undefined): boolean {+ return /-canary\./.test(tag || '')+}++export interface FeatureFlagInput {+ /** The main process argv (launch flags like `--local`). */+ argv: readonly string[]+ /** Whether this artifact is a canary-channel build. */+ canary: boolean+}++/**+ * Resolve every feature flag for this process. A flag is on when the launch+ * argv opts in (`--local`) OR the artifact is a canary build — canary is the+ * preview channel, so gated features ride along by default there.+ */+export function resolveFeatureFlags({ argv, canary }: FeatureFlagInput): FeatureFlags {+ return {+ localModels: canary || argv.includes('--local')+ }+}diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 3cb67bed530..72be6fcb1a8 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -178,6 +178,7 @@ import {tuiResumeArgs} from './external-terminal'import { type FaviconIo, resolveFavicon } from './favicon'+import { isCanaryTag, resolveFeatureFlags } from './feature-flags'import {installFindShortcut,installFoundInPageForwarder,@@ -3218,8 +3219,7 @@ function readUpdatesFeedBaseFromConfig(): string {/** The updater channel from the baked install stamp ('canary' vs 'stable'). */function resolveUpdaterChannelFromStamp(): 'stable' | 'canary' {- const tag = INSTALL_STAMP?.tag || ''- return /-canary\./.test(tag) ? 'canary' : 'stable'+ return isCanaryTag(INSTALL_STAMP?.tag) ? 'canary' : 'stable'}/** True when this artifact is the light (remote-only) variant. */@@ -17134,13 +17134,18 @@ ipcMain.on('hermes:translucency:support', event => {event.returnValue = { glass: GLASS_SUPPORTED, translucency: TRANSLUCENCY_SUPPORTED }})-// Launch-flag facts the renderer needs before first paint (same sendSync-// pattern as translucency). `--local` gates every local-models GUI surface;-// it arrives from `hermes desktop --local` or directly on Hermes.exe (a-// shortcut edit), and survives self-relaunches because collectRelaunchArgs-// only strips internal flags.-ipcMain.on('hermes:launch-flags', event => {- event.returnValue = { localModels: process.argv.includes('--local') }+// Feature-flag facts the renderer needs before first paint (same sendSync+// pattern as translucency). Resolved in feature-flags.ts from the launch+// argv and the artifact's channel: `--local` (from `hermes desktop --local`+// or directly on Hermes.exe, a shortcut edit) gates the local-models GUI on+// stable builds, and canary builds get the same surfaces by default. Launch+// flags survive self-relaunches because collectRelaunchArgs only strips+// internal flags.+ipcMain.on('hermes:feature-flags', event => {+ event.returnValue = resolveFeatureFlags({+ argv: process.argv,+ canary: resolveUpdaterChannelFromStamp() === 'canary'+ })})ipcMain.on('hermes:translucency', (_event, payload) => {diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.tsindex 8b4f2e0a6e1..3062ef19b7b 100644--- a/apps/desktop/electron/preload.ts+++ b/apps/desktop/electron/preload.ts@@ -10,14 +10,12 @@ import { contextBridge, ipcRenderer, webFrame, webUtils } from 'electron'const translucencySupport = ipcRenderer.sendSync('hermes:translucency:support')const hudWindowing = ipcRenderer.sendSync('hermes:hud:windowing')const hudNativeDrag = hudWindowing?.nativeDrag === true-const launchFlags = ipcRenderer.sendSync('hermes:launch-flags')+const featureFlags = ipcRenderer.sendSync('hermes:feature-flags')contextBridge.exposeInMainWorld('hermesDesktop', {glassSupported: translucencySupport?.glass === true,translucencySupported: translucencySupport?.translucency === true,- // Launch-flag fact: the app was started with --local, so the renderer may- // show the local-models surfaces. Static for the window's lifetime.- localModelsEnabled: launchFlags?.localModels === true,+ localModelsEnabled: featureFlags?.localModels === true,getConnection: profile => ipcRenderer.invoke('hermes:connection', profile),// Registry-scoped backend resolution: { connectionId, profile } → descriptor.getConnectionFor: payload => ipcRenderer.invoke('hermes:connection:for', payload),diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.tsindex 1ea449b0f41..c9e70d9d5d8 100644--- a/apps/desktop/src/global.d.ts+++ b/apps/desktop/src/global.d.ts@@ -301,8 +301,7 @@ declare global {glassSupported?: boolean/** Main-process fact: this OS can do any translucency at all (not Linux). */translucencySupported?: boolean- /** Launch flag: the app was started with --local, enabling the- * local-models GUI surfaces. Absent/false = every local surface hides. */+ /** Feature flag: the local-models UI is enabled. */localModelsEnabled?: booleansetTranslucency?: (payload: TranslucencyState) => voidsetKeepAwake?: (on: boolean) => voiddiff --git a/apps/desktop/src/store/local-models-flag.ts b/apps/desktop/src/store/local-models-flag.tsindex d42625f520c..a8f3d2891ec 100644--- a/apps/desktop/src/store/local-models-flag.ts+++ b/apps/desktop/src/store/local-models-flag.ts@@ -1,15 +1,13 @@import { atom } from 'nanostores'/**- * Launch-flag gate for every local-models surface in the GUI.+ * Feature-flag gate for every local-models surface in the GUI.*- * Local models ship on main behind `--local` (either `hermes desktop --local`- * or the flag on Hermes.exe itself). The flag is strict: without it the GUI- * shows no local-models surface at all, even on a machine where local models- * are configured and running — the backend routes stay live, only the- * desktop's presentation is gated. Read once from the preload bridge at- * module load; a launch flag can't change mid-session, so nothing rewrites- * it outside tests.+ * Local models ship on main when the app was launched with `--local` (either+ * `hermes desktop --local` or the flag on Hermes.exe itself), OR when this+ * is a canary build, which previews gated features by default. Without the+ * flag the Desktop App shows no local-models surface at all, even on a machine+ * where local models are configured and running.*/export const $localModelsEnabled = atom<boolean>(typeof window !== 'undefined' && window.hermesDesktop?.localModelsEnabled === true