Skip to content

Commit 1f1f3de

Browse files
bkudiessCopilot
andcommitted
Merge paulcam206-themes-11-runtime (4c9e7f7) into paulcam206-themes-12-design
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2 parents 91d9f2b + 4c9e7f7 commit 1f1f3de

9 files changed

Lines changed: 146 additions & 46 deletions

File tree

‎.github/scripts/gateway-fixture-report/package-lock.json‎

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/scripts/gateway-fixture-report/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"type": "module",
55
"dependencies": {
66
"@actions/artifact": "6.3.1",
7-
"fast-xml-parser": "5.11.2"
7+
"fast-xml-parser": "5.12.1"
88
}
99
}

‎.github/workflows/copilot-setup-steps.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v7
2323
- name: Install gh-aw extension
24-
uses: github/gh-aw-actions/setup-cli@406c7719e31d7fe354224d4bb8fe3d4aeb47da1c # v1.2.1
24+
uses: github/gh-aw-actions/setup-cli@dfe97a19c8249d41e2adfc95f92db2b8facea58f # v1.3.1
2525
with:
2626
version: v0.72.1

‎scripts/test-alpha-promotion-versioning.ps1‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ $root = Split-Path $PSScriptRoot -Parent
1212
$fixture = Join-Path ([IO.Path]::GetTempPath()) "openclaw-promotion-version-$([guid]::NewGuid().ToString('N'))"
1313
New-Item -ItemType Directory -Path $fixture | Out-Null
1414
$savedEnvironment = @{}
15-
foreach ($name in @('GITHUB_ACTIONS', 'GITHUB_REF', 'GITHUB_SHA', 'OPENCLAW_RELEASE_TAG', 'OPENCLAW_RELEASE_SOURCE_SHA')) {
15+
# Start neutral: on a main push runner, GitVersion 7 would version the local main tip instead of the detached candidate.
16+
foreach ($name in @('GITHUB_ACTIONS', 'GITHUB_REF', 'GITHUB_HEAD_REF', 'GITHUB_SHA', 'OPENCLAW_RELEASE_TAG', 'OPENCLAW_RELEASE_SOURCE_SHA')) {
1617
$savedEnvironment[$name] = [Environment]::GetEnvironmentVariable($name)
18+
[Environment]::SetEnvironmentVariable($name, $null)
1719
}
1820

1921
function Invoke-FixtureGit {
@@ -70,7 +72,7 @@ try {
7072
if ((Get-FixtureVersion $checkout) -cne '2026.9.5') { throw 'Alpha and stable tags at the same SHA did not resolve to stable.' }
7173
if ((& git -C $checkout rev-parse HEAD).Trim() -cne $candidate) { throw 'GitVersion replaced the product checkout with the pipeline revision.' }
7274
foreach ($name in $savedEnvironment.Keys) {
73-
[Environment]::SetEnvironmentVariable($name, $savedEnvironment[$name])
75+
[Environment]::SetEnvironmentVariable($name, $null)
7476
}
7577
& git -C $fixture show-ref --verify --quiet refs/tags/v2026.9.5
7678
if ($LASTEXITCODE -eq 0) { throw 'Preparation leaked a public stable tag.' }

‎scripts/test-wipe-openclaw-state.ps1‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ with tempfile.TemporaryDirectory() as tree:
240240
check("non-model removed", (root / "OpenClawTray" / "settings.json").exists(), False)
241241
check("kept list records model", kept, [root / "OpenClawTray" / "LocalAI" / "models" / "keep.gguf"])
242242
243+
# Junctions are not walked and rmdir removes only the link. The lstat helper
244+
# is the Python 3.11 path; 3.12+ also has Path.is_junction.
245+
junction_root = Path(wipe.temp) / "junction-proof"
246+
target = junction_root / "target"
247+
parent = junction_root / "OpenClawTray"
248+
junction = parent / "via"
249+
target.mkdir(parents=True)
250+
parent.mkdir()
251+
(target / "hidden.gguf").write_bytes(b"through-junction")
252+
created = subprocess.run(["cmd", "/c", "mklink", "/J", str(junction), str(target)], check=False, capture_output=True, text=True)
253+
if created.returncode != 0:
254+
failures.append(f"mklink /J failed: {created.stderr.strip() or created.stdout.strip()}")
255+
else:
256+
check("directory is not a junction", wipe.is_junction(parent), False)
257+
check("missing path is not a junction", wipe.is_junction(junction_root / "missing"), False)
258+
check("mount point is a junction", wipe.is_junction(junction), True)
259+
check("fallback sees the mount point", wipe._is_mount_point(junction), True)
260+
check("fallback ignores a directory", wipe._is_mount_point(parent), False)
261+
check("models do not walk a junction", wipe.models_in(junction), [])
262+
kept = []
263+
wipe.remove_path(junction, kept)
264+
check("junction link removed", junction.exists(), False)
265+
check("junction target kept", (target / "hidden.gguf").is_file(), True)
266+
243267
# Orphan session detection covers the retained development identity, not just the Store prefix.
244268
packages_root = Path(wipe.localappdata) / "Packages"
245269
dev_family = "OpenClaw.Gateway_4tq5h6e8r9k2m"

‎scripts/wipe_openclaw_state.py‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"openclawfoundation.openclawgateway", # Store
102102
"openclaw.gateway", # retained development identity
103103
))
104-
DEV_PATCH = re.compile(r"\A[a-z0-9](?:[a-z0-9-]{0,13}[a-z0-9])?\z") # mirrors -Patch in Deploy-LocalPackage.ps1
104+
DEV_PATCH = re.compile(r"\A[a-z0-9](?:[a-z0-9-]{0,13}[a-z0-9])?\Z") # mirrors -Patch in Deploy-LocalPackage.ps1
105105
GATEWAY_PACKAGE_PREFIX = "openclawfoundation.openclawgateway" # Store name or Store-<dev patch>
106106
LXSS_KEY = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss" # per-user WSL distro registrations (name + BasePath)
107107
NATIVE_SESSION = Path("LocalState", "OpenClawGatewayMSIX", "session.json")
@@ -739,11 +739,36 @@ def scan(root: Path, shortcuts_only: bool) -> None:
739739
return sorted((p for p in found.values() if not is_excluded(p)), key=lambda p: str(p).lower())
740740

741741

742+
def _is_mount_point(path: Path) -> bool:
743+
"""Directory junction test for interpreters without Path.is_junction (before 3.12).
744+
745+
os.lstat already returns the reparse tag. A missing path is not a junction.
746+
Any other inspection failure aborts the inventory.
747+
"""
748+
try:
749+
info = os.lstat(path)
750+
except FileNotFoundError:
751+
return False
752+
except OSError as exc:
753+
raise InventoryError(f"could not tell whether {path} is a junction: {exc}") from exc
754+
return getattr(info, "st_reparse_tag", 0) == stat.IO_REPARSE_TAG_MOUNT_POINT
755+
756+
757+
def is_junction(path: Path) -> bool:
758+
"""True for a directory junction. A missing path is false. An unreadable reparse point aborts."""
759+
native = getattr(type(path), "is_junction", None)
760+
if native is not None:
761+
return bool(native(path))
762+
if os.name != "nt":
763+
return False
764+
return _is_mount_point(path)
765+
766+
742767
def models_in(path: Path) -> list[Path]:
743768
"""*.gguf files remove_path would keep (symlinks are removed: they are not the model)."""
744769
if path.suffix.lower() == MODEL_SUFFIX and not path.is_symlink():
745770
return [path]
746-
if path.is_dir() and not path.is_symlink() and not path.is_junction():
771+
if path.is_dir() and not path.is_symlink() and not is_junction(path):
747772
return [p for p in path.rglob(f"*{MODEL_SUFFIX}")
748773
if p.is_file() and not p.is_symlink() and not is_excluded(p)]
749774
return []
@@ -797,7 +822,7 @@ def remove_path(path: Path, kept: list[Path]) -> None:
797822
if is_excluded(path):
798823
kept.append(path)
799824
return
800-
if path.is_junction() or (path.is_symlink() and path.is_dir()):
825+
if is_junction(path) or (path.is_symlink() and path.is_dir()):
801826
os.rmdir(path) # removes the link only, never the target's contents
802827
elif path.is_symlink():
803828
path.unlink()

‎src/OpenClaw.Tray.WinUI/Helpers/CanvasGatewayUrlRewriter.cs‎

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,21 @@ internal static class CanvasGatewayUrlRewriter
1111

1212
var uri = new Uri(GatewayUrlHelper.NormalizeForWebSocket(gatewayUrl));
1313
var httpScheme = uri.Scheme == "wss" ? "https" : "http";
14-
return $"{httpScheme}://{uri.Host}:{uri.Port}";
14+
return FormatHttpOrigin(httpScheme, uri.Host, uri.Port);
15+
}
16+
17+
/// <summary>
18+
/// True when both values are http(s) URLs with the same scheme, host, and port.
19+
/// Default ports match whether or not the URL text includes <c>:443</c> or <c>:80</c>.
20+
/// </summary>
21+
public static bool SharesHttpOrigin(string? url, string? origin)
22+
{
23+
if (!TryReadHttpOrigin(url, out var left) || !TryReadHttpOrigin(origin, out var right))
24+
return false;
25+
26+
return string.Equals(left.Scheme, right.Scheme, StringComparison.OrdinalIgnoreCase)
27+
&& string.Equals(left.IdnHost, right.IdnHost, StringComparison.OrdinalIgnoreCase)
28+
&& left.Port == right.Port;
1529
}
1630

1731
public static string Rewrite(string url, string? effectiveGatewayOrigin, string? configuredGatewayOrigin)
@@ -23,21 +37,38 @@ public static string Rewrite(string url, string? effectiveGatewayOrigin, string?
2337
return effectiveGatewayOrigin + url;
2438

2539
var uri = new Uri(url);
26-
var urlOrigin = $"{uri.Scheme}://{uri.Host}:{uri.Port}";
40+
if (uri.Scheme is not ("http" or "https"))
41+
return url;
2742

28-
if (IsGatewayOrigin(urlOrigin, effectiveGatewayOrigin, configuredGatewayOrigin) &&
29-
!urlOrigin.Equals(effectiveGatewayOrigin, StringComparison.OrdinalIgnoreCase))
43+
if (SharesHttpOrigin(url, configuredGatewayOrigin) &&
44+
!SharesHttpOrigin(url, effectiveGatewayOrigin))
3045
{
3146
return effectiveGatewayOrigin + uri.PathAndQuery;
3247
}
3348

3449
return url;
3550
}
3651

37-
private static bool IsGatewayOrigin(string urlOrigin, string effectiveGatewayOrigin, string? configuredGatewayOrigin)
52+
private static string FormatHttpOrigin(string scheme, string host, int port)
3853
{
39-
return urlOrigin.Equals(effectiveGatewayOrigin, StringComparison.OrdinalIgnoreCase) ||
40-
(!string.IsNullOrEmpty(configuredGatewayOrigin) &&
41-
urlOrigin.Equals(configuredGatewayOrigin, StringComparison.OrdinalIgnoreCase));
54+
var formattedHost = host.Contains(':') && !host.StartsWith('[') ? $"[{host}]" : host;
55+
var omitDefaultPort = (scheme == "https" && port == 443) || (scheme == "http" && port == 80);
56+
return omitDefaultPort
57+
? $"{scheme}://{formattedHost}"
58+
: $"{scheme}://{formattedHost}:{port}";
59+
}
60+
61+
private static bool TryReadHttpOrigin(string? value, out Uri uri)
62+
{
63+
uri = null!;
64+
if (string.IsNullOrWhiteSpace(value) ||
65+
!Uri.TryCreate(value, UriKind.Absolute, out var parsed) ||
66+
parsed.Scheme is not ("http" or "https"))
67+
{
68+
return false;
69+
}
70+
71+
uri = parsed;
72+
return true;
4273
}
4374
}

