Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(shell): a screen that fails to load no longer reports a canvas error
trohitgf5a2b5e94688
diff --git a/client/src/app/ShellModeSwitch.tsx b/client/src/app/ShellModeSwitch.tsxindex dbf7b85c..ab2540c3 100644--- a/client/src/app/ShellModeSwitch.tsx+++ b/client/src/app/ShellModeSwitch.tsx@@ -72,7 +72,13 @@ export function ShellModeSwitch() {const mode = useShellMode();return (<ShellScreen key={mode} mode={mode}>- <ErrorBoundary>+ {/* A screen whose chunk failed to load stays failed (React.lazy keeps+ the error), so the card also points at Reload. */}+ <ErrorBoundary+ title="This screen didn't load"+ description="Try again, or reload the page if it still doesn't load."+ resetLabel="Try again"+ ><Suspense fallback={<ScreenLoading />}>{mode === 'normal' ? <LazyHome /> : <LazyEditor />}</Suspense></ErrorBoundary></ShellScreen>diff --git a/client/src/app/__tests__/screenLoadFailure.test.tsx b/client/src/app/__tests__/screenLoadFailure.test.tsxnew file mode 100644index 00000000..ed07442c--- /dev/null+++ b/client/src/app/__tests__/screenLoadFailure.test.tsx@@ -0,0 +1,37 @@+/**+ * A screen whose chunk fails to load (a tab left open across a dev-server+ * restart, or across an upgrade) shows the shell's card, not the canvas one.+ */++import { render, screen } from '@testing-library/react';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++vi.mock('../../lib/featureFlags', () => ({ featureFlags: { normalMode: true, nodeSpecBackend: true } }));+vi.mock('../../Dashboard', () => ({ default: () => <div>Workflow editor</div> }));+vi.mock('../../features/home/HomeShell', () => {+ throw new TypeError('Failed to fetch dynamically imported module: /src/features/home/HomeShell.tsx');+});++import { useAppStore } from '../../store/useAppStore';+import { ShellModeSwitch } from '../ShellModeSwitch';++beforeEach(() => {+ vi.spyOn(console, 'error').mockImplementation(() => {});+ useAppStore.setState({ shellMode: 'normal' });+});++afterEach(() => {+ vi.restoreAllMocks();+});++describe('a screen that fails to load', () => {+ it('says the screen did not load and offers Try again and Reload', async () => {+ render(<ShellModeSwitch />);++ expect(await screen.findByText("This screen didn't load")).toBeInTheDocument();+ expect(screen.getByText("Try again, or reload the page if it still doesn't load.")).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Try again' })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Reload Page' })).toBeInTheDocument();+ expect(screen.queryByText('Canvas Error Detected')).not.toBeInTheDocument();+ });+});diff --git a/client/src/components/ui/ErrorBoundary.tsx b/client/src/components/ui/ErrorBoundary.tsxindex 803e3dcf..ccdae05e 100644--- a/client/src/components/ui/ErrorBoundary.tsx+++ b/client/src/components/ui/ErrorBoundary.tsx@@ -7,6 +7,10 @@ import { Card, CardContent } from '@/components/ui/card';interface Props {children: ReactNode;fallback?: ReactNode;+ /** The card's wording. The defaults describe the workflow canvas. */+ title?: string;+ description?: string;+ resetLabel?: string;}interface State {@@ -38,6 +42,11 @@ class ErrorBoundary extends Component<Props, State> {public render() {if (!this.state.hasError) return this.props.children;if (this.props.fallback) return this.props.fallback;+ const {+ title = 'Canvas Error Detected',+ description = 'The workflow canvas encountered an error and needs to be reset. Your workflow data is safe and will be restored.',+ resetLabel = 'Reset Canvas',+ } = this.props;return (<div className="flex h-full w-full items-center justify-center bg-background p-8">@@ -45,17 +54,14 @@ class ErrorBoundary extends Component<Props, State> {<CardContent className="space-y-4 p-6 text-center"><Alert variant="destructive"><AlertTriangle className="h-4 w-4" />- <AlertTitle>Canvas Error Detected</AlertTitle>- <AlertDescription>- The workflow canvas encountered an error and needs to be reset.- Your workflow data is safe and will be restored.- </AlertDescription>+ <AlertTitle>{title}</AlertTitle>+ <AlertDescription>{description}</AlertDescription></Alert><div className="flex flex-wrap justify-center gap-3"><Button onClick={this.handleReset}><RotateCcw className="h-4 w-4" />- Reset Canvas+ {resetLabel}</Button><Button variant="outline" onClick={this.handleReload}><RefreshCw className="h-4 w-4" />