ServerPack web open: a request never prints its URL; Windows error wording

WebOpenRequest is a record, so its generated ToString printed the URL, which
can carry a one-time code. It now names the title only. The browser failure
reads "Couldn't open your browser (Windows error N)."

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 15:45:18 -08:00
commit 8dda4fdf96
3 changed files with 26 additions and 4 deletions

View file

@ -70,12 +70,12 @@ public sealed partial class ServerPackPlugin
{
long code = ShellExecuteW(IntPtr.Zero, "open", url, null, null, 1).ToInt64();
ok = code > 32;
message = ok ? "Opened in your browser." : $"Couldn't open your browser (code {code}).";
message = ok ? "Opened in your browser." : $"Couldn't open your browser (Windows error {code}).";
}
catch (Exception)
{
ok = false;
message = "Couldn't open your browser (code 0).";
message = "Couldn't open your browser (Windows error 0).";
}
Finish(done, new WebOpenOutcome(WebOpenRoute.Browser, ok, message));
})

View file

@ -7,8 +7,14 @@ using System.Collections.Generic;
namespace RynthCore.Plugin.ServerPack;
/// <summary>A page to open. The URL comes from constants in the plugin, never from chat.</summary>
internal sealed record WebOpenRequest(string Url, IReadOnlyList<string> AllowedHosts, string ProfileKey, string Title);
/// <summary>
/// A page to open. The URL comes from constants in the plugin, never from chat, but it may carry a
/// one-time code, so ToString names the title only (a record's generated ToString would print the URL).
/// </summary>
internal sealed record WebOpenRequest(string Url, IReadOnlyList<string> AllowedHosts, string ProfileKey, string Title)
{
public override string ToString() => "WebOpenRequest(" + Title + ")";
}
internal enum WebOpenRoute { Panel, Browser, Refused }