Skip to content

The agent that grows with you

fix: address review feedback on Disable F12 DevTools PR

kas-cor3b5d5e48d12d
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index d42ab7ed74f..f518d14605b 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -5827,7 +5827,7 @@ function buildApplicationMenu() {
{
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Ctrl+Shift+I',
- click: () => toggleDevTools(mainWindow)
+ click: (_menuItem, browserWindow) => toggleDevTools(browserWindow || mainWindow)
},
{ type: 'separator' },
{
@@ -11279,8 +11279,6 @@ 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 : request
const isScreen = Boolean(request && request.screen)
@@ -12676,6 +12674,30 @@ ipcMain.on('hermes:quick-entry:state', (_event, payload) => {
ipcMain.on('hermes:quick-entry:dismiss', () => hideQuickEntryWindow())
+// Disable F12 DevTools: maintained in the main process so a cold launch
+// restores it before any window is shown (applied on ready). The renderer
+// toggles it from Settings → Advanced over IPC. See store/disable-f12.
+const DISABLE_F12_CONFIG_PATH = path.join(app.getPath('userData'), 'disable-f12.json')
+
+function readPersistedDisableF12() {
+ try {
+ return JSON.parse(fs.readFileSync(DISABLE_F12_CONFIG_PATH, 'utf8')).on === true
+ } catch {
+ return false
+ }
+}
+
+ipcMain.on('hermes:devtools:disable-f12', (_event, on) => {
+ f12Blocked = Boolean(on)
+
+ try {
+ fs.mkdirSync(path.dirname(DISABLE_F12_CONFIG_PATH), { recursive: true })
+ fs.writeFileSync(DISABLE_F12_CONFIG_PATH, JSON.stringify({ on: f12Blocked }, null, 2), 'utf8')
+ } catch (error) {
+ rememberLog(`[disable-f12] write failed: ${error.message}`)
+ }
+})
+
ipcMain.handle('hermes:openExternal', (_event, url) => {
if (!openExternalUrl(url)) {
throw new Error('Invalid external URL')
@@ -13808,6 +13830,7 @@ app.whenReady().then(() => {
configureSpellChecker()
registerPowerResumeListeners()
keepAwake.set(readPersistedKeepAwake())
+ f12Blocked = readPersistedDisableF12()
// Quick Entry's global chord — registered on ready so a cold launch restores
// it without the renderer visiting Settings. A failed registration is logged
// here and surfaced in Settings via the IPC state (never silent).
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index dcb27056c22..835b8d664f0 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -492,6 +492,8 @@ export interface Translations {
toolsetsWipeConfirm: string
keepAwakeTitle: string
keepAwakeDesc: string
+ disableF12Title: string
+ disableF12Desc: string
attachmentSizeTitle: string
attachmentSizeDesc: string
attachmentSizeUnit: string