Skip to content

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jinzhongjia
Copy link
Member

…, 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

…, 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
@jinzhongjia jinzhongjia requested a review from Copilot August 7, 2025 15:10
Copy link

@Copilot Copilot AI left a 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 win32GetHwnd method
  • 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: isHighConstrast should be isHighContrast (missing 'n').
    _ = try window.bind("test_encode_error", testEncodeError);

Comment on lines +461 to +462
if (tmp_hwnd) |hwnd| {
return @ptrCast(hwnd);
Copy link
Preview

Copilot AI Aug 7, 2025

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.

Suggested change
if (tmp_hwnd) |hwnd| {
return @ptrCast(hwnd);
if (tmp_hwnd) |valid_hwnd| {
return @ptrCast(valid_hwnd);

Copilot uses AI. Check for mistakes.

// 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]);
Copy link
Preview

Copilot AI Aug 7, 2025

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.

Suggested change
webui.memcpy(buffer[0..copy_len], test_data[0..copy_len]);
@memcpy(buffer[0..copy_len], test_data[0..copy_len]);

Copilot uses AI. Check for mistakes.

};
defer webui.free(buffer2);

webui.memcpy(buffer2[0..copy_len], buffer[0..copy_len]);
Copy link
Preview

Copilot AI Aug 7, 2025

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.

Suggested change
webui.memcpy(buffer2[0..copy_len], buffer[0..copy_len]);
@memcpy(buffer2[0..copy_len], buffer[0..copy_len]);

Copilot uses AI. Check for mistakes.

@AlbertShown
Copy link
Contributor

…, 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

Is this PR a draft?

@jinzhongjia
Copy link
Member Author

yes, this pr is a draft

@AlbertShown AlbertShown marked this pull request as draft August 8, 2025 15:07
@jinzhongjia
Copy link
Member Author

Many examples can only be built and passed, but the test has not been completed yet, so I need more tests

@AlbertShown
Copy link
Contributor

Understood, take your time @jinzhongjia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants