The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): add option to disable F12 DevTools shortcut
Hermes Agentd4fa3f735277
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 20ce3757e55..d42ab7ed74f 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -321,6 +321,10 @@ const IS_WSL = isWslEnvironment()const DARWIN_MAJOR = IS_MAC ? Number.parseInt(os.release(), 10) || 0 : 0const APP_ROOT = app.getAppPath()+// Device-local preference: block F12 from opening DevTools.+// Set dynamically via IPC from the renderer Settings → Advanced.+let f12Blocked = false+// Preload must be plain JS — Electron's sandbox can't run .ts, and tsx's// ESM loader is broken on Electron 40's Node (ERR_INVALID_RETURN_PROPERTY_VALUE).// Dev (`npm run dev`) and prod both load the esbuild output from dist/.@@ -5820,7 +5824,11 @@ function buildApplicationMenu() {submenu: [{ role: 'reload' },{ role: 'forceReload' },- { role: 'toggleDevTools' },+ {+ label: 'Toggle Developer Tools',+ accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Ctrl+Shift+I',+ click: () => toggleDevTools(mainWindow)+ },{ type: 'separator' },{label: 'Actual Size',@@ -5881,10 +5889,20 @@ function toggleDevTools(window) {}function installDevToolsShortcut(window) {- // F12 / Cmd+Opt+I works in both dev and packaged builds.+ // Only Ctrl+Shift+I (or Cmd+Opt+I on Mac) opens DevTools.+ // F12 is explicitly blocked so Chromium's built-in handler doesn't open it.window.webContents.on('before-input-event', (event, input) => {const key = input.key.toLowerCase()+ // F12 opens DevTools by default; block only when the user disabled it.+ if (input.key === 'F12') {+ if (f12Blocked) {+ event.preventDefault()+ return+ }+ // Not blocked — fall through to open DevTools.+ }+const isInspectShortcut =input.key === 'F12' ||(IS_MAC && input.meta && input.alt && key === 'i') ||@@ -11261,6 +11279,8 @@ ipcMain.on('hermes:zoom:set-percent', (event, percent) => {// content origin so the pet lands where it sat in-window. A remembered/dragged// spot passes screen-space bounds (screen=true) and is used as-is. We return the// resolved screen bounds so the renderer can persist exactly where it opened.+ipcMain.on('hermes:devtools:disable-f12', (_event, blocked) => { f12Blocked = blocked })+ipcMain.handle('hermes:pet-overlay:open', async (_event, request) => {const bounds = request && request.bounds ? request.bounds : requestconst isScreen = Boolean(request && request.screen)diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.tsindex 86f61263877..72173637293 100644--- a/apps/desktop/electron/preload.ts+++ b/apps/desktop/electron/preload.ts@@ -184,6 +184,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {setNativeTheme: mode => ipcRenderer.send('hermes:native-theme', mode),setTranslucency: payload => ipcRenderer.send('hermes:translucency', payload),setKeepAwake: on => ipcRenderer.send('hermes:keep-awake', on),+ setDisableF12: blocked => ipcRenderer.send('hermes:devtools:disable-f12', blocked),setPreviewShortcutActive: active => ipcRenderer.send('hermes:previewShortcutActive', Boolean(active)),openExternal: url => ipcRenderer.invoke('hermes:openExternal', url),openPreviewInBrowser: url => ipcRenderer.invoke('hermes:openPreviewInBrowser', url),diff --git a/apps/desktop/src/app/settings/config-settings.tsx b/apps/desktop/src/app/settings/config-settings.tsxindex 6e8bfcf9d76..d2d0adb66cb 100644--- a/apps/desktop/src/app/settings/config-settings.tsx+++ b/apps/desktop/src/app/settings/config-settings.tsx@@ -19,6 +19,7 @@ import {setDataUrlReadMaxMb} from '@/store/data-url-read-max'import { $keepAwake, setKeepAwake } from '@/store/keep-awake'+import { $disableF12, setDisableF12 } from '@/store/disable-f12'import { notify, notifyError } from '@/store/notifications'import { repoDiscoveryPolicyFromConfig, repoDiscoveryPolicySignature, scanAndRecordRepos } from '@/store/projects'import type { ConfigFieldSchema, HermesConfigRecord } from '@/types/hermes'@@ -76,6 +77,7 @@ export function ConfigSettings({const { t } = useI18n()const c = t.settings.configconst keepAwake = useStore($keepAwake)+ const disableF12 = useStore($disableF12)// The editable draft is local (debounced autosave watches it), but it's seeded// from — and saved back through — the shared config cache, so edits are visible// in the MCP/model surfaces and reopening the page doesn't reload-flash.@@ -329,6 +331,12 @@ export function ConfigSettings({label={c.keepAwakeTitle}onChange={setKeepAwake}/>+ <ToggleRow+ checked={disableF12}+ description={c.disableF12Desc}+ label={c.disableF12Title}+ onChange={setDisableF12}+ /><QuickEntrySettings /></>)}diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.tsindex 14f16b3eff8..2ebb647d906 100644--- a/apps/desktop/src/global.d.ts+++ b/apps/desktop/src/global.d.ts@@ -203,6 +203,7 @@ declare global {setNativeTheme?: (mode: 'dark' | 'light' | 'system') => voidsetTranslucency?: (payload: { intensity: number }) => voidsetKeepAwake?: (on: boolean) => void+ setDisableF12?: (blocked: boolean) => voidsetPreviewShortcutActive?: (active: boolean) => voidopenExternal: (url: string) => Promise<void>openPreviewInBrowser?: (url: string) => Promise<void>diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex c56875e6dac..1b9918f63fd 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -598,6 +598,8 @@ export const en: Translations = {'Remove all enabled toolsets? This disables memory, terminal, web search, delegation, and most other tools until you re-enable them.',keepAwakeTitle: 'Keep computer awake',keepAwakeDesc: 'Stop this machine from sleeping so long or overnight runs keep going. The display can still dim.',+ disableF12Title: 'Disable F12 DevTools',+ disableF12Desc: 'Block F12 from opening Developer Tools. Ctrl+Shift+I (or Cmd+Opt+I on Mac) still works.',attachmentSizeTitle: 'Max preview / image load size',attachmentSizeDesc:'How big a local file Desktop will load for previews and image attach, in MB. Default is 16. Remote non-image attach uses a separate 256 MB cap. Setting this very high loads the whole file into memory and can freeze or crash the app.',diff --git a/apps/desktop/src/store/disable-f12.ts b/apps/desktop/src/store/disable-f12.tsnew file mode 100644index 00000000000..5686cfc3958--- /dev/null+++ b/apps/desktop/src/store/disable-f12.ts@@ -0,0 +1,26 @@+/**+ * Disable F12 DevTools shortcut — a device-local preference.+ *+ * When enabled, F12 is blocked in the main process (before-input-event).+ * Ctrl+Shift+I (or Cmd+Opt+I on Mac) still works regardless.+ * Mirrors the toggle to the main process via IPC.+ */++import { atom } from 'nanostores'++import { persistBoolean, storedBoolean } from '@/lib/storage'++const KEY = 'hermes.desktop.disableF12.v1'++export const $disableF12 = atom<boolean>(typeof window === 'undefined' ? false : storedBoolean(KEY, false))++export function setDisableF12(on: boolean): void {+ $disableF12.set(on)+}++if (typeof window !== 'undefined') {+ $disableF12.subscribe(on => {+ persistBoolean(KEY, on)+ window.hermesDesktop?.setDisableF12?.(on)+ })+}