Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Improve startup session UX and import readiness flow

Yuechen Lid2842c720e4a
diff --git a/aetheris.client/src/App.css b/aetheris.client/src/App.css
index a6fe6d9c..2aabcfd1 100644
--- a/aetheris.client/src/App.css
+++ b/aetheris.client/src/App.css
@@ -36,6 +36,49 @@
padding: var(--layout-space-1) var(--layout-space-3);
}
+.status-row {
+ display: flex;
+ gap: var(--layout-space-1);
+ padding: 0 var(--layout-space-3) var(--layout-space-1);
+}
+
+.status-pill {
+ border: var(--layout-border-weight) solid var(--layout-border-color);
+ border-radius: 999px;
+ padding: 3px 10px;
+ font-size: 0.75rem;
+ background: hsla(var(--muted), 0.7);
+}
+
+.status-pill--connected,
+.status-pill--ready {
+ border-color: #6f8f8a;
+}
+
+.status-pill--error,
+.status-pill--disconnected {
+ border-color: #9e6767;
+}
+
+.import-status-box {
+ border: var(--layout-border-weight) solid var(--layout-border-color);
+ border-radius: var(--layout-radius);
+ background: hsla(var(--muted), 0.45);
+ padding: var(--layout-space-1);
+}
+
+.import-status-box p {
+ margin: 0;
+}
+
+.import-status-box--success {
+ border-color: #6f8f8a;
+}
+
+.import-status-box--error {
+ border-color: #9e6767;
+}
+
.top-bar__title {
margin: 0;
font-size: 0.95rem;
diff --git a/aetheris.client/src/App.tsx b/aetheris.client/src/App.tsx
index 595cb096..8deda97c 100644
--- a/aetheris.client/src/App.tsx
+++ b/aetheris.client/src/App.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useMemo, useState } from 'react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
import './App.css';
import {
ApiError,
@@ -24,6 +24,9 @@ import { mapTessellationToRenderData } from './viewer/tessellationMapper';
type RequestStatus = 'idle' | 'loading' | 'success' | 'error';
type BooleanOperationUi = 'Union' | 'Subtract' | 'Intersect';
type TopLevelTab = 'viewer' | 'modeling-demo';
+type ServerStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
+type DocumentStatus = 'creating' | 'ready' | 'error';
+type ImportStatus = 'idle' | 'creating' | 'importing' | 'success' | 'error';
const BOOLEAN_OP_TO_API: Record<BooleanOperationUi, BooleanOperation> = {
Union: 'union',
@@ -40,6 +43,10 @@ function App() {
const [tessellation, setTessellation] = useState<TessellationResponseDto | null>(null);
const [status, setStatus] = useState<RequestStatus>('idle');
const [statusMessage, setStatusMessage] = useState<string>('Ready. Create a document to begin.');
+ const [serverStatus, setServerStatus] = useState<ServerStatus>('connecting');
+ const [documentStatus, setDocumentStatus] = useState<DocumentStatus>('creating');
+ const [importStatus, setImportStatus] = useState<ImportStatus>('creating');
+ const [importStatusMessage, setImportStatusMessage] = useState('Preparing workspace…');
const [diagnostics, setDiagnostics] = useState<DiagnosticDto[]>([]);
const [pickStatus, setPickStatus] = useState<RequestStatus>('idle');
const [pickMessage, setPickMessage] = useState<string>('Click in the viewport to run nearest-hit pick.');
@@ -59,9 +66,65 @@ function App() {
const [stepCanonicalHash, setStepCanonicalHash] = useState<string | null>(null);
const [stepImportSelectionMessage, setStepImportSelectionMessage] = useState('No file selected.');
const [copyHashMessage, setCopyHashMessage] = useState('');
+ const [isImporting, setIsImporting] = useState(false);
+ const [isRefreshing, setIsRefreshing] = useState(false);
+ const [isResetting, setIsResetting] = useState(false);
const maxStepFileSizeBytes = 5 * 1024 * 1024;
+ const resetSessionState = useCallback(() => {
+ setBodyIds([]);
+ setActiveBodyId(null);
+ setOccurrences([]);
+ setTessellation(null);
+ setPickStatus('idle');
+ setPickMessage('Click in the viewport to run nearest-hit pick.');
+ setPickDiagnostics([]);
+ setPickHits([]);
+ setBooleanTargetBodyId('');
+ setBooleanToolBodyId('');
+ setBooleanOperation('Union');
+ setStepExportText('');
+ setStepImportFile(null);
+ setStepCanonicalHash(null);
+ setStepImportSelectionMessage('No file selected.');
+ setCopyHashMessage('');
+ setDiagnostics([]);
+ setImportStatusMessage('Preparing workspace…');
+ }, []);
+
+ const createFreshDocument = useCallback(async () => {
+ setServerStatus('connecting');
+ setDocumentStatus('creating');
+ setImportStatus('creating');
+ setImportStatusMessage('Preparing workspace…');
+ setStatus('loading');
+ setStatusMessage('Preparing workspace...');
+
+ try {
+ const created = await createDocument('STEP 242 Viewer UI');
+ setDocumentId(created.documentId);
+ setServerStatus('connected');
+ setDocumentStatus('ready');
+ setImportStatus('idle');
+ setImportStatusMessage('Ready. Select a file to import.');
+ setStatus('success');
+ setStatusMessage('Workspace ready.');
+ } catch (error) {
+ const apiError = error instanceof ApiError
+ ? error
+ : new ApiError((error as Error).message || 'Unexpected error.', []);
+ setDocumentId(null);
+ setServerStatus('error');
+ setDocumentStatus('error');
+ setImportStatus('error');
+ setImportStatusMessage(`Import error: ${apiError.message}`);
+ setStatus('error');
+ setStatusMessage(apiError.message);
+ setDiagnostics(apiError.diagnostics);
+ }
+ }, []);
+
const runAction = useCallback(async (actionName: string, action: () => Promise<void>) => {
setStatus('loading');
setStatusMessage(`${actionName}...`);
@@ -71,6 +134,7 @@ function App() {
await action();
setStatus('success');
setStatusMessage(`${actionName} complete.`);
+ return true;
} catch (error) {
const apiError = error instanceof ApiError
? error
@@ -78,6 +142,7 @@ function App() {
setStatus('error');
setStatusMessage(apiError.message);
setDiagnostics(apiError.diagnostics);
+ return false;
}
}, []);
@@ -102,27 +167,15 @@ function App() {
}, [activeBodyId, documentId]);
const handleCreateDocument = useCallback(async () => {
- await runAction('Create document', async () => {
- const created = await createDocument('STEP 242 Viewer UI');
- setDocumentId(created.documentId);
- setBodyIds([]);
- setActiveBodyId(null);
- setOccurrences([]);
- setTessellation(null);
- setPickStatus('idle');
- setPickMessage('Click in the viewport to run nearest-hit pick.');
- setPickDiagnostics([]);
- setPickHits([]);
- setBooleanTargetBodyId('');
- setBooleanToolBodyId('');
- setBooleanOperation('Union');
- setStepExportText('');
- setStepImportFile(null);
- setStepCanonicalHash(null);
- setStepImportSelectionMessage('No file selected.');
- setCopyHashMessage('');
- });
- }, [runAction]);
+ setIsResetting(true);
+ resetSessionState();
+ await createFreshDocument();
+ setIsResetting(false);
+ }, [createFreshDocument, resetSessionState]);
+
+ useEffect(() => {
+ void handleCreateDocument();
+ }, [handleCreateDocument]);
const handleCreateBox = useCallback(async () => {
if (!documentId) {
@@ -195,10 +248,12 @@ function App() {
return;
}
+ setIsRefreshing(true);
await runAction('Refresh tessellation', async () => {
const tessellated = await tessellateBody(documentId, activeBodyId);
setTessellation(tessellated);
});
+ setIsRefreshing(false);
}, [activeBodyId, documentId, runAction]);
const activeOccurrence = useMemo(
@@ -262,7 +317,7 @@ function App() {
}, [stepCanonicalHash]);
const handleImportStep = useCallback(async () => {
- if (!documentId || !stepImportFile) {
+ if (!documentId || !stepImportFile || documentStatus !== 'ready' || serverStatus !== 'connected') {
return;
}
@@ -270,6 +325,8 @@ function App() {
setStatus('error');
setStatusMessage('Selected STEP file is empty.');
setDiagnostics([]);
+ setImportStatus('error');
+ setImportStatusMessage('Import error: Selected STEP file is empty.');
return;
}
@@ -277,27 +334,39 @@ function App() {
setStatus('error');
setStatusMessage(`Selected STEP file is too large (${stepImportFile.size} bytes). Limit is ${maxStepFileSizeBytes} bytes.`);
setDiagnostics([]);
+ setImportStatus('error');
+ setImportStatusMessage(`Import error: Selected STEP file is too large (${stepImportFile.size} bytes).`);
return;
}
- await runAction('Import STEP', async () => {
- const stepText = await stepImportFile.text();
- if (stepText.trim().length === 0) {
- throw new ApiError('Selected STEP file is empty.', []);
- }
+ setImportStatus('importing');
+ setImportStatusMessage('Importing STEP…');
+ setIsImporting(true);
- const imported = await importStep(documentId, stepText);
- setStepExportText('');
- await refreshSummaryAndActiveTessellation(imported.occurrenceId);
- const exported = await exportDefinitionStep(documentId, imported.definitionId);
- setStepCanonicalHash(exported.canonicalHash);
- setPickStatus('idle');
- setPickMessage(`Imported occurrence ${imported.occurrenceId} is now active.`);
- setPickDiagnostics([]);
- setPickHits([]);
- setCopyHashMessage('');
- });
- }, [documentId, maxStepFileSizeBytes, refreshSummaryAndActiveTessellation, runAction, stepImportFile]);
+ try {
+ const didImport = await runAction('Import STEP', async () => {
+ const stepText = await stepImportFile.text();
+ if (stepText.trim().length === 0) {
+ throw new ApiError('Selected STEP file is empty.', []);
+ }
+
+ const imported = await importStep(documentId, stepText);
+ setStepExportText('');
+ await refreshSummaryAndActiveTessellation(imported.occurrenceId);
+ const exported = await exportDefinitionStep(documentId, imported.definitionId);
+ setStepCanonicalHash(exported.canonicalHash);
+ setPickStatus('idle');
+ setPickMessage(`Imported occurrence ${imported.occurrenceId} is now active.`);
+ setPickDiagnostics([]);
+ setPickHits([]);
+ setCopyHashMessage('');
+ });
+ setImportStatus(didImport ? 'success' : 'error');
+ setImportStatusMessage(didImport ? 'Import complete.' : 'Import error: Request failed.');
+ } finally {
+ setIsImporting(false);
+ }
+ }, [documentId, documentStatus, maxStepFileSizeBytes, refreshSummaryAndActiveTessellation, runAction, serverStatus, stepImportFile]);
const handleStepFileSelection = useCallback((fileList: FileList | null) => {
const selected = fileList?.[0] ?? null;
@@ -398,7 +467,12 @@ function App() {
const nearestHit = pickHits[0] ?? null;
const highlightedFaceId = nearestHit?.entityKind === 'Face' ? nearestHit.faceId : null;
const highlightedEdgeId = nearestHit?.entityKind === 'Edge' ? nearestHit.edgeId : null;
- const canImportStep = Boolean(documentId && stepImportFile && status !== 'loading');
+ const canImportStep = Boolean(
+ serverStatus === 'connected'
+ && documentStatus === 'ready'
+ && stepImportFile
+ && !isImporting
+ && status !== 'loading');
const canExecuteBoolean = Boolean(
documentId
&& bodyIds.length >= 2
@@ -406,6 +480,18 @@ function App() {
&& booleanToolBodyId
&& booleanTargetBodyId !== booleanToolBodyId
&& status !== 'loading');
+ const serverStatusLabel: Record<ServerStatus, string> = {
+ connecting: 'Server: Connecting',
+ connected: 'Server: Connected',
+ disconnected: 'Server: Disconnected',
+ error: 'Server: Error',
+ };
+ const documentStatusLabel: Record<DocumentStatus, string> = {
+ creating: 'Document: Preparing',
+ ready: 'Document: Ready',
+ error: 'Document: Error',
+ };
+ const importStatusTone = importStatus === 'error' ? 'error' : (importStatus === 'success' ? 'success' : 'neutral');
return (
<div className="app-shell">
@@ -414,13 +500,21 @@ function App() {
<div className="top-bar__title">STEP 242 VIEWER</div>
<div className="top-bar__actions">
<Button type="button" variant="outline" onClick={() => void handleCreateDocument()} disabled={status === 'loading'}>
- Create Document
+ {isResetting ? 'Preparing…' : 'New Document'}
</Button>
- <Button type="button" variant="outline" onClick={() => void handleRefreshTessellation()} disabled={!activeBodyId || status === 'loading'}>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => void handleRefreshTessellation()}
+ disabled={documentStatus !== 'ready' || !activeBodyId || status === 'loading' || isRefreshing}>
Refresh Tessellation
</Button>
</div>
</div>
+ <div className="status-row" role="status" aria-live="polite">
+ <span className={`status-pill status-pill--${serverStatus}`}>{serverStatusLabel[serverStatus]}</span>
+ <span className={`status-pill status-pill--${documentStatus}`}>{documentStatusLabel[documentStatus]}</span>
+ </div>
<div className="top-bar__tabs-row">
<div className="top-bar__tabs" role="tablist" aria-label="Top-level product surface">
<Button
@@ -473,7 +567,10 @@ function App() {
</label>
<p>{stepImportSelectionMessage}</p>
<Button type="button" onClick={() => void handleImportStep()} disabled={!canImportStep}>Import STEP 242</Button>
- <p><strong>Status:</strong> {statusMessage}</p>
+ <div className={`import-status-box import-status-box--${importStatusTone}`}>
+ <p><strong>Import Status</strong></p>
+ <p>{importStatusMessage}</p>
+ </div>
{diagnostics.length === 0 ? null : (
<ul>
{diagnostics.map((diagnostic, index) => (
diff --git a/aetheris.client/src/__tests__/App.test.tsx b/aetheris.client/src/__tests__/App.test.tsx
index 45147578..e1f6e002 100644
--- a/aetheris.client/src/__tests__/App.test.tsx
+++ b/aetheris.client/src/__tests__/App.test.tsx
@@ -84,6 +84,14 @@ describe('App STEP file upload flow', () => {
expect(screen.getByRole('button', { name: 'Create Box' })).toBeTruthy();
});
+ it('auto-creates a workspace and shows connected/ready status on startup', async () => {
+ render(<App />);
+
+ await screen.findByText('Server: Connected');
+ await screen.findByText('Document: Ready');
+ expect(apiMocks.createDocument).toHaveBeenCalledTimes(1);
+ });
+
it('keeps canonical hash visible from viewer inspector', async () => {
apiMocks.importStep.mockResolvedValue({
documentId: 'doc-1',
@@ -101,9 +109,7 @@ describe('App STEP file upload flow', () => {
});
render(<App />);
-
- fireEvent.click(screen.getByRole('button', { name: 'Create Document' }));
- await screen.findByText(/Create document complete/i);
+ await screen.findByText('Document: Ready');
const fileInput = screen.getByLabelText('STEP 242 File') as HTMLInputElement;
const file = new File(['ISO-10303-21;DATA;'], 'part.stp', { type: 'text/plain' });
@@ -116,9 +122,7 @@ describe('App STEP file upload flow', () => {
it('updates local file selection state when a file is chosen', async () => {
render(<App />);
-
- fireEvent.click(screen.getByRole('button', { name: 'Create Document' }));
- await screen.findByText(/Create document complete/i);
+ await screen.findByText('Document: Ready');
const fileInput = screen.getByLabelText('STEP 242 File') as HTMLInputElement;
const file = new File(['ISO-10303-21;'], 'sample.step', { type: 'text/plain' });
@@ -144,9 +148,7 @@ describe('App STEP file upload flow', () => {
});
render(<App />);
-
- fireEvent.click(screen.getByRole('button', { name: 'Create Document' }));
- await screen.findByText(/Create document complete/i);
+ await screen.findByText('Document: Ready');
const fileInput = screen.getByLabelText('STEP 242 File') as HTMLInputElement;
const file = new File(['ISO-10303-21;DATA;'], 'part.stp', { type: 'text/plain' });
@@ -184,9 +186,7 @@ describe('App STEP file upload flow', () => {
});
render(<App />);
-
- fireEvent.click(screen.getByRole('button', { name: 'Create Document' }));
- await screen.findByText(/Create document complete/i);
+ await screen.findByText('Document: Ready');
fireEvent.click(screen.getByRole('tab', { name: /Modeling Demo/i }));
fireEvent.click(screen.getByRole('button', { name: 'Create Box' }));
@@ -223,9 +223,7 @@ describe('App STEP file upload flow', () => {
}]));
render(<App />);
-
- fireEvent.click(screen.getByRole('button', { name: 'Create Document' }));
- await screen.findByText(/Create document complete/i);
+ await screen.findByText('Document: Ready');
const fileInput = screen.getByLabelText('STEP 242 File') as HTMLInputElement;
const file = new File(['BAD'], 'bad.step', { type: 'text/plain' });
@@ -233,7 +231,7 @@ describe('App STEP file upload flow', () => {
fireEvent.click(screen.getByRole('button', { name: 'Import STEP 242' }));
- await screen.findByText('Malformed STEP payload.');
+ await screen.findByText('Import error: Request failed.');
await screen.findByText('[Error] ValidationFailed: Malformed STEP payload.');
});
@@ -246,9 +244,7 @@ describe('App STEP file upload flow', () => {
}]));
render(<App />);
-
- fireEvent.click(screen.getByRole('button', { name: 'Create Document' }));
- await screen.findByText(/Create document complete/i);
+ await screen.findByText('Document: Ready');
fireEvent.click(screen.getByRole('tab', { name: /Modeling Demo/i }));
fireEvent.click(screen.getByRole('button', { name: 'Create Box' }));
await screen.findByText(/Create box complete/i);
@@ -256,7 +252,54 @@ describe('App STEP file upload flow', () => {
fireEvent.click(screen.getByRole('button', { name: 'Download Canonical 242' }));
- await screen.findByText('Export failed.');
await screen.findByText('[Error] StepExportFailed: Export failed.');
});
+
+ it('keeps file selection while document is still preparing and enables import when ready', async () => {
+ let resolveCreate: (value: { documentId: string; name: string; volatile: boolean; }) => void = () => undefined;
+ apiMocks.createDocument.mockImplementationOnce(() => new Promise<{ documentId: string; name: string; volatile: boolean; }>((resolve) => {
+ resolveCreate = resolve;
+ }));
+
+ render(<App />);
+
+ const fileInput = screen.getByLabelText('STEP 242 File') as HTMLInputElement;
+ const file = new File(['ISO-10303-21;DATA;'], 'part.stp', { type: 'text/plain' });
+ fireEvent.change(fileInput, { target: { files: [file] } });
+
+ expect(screen.getByText('Selected file: part.stp (18 bytes)')).toBeTruthy();
+ expect((screen.getByRole('button', { name: 'Import STEP 242' }) as HTMLButtonElement).disabled).toBe(true);
+
+ resolveCreate({ documentId: 'doc-1', name: 'Test', volatile: true });
+ await screen.findByText('Document: Ready');
+
+ await waitFor(() => {
+ expect((screen.getByRole('button', { name: 'Import STEP 242' }) as HTMLButtonElement).disabled).toBe(false);
+ });
+ });
+
+ it('resets file selection and document-bound state when New Document is pressed', async () => {
+ render(<App />);
+ await screen.findByText('Document: Ready');
+
+ const fileInput = screen.getByLabelText('STEP 242 File') as HTMLInputElement;
+ const file = new File(['ISO-10303-21;'], 'sample.step', { type: 'text/plain' });
+ fireEvent.change(fileInput, { target: { files: [file] } });
+ expect(screen.getByText(/Selected file: sample.step \(\d+ bytes\)/)).toBeTruthy();
+
+ fireEvent.click(screen.getByRole('button', { name: 'New Document' }));
+
+ await screen.findByText('No file selected.');
+ expect(screen.getByText('Document: Ready')).toBeTruthy();
+ expect(screen.getByText('Ready. Select a file to import.')).toBeTruthy();
+ expect(apiMocks.createDocument).toHaveBeenCalledTimes(2);
+ });
+
+ it('disables import button unless server connected, document ready, and file selected', async () => {
+ apiMocks.createDocument.mockRejectedValueOnce(new ApiError('Server unavailable.', []));
+ render(<App />);
+
+ await screen.findByText('Server: Error');
+ expect((screen.getByRole('button', { name: 'Import STEP 242' }) as HTMLButtonElement).disabled).toBe(true);
+ });
});