Web panel: an in-game WebView2 page for plugins (API v94) #12

Open
AwfulWaffle wants to merge 17 commits from AwfulWaffle/RynthCore:web-panel into main
First-time contributor

Stack (apply in order): RynthCore #12, RynthCore #13, RynthServers #1, RynthServers #2, RynthServers #3, RynthServers #4. RynthCore first; the RynthServers PRs build against it.

What this adds

An in-game web panel. A plugin can open one WebView2 page over the game window (on its own STA thread, an unowned popup), so a server's website (a market, a suit builder, a character planner) opens inside the game instead of in a separate browser. DreamWeave uses it for its website tools; the RynthServers PRs for that follow.

Plugin API v94, after upstream's v93 (GetMonsterHealth). The number is provisional: upstream's note says unmerged branches also use 94, and whichever merges second renumbers. CoreCLR engine only; the NativeAOT engine leaves the slots zero and HasWebPanel is false.

  • Four slots at the END of the function table, after GetMonsterHealthFn: WebPanelOpenFn, WebPanelNavigateFn, WebPanelCloseFn, WebPanelGetStateFn. SDK wrappers on RynthCoreHost: HasWebPanel, OpenWebPanel(WebPanelOptions), NavigateWebPanel, CloseWebPanel, GetWebPanelState. No call blocks its caller.
  • The plugin passes a host allowlist: https only, default port, no user info, exact host or *.suffix. Off-list navigations and pop-ups never load in the panel (an http(s) URL goes to the system browser, anything else is dropped).
  • A per-world, per-key WebView2 profile, so each account keeps its own cookies.
  • Logs and chat never carry a URL's query, fragment or user info.
  • The panel never steals focus from another program: it takes the foreground only when the game already has it, and hides while another program is in front.
  • /rc webpanel [status|close], and an engine.json kill switch "WebPanel": false.
  • Ships the WebView2 Core and x86 loader in Runtime, with installer checks and notices.
  • docs/WEB_PANEL.md is the plugin contract; Changelog/2026-11-07-web-panel.md has the detail.

RynthCore.PluginSdk.targets raises a shared-SDK release build's RynthPluginMinEngineApi (below 88) to the SDK's API, which is now 94. Plugins that must run on older cores should declare 88 or higher explicitly.

How it was tested

On this branch (upstream c68204f plus this stack):

tools\PluginManifestTests          PASS (354 assertions); -a x86: PASS (360 assertions), offset checks ran with IntPtr.Size=4
tools\SectionsTests                190/190 checks passed
tools\WebPanelTests                PASS (147 assertions)
Publish-EngineCoreClr.ps1 -EngineOnly    0 errors

tools\WebPanelHarness runs the host against real WebView2 offline (needs a desktop; not in Run-AllTests).

In game: run on DreamWeave stage with the DreamWeave plugin. The market, suit builder and class ability planner opened in the panel, logged in through a one-time launch code.

Rebase note

This was built on 418d80b and rebased onto 2026.11.8.1. The only changes from that are the slot order (after GetMonsterHealthFn) and the renumber from 93 to 94, which is its own commit at the tip.

🤖 Generated with Claude Code