‎src/OpenClaw.Tray.WinUI/Windows/CanvasWindow.xaml.cs‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,8 @@ private bool IsUrlSafe(string url)
9494
{
9595
return true;
9696
}
97-
// Allow URLs from the trusted gateway origin with strict boundary check
98-
if (!string.IsNullOrEmpty(_trustedGatewayOrigin) &&
99-
url.StartsWith(_trustedGatewayOrigin, StringComparison.OrdinalIgnoreCase) &&
100-
(url.Length == _trustedGatewayOrigin.Length ||
101-
url[_trustedGatewayOrigin.Length] == '/' ||
102-
url[_trustedGatewayOrigin.Length] == '?' ||
103-
url[_trustedGatewayOrigin.Length] == '#'))
97+
// Scheme, host, and port. A portless https URL and the same URL with :443 are one origin.
98+
if (CanvasGatewayUrlRewriter.SharesHttpOrigin(url, _trustedGatewayOrigin))
10499
{
105100
return true;
106101
}
@@ -790,14 +785,8 @@ private static bool IsTrustedA2UIUrl(string url)
790785
return uri.AbsolutePath.StartsWith("/__openclaw__/a2ui/", StringComparison.OrdinalIgnoreCase);
791786
}
792787

793-
private static bool IsUriForOrigin(string uri, string origin)
794-
{
795-
return uri.StartsWith(origin, StringComparison.OrdinalIgnoreCase) &&
796-
(uri.Length == origin.Length ||
797-
uri[origin.Length] == '/' ||
798-
uri[origin.Length] == '?' ||
799-
uri[origin.Length] == '#');
800-
}
788+
private static bool IsUriForOrigin(string uri, string origin) =>
789+
CanvasGatewayUrlRewriter.SharesHttpOrigin(uri, origin);
801790

