Skip to content

Commit 79969de

Browse files
authored
Merge branch 'main' into fix-discord-final-answer-payload
2 parents a0690eb + 9e67f53 commit 79969de

275 files changed

Lines changed: 12014 additions & 3385 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.

‎.agents/skills/crabbox/SKILL.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ Use the smallest Crabbox lane that proves the reported user path, not just the
287287
touched code. Aim for one after-fix E2E proof before commenting, closing, or
288288
opening a PR for a user-visible bug.
289289

290+
When the user says "test in Crabbox", do not simply copy tests to the remote
291+
box and run them there. Crabbox is for remote real-scenario proof: copy or
292+
install OpenClaw as the user would, run the same setup/update/CLI/Gateway/API
293+
call that failed, and capture behavior from that entrypoint. For regressions or
294+
bug reports, prove the broken state first when feasible, then run the same
295+
scenario after the fix.
296+
290297
Pick the lane by symptom:
291298

292299
- Docker/setup/install bug: build a package tarball and run the matching
@@ -308,8 +315,9 @@ Pick the lane by symptom:
308315

309316
Efficient flow:
310317

311-
1. Reproduce or prove the pre-fix symptom when feasible. If the issue cannot be
312-
reproduced, capture the exact command and observed behavior instead.
318+
1. Reproduce or prove the pre-fix symptom from the real user-facing entrypoint
319+
when feasible. If the issue cannot be reproduced, capture the exact command
320+
and observed behavior instead.
313321
2. Patch locally and run narrow local tests for edit speed.
314322
3. Run one Crabbox E2E command that starts from the user-facing entrypoint:
315323
package install, Docker setup, onboarding, channel add, gateway start, or

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Skills own workflows; root owns hard policy and routing.
6565
## Validation
6666

6767
- Use `$openclaw-testing` for test/CI choice and `$crabbox` for remote/full/E2E proof.
68+
- Crabbox request means real scenario proof: install/update/call/repro user path; not just copy tests and run them remotely.
6869
- Small/narrow tests, lints, format checks, and type probes are fine locally only in a healthy normal checkout.
6970
- In Codex worktrees, direct local `pnpm test*`, `pnpm check*`, `pnpm crabbox:run`, and `scripts/committer` can trigger pnpm dependency reconciliation or install prompts. Prefer `node` wrappers locally and Crabbox/Testbox for pnpm-gated proof.
7071
- Full suites, broad changed gates, Docker/package/E2E/live/cross-OS proof, or anything that bogs down the Mac: Crabbox/Testbox.

‎CHANGELOG.md‎

