- Notifications
You must be signed in to change notification settings - Fork 30
feat(examples): add advanced window, browser profiles, error handling… #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…, and secure communication demos - introduce advanced_window example with window controls and info - add browser_profiles example for managing browser profiles and info - provide error_handling example demonstrating error reporting and recovery - add secure_communication example for encoding, binary transfer, and memory management - update win32GetHwnd for improved pointer handling on Windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces comprehensive advanced example applications demonstrating WebUI's enhanced capabilities for window management, browser profiles, error handling, and secure communication, along with an improvement to pointer handling on Windows.
- Adds four new advanced example applications showcasing different WebUI features
- Improves Windows pointer handling in the
win32GetHwndmethod - Provides comprehensive demonstrations of error handling, encoding, browser management, and window controls
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/webui.zig | Updates Windows HWND pointer handling to use optional capture syntax |
| examples/secure_communication/main.zig | Implements secure communication example with encoding, binary transfer, and memory management |
| examples/secure_communication/index.html | Provides UI for testing encoding/decoding and binary data transfer features |
| examples/error_handling/main.zig | Demonstrates comprehensive error handling patterns throughout WebUI operations |
| examples/error_handling/index.html | Interactive UI for testing various error scenarios and recovery mechanisms |
| examples/browser_profiles/main.zig | Shows browser profile management and browser detection capabilities |
| examples/browser_profiles/profile.html | Simple test page for demonstrating profile isolation |
| examples/browser_profiles/index.html | Main UI for browser profile management and information display |
| examples/advanced_window/main.zig | Comprehensive window control functionality including positioning, sizing, and system integration |
| examples/advanced_window/index.html | Advanced UI with controls for all window management features |
Comments suppressed due to low confidence (1)
examples/error_handling/main.zig:18
- Function name has a typo:
isHighConstrastshould beisHighContrast(missing 'n').
_ = try window.bind("test_encode_error", testEncodeError); | if (tmp_hwnd) |hwnd| { | ||
| return @ptrCast(hwnd); |
Copilot AI Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The variable name hwnd shadows the outer scope variable name tmp_hwnd. Consider using a different name like valid_hwnd to improve clarity.
| if (tmp_hwnd) |hwnd| { | |
| return @ptrCast(hwnd); | |
| if (tmp_hwnd) |valid_hwnd| { | |
| return @ptrCast(valid_hwnd); |
| // Fill buffer with test data | ||
| const test_data = "This is test data for memory management"; | ||
| const copy_len = @min(test_data.len, buffer.len); | ||
| webui.memcpy(buffer[0..copy_len], test_data[0..copy_len]); |
Copilot AI Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using webui.memcpy instead of Zig's standard @memcpy is inconsistent with the pattern used elsewhere in the file (line 44, 67). Consider using @memcpy for consistency.
| webui.memcpy(buffer[0..copy_len], test_data[0..copy_len]); | |
| @memcpy(buffer[0..copy_len], test_data[0..copy_len]); |
| }; | ||
| defer webui.free(buffer2); | ||
| | ||
| webui.memcpy(buffer2[0..copy_len], buffer[0..copy_len]); |
Copilot AI Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using webui.memcpy instead of Zig's standard @memcpy is inconsistent with the pattern used elsewhere in the file. Consider using @memcpy for consistency.
| webui.memcpy(buffer2[0..copy_len], buffer[0..copy_len]); | |
| @memcpy(buffer2[0..copy_len], buffer[0..copy_len]); |
Is this PR a draft? |
| yes, this pr is a draft |
| Many examples can only be built and passed, but the test has not been completed yet, so I need more tests |
| Understood, take your time @jinzhongjia |
- add version checks to support managed and unmanaged ArrayList initialization - update user append logic to handle allocator parameter for Zig 0.16+ - ensure event handling example works across Zig 0.14, 0.15, and 0.16+
- update CI configuration to test against Zig 0.15.1 - ensure compatibility across multiple Zig versions
- update ArrayList compatibility logic to support Zig 0.15+ - adjust version checks from 0.16 to 0.15 for managed/unmanaged ArrayList - update webui dependency to latest commit in build.zig.zon
- update window icon to use raw SVG string instead of base64 - refine window hide/show logic to use minimize/maximize for better UX - replace window.destroy with window.close for proper resource management - add missing charset meta tag and webui.js script to HTML
- include webui.js in index.html to enable proper functionality - ensure browser_profiles example loads required scripts
- delete error_handling and secure_communication example directories - remove related Zig and HTML files for both demos
- delete browser_profiles example including HTML and Zig files - remove profile management and browser detection sample code
…, and secure communication demos