{"record":{"id":"1f682329ebca5780","repo":"Molunerfinn/PicGo","slug":"failed-to-update-shortcut-shortcutid","errorCode":null,"errorMessage":"Failed to update shortcut: ${shortcutId}","messagePattern":"Failed to update shortcut: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/store/settings/actions.ts","lineNumber":125,"sourceCode":"      defaultSettingsConfig.shortKey\n    const targetShortcut = currentShortKey[shortcutId]\n\n    if (!targetShortcut) {\n      throw new Error(`Shortcut not found: ${shortcutId}`)\n    }\n\n    const nextKey = keys.join('+')\n    const [from = 'picgo'] = shortcutId.split(':')\n    const didUpdate = await settingsAdapter.updateShortcut({\n      enable: targetShortcut.enable,\n      key: nextKey,\n      label: targetShortcut.label,\n      name: targetShortcut.name,\n      from\n    }, targetShortcut.key)\n\n    if (!didUpdate) {\n      throw new Error(`Failed to update shortcut: ${shortcutId}`)\n    }\n\n    updateSettingsState({\n      shortKey: {\n        ...currentShortKey,\n        [shortcutId]: {\n          ...targetShortcut,\n          key: nextKey\n        }\n      }\n    })\n  },\n  async setShortcutEnabled (shortcutId: string, enable: boolean) {\n    await appActions.ensureSettingsHydrated()\n    const currentShortKey =\n      useAppStore.getState().appConfig?.settings.shortKey ??\n      defaultSettingsConfig.shortKey\n    const targetShortcut = currentShortKey[shortcutId]","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/Molunerfinn/PicGo/blob/07ec7068a5512344da093d49a8408fa63ba3421e/src/renderer/store/settings/actions.ts#L107-L143","documentation":"updateShortcutKeys calls settingsAdapter.updateShortcut(...) which registers the new global shortcut in the main process and returns a boolean didUpdate. This error is thrown when the adapter returns false — the shortcut could not be registered/updated, most commonly because the key combination is already bound by another application or another PicGo shortcut. Note the local shortKey state is only mutated after this check, so no partial update occurs.","triggerScenarios":"Calling updateShortcutKeys(shortcutId, keys) where the joined keys (keys.join('+')) collide with an OS-level or in-app reserved shortcut, causing the main process globalShortcut.register to fail and the adapter to resolve false.","commonSituations":"User picks a combination already owned by the OS or another app (e.g. Cmd+Shift+4 on macOS); assigning the same combination to two PicGo shortcuts; Electron failing to register accelerators with unsupported modifier combos.","solutions":["Choose a different key combination that is not already registered by the OS or another app.","Check for duplicate assignments among PicGo's own shortcuts before saving.","Catch this error in the UI and show a 'shortcut in use' message with the offending shortcutId.","Verify Electron can register the accelerator format (valid modifiers like CommandOrControl/Alt/Shift plus a key)."],"exampleFix":"// before\nawait settingsStoreActions.updateShortcutKeys(shortcutId, keys)\n\n// after\ntry {\n  await settingsStoreActions.updateShortcutKeys(shortcutId, keys)\n} catch (err) {\n  toast.error(`${(err as Error).message} — key combination may already be in use`)\n}","handlingStrategy":"try-catch","validationCode":"const combo = keys.join('+')\nconst duplicate = Object.entries(shortKey).some(\n  ([id, cfg]) => id !== shortcutId && cfg.key === combo\n)\nif (duplicate) {\n  // combination already used by another PicGo shortcut\n  return\n}","typeGuard":"function isRegistrationFailure(\n  didUpdate: boolean | undefined\n): didUpdate is false {\n  return didUpdate !== true\n}","tryCatchPattern":"try {\n  await settingsStoreActions.updateShortcutKeys(shortcutId, keys)\n} catch (err) {\n  if ((err as Error).message.startsWith('Failed to update shortcut')) {\n    toast.error(i18n.t('SHORTCUT_IN_USE', { shortcutId }))\n  }\n}","preventionTips":["Offer only key combos Electron globalShortcut can register (valid modifier + key).","Check for duplicate combos across all PicGo shortcuts before saving.","Warn users that OS-reserved shortcuts (screenshots, etc.) cannot be bound.","Catch the failure and keep the previous binding instead of leaving the shortcut unbound."],"tags":["shortcut","hotkey","registration","os-conflict"],"backgroundTag":"shortcut-registration-failed","analyzedSha":"07ec7068a5512344da093d49a8408fa63ba3421e","analyzedAt":"2026-08-30T01:45:22.289Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}