feat: Enhanced alert system with multiple types and flexible configuration #32
+119
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enhanced Alert System with Multi-Type Support and Custom UI
PR Overview
This pull request introduces a comprehensive enhancement to the Puter alert system, transforming it from a single-type warning dialog into a flexible, multi-purpose notification framework. The implementation adds support for five distinct alert types (info, success, warning, error, question), enables simplified button configuration through string arrays, introduces custom UI content injection, and provides a modern object-based API while maintaining complete backward compatibility with existing codebases.
Branch:
feat/enhanced-alert-systemType: Feature Enhancement
Complexity: Moderate
Closes Feature
Closes Issue #3 - [FEATURE] Add multiple alert box types and customization options #7
##Before
Video: https://cap.link/v677g7a9ps1c0nj
Key Changes
1. Multi-Type Alert System
Introduced five semantic alert types with distinct visual identities:
2. Intelligent Default Button Sets
Type-aware default button configurations eliminate boilerplate code:
3. String Array Button Syntax
Simplified button definition through string arrays with automatic conversion:
4. Object-Based API
Modern fluent API design with single object parameter:
5. Custom UI Content Injection
Extensible content area between message and buttons:
<strong>,<p>,<br>)Implementation
Video: https://cap.link/yc7j6957rfn3hmx
Architecture Overview
The alert system follows a three-layer architecture with cross-iframe communication:
Implementation Details
Type-Specific Default Buttons
String Array Conversion
Icon Mapping System
API Flexibility
Custom UI Sanitization
IPC Message Normalization
Design Philosophy
Non-Breaking Evolution - Every enhancement layers atop existing functionality rather than replacing it. Type system added through icon lookup, button arrays through preprocessing, custom UI through template injection.
Security-First - Custom UI uses allowlist-based sanitization assuming all input is malicious. Only explicitly verified formatting tags render, preventing XSS vulnerabilities.
Semantic Type System - Alert types match universal UX patterns (info, success, warning, error, question) found across all major platforms for immediate developer intuitiveness.
Progressive API - Object-based API introduced as alternative, not replacement. Developers can use positional parameters indefinitely, adopt object syntax selectively, or mix both styles.
Testing
After: https://cap.link/fv5wvbnhrptwxbs
Manual Testing Checklist
Type System Verification:
Button Functionality:
Default Button Behavior:
API Compatibility:
alert('message')string syntax worksalert({ message, type, buttons })syntax worksCustom UI:
<strong>,<p>,<br>) render correctlyIntegration:
Breaking Changes
None. This implementation maintains complete backward compatibility.
Compatibility Analysis
Existing Call Patterns:
puter.ui.alert('message')- Continues to work identicallyputer.ui.alert('message', [buttons])- Continues to work identicallyputer.ui.alert('message', [buttons], {options})- Continues to work identicallyUIAlert('message')- Internal usage unaffectedUIAlert({message, buttons})- Internal usage unaffectedBehavioral Consistency:
Risk Assessment:
Migration Path: None required. Applications can adopt new features incrementally without modifying existing alert calls.
Files Modified:
src/gui/src/UI/UIAlert.js- Core alert rendering logicsrc/puter-js/src/modules/UI.js- SDK public APIsrc/gui/src/IPC.js- Cross-frame message handling