Stack (apply in order): RynthCore #12, RynthCore #13, RynthServers #1, RynthServers #2, RynthServers #3, RynthServers #4. RynthCore first; the RynthServers PRs build against it. ## What this adds An in-game web panel. A plugin can open one WebView2 page over the game window (on its own STA thread, an unowned popup), so a server's website (a market, a suit builder, a character planner) opens inside the game instead of in a separate browser. DreamWeave uses it for its website tools; the RynthServers PRs for that follow. Plugin API **v94**, after upstream's v93 (GetMonsterHealth). The number is provisional: upstream's note says unmerged branches also use 94, and whichever merges second renumbers. CoreCLR engine only; the NativeAOT engine leaves the slots zero and `HasWebPanel` is false. - Four slots at the END of the function table, after `GetMonsterHealthFn`: `WebPanelOpenFn`, `WebPanelNavigateFn`, `WebPanelCloseFn`, `WebPanelGetStateFn`. SDK wrappers on `RynthCoreHost`: `HasWebPanel`, `OpenWebPanel(WebPanelOptions)`, `NavigateWebPanel`, `CloseWebPanel`, `GetWebPanelState`. No call blocks its caller. - The plugin passes a host allowlist: https only, default port, no user info, exact host or `*.suffix`. Off-list navigations and pop-ups never load in the panel (an http(s) URL goes to the system browser, anything else is dropped). - A per-world, per-key WebView2 profile, so each account keeps its own cookies. - Logs and chat never carry a URL's query, fragment or user info. - The panel never steals focus from another program: it takes the foreground only when the game already has it, and hides while another program is in front. - `/rc webpanel [status|close]`, and an `engine.json` kill switch `"WebPanel": false`. - Ships the WebView2 Core and x86 loader in Runtime, with installer checks and notices. - `docs/WEB_PANEL.md` is the plugin contract; `Changelog/2026-11-07-web-panel.md` has the detail. `RynthCore.PluginSdk.targets` raises a shared-SDK release build's `RynthPluginMinEngineApi` (below 88) to the SDK's API, which is now 94. Plugins that must run on older cores should declare 88 or higher explicitly. ## How it was tested On this branch (upstream c68204f plus this stack): ``` tools\PluginManifestTests PASS (354 assertions); -a x86: PASS (360 assertions), offset checks ran with IntPtr.Size=4 tools\SectionsTests 190/190 checks passed tools\WebPanelTests PASS (147 assertions) Publish-EngineCoreClr.ps1 -EngineOnly 0 errors ``` `tools\WebPanelHarness` runs the host against real WebView2 offline (needs a desktop; not in Run-AllTests). In game: run on DreamWeave stage with the DreamWeave plugin. The market, suit builder and class ability planner opened in the panel, logged in through a one-time launch code. ## Rebase note This was built on 418d80b and rebased onto 2026.11.8.1. The only changes from that are the slot order (after `GetMonsterHealthFn`) and the renumber from 93 to 94, which is its own commit at the tip. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pure C# policies (allowlist/redaction, visibility/layout, profile folder) plus tools/WebPanelTests (107 assertions).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Uri.IdnHost throws UriFormatException for hosts like c<U+2100>; catch and reject. Test project now runs with ICU so the case is covered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the shipped engine; the surrogate host discriminates the IdnHost try/catch under invariant mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four appended table slots (WebPanelOpen/Navigate/Close/GetState), native structs and code enums in engine and SDK, a WebPanelApi stub answering Unavailable (CoreCLR flavour only; AOT leaves the slots zero), SDK OpenWebPanel/NavigateWebPanel/CloseWebPanel/GetWebPanelState with HasWebPanel gated on Version >= 93, parity tests in PluginManifestTests. Also adds the missing System usings to the Task 1 WebPanel files, which did not compile in the engine project (no ImplicitUsings).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WebPanelStructsMatch now asserts 48 bytes / Reserved at 32 on x86 for engine and SDK types when run 32-bit. PluginContract.cs v93 divider was double-encoded (cp1252 read of UTF-8); restored to box-drawing chars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WebPanelHost (CoreCLR engine only): one unowned WS_POPUP over the game client area on its own STA thread and GetMessage loop, lifted from the 2026-11-07 spike's popup-free path. Open/Navigate/Close/GetState never block: they validate, update the caller-visible state under a lock, queue work and post WM_APP+1 to the host window. WebView2Loader.dll is loaded by full path from the shim's Runtime folder; the runtime probe on the panel thread decides RuntimeMissing, any later creation failure is CreateFailed. Navigation guard (NavigationStarting incl. redirects, NewWindowRequested, LaunchingExternalUriScheme): off-list http/https goes to the system browser, anything else is dropped; logs carry only Redact()ed URLs or hosts. Escape via AcceleratorKeyPressed unless PageKeepsEscape. Visibility by the PID rule on a 50 ms timer plus a foreground WinEvent; raises only when below the game; layout remembered in layout.json. Shutdown unhooks, closes the controller, destroys the window and unregisters the class before the collectible context unloads.

