{"record":{"id":"03d387a809931f62","repo":"cjpais/Handy","slug":"failed-to-show-main-window-for-permission-onboardi","errorCode":null,"errorMessage":"Failed to show main window for permission onboarding:","messagePattern":"Failed to show main window for permission onboarding:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/App.tsx","lineNumber":180,"sourceCode":"            model:\n              event.payload.model_name || t(\"errors.modelLoadFailedUnknown\"),\n          }),\n          {\n            description: event.payload.error,\n          },\n        );\n      }\n    });\n    return () => {\n      unlisten.then((fn) => fn());\n    };\n  }, [t]);\n\n  const revealMainWindowForPermissions = async () => {\n    try {\n      await commands.showMainWindowCommand();\n    } catch (e) {\n      console.warn(\"Failed to show main window for permission onboarding:\", e);\n    }\n  };\n\n  const checkOnboardingStatus = async () => {\n    try {\n      const settingsResult = await commands.getAppSettings();\n      const hasCompletedOnboarding =\n        settingsResult.status === \"ok\" &&\n        settingsResult.data.onboarding_completed === true;\n      const currentPlatform = platform();\n\n      if (hasCompletedOnboarding) {\n        // Returning user - check if they need to grant permissions first\n        setIsReturningUser(true);\n\n        if (currentPlatform === \"macos\") {\n          try {\n            const [hasAccessibility, hasMicrophone] = await Promise.all([","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/cjpais/Handy/blob/c89b7bf38974ad317177389f5bfe28236f0d64e3/src/App.tsx#L162-L198","documentation":"revealMainWindowForPermissions invokes the showMainWindowCommand Tauri command to bring the main window forward when permission onboarding needs attention. A rejection lands in this catch; the onboarding flow continues, but the settings/permission window may remain hidden behind other windows or minimized, so the user sees an app that started without any visible window.","triggerScenarios":"The invoke rejecting because the main window label was renamed/removed from tauri.conf.json while the command still targets the old label; invoking during app shutdown; the command missing from the invoke_handler in a trimmed build; browser-context dev where invoke always rejects.","commonSituations":"Window-label refactors; startup races on slow machines; --start-hidden runs where the window is expected to stay hidden and the call is arguably wrong anyway.","solutions":["Confirm the label showMainWindowCommand targets matches the main window label in tauri.conf.json","Respect --start-hidden: skip the reveal when the user explicitly requested a hidden start","Retry once after a short delay to cover startup races","Log the raw error to distinguish 'window not found' from 'command not found'"],"exampleFix":"// before\ntry {\n  await commands.showMainWindowCommand();\n} catch (e) {\n  console.warn(\"Failed to show main window for permission onboarding:\", e);\n}\n\n// after\nfor (const delay of [0, 1000]) {\n  try {\n    if (delay) await new Promise((r) => setTimeout(r, delay));\n    await commands.showMainWindowCommand();\n    break;\n  } catch (e) {\n    if (delay) console.warn(\"Failed to show main window for permission onboarding:\", e);\n  }\n}","handlingStrategy":"retry","validationCode":"import { isTauri } from \"@tauri-apps/api/core\";\nif (!isTauri()) return;","typeGuard":null,"tryCatchPattern":"try { await commands.showMainWindowCommand(); }\ncatch (e) {\n  console.warn(\"Failed to show main window for permission onboarding:\", e);\n  setTimeout(() => void commands.showMainWindowCommand().catch(() => {}), 1000);\n}","preventionTips":["Keep window labels in tauri.conf.json in sync with commands that reference them","Respect --start-hidden so the reveal is not fought by the user's own launch flag","Distinguish 'window not found' from 'command not found' in the logged error before changing code"],"tags":["tauri","window-management","onboarding","invoke"],"backgroundTag":"tauri-command-invoke-failed","analyzedSha":"c89b7bf38974ad317177389f5bfe28236f0d64e3","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}