Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,11 @@ async function writeMcpConfig(config: MCPConfigFile): Promise<void> {
import { getAllSkills } from './skills';

// Agent discovery - imported from agents module
import { getAllAgents } from './agents';
import { getAllAgents, parseAgentFrontmatter } from './agents';

// Copilot Instructions - imported from instructions module
import { getAllInstructions, getGitRoot } from './instructions';

import { getAllAgents } from './agents';

// Set up file logging only - no IPC to renderer (causes errors)
log.transports.file.level = 'info';
log.transports.console.level = 'info';
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3357,7 +3357,7 @@ Only when ALL the above are verified complete, output exactly: ${RALPH_COMPLETIO
command: isLocal ? (server as MCPLocalServerConfig).command : '',
args: isLocal ? (server as MCPLocalServerConfig).args.join(' ') : '',
url: !isLocal ? (server as MCPRemoteServerConfig).url : '',
tools: server.tools[0] === '*' ? '*' : server.tools.join(', '),
tools: server.tools?.[0] === '*' ? '*' : (server.tools || []).join(', '),
});
setShowMcpModal(true);
};
Expand Down Expand Up @@ -4567,7 +4567,7 @@ Only when ALL the above are verified complete, output exactly: ${RALPH_COMPLETIO
const isLocal =
!server.type || server.type === 'local' || server.type === 'stdio';
const toolCount =
server.tools[0] === '*' ? 'all' : `${server.tools.length}`;
server.tools?.[0] === '*' ? 'all' : `${server.tools?.length ?? 0}`;
return (
<div key={name} className="flex items-center gap-2 text-xs">
{isLocal ? (
Expand Down
69 changes: 69 additions & 0 deletions src/renderer/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react';

interface ErrorBoundaryProps {
children: React.ReactNode;
}

interface ErrorBoundaryState {
hasError: boolean;
error: Error | null;
}

export class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
constructor(props: ErrorBoundaryProps) {
super(props);
this.state = { hasError: false, error: null };
}

static getDerivedStateFromError(error: Error): ErrorBoundaryState {
return { hasError: true, error };
}

componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
console.error('[ErrorBoundary] Uncaught render error:', error, errorInfo.componentStack);
}

handleReload = (): void => {
window.location.reload();
};

handleDismiss = (): void => {
this.setState({ hasError: false, error: null });
};

render(): React.ReactNode {
if (this.state.hasError) {
return (
<div className="flex items-center justify-center h-screen bg-copilot-bg text-copilot-text">
<div className="text-center max-w-md px-6">
<h2 className="text-lg font-semibold mb-2">Something went wrong</h2>
<p className="text-sm text-copilot-text-muted mb-4">
An unexpected error occurred. You can try dismissing this or reloading the app.
</p>
{this.state.error && (
<pre className="text-xs text-copilot-error bg-copilot-surface rounded p-3 mb-4 text-left overflow-auto max-h-32">
{this.state.error.message}
</pre>
)}
<div className="flex gap-3 justify-center">
<button
onClick={this.handleDismiss}
className="px-4 py-2 text-sm rounded bg-copilot-surface hover:bg-copilot-surface-hover transition-colors"
>
Dismiss
</button>
<button
onClick={this.handleReload}
className="px-4 py-2 text-sm rounded bg-copilot-accent text-white hover:opacity-90 transition-opacity"
>
Reload
</button>
</div>
</div>
</div>
);
}

return this.props.children;
}
}
9 changes: 6 additions & 3 deletions src/renderer/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { ThemeProvider } from './context/ThemeContext';
import { ErrorBoundary } from './components/ErrorBoundary';
import './styles/global.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ThemeProvider>
<App />
</ThemeProvider>
<ErrorBoundary>
<ThemeProvider>
<App />
</ThemeProvider>
</ErrorBoundary>
</React.StrictMode>
);