WebPanelNativeArgs copies every string out of the caller's (stack or pooled) buffers before anything is queued. WebPanelApi is the ABI glue (AOT keeps the Unavailable stub). engine.json "WebPanel" (default true) is the kill switch. EngineLifecycle shuts the panel down after EndSceneHook.Uninstall. The WebView2 package's WinForms/WPF references are dropped before reference resolution.

Deviations from the brief: IWebPanelEnvironment gains BrowserExecutableFolderForTests (the harness forces a creation failure with it) and is excluded from the AOT build with the host; Show only takes the foreground when it is already in this process (or none).

tools\WebPanelHarness (x86 exe) + tools\WebPanelHarness.Payload: fake game thread, fake 16 ms pump, collectible context mirroring EngineLoadContext, local virtual hosts, posted input only. 17 ok, 0 FAIL, 4 UNVERIFIED offline (Escape via posted input never raises AcceleratorKeyPressed; visibility needs the foreground): owner in-game checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ProcessFailed: only BrowserProcessExited (teardown) and RenderProcessExited (about:blank, recreate on the next Open) fail the panel, as WebView2's docs describe the kinds; GPU, utility, sandbox, PPAPI and frame-only renderer exits are logged only. RenderProcessUnresponsive fails it at 3 reports within 30 s. The handler acts on the panel being served now.
- Fail decides "ignored" under the lock first and hides the panel only when the failure is live: a late failure for a superseded handle no longer hides the newer panel.
- The panel thread's finally restarts the thread when an Open is still queued and the host is not shutting down; _threadDone goes false only after StartStaThread returns.
- Show takes the foreground only when a window of this process (or of this panel's WebView2 browser process) holds it, never while the foreground is null. The visibility rule counts the browser process (CoreWebView2.BrowserProcessId) as ours, so the page's own dialogs do not hide the panel.
- ClipboardRead is allowed only for an allowlisted origin. NavigationStarting and NewWindowRequested fail closed on an exception.
- WebPanelApiRules: the ABI glue's pure parts (refusals, GetState Size check, state write), tested in WebPanelTests with WebPanelNativeArgs. WebPanelApi.LiveHandle and the browser pid in Describe for Task 4.
- Harness: GpuProcessCrashKeepsPanel and LateFailureForSupersededHandle (both RED before the fix), UnloadWhileVisibleCollected reports UNVERIFIED when the window was not visible, the game-side key count is informational. EngineSettingsTests: WebPanel default-on round trip and setter case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reset the unresponsive counter on teardown, on each new open and on
  navigation completed; harness check UnresponsiveCountResetsPerOpen.
- Show only calls SetForegroundWindow when our process holds the foreground.
- ClipboardRead permission is denied for about:blank.
- Open rolls back live handle and status fields if the STA thread fails to start.
- State struct minimum size is 28 on both platforms; test asserts it unguarded.
- Harness Escape message reports game key count as informational.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Status prints one redacted line (WebPanelApi.Describe plus the address space);
close closes the live panel. Neither opens a URL. WebPanelHost.Describe now
reports visible/focused/in-browser instead of raw flags; the stacked test-hook
summaries are put back on their own members. ChatCommandReplyTests covers the verb.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build-Installer.ps1 now requires Runtime\Microsoft.Web.WebView2.Core.dll and
Runtime\WebView2Loader.dll in a CoreCLR staging tree. THIRD-PARTY-NOTICES.md
gains the Microsoft WebView2 SDK entry with the licence copied from the package's
LICENSE.txt. A scratch EngineOnly publish put both DLLs at the target root, the
loader is x86 (0x14C), and no runtimes\ folder or WinForms/Wpf DLL is present, so
no csproj change was needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- RynthCoreChatCommands: each method keeps its own summary; /rc webpanel close answers by the Close code (closing / already closed / could not close); verb added to the class header list.
- Build-Installer.ps1: Assert-PeMachine throws unless Runtime\WebView2Loader.dll is x86 (0x14C).
- ChatCommandReplyTests: HandleWebPanelCommand has no Open(, Navigate( or ShellExecute.
- Engine csproj: Microsoft.Web.WebView2.Core.xml is not copied (with the other dropped WebView2 copies).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plugin contract (docs/WEB_PANEL.md) and changelog for the v93 web panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Creation-failure fallback sets OpenedInBrowser and says "opened" only
  when the system browser actually opened; otherwise chat says the
  browser did not open. Harness check CreateFailureBrowserFails.
- FocusPage follows the same in-process foreground rule as
  SetForegroundWindow (Show and controller creation). Harness check
  NoFocusFromAnotherProcess; posted-key checks report UNVERIFIED when
  another process holds the foreground.
- PermissionRequested: SavesInProfile = false.
- WEB_PANEL.md: allowlist empty-entry rule, GetState -4, AOT renumber
  caveat, softened focus claim (also in the Changelog).
- Formatting: ChatCommandReplyTests brace, /rc layout comment,
  PluginContract blank line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plugin polling between Failed and OpenedInBrowser saw Failed with no
flag and, per the docs, opened the page itself: a second open with a
spent code. While the fallback is pending the status keeps its
pre-failure value; after OpenInBrowser (outside the lock) one lock sets
Failed, the error and, when the browser opened, the flag. The
no-fallback path is unchanged. Harness: OpenInBrowser delay mode and a
continuous poll in CreateFailureFallsBack. Show comments reworded as
defensive, not observed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream release 2026.11.8.1 took v93 for GetMonsterHealth. The web panel's four slots now follow
GetMonsterHealthFn in the engine table and the SDK's RynthCoreApiNative, and the web panel is v94:
PluginContractVersion.Current, RynthCoreSdkApiVersion, HasWebPanel (Version >= 94), the comments,
docs/WEB_PANEL.md, the changelog and PluginManifestTests (HasWebPanel version cases, slot names).
Still provisional: unmerged upstream branches also use 94.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This pull request has changes conflicting with the target branch.
  • src/RynthCore.Engine/Plugins/PluginContract.cs
  • src/RynthCore.Engine/Plugins/PluginContractVersion.cs
  • src/RynthCore.Engine/Plugins/PluginManager.cs
  • src/RynthCore.Engine/WebPanel/WebPanelHost.cs
  • src/RynthCore.Engine/WebPanel/WebPanelNative.cs
  • src/RynthCore.Engine/WebPanel/WebPanelWindowPolicy.cs
  • src/RynthCore.PluginSdk/RynthCoreApiNative.cs
  • src/RynthCore.PluginSdk/RynthCoreHost.cs
  • src/RynthCore.PluginSdk/build/RynthCore.PluginSdk.targets
  • tools/PluginManifestTests/Program.cs
  • tools/WebPanelHarness/Program.cs
  • tools/WebPanelTests/Program.cs
  • tools/WebPanelTests/WebPanelTests.csproj
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u web-panel:AwfulWaffle-web-panel
git switch AwfulWaffle-web-panel

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff AwfulWaffle-web-panel
git switch AwfulWaffle-web-panel
git rebase main
git switch main
git merge --ff-only AwfulWaffle-web-panel
git switch AwfulWaffle-web-panel
git rebase main
git switch main
git merge --no-ff AwfulWaffle-web-panel
git switch main
git merge --squash AwfulWaffle-web-panel
git switch main
git merge --ff-only AwfulWaffle-web-panel
git switch main
git merge AwfulWaffle-web-panel
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rynth/RynthCore!12
No description provided.