Skip to content

Commit f627285

Browse files
authored
Merge branch 'main' into fix/discord-gateway-exponential-backoff
2 parents 8d08bd3 + 2e2366b commit f627285

62 files changed

Lines changed: 1316 additions & 547 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@ jobs:
13481348
;;
13491349
test-types)
13501350
pnpm check:test-types
1351+
pnpm tsgo:scripts
13511352
;;
13521353
*)
13531354
echo "Unsupported check task: $TASK" >&2

‎apps/.i18n/native-source.json‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18321,33 +18321,49 @@
1832118321
"surface": "apple",
1832218322
"id": "native.apple.185a1b27c9859cc0"
1832318323
},
18324+
{
18325+
"kind": "ui-call",
18326+
"line": 114,
18327+
"path": "apps/macos/Sources/OpenClaw/MenuBar.swift",
18328+
"source": "Back",
18329+
"surface": "apple",
18330+
"id": "native.apple.f6048387f9b99c8e"
18331+
},
18332+
{
18333+
"kind": "ui-call",
18334+
"line": 119,
18335+
"path": "apps/macos/Sources/OpenClaw/MenuBar.swift",
18336+
"source": "Forward",
18337+
"surface": "apple",
18338+
"id": "native.apple.c19b0989064c0020"
18339+
},
1832418340
{
1832518341
"kind": "conditional-branch",
18326-
"line": 126,
18342+
"line": 137,
1832718343
"path": "apps/macos/Sources/OpenClaw/MenuBar.swift",
1832818344
"source": "OpenClaw",
1832918345
"surface": "apple",
1833018346
"id": "native.apple.fae2cf18519da0d5"
1833118347
},
1833218348
{
1833318349
"kind": "conditional-branch",
18334-
"line": 126,
18350+
"line": 137,
1833518351
"path": "apps/macos/Sources/OpenClaw/MenuBar.swift",
1833618352
"source": "OpenClaw - Voice Wake live meter active",
1833718353
"surface": "apple",
1833818354
"id": "native.apple.13a7356f48278757"
1833918355
},
1834018356
{
1834118357
"kind": "conditional-branch",
18342-
"line": 327,
18358+
"line": 338,
1834318359
"path": "apps/macos/Sources/OpenClaw/MenuBar.swift",
1834418360
"source": "Close Canvas",
1834518361
"surface": "apple",
1834618362
"id": "native.apple.ef59188264be95d4"
1834718363
},
1834818364
{
1834918365
"kind": "conditional-branch",
18350-
"line": 327,
18366+
"line": 338,
1835118367
"path": "apps/macos/Sources/OpenClaw/MenuBar.swift",
1835218368
"source": "Open Canvas",
1835318369
"surface": "apple",

‎apps/macos/Sources/OpenClaw/DashboardManager.swift‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ final class DashboardManager {
163163
self.controller?.closeDashboard()
164164
}
165165

166+
func navigateBack() {
167+
guard self.controller?.window?.isKeyWindow == true else { return }
168+
self.controller?.navigateBack()
169+
}
170+
171+
func navigateForward() {
172+
guard self.controller?.window?.isKeyWindow == true else { return }
173+
self.controller?.navigateForward()
174+
}
175+
166176
private static func websocketURLString(for dashboardURL: URL) -> String {
167177
guard var components = URLComponents(url: dashboardURL, resolvingAgainstBaseURL: false) else {
168178
return dashboardURL.absoluteString

‎apps/macos/Sources/OpenClaw/DashboardWindowController.swift‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,14 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
537537
return button
538538
}
539539

540+
func navigateBack() {
541+
self.activeNavigationWebView.goBack()
542+
}
543+
544+
func navigateForward() {
545+
self.activeNavigationWebView.goForward()
546+
}
547+
540548
@objc private func navigateBack(_: Any?) {
541549
self.webView.goBack()
542550
}
@@ -545,6 +553,16 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
545553
self.webView.goForward()
546554
}
547555

556+
private var activeNavigationWebView: WKWebView {
557+
guard let linkWebView = self.linkBrowser.activeWebView,
558+
let firstResponder = self.window?.firstResponder as? NSView,
559+
firstResponder === linkWebView || firstResponder.isDescendant(of: linkWebView)
560+
else {
561+
return self.webView
562+
}
563+
return linkWebView
564+
}
565+
548566
private static func makeWindow(contentView: NSView) -> NSWindow {
549567
let window = NSWindow(
550568
contentRect: NSRect(origin: .zero, size: DashboardWindowLayout.windowSize),
@@ -1036,5 +1054,18 @@ extension DashboardWindowController {
10361054
var _testAllowsBackForwardGestures: Bool {
10371055
self.webView.allowsBackForwardNavigationGestures
10381056
}
1057+
1058+
var _testNavigationWebViewIdentity: ObjectIdentifier {
1059+
ObjectIdentifier(self.activeNavigationWebView)
1060+
}
1061+
1062+
var _testDashboardWebViewIdentity: ObjectIdentifier {
1063+
ObjectIdentifier(self.webView)
1064+
}
1065+
1066+
func _testFocusLinkBrowser() -> Bool {
1067+
guard let webView = self.linkBrowser.activeWebView else { return false }
1068+
return self.window?.makeFirstResponder(webView) == true
1069+
}
10391070
}
10401071
#endif

‎apps/macos/Sources/OpenClaw/MenuBar.swift‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ struct OpenClawApp: App {
110110
.keyboardShortcut(",", modifiers: .command)
111111
}
112112
SidebarCommands()
113+
CommandMenu("Navigate") {
114+
Button("Back") {
115+
DashboardManager.shared.navigateBack()
116+
}
117+
.keyboardShortcut("[", modifiers: .command)
118+
119+
Button("Forward") {
120+
DashboardManager.shared.navigateForward()
121+
}
122+
.keyboardShortcut("]", modifiers: .command)
123+
}
113124
}
114125
.onChange(of: self.isMenuPresented) { _, _ in
115126
self.updateStatusHighlight()

‎apps/macos/Tests/OpenClawIPCTests/DashboardWindowSmokeTests.swift‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ struct DashboardWindowSmokeTests {
4242
buttonNumber: 1))
4343
}
4444

45+
@Test func `dashboard navigation shortcuts target the focused browser`() throws {
46+
let dashboard = try #require(URL(string: "http://127.0.0.1:18789/control/"))
47+
let controller = DashboardWindowController(
48+
url: dashboard,
49+
auth: DashboardWindowAuth(gatewayUrl: nil, token: nil, password: nil))
50+
#expect(controller._testNavigationWebViewIdentity == controller._testDashboardWebViewIdentity)
51+
52+
controller._testOpenLinkBrowser(try #require(URL(string: "https://docs.openclaw.ai/")))
53+
let linkWebView = try #require(controller._testLinkBrowserWebViewIdentity)
54+
#expect(controller._testFocusLinkBrowser())
55+
#expect(controller._testNavigationWebViewIdentity == linkWebView)
56+
}
57+
4558
@Test func `dashboard parses only bounded native link requests`() throws {
4659
let request = DashboardWindowController.linkRequest(from: [
4760
"type": "open-link",

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,7 @@
19621962
"tsgo:extensions:test": "node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo",
19631963
"tsgo:prod": "pnpm tsgo:core && pnpm tsgo:extensions",
19641964
"tsgo:profile": "node scripts/profile-tsgo.mjs",
1965+
"tsgo:scripts": "node scripts/run-tsgo.mjs -p tsconfig.scripts.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/scripts.tsbuildinfo",
19651966
"tsgo:test": "pnpm tsgo:core:test && pnpm tsgo:extensions:test",
19661967
"tsgo:test:extensions": "pnpm tsgo:extensions:test",
19671968
"tsgo:test:packages": "node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.packages.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-packages.tsbuildinfo",

‎scripts/android-app-i18n.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function checkAndroidAppI18n() {
6565
]);
6666
const [base, ...translations] = localeStrings;
6767
const baseKeys = new Set(base.keys());
68-
const problems = translations.flatMap((strings, index) => {
68+
const problems: Array<readonly [string, string[]]> = translations.flatMap((strings, index) => {
6969
const locale = NATIVE_I18N_LOCALES[index];
7070
const keys = new Set(strings.keys());
7171
const placeholderMismatches = [...base].flatMap(([key, sourceValue]) => {

‎scripts/anthropic-prompt-probe.ts‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,16 @@ function listSetupTokenProfiles(
212212
store: { profiles: Record<string, AuthProfileCredential> },
213213
normalizeProviderId: (provider: string) => string,
214214
): Array<{ id: string; token: string }> {
215-
return Object.entries(store.profiles)
216-
.filter(([, cred]) => {
217-
if (cred.type !== "token") {
218-
return false;
219-
}
220-
if (normalizeProviderId(cred.provider) !== "anthropic") {
221-
return false;
222-
}
223-
return isSetupToken(cred.token ?? "");
224-
})
225-
.map(([id, cred]) => ({ id, token: cred.token ?? "" }));
215+
return Object.entries(store.profiles).flatMap(([id, cred]) => {
216+
if (
217+
cred.type !== "token" ||
218+
normalizeProviderId(cred.provider) !== "anthropic" ||
219+
!isSetupToken(cred.token ?? "")
220+
) {
221+
return [];
222+
}
223+
return [{ id, token: cred.token ?? "" }];
224+
});
226225
}
227226

228227
function pickSetupTokenProfile(candidates: Array<{ id: string; token: string }>): {
@@ -390,15 +389,16 @@ async function startAnthropicProxy(params: { port: number; upstreamBaseUrl: stri
390389
}
391390
headers.set(key, Array.isArray(value) ? value.join(", ") : value);
392391
}
393-
const upstreamRes = await fetch(upstreamUrl, {
392+
const upstreamInit = {
394393
method,
395394
headers,
396395
body:
397396
method === "GET" || method === "HEAD" || requestBody.byteLength === 0
398397
? undefined
399-
: requestBody,
398+
: Uint8Array.from(requestBody),
400399
duplex: "half",
401-
});
400+
} as RequestInit & { duplex: "half" };
401+
const upstreamRes = await fetch(upstreamUrl, upstreamInit);
402402
const responseHeaders: Record<string, string> = {};
403403
for (const [key, value] of upstreamRes.headers.entries()) {
404404
const lower = key.toLowerCase();
@@ -926,19 +926,21 @@ async function runGatewayPrompt(prompt: string): Promise<PromptResult> {
926926
mode: "cli",
927927
});
928928
const text = extractPayloadText(waitRes);
929+
const waitStatus = typeof waitRes.status === "string" ? waitRes.status : undefined;
930+
const waitError = typeof waitRes.error === "string" ? waitRes.error : undefined;
929931
const logTail = await readLogTail(logPath);
930-
const matched400 = matchesExtraUsage400(waitRes.error, logTail, JSON.stringify(waitRes));
932+
const matched400 = matchesExtraUsage400(waitError, logTail, JSON.stringify(waitRes));
931933
return {
932934
prompt,
933-
ok: waitRes.status === "ok" && !matched400,
935+
ok: waitStatus === "ok" && !matched400,
934936
transport: "gateway",
935937
promptMode: GATEWAY_PROMPT_MODE,
936-
status: waitRes.status,
938+
status: waitStatus,
937939
text: text || undefined,
938940
error:
939-
waitRes.status === "ok"
941+
waitStatus === "ok"
940942
? undefined
941-
: redactForDevToolLog(waitRes.error || logTail || "agent.wait failed"),
943+
: redactForDevToolLog(waitError || logTail || "agent.wait failed"),
942944
matchedExtraUsage400: matched400,
943945
capture: summarizeCapture(proxy?.getLastCapture(), prompt),
944946
...promptProbeTmpResult(tmpDir),

‎scripts/apple-app-i18n.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ const LOCALIZED_WRAPPER_CONTRACTS: Record<string, string[]> = {
2424
],
2525
};
2626

27-
const CATALOGS = [
27+
type AppleCatalogSpec = {
28+
path: string;
29+
coverage: Record<string, readonly string[]>;
30+
};
31+
32+
const CATALOGS: readonly AppleCatalogSpec[] = [
2833
{
2934
path: "apps/ios/Resources/Localizable.xcstrings",
3035
coverage: {
@@ -99,7 +104,7 @@ const CATALOGS = [
99104
"apps/macos/Sources/OpenClaw/CronSettings+Rows.swift": ["Run now"],
100105
},
101106
},
102-
] as const;
107+
];
103108

104109
type Catalog = {
105110
sourceLanguage?: string;

0 commit comments

Comments
 (0)