Skip to content

Add windows support#20

Open
PrathamGhaywat wants to merge 5 commits into
vercel-labs:mainfrom
PrathamGhaywat:feature/add-windows-platform
Open

Add windows support#20
PrathamGhaywat wants to merge 5 commits into
vercel-labs:mainfrom
PrathamGhaywat:feature/add-windows-platform

Conversation

@PrathamGhaywat
Copy link
Copy Markdown
Contributor

Hey! I am happy to say that I successfully added windows as a platfom! So the setup is rather a bit time consuming, since you have to add the WebView SDK if you don't have it (see updated docs). I tested the whole thing with react, vue, next, svelte (had to patch up the svelte example to work by referring to #6)

Please let me know if any changes are required, @ctate. Here is a working app in vue:
image

This should actively close #7 (since it now works on windows!)

cc @ModerIRAQ

ModerIRAQ and others added 4 commits May 9, 2026 23:14
Restore webview2_host.cpp from upstream stub and add full Win32
implementation with dialog and tray support:

- Restore window management, message pump, clipboard (core host)
- Add show_open_dialog via IFileDialog/GetResults (struct return)
- Add show_save_dialog via IFileDialog/GetResult
- Add show_message_dialog via MessageBoxW
- Add tray support: create_tray, update_tray_menu, remove_tray, set_tray_callback
- Add COM initialization (CoInitializeEx) for file dialog support
- Use WM_TRAY_CALLBACK (WM_APP+1) to avoid WM_COMMAND conflicts
- Add WM_NCDESTROY cleanup for GWLP_USERDATA
- Update root.zig: WindowsOpenDialogResult struct, tray/dialog FFI
- Wire tray callback in run() via zero_native_windows_set_tray_callback
- Update 6 example app.zon files to add windows platform
…gfault

- Add webview2_host_types.h with WindowsOpenDialogOpts, WindowsOpenDialogResult,
  WindowsSaveDialogOpts, WindowsMessageDialogOpts struct definitions matching
  Zig FFI layout (prevents ABI mismatch / segfault)
- Fix show_open_dialog: GetResults() returns IShellItemArray**, not IShellItem**
  (calling EnumItems on wrong vtable was the segfault cause)
- Add shobjidl.h include for IShellItemArray type
…lity

Zig 0.17 rejects binary operator '*' with inconsistent whitespace.
Fix three instances in upstream files to allow compilation.
Copilot AI review requested due to automatic review settings May 10, 2026 19:47
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

@PrathamGhaywat is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines +851 to +852
// Set options
DWORD options = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Set options
DWORD options = 0;
// Set options (preserve defaults like FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, etc.)
DWORD options = 0;
pfd->GetOptions(&options);

IFileOpenDialog::SetOptions overwrites all default dialog options (FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, FOS_FORCEFILESYSTEM, etc.) because the code starts from options = 0 instead of reading existing defaults first.

Fix on Vercel

// Set title
if (opts->title && opts->title_len > 0) {
wchar_t *wtitle = new wchar_t[opts->title_len + 1];
MultiByteToWideChar(CP_UTF8, 0, opts->title, (int)opts->title_len, wtitle, (int)opts->title_len + 1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing null-termination in UTF-8 to wide string conversions causes undefined behavior when passed to Windows APIs expecting null-terminated strings.

Fix on Vercel

delete[] wicon;
}

if (tooltip && tooltip_len > 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tray tooltip text is set after Shell_NotifyIconW(NIM_ADD) is called, so the tooltip is never applied to the tray icon.

Fix on Vercel

Comment on lines +851 to +852
// Set options
DWORD options = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Set options
DWORD options = 0;
// Set options (preserve defaults like FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, etc.)
DWORD options = 0;
pfd->GetOptions(&options);

IFileOpenDialog::SetOptions overwrites all default dialog options (FOS_PATHMUSTEXIST, FOS_FILEMUSTEXIST, FOS_FORCEFILESYSTEM, etc.) because the code starts from options = 0 instead of reading existing defaults first.

Fix on Vercel

// Set title
if (opts->title && opts->title_len > 0) {
wchar_t *wtitle = new wchar_t[opts->title_len + 1];
MultiByteToWideChar(CP_UTF8, 0, opts->title, (int)opts->title_len, wtitle, (int)opts->title_len + 1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing null-termination in UTF-8 to wide string conversions causes undefined behavior when passed to Windows APIs expecting null-terminated strings.

Fix on Vercel

delete[] wicon;
}

if (tooltip && tooltip_len > 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tray tooltip text is set after Shell_NotifyIconW(NIM_ADD) is called, so the tooltip is never applied to the tray icon.

Fix on Vercel

Copy link
Copy Markdown

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@k00lagin
Copy link
Copy Markdown

It was also quite easy to build it with CEF
image
https://github.com/k00lagin/vercel_zero-native/tree/windows-cef
This particular aproach is far from best practices, but can be used as a reference

@PrathamGhaywat
Copy link
Copy Markdown
Contributor Author

The CEF one looks even better then native webview. Did you already open a PR @k00lagin?

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.

Windows bridge ABI mismatch breaks build, dev, ...

4 participants