High-Level Architecture
Gitlantis is built as a VS Code extension with a webview-based UI. It consists of two main processes that communicate via message passing:Extension Process
The extension process runs in Node.js and has full access to the VS Code API.Entry Point (src/extension/index.ts)
The extension activates when:
- VS Code starts up (
onStartupFinished) - User runs the “Gitlantis” command
activate() function:
- Registers commands via
registerCommands() - Launches the extension if previously active via
launchExtension()
Command Registration (src/extension/commands/index.ts)
The extension registers a single command:
gitlantis.start- Launches the Gitlantis webview
- Transpiled JavaScript from
out/assets/ - Public assets (images, audio)
- Generates HTML with proper CSP (Content Security Policy)
- Tracks if Gitlantis is active via
globalState - Auto-restores on VS Code restart
- Relaunches when workspace folder changes
Message Handling (src/extension/handlers/)
The extension responds to messages from the webview:
File Operations
readDirectory- List files/folders in a directoryopenFile- Open file in VS Code editoropenExplorer- Reveal file in VS Code Explorer
src/extension/handlers/git/)
listBranches- Get all git branchescheckoutBranch- Switch to a different branch
src/extension/handlers/handleSettings/)
getSettings- Retrieve user settingsupdateSettings- Save user preferences
Browser Process (Webview)
The webview runs a full React application with 3D rendering capabilities.Entry Point (src/main/index.tsx)
Bootstraps the React app:
Context Providers
ExtensionContext (src/browser/context/extension/)
- Provides VS Code API access to components
- Manages message passing with extension
- Exposes helper functions for file operations
src/browser/context/game/)
- Manages global game state
- Tracks boat position, camera settings
- Stores user preferences
World Component (src/browser/components/world/)
The root component that assembles the 3D scene:
3D Rendering Pipeline
Gitlantis uses React Three Fiber, which creates a declarative API for Three.js:- Canvas Setup - WebGL renderer initialization
- Scene Graph - React components = Three.js objects
- Physics Simulation -
@react-three/cannonfor collisions and floating - Animation Loop - 60fps render cycle with
useFramehooks - User Input - Keyboard, mouse, joystick controls
Key 3D Components
Boat (src/browser/components/world/boat/)
- Player-controlled object
- Keyboard navigation (WASD/Arrow keys)
- Joystick support for touch devices
- Physics body with collision detection
- Custom hooks:
useBoat/keyboard- Keyboard inputuseBoat/navigation- Movement logicuseBoat/floating- Bobbing animationuseBoat/compass- Direction tracking
src/browser/components/world/nodes/)
- Represents files and folders as 3D objects
- Folders = Tall lighthouses
- Files = Short buoys
- Positioned in a grid layout
- Clickable interactions:
- Folders: Navigate into directory
- Files: Open in VS Code editor
src/browser/components/world/ocean/)
- Infinite water plane
- Animated waves using shaders
- Dynamic regeneration based on boat position
src/browser/components/world/sky/)
- Skybox/environment
- Day/night cycle (future feature)
src/browser/components/world/camera/)
- Third-person perspective
- Follows boat movement
- Configurable distance and angle
src/browser/components/world/minimap/)
- Overhead 2D view
- Shows boat position
- Displays nearby nodes
- Toggleable visibility
UI Overlays (src/browser/components/ui/)
2D HTML/CSS overlays rendered on top of the 3D canvas:
- Breadcrumbs - Current directory path
- Compass - Navigation aid
- Settings Modal - User preferences
- Color Picker - Boat customization
- Splash Screen - Welcome message
- Loading States - Async operation indicators
State Management
Gitlantis uses Zustand for lightweight state management: Game Store (src/browser/hooks/useGame/store/)
src/extension/store/)
- Manages extension-level state
- Caches directory listings
- Tracks active webview panels
Custom Hooks
Thesrc/browser/hooks/ directory contains reusable logic:
useNode/- Node placement, collision, movementuseBoat/- Boat controls and physicsuseGame/- Game state and settingsuseExtension/- VS Code API integrationuseGit/- Git operationsuseWalker/- File system traversalusePersistence/- State persistence
Communication Protocol
Webview → Extension
The webview sends messages using the VS Code API:Extension → Webview
The extension responds with data:Message Types
Commands (Webview → Extension)readDirectory- Get directory contentsopenFile- Open file in editoropenExplorer- Reveal in file treelistBranches- Get git branchescheckoutBranch- Switch branchgetSettings- Load user settingsupdateSettings- Save settings
directoryContents- Directory listing resultsbranchList- Available git branchessettingsLoaded- User preferenceserror- Operation failed
Performance Optimizations
Lazy Loading- Only load visible nodes
- Directories loaded on-demand
- Reuse Three.js geometries and materials
- Reduce garbage collection
- Simplify distant objects
- Reduce polygon count for performance
- Limit message frequency
- Prevent overwhelming the extension process
- Lazy load components
- Show loading states
Build Process
-
Browser Build (Vite)
- Bundles React + Three.js code
- Outputs to
out/assets/ - Generates
index.html
-
Extension Build (TypeScript)
- Compiles Node.js code
- Outputs to
out/extension/ - Creates CommonJS modules
-
Packaging (vsce)
- Bundles all assets
- Creates
.vsixfile - Ready for distribution