- AffordanceManager (
/frontend/utils/affordanceManager.ts
)- Central registry for all UI affordances
- Component lifecycle management (mount/unmount)
- Method invocation proxy system
- Global CSS styling injection
-
OverlayContainerManager (
/frontend/utils/containers/overlayContainer.ts
)- Modal/popup overlays with backdrop
- Flexible positioning (center, top, bottom, left, right)
- Custom sizing and close functionality
- Animation support
-
SidebarContainerManager (
/frontend/utils/containers/sidebarContainer.ts
)- Collapsible side panels (left/right)
- Toggle buttons for collapsed state
- Header with title and controls
- Custom width configuration
-
HeaderContainerManager (
/frontend/utils/containers/headerContainer.ts
)- Fixed header extensions
- Priority-based ordering
- Integration with existing layout
- Automatic body padding adjustment
-
FooterContainerManager (
/frontend/utils/containers/footerContainer.ts
)- Footer extensions alongside existing controls
- Priority-based ordering
- Integration with existing footer
- Compact design for mobile
-
InlineContainerManager (
/frontend/utils/containers/inlineContainer.ts
)- Components embedded in chat flow
- Automatic insertion point detection
- Animation support
- Flexible sizing
- register_affordance - Register new UI components from file keys
- call_affordance_method - Invoke methods on registered components
- unregister_affordance - Remove registered components
- list_affordances - List all active affordances
- Shared Types (
/shared/affordance-types.ts
)- Complete TypeScript interface definitions
- AffordanceComponent interface contract
- Configuration options schema
- Method call result types
-
CounterAffordance (
/frontend/components/affordances/CounterAffordance.tsx
)- Simple counter with increment/decrement
- Demonstrates basic state management
- Public method exposure (getValue, setValue, increment, decrement, reset)
-
StatusDashboard (
/frontend/components/affordances/StatusDashboard.tsx
)- System status monitoring dashboard
- Dynamic item management (add, update, remove)
- Refresh functionality with callbacks
- Complex state management example
-
NotificationCenter (
/frontend/components/affordances/NotificationCenter.tsx
)- Notification management system
- Auto-close timers
- Multiple notification types (info, success, warning, error)
- List management with cleanup
-
TestAffordance (
/frontend/components/affordances/TestAffordance.tsx
)- Simple test component for framework validation
- Basic interaction demonstration
- Method testing (getMessage, setMessage, ping)
- Affordance manager is lazy-loaded to avoid circular dependencies
- Container managers are imported only when needed
- Prevents app startup issues
All affordance components must implement:
interface AffordanceComponent {
mount(container: HTMLElement, config: AffordanceConfig): Promise<void>;
unmount(): Promise<void>;
getPublicMethods(): Record<string, Function>;
[customMethod: string]: any;
}
Flexible configuration with type-specific options:
- Common: title, className, zIndex, persistent
- Positioning: position, width, height, maxWidth, maxHeight
- Overlay: modal, backdrop, closable
- Header/Footer: priority
- Sidebar: collapsible, defaultCollapsed
- Graceful component loading failures
- Method call validation and error reporting
- Container creation error handling
- Comprehensive logging for debugging
- Uses existing CSS custom properties
- Consistent design tokens
- Responsive design support
- Animation system integration
const counterId = await register_affordance('sidebar',
'/frontend/components/affordances/CounterAffordance.tsx',
{
title: 'Counter Widget',
position: 'right',
width: '250px',
initialValue: 10,
step: 5
}
);
// Interact with counter
await call_affordance_method(counterId, 'increment', []);
const value = await call_affordance_method(counterId, 'getValue', []);
const dashboardId = await register_affordance('sidebar',
'/frontend/components/affordances/StatusDashboard.tsx',
{
title: 'System Status',
position: 'left',
width: '300px'
}
);
// Add status items
await call_affordance_method(dashboardId, 'addItem', [{
id: 'cpu',
label: 'CPU Usage',
value: '45%',
status: 'success'
}]);
const notificationId = await register_affordance('overlay',
'/frontend/components/affordances/NotificationCenter.tsx',
{
title: 'Notifications',
position: 'top',
maxWidth: '400px'
}
);
// Add notification
await call_affordance_method(notificationId, 'addNotification', [{
title: 'Task Complete',
message: 'Processing finished successfully.',
type: 'success',
autoClose: true
}]);
- Rich UI Creation: Can create complex, interactive interfaces
- Real-time Updates: Components can be updated dynamically
- Flexible Positioning: Multiple container types for different use cases
- State Management: Components maintain their own state
- Method Invocation: Direct interaction with component functionality
- Non-intrusive: Containers don't interfere with existing chat
- Responsive: Works on mobile and desktop
- Accessible: Keyboard navigation and screen reader support
- Animated: Smooth transitions and micro-interactions
- Customizable: Flexible configuration options
- Type Safety: Full TypeScript support
- Modular: Clean separation of concerns
- Extensible: Easy to add new container types
- Debuggable: Comprehensive logging and error handling
- Testable: Clear interfaces and dependency injection
- Core framework implementation
- All container types working
- Client tools integration
- Example components
- Documentation
- Error handling
- Lazy loading system
- Framework is fully functional
- Tools are available in the client
- Example components can be registered
- All container types operational
- State Persistence: Save component state across sessions
- Component Communication: Message passing between affordances
- Performance Monitoring: Component performance metrics
- Hot Reloading: Development-time component updates
- Component Library: Curated collection of common components
- JSON Schema Validation: Fixed invalid schema types for Anthropic API
- Circular Dependencies: Implemented lazy loading to prevent import issues
- App Loading: Resolved module loading problems that caused blank page
- File-based Components: Components loaded from project files for version control
- Standardized Interface: Consistent API across all component types
- Container Abstraction: Separate managers for each container type
- Safe Method Calls: Proxy system for secure method invocation
The UI Affordance Framework is now fully operational and ready for use. The assistant can create rich, interactive UI experiences by registering components and controlling them through the standardized tool interface.