Component Organization
The UI layer is located inapp/src/ui/ with 80+ feature directories, each containing related components:
Root Component
App Component
File:app/src/ui/app.tsx
The main application component managing global state and routing:
The App component acts as a “smart container” that manages application-wide state and delegates rendering to specialized components.
Component Patterns
Smart vs Presentational Components
Smart Components
Connected to stores, handle business logic, manage local state
Presentational Components
Pure rendering, receive data via props, reusable across features
Smart Component Example
Presentational Component Example
Reusable Component Library
Dialog System
Location:app/src/ui/dialog/
A flexible dialog system with consistent styling:
The Dialog system includes accessibility features like focus trapping, keyboard navigation, and ARIA attributes.
Virtualized List
Location:app/src/ui/lib/list/
High-performance list rendering for large datasets:
- Only renders visible items
- Handles keyboard navigation
- Supports multi-selection
- Smooth scrolling with momentum
Form Components
Location:app/src/ui/lib/
Type-safe form input components:
Feature Components
Repository View
File:app/src/ui/repository/repository.tsx
Main view when a repository is selected:
Changes View
Directory:app/src/ui/changes/
Viewing and committing changes:
- changes-list.tsx: List of modified files
- changes-sidebar.tsx: File tree with change indicators
- commit-message.tsx: Commit message editor with co-authors
- oversized-files-warning.tsx: Warning for large files
Diff Viewer
Directory:app/src/ui/diff/
Syntax-highlighted diff display:
- Syntax highlighting via CodeMirror
- Line-by-line or side-by-side view
- Partial commit support (stage lines)
- Image diff support (2-up, swipe, onion skin)
Branch Management
Directory:app/src/ui/branches/
Branch operations UI:
- branches-list.tsx: Branch list with filtering
- create-branch.tsx: Create new branch dialog
- rename-branch.tsx: Rename branch dialog
- delete-branch.tsx: Delete branch confirmation
- push-branch-commits.tsx: Push branch dialog
History View
Directory:app/src/ui/history/
Commit history browser:
State Management Integration
Dispatcher Pattern
File:app/src/ui/dispatcher/dispatcher.ts
Central action dispatcher decoupling UI from stores:
Components never directly call store methods. All actions go through the Dispatcher, providing a clear audit trail and easier testing.
Props vs State
Convention:- Props: Data from parent or stores (readonly)
- Local State: UI-only state (form inputs, open/closed states)
Styling
SCSS Modules
Location:app/styles/
Component-specific styles:
CSS Variables
Theme-aware styling:Accessibility
ARIA Attributes
Keyboard Navigation
- Tab: Focus navigation
- Arrow keys: List navigation
- Enter/Space: Activate buttons
- Escape: Close dialogs
- Cmd/Ctrl+shortcuts: Menu actions
Focus Management
File:app/src/ui/lib/focus-container.tsx
Manages focus within a component:
Performance Optimizations
React.memo
Memoize expensive pure components
shouldComponentUpdate
Prevent unnecessary re-renders
Lazy Loading
Code-split large feature components
Virtualization
Render only visible list items
Memoization Example
Testing Components
Unit Tests
Component Lifecycle
Mounting
constructor()- Initialize staterender()- Return JSXcomponentDidMount()- Fetch data, subscribe to events
Updating
shouldComponentUpdate()- Optimize renderingrender()- Re-render with new props/statecomponentDidUpdate()- React to changes
Unmounting
componentWillUnmount()- Cleanup subscriptions, timers
Related Pages
State Management
Learn how data flows through components
Electron Structure
Understand the process architecture