Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
fix(#768): add ErrorBoundary to workspace Suspense blocks
Sameer63059a21e523f049
diff --git a/explorer/src/App.tsx b/explorer/src/App.tsxindex 3f2b7331..f3f97520 100644--- a/explorer/src/App.tsx+++ b/explorer/src/App.tsx@@ -1,4 +1,4 @@-import { lazy, Suspense, useEffect, useState, type ReactNode } from 'react';+import { lazy, Suspense, useEffect, useState, type ReactNode } from 'react';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import {ArrowRight,@@ -16,6 +16,7 @@ import {ShieldCheck,type LucideIcon,} from 'lucide-react';+import { ErrorBoundary } from './ErrorBoundary';const DecisionWorkspace = lazy(() => import('./workspaces/DecisionWorkspace/DecisionWorkspace').then((module) => ({ default: module.DecisionWorkspace })));const DiffMergeWorkspace = lazy(() => import('./workspaces/DiffMergeWorkspace/DiffMergeWorkspace').then((module) => ({ default: module.DiffMergeWorkspace })));@@ -1800,14 +1801,16 @@ export default function App() {</>}>- <Suspense fallback={<WorkspaceFallback />}>- {exploreView === 'graph' ? (- <GraphWorkspace- externalFocusNodeId={graphFocusRequest?.nodeId}- externalFocusToken={graphFocusRequest?.token}- />- ) : <VocabularyWorkspace />}- </Suspense>+ <ErrorBoundary key={`explore-${exploreView}`}>+ <Suspense fallback={<WorkspaceFallback />}>+ {exploreView === 'graph' ? (+ <GraphWorkspace+ externalFocusNodeId={graphFocusRequest?.nodeId}+ externalFocusToken={graphFocusRequest?.token}+ />+ ) : <VocabularyWorkspace />}+ </Suspense>+ </ErrorBoundary></WorkspaceShell>);}@@ -1829,9 +1832,11 @@ export default function App() {</>}>- <Suspense fallback={<WorkspaceFallback />}>- {analyzeView === 'reasoning' ? <ReasoningWorkspace /> : <SparqlWorkspace />}- </Suspense>+ <ErrorBoundary key={`analyze-${analyzeView}`}>+ <Suspense fallback={<WorkspaceFallback />}>+ {analyzeView === 'reasoning' ? <ReasoningWorkspace /> : <SparqlWorkspace />}+ </Suspense>+ </ErrorBoundary></WorkspaceShell>);}@@ -1843,9 +1848,11 @@ export default function App() {subtitle="Inspect decision chains, causal context, and precedent matches."kicker="Decision Intelligence">- <Suspense fallback={<WorkspaceFallback />}>- <DecisionWorkspace />- </Suspense>+ <ErrorBoundary key="decisions">+ <Suspense fallback={<WorkspaceFallback />}>+ <DecisionWorkspace />+ </Suspense>+ </ErrorBoundary></WorkspaceShell>);}@@ -1873,12 +1880,14 @@ export default function App() {</>}>- <Suspense fallback={<WorkspaceFallback />}>- {enrichView === 'import' ? <ImportExportWorkspace /> :- enrichView === 'merge' ? <DiffMergeWorkspace /> :- enrichView === 'resolve' ? <EntityResolutionTab /> :- <RegistryTab />}- </Suspense>+ <ErrorBoundary key={`enrich-${enrichView}`}>+ <Suspense fallback={<WorkspaceFallback />}>+ {enrichView === 'import' ? <ImportExportWorkspace /> :+ enrichView === 'merge' ? <DiffMergeWorkspace /> :+ enrichView === 'resolve' ? <EntityResolutionTab /> :+ <RegistryTab />}+ </Suspense>+ </ErrorBoundary></WorkspaceShell>);}@@ -1891,15 +1900,17 @@ export default function App() {kicker="Schema Governance"compact>- <Suspense fallback={<WorkspaceFallback />}>- <OntologyWorkspace- onJumpToGraphNode={(nodeId: string) => {- setGraphFocusRequest({ nodeId, token: Date.now() });- setActiveWorkspace('explore');- setExploreView('graph');- }}- />- </Suspense>+ <ErrorBoundary key="ontology-hub">+ <Suspense fallback={<WorkspaceFallback />}>+ <OntologyWorkspace+ onJumpToGraphNode={(nodeId: string) => {+ setGraphFocusRequest({ nodeId, token: Date.now() });+ setActiveWorkspace('explore');+ setExploreView('graph');+ }}+ />+ </Suspense>+ </ErrorBoundary></WorkspaceShell>);}@@ -1923,14 +1934,16 @@ export default function App() {</>}>- <Suspense fallback={<WorkspaceFallback />}>- {manageView === 'lineage' ? <LineageDiagram /> :- manageView === 'kg-overview' ? <KGOverviewTab /> :- <OntologySummaryTab onOpenVocabularyBrowser={() => {- setActiveWorkspace('explore');- setExploreView('vocabulary');- }} />}- </Suspense>+ <ErrorBoundary key={`manage-${manageView}`}>+ <Suspense fallback={<WorkspaceFallback />}>+ {manageView === 'lineage' ? <LineageDiagram /> :+ manageView === 'kg-overview' ? <KGOverviewTab /> :+ <OntologySummaryTab onOpenVocabularyBrowser={() => {+ setActiveWorkspace('explore');+ setExploreView('vocabulary');+ }} />}+ </Suspense>+ </ErrorBoundary></WorkspaceShell>);};diff --git a/explorer/src/ErrorBoundary.tsx b/explorer/src/ErrorBoundary.tsxnew file mode 100644index 00000000..26aa9f12--- /dev/null+++ b/explorer/src/ErrorBoundary.tsx@@ -0,0 +1,97 @@+import { Component, type ErrorInfo, type ReactNode } from 'react';+import { AlertCircle } from 'lucide-react';++interface ErrorBoundaryProps {+ children: ReactNode;+}++interface ErrorBoundaryState {+ hasError: boolean;+ error: Error | null;+ retryCount: number;+}++export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {+ constructor(props: ErrorBoundaryProps) {+ super(props);+ this.state = { hasError: false, error: null, retryCount: 0 };+ }++ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState> {+ return { hasError: true, error };+ }++ componentDidCatch(error: Error, errorInfo: ErrorInfo) {+ console.error("ErrorBoundary caught an error:", error, errorInfo);+ }++ componentDidUpdate() {+ // If the component has successfully rendered (hasError is false)+ // and we were previously tracking retries, reset the retry counter.+ // This ensures a transient error that recovers doesn't permanently leave the+ // component one strike closer to a hard failure.+ if (!this.state.hasError && this.state.retryCount > 0) {+ this.setState({ retryCount: 0 });+ }+ }++ resetErrorBoundary = () => {+ this.setState((prev) => ({+ hasError: false,+ error: null,+ retryCount: prev.retryCount + 1+ }));+ };++ render() {+ if (this.state.hasError) {+ const maxRetriesReached = this.state.retryCount >= 3;++ return (+ <div+ className="workspace-loading"+ style={{+ flexDirection: 'column',+ gap: 12,+ color: 'var(--ws-red)'+ }}+ >+ <AlertCircle size={32} style={{ marginBottom: 4, opacity: 0.8 }} />+ <div style={{ fontWeight: 500, fontSize: '15px' }}>+ Something went wrong in this view.+ </div>+ <div style={{ fontSize: '13px', opacity: 0.7, maxWidth: 450, textAlign: 'center', marginBottom: 8, lineHeight: 1.5 }}>+ {maxRetriesReached+ ? "This view continues to encounter a critical error. Please switch to another workspace or reload the page to restore functionality."+ : "An unexpected problem occurred while rendering this workspace. Your data is safe, but this view cannot be displayed."}+ </div>+ {!maxRetriesReached ? (+ <button+ className="ws-btn ws-btn--ghost"+ style={{+ borderColor: 'var(--ws-red-soft)',+ color: 'var(--ws-red)'+ }}+ onClick={this.resetErrorBoundary}+ >+ Try Again+ </button>+ ) : (+ <button+ className="ws-btn ws-btn--ghost"+ style={{+ borderColor: 'var(--ws-border)',+ color: 'var(--ws-text)'+ }}+ onClick={() => window.location.reload()}+ >+ Reload Application+ </button>+ )}+ </div>+ );+ }++ return this.props.children;+ }+}