Lines changed: 26 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ final class AppState {
380380
{
381381
self.remoteTarget = configRemoteTarget
382382
} else if resolvedConnectionMode == .remote,
383-
configRemoteTransport != .direct,
384-
storedRemoteTarget.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty,
385-
let host = AppState.remoteHost(from: configRemoteUrl),
386-
!LoopbackHost.isLoopbackHost(host)
383+
configRemoteTransport != .direct,
384+
storedRemoteTarget.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty,
385+
let host = AppState.remoteHost(from: configRemoteUrl),
386+
!LoopbackHost.isLoopbackHost(host)
387387
{
388388
self.remoteTarget = "\(NSUserName())@\(host)"
389389
} else {

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

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,51 @@ struct ContextRootMenuLabelView: View {
99
MenuItemHighlightColors.palette(self.isHighlighted)
1010
}
1111

12+
private var usesStackedLayout: Bool {
13+
self.subtitle.count > 28 || self.subtitle.contains("\n")
14+
}
15+
1216
var body: some View {
13-
HStack(alignment: .firstTextBaseline, spacing: 8) {
14-
Text("Context")
15-
.font(.callout.weight(.semibold))
16-
.foregroundStyle(self.palette.primary)
17-
.lineLimit(1)
18-
.layoutPriority(1)
17+
HStack(alignment: self.usesStackedLayout ? .top : .firstTextBaseline, spacing: 8) {
18+
VStack(alignment: .leading, spacing: 2) {
19+
Text("Context")
20+
.font(.callout.weight(.semibold))
21+
.foregroundStyle(self.palette.primary)
22+
.lineLimit(1)
23+
24+
if self.usesStackedLayout {
25+
self.subtitleText
26+
.lineLimit(3)
27+
.fixedSize(horizontal: false, vertical: true)
28+
}
29+
}
30+
.layoutPriority(1)
1931

2032
Spacer(minLength: 8)
2133

22-
Text(self.subtitle)
23-
.font(.caption.monospacedDigit())
24-
.foregroundStyle(self.palette.secondary)
25-
.lineLimit(1)
26-
.truncationMode(.tail)
27-
.layoutPriority(2)
34+
if !self.usesStackedLayout {
35+
self.subtitleText
36+
.lineLimit(1)
37+
.layoutPriority(2)
38+
}
2839

2940
Image(systemName: "chevron.right")
3041
.font(.caption.weight(.semibold))
3142
.foregroundStyle(self.palette.secondary)
3243
.padding(.leading, 2)
44+
.padding(.top, self.usesStackedLayout ? 2 : 0)
3345
}
34-
.padding(.vertical, 8)
46+
.padding(.vertical, self.usesStackedLayout ? 7 : 8)
3547
.padding(.leading, 22)
3648
.padding(.trailing, 14)
3749
.frame(width: max(1, self.width), alignment: .leading)
3850
}
51+
52+
private var subtitleText: some View {
53+
Text(self.subtitle)
54+
.font(.caption.monospacedDigit())
55+
.foregroundStyle(self.palette.secondary)
56+
.multilineTextAlignment(.leading)
57+
.truncationMode(.tail)
58+
}
3959
}

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import Foundation
33
import WebKit
44

55
private final class DashboardWindowContentView: NSView {
6-
override var mouseDownCanMoveWindow: Bool { true }
6+
override var mouseDownCanMoveWindow: Bool {
7+
true
8+
}
79
}
810

911
private final class DashboardWindowDragRegionView: NSView {
10-
override var mouseDownCanMoveWindow: Bool { true }
12+
override var mouseDownCanMoveWindow: Bool {
13+
true
14+
}
1115

1216
override func mouseDown(with event: NSEvent) {
1317
self.window?.performDrag(with: event)
@@ -275,7 +279,7 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
275279

276280
private func showLoadFailure(_ error: Error) {
277281
let nsError = error as NSError
278-
if nsError.domain == NSURLErrorDomain && nsError.code == NSURLErrorCancelled { return }
282+
if nsError.domain == NSURLErrorDomain, nsError.code == NSURLErrorCancelled { return }
279283
dashboardWindowLogger.error(
280284
"dashboard load failed url=\(self.currentURL.absoluteString, privacy: .public) error=\(error.localizedDescription, privacy: .public)")
281285
let html = Self.failureHTML(url: self.currentURL, message: error.localizedDescription)
@@ -324,8 +328,8 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
324328
<body>
325329
<main>
326330
<h1>Dashboard unavailable</h1>
327-
<p>\(Self.htmlEscape(message))</p>
328-
<code>\(Self.htmlEscape(url.absoluteString))</code>
331+
<p>\(self.htmlEscape(message))</p>
332+
<code>\(self.htmlEscape(url.absoluteString))</code>
329333
</main>
330334
</body>
331335
</html>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ struct MenuHeaderCard<Content: View>: View {
3737
Text(statusText)
3838
.font(.caption)
3939
.foregroundStyle(.secondary)
40-
.lineLimit(1)
40+
.multilineTextAlignment(.leading)
41+
.lineLimit(3)
4142
.truncationMode(.tail)
43+
.fixedSize(horizontal: false, vertical: true)
4244
}
4345
self.content
4446
}

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

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,28 @@ final class MenuSessionsInjector: NSObject, NSMenuDelegate {
6565
self.inject(into: menu)
6666
self.injectNodes(into: menu)
6767

68-
// Refresh in background for the next open; keep width stable while open.
68+
// Refresh in the background for the next open. Rebuilding custom menu
69+
// rows while AppKit is tracking the menu causes visible flicker.
6970
self.loadTask?.cancel()
70-
let forceRefresh = self.cachedSnapshot == nil || self.cachedErrorText != nil
71-
self.loadTask = Task { [weak self] in
71+
let shouldRepaintAfterRefresh = self.cachedSnapshot == nil || self.cachedErrorText != nil
72+
self.loadTask = Task { [weak self, weak menu] in
7273
guard let self else { return }
74+
let forceRefresh = shouldRepaintAfterRefresh
7375
await self.refreshCache(force: forceRefresh)
7476
await self.refreshUsageCache(force: forceRefresh)
7577
await self.refreshCostUsageCache(force: forceRefresh)
76-
await MainActor.run {
77-
guard self.isMenuOpen else { return }
78-
self.inject(into: menu)
79-
self.injectNodes(into: menu)
78+
if shouldRepaintAfterRefresh {
79+
await self.repaintOpenMenu(menu)
8080
}
8181
}
8282

8383
self.nodesLoadTask?.cancel()
84-
self.nodesLoadTask = Task { [weak self] in
84+
let shouldRepaintNodesAfterRefresh = self.shouldRepaintNodesAfterRefresh()
85+
self.nodesLoadTask = Task { [weak self, weak menu] in
8586
guard let self else { return }
8687
await self.nodesStore.refresh()
87-
await MainActor.run {
88-
guard self.isMenuOpen else { return }
89-
self.injectNodes(into: menu)
88+
if !shouldRepaintAfterRefresh, shouldRepaintNodesAfterRefresh {
89+
await self.repaintOpenMenuNodes(menu)
9090
}
9191
}
9292
}
@@ -95,8 +95,6 @@ final class MenuSessionsInjector: NSObject, NSMenuDelegate {
9595
self.originalDelegate?.menuDidClose?(menu)
9696
self.isMenuOpen = false
9797
self.menuOpenWidth = nil
98-
self.loadTask?.cancel()
99-
self.nodesLoadTask?.cancel()
10098
self.cancelPreviewTasks()
10199
}
102100

@@ -122,25 +120,18 @@ final class MenuSessionsInjector: NSObject, NSMenuDelegate {
122120
guard self.isMenuOpen, let menu = self.statusItem?.menu else { return }
123121
self.loadTask?.cancel()
124122
self.loadTask = Task { [weak self, weak menu] in
125-
guard let self, let menu else { return }
123+
guard let self else { return }
126124
await self.refreshCache(force: true)
127125
await self.refreshUsageCache(force: true)
128126
await self.refreshCostUsageCache(force: true)
129-
await MainActor.run {
130-
guard self.isMenuOpen else { return }
131-
self.inject(into: menu)
132-
self.injectNodes(into: menu)
133-
}
127+
await self.repaintOpenMenu(menu)
134128
}
135129

136130
self.nodesLoadTask?.cancel()
137131
self.nodesLoadTask = Task { [weak self, weak menu] in
138-
guard let self, let menu else { return }
132+
guard let self else { return }
139133
await self.nodesStore.refresh()
140-
await MainActor.run {
141-
guard self.isMenuOpen else { return }
142-
self.injectNodes(into: menu)
143-
}
134+
await self.repaintOpenMenuNodes(menu)
144135
}
145136
}
146137

@@ -278,6 +269,28 @@ extension MenuSessionsInjector {
278269
_ = cursor
279270
}
280271

272+
private func repaintOpenMenu(_ menu: NSMenu?) async {
273+
await MainActor.run {
274+
guard self.isMenuOpen, let menu else { return }
275+
self.inject(into: menu)
276+
self.injectNodes(into: menu)
277+
}
278+
}
279+
280+
private func repaintOpenMenuNodes(_ menu: NSMenu?) async {
281+
await MainActor.run {
282+
guard self.isMenuOpen, let menu else { return }
283+
self.injectNodes(into: menu)
284+
}
285+
}
286+
287+
private func shouldRepaintNodesAfterRefresh() -> Bool {
288+
guard self.isControlChannelConnected else { return false }
289+
return self.sortedNodeEntries().isEmpty
290+
|| self.nodesStore.lastError?.nonEmpty != nil
291+
|| self.nodesStore.statusMessage?.nonEmpty != nil
292+
}
293+
281294
private func buildContextSubmenu(
282295
width: CGFloat,
283296
isConnected: Bool,
@@ -374,7 +387,7 @@ extension MenuSessionsInjector {
374387
return self.cachedErrorText ?? "Loading…"
375388
}
376389

377-
return self.controlChannelStatusText(for: channelState)
390+
return Self.menuStatusText(self.controlChannelStatusText(for: channelState))
378391
}
379392

380393
private func activeRows(from snapshot: SessionStoreSnapshot) -> [SessionRow] {
@@ -527,7 +540,7 @@ extension MenuSessionsInjector {
527540
case .connecting:
528541
"Connecting…"
529542
case let .degraded(message):
530-
message.nonEmpty ?? "Gateway disconnected"
543+
Self.menuStatusText(message.nonEmpty ?? "Gateway disconnected")
531544
case .disconnected:
532545
"Gateway disconnected"
533546
}
@@ -684,7 +697,7 @@ extension MenuSessionsInjector {
684697
self.previewTasks.removeAll()
685698
}
686699

687-
private func makeMessageItem(text: String, symbolName: String, width: CGFloat, maxLines: Int? = 2) -> NSMenuItem {
700+
private func makeMessageItem(text: String, symbolName: String, width: CGFloat, maxLines: Int? = 3) -> NSMenuItem {
688701
let view = AnyView(
689702
HStack(alignment: .top, spacing: 8) {
690703
Image(systemName: symbolName)
@@ -810,6 +823,19 @@ extension MenuSessionsInjector {
810823
}
811824
return "Sessions unavailable"
812825
}
826+
827+
private static func menuStatusText(_ text: String) -> String {
828+
let lines = text
829+
.trimmingCharacters(in: .whitespacesAndNewlines)
830+
.split(whereSeparator: \.isNewline)
831+
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
832+
.filter { !$0.isEmpty }
833+
834+
let singleLine = (lines.isEmpty ? text : lines.joined(separator: " "))
835+
.trimmingCharacters(in: .whitespacesAndNewlines)
836+
guard singleLine.count > 180 else { return singleLine }
837+
return "\(singleLine.prefix(177))…"
838+
}
813839
}
814840

815841
extension MenuSessionsInjector {
@@ -1283,6 +1309,14 @@ extension MenuSessionsInjector {
12831309
self.inject(into: menu)
12841310
}
12851311

1312+
func testingControlChannelStatusText(for state: ControlChannel.ConnectionState) -> String {
1313+
self.controlChannelStatusText(for: state)
1314+
}
1315+
1316+
func testingMenuStatusText(_ text: String) -> String {
1317+
Self.menuStatusText(text)
1318+
}
1319+
12861320
func testingFindInsertIndex(in menu: NSMenu) -> Int? {
12871321
self.findInsertIndex(in: menu)
12881322
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ actor RemoteTunnelManager {
5555
if let create = self.createInFlight {
5656
self.logger.info("control tunnel create in flight; joining")
5757
let tunnel = try await create.task.value
58-
return try await self.installCreatedTunnel(tunnel, token: create.token, fallbackPort: UInt16(GatewayEnvironment.gatewayPort()))
58+
return try await self.installCreatedTunnel(
59+
tunnel,
60+
token: create.token,
61+
fallbackPort: UInt16(GatewayEnvironment.gatewayPort()))
5962
}
6063
await self.waitForRestartBackoffIfNeeded()
6164

@@ -80,7 +83,11 @@ actor RemoteTunnelManager {
8083
return try await self.installCreatedTunnel(tunnel, token: token, fallbackPort: desiredPort)
8184
}
8285

83-
private func installCreatedTunnel(_ tunnel: RemotePortTunnel, token: UUID, fallbackPort: UInt16) async throws -> UInt16 {
86+
private func installCreatedTunnel(
87+
_ tunnel: RemotePortTunnel,
88+
token: UUID,
89+
fallbackPort: UInt16) async throws -> UInt16
90+
{
8491
if self.createInFlight?.token == token {
8592
self.createInFlight = nil
8693
}

‎apps/macos/Sources/OpenClawMacCLI/ConfigureRemoteCommand.swift‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,17 @@ private func configureSSHRemote(_ opts: ConfigureRemoteOptions) throws -> Config
161161
onboardingSkipped: true)
162162
}
163163

164-
private func configureDirectRemote(_ opts: ConfigureRemoteOptions, directUrlRaw: String) throws -> ConfigureRemoteOutput {
164+
private func configureDirectRemote(
165+
_ opts: ConfigureRemoteOptions,
166+
directUrlRaw: String) throws -> ConfigureRemoteOutput
167+
{
165168
guard let directURL = normalizeDirectURL(directUrlRaw) else {
166169
throw NSError(
167170
domain: "ConfigureRemote",
168171
code: 2,
169-
userInfo: [NSLocalizedDescriptionKey: "Direct URL must be ws:// for private/Tailscale hosts or wss:// for remote hosts"])
172+
userInfo: [
173+
NSLocalizedDescriptionKey: "Direct URL must be ws:// for private/Tailscale hosts or wss:// for remote hosts",
174+
])
170175
}
171176

172177
let configURL = openClawConfigURL()
@@ -212,7 +217,7 @@ private func openClawConfigURL() -> URL {
212217
private func loadConfigRoot(from url: URL) throws -> [String: Any] {
213218
guard FileManager().isReadableFile(atPath: url.path) else { return [:] }
214219
let data = try Data(contentsOf: url)
215-
return (try JSONSerialization.jsonObject(with: data) as? [String: Any]) ?? [:]
220+
return try (JSONSerialization.jsonObject(with: data) as? [String: Any]) ?? [:]
216221
}
217222

218223
private func saveConfigRoot(_ root: [String: Any], to url: URL) throws {

0 commit comments

Comments
 (0)