Skip to content

Data Flow ​

This page documents the key data flows and workflows in SpecTacular.

Project Initialization Flow ​

The complete flow from CLI installation to first spec.

File Editing Workflow ​

Complete cycle from opening a file to saving edits.

Task Status Auto-Update Flow ​

Automatic status updates when acceptance criteria are checked.

File Watching Flow ​

Real-time updates from external file changes (e.g., git pull).

AI Workflow Pipeline ​

Specification-driven development workflow using AI commands.

Configuration Loading Flow ​

How configuration is loaded and merged.

State Management ​

Extension Host State ​

Persistent:

  • Global configuration (~/.spectacular/config.json)
  • Workspace state (VS Code workspaceState)

Runtime:

  • File watcher instances
  • Dashboard panel instance (singleton)
  • Modified files tracking
  • Navigation history

Webview State ​

Persisted (via vscodeApi.setState()):

typescript
{
  currentFile: string | null;
  modifiedFiles: [string, string][]; // Map entries
  navigationHistory: string[];
  historyIndex: number;
}

Runtime (React state):

typescript
{
  rootPath: string | null;
  fileContent: string;
  isLoading: boolean;
  error: string | null;
  theme: 'light' | 'dark';
  isWatching: boolean;
}

Error Propagation ​

Extension → Webview ​

typescript
try {
  const content = await fs.readFile(filePath, 'utf8');
  panel.webview.postMessage({
    type: 'fileContent',
    data: { path: filePath, content }
  });
} catch (error) {
  panel.webview.postMessage({
    type: 'error',
    data: {
      message: `Failed to read file: ${error.message}`,
      code: 'READ_ERROR',
      path: filePath
    }
  });
}

Webview → User ​

typescript
useEffect(() => {
  const handleMessage = (event: MessageEvent) => {
    if (event.data.type === 'error') {
      setError(event.data.data.message);
      // Show error in UI
      toast.error(event.data.data.message);
    }
  };

  window.addEventListener('message', handleMessage);
  return () => window.removeEventListener('message', handleMessage);
}, []);

Performance Optimizations ​

Debouncing ​

OperationDelayReason
File watcher300msBatch rapid changes (git pull)
Search input500msReduce search queries
Auto-save (disabled)N/AManual save only (Ctrl+S)

Lazy Loading ​

ResourceStrategy
File treeLoad on demand (expand folder)
File contentLoad when selected
Markdown renderingRender visible content only
ImagesLazy load images in preview

Caching ​

DataCache LocationInvalidation
File treeExtension host memoryFile watcher events
File contentWebview stateFile change events
Rendered markdownTipTap documentContent change
ConfigurationExtension hostConfig file change

Next Steps ​

Released under the MIT License.