fix: add missing parseAgentFrontmatter import causing black screen #341
+78
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When navigating between agents in Cooper's UI, the app goes completely black (no crash, just blank screen). The main.log shows hundreds of
ReferenceError: parseAgentFrontmatter is not definederrors.Additionally, clicking MCP servers crashes with
TypeError: Cannot read properties of undefined (reading '0')whenserver.toolsis undefined.Root Cause
Black Screen (Agent Navigation)
parseAgentFrontmatteris used at 5 locations insrc/main/main.ts(lines 879, 1577, 1875, 2731, 2842) but was never imported — onlygetAllAgentswas imported from./agents. There was also a duplicategetAllAgentsimport.The bundler (electron-vite/esbuild) renames the
agents.tsexport toparseAgentFrontmatter$1in the bundle, but the unimported direct references inmain.tsremain asparseAgentFrontmatter(undefined at runtime). This causes aReferenceErrorflood every time sessions are resumed or agents are loaded.Combined with no React ErrorBoundary in the renderer, cascading failures result in a total black screen.
MCP Panel Crash
server.tools[0]is accessed without checking ifserver.toolsis defined. TheMCPServerConfigBasetype declarestools: string[]but runtime data can havetools: undefined, causing aTypeErrorwhen opening the MCP panel.Changes
src/main/main.ts: AddedparseAgentFrontmatterto the import from./agentsand removed the duplicategetAllAgentsimportsrc/renderer/components/ErrorBoundary.tsx: New ErrorBoundary component to catch uncaught render errors and show a recovery UI instead of a black screensrc/renderer/main.tsx: Wrapped the app with ErrorBoundarysrc/renderer/App.tsx: Added optional chaining forserver.toolsaccess at two locations to prevent TypeError when MCP server config has undefined toolsErrorBoundary Recovery UI
Instead of a black screen, users now see this recovery screen when an uncaught render error occurs:
The component:
window.location.reload()Verification
TS2304: Cannot find name 'parseAgentFrontmatter'errorsparseAgentFrontmatterreferences to the same functiontoolsgracefully ✅