802791
private Task EnsureWebViewReadyAsync()
803792
{

‎tests/OpenClaw.Tray.Tests/CanvasGatewayUrlRewriterTests.cs‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,38 @@ public void Rewrite_MapsRelativePathToEffectiveGatewayOrigin()
3838
}
3939

4040
[Fact]
41-
public void ToHttpOrigin_NormalizesWebSocketUrls()
41+
public void ToHttpOrigin_OmitsDefaultPortsAndKeepsExplicitPorts()
4242
{
43-
Assert.Equal("https://gateway.example:443", CanvasGatewayUrlRewriter.ToHttpOrigin("wss://gateway.example"));
43+
Assert.Equal("https://gateway.example", CanvasGatewayUrlRewriter.ToHttpOrigin("wss://gateway.example"));
44+
Assert.Equal("https://gateway.example:8443", CanvasGatewayUrlRewriter.ToHttpOrigin("wss://gateway.example:8443"));
4445
Assert.Equal("http://localhost:18789", CanvasGatewayUrlRewriter.ToHttpOrigin("ws://localhost:18789"));
46+
Assert.Equal("https://[::1]", CanvasGatewayUrlRewriter.ToHttpOrigin("wss://[::1]"));
47+
}
48+
49+
[Fact]
50+
public void Rewrite_MapsPortlessPrivateGatewayIncludingExplicitDefaultPort()
51+
{
52+
var configured = CanvasGatewayUrlRewriter.ToHttpOrigin("wss://192.168.1.5");
53+
var effective = CanvasGatewayUrlRewriter.ToHttpOrigin("ws://127.0.0.1:18789");
54+
55+
Assert.Equal("https://192.168.1.5", configured);
56+
Assert.Equal(
57+
"http://127.0.0.1:18789/__openclaw__/canvas/",
58+
CanvasGatewayUrlRewriter.Rewrite("https://192.168.1.5/__openclaw__/canvas/", effective, configured));
59+
Assert.Equal(
60+
"http://127.0.0.1:18789/__openclaw__/canvas/",
61+
CanvasGatewayUrlRewriter.Rewrite("https://192.168.1.5:443/__openclaw__/canvas/", effective, configured));
62+
}
63+
64+
[Theory]
65+
[InlineData("https://192.168.1.5/canvas", "https://192.168.1.5", true)]
66+
[InlineData("https://192.168.1.5:443/canvas", "https://192.168.1.5", true)]
67+
[InlineData("https://100.64.0.1/canvas", "https://100.64.0.1", true)]
68+
[InlineData("https://192.168.1.5.evil/canvas", "https://192.168.1.5", false)]
69+
[InlineData("https://192.168.1.5/canvas", "https://192.168.1.5:8443", false)]
70+
[InlineData("https://example.com/canvas", "https://192.168.1.5", false)]
71+
public void SharesHttpOrigin_MatchesSchemeHostAndPort(string url, string origin, bool expected)
72+
{
73+
Assert.Equal(expected, CanvasGatewayUrlRewriter.SharesHttpOrigin(url, origin));
4574
}
4675
}

0 commit comments

Comments
 (0)