openclaw/scripts/format-swift.sh
Peter Steinberger d0cdaabc85
feat(macos): show page favicons on Mac tabs in the chat side panel (#145714)
* feat(macos): show page favicons on Mac tabs in the chat side panel

Mac tabs only showed a favicon when the Gateway's hostname lookup could
fetch /favicon.ico, so sites that declare their icon via <link rel=icon>
kept the generic Mac icon and a proxy timeout hid it for five minutes.

The macOS app now reads the page-declared icon itself: after a main-frame
navigation finishes, DashboardNativeBrowserHost runs a generated page
script (browser-favicon-script.ts, produced into Swift by the inspect
script generator) via callAsyncJavaScript that tries link[rel~=icon],
apple-touch-icon, then /favicon.ico with a byte cap and one deadline,
and pushes the resulting data URL with tab state. Navigation clears the
icon and advances a generation so late results never attach to a new
page. The bridge validates the optional favicon field; the hosted-tabs
contract's explicit favicon wins over the hostname lookup in the header
and in the browser panel's own strip. Agent browser tabs are unchanged.

* fix(ci): register native browser script generator with Knip
2026-09-12 00:41:49 -07:00

39 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
cd "$repo_root"
scope="${1:-all}"
if [[ "$scope" != "all" && "$scope" != "ios" && "$scope" != "macos" ]]; then
echo "usage: $0 [ios|macos]" >&2
exit 2
fi
./scripts/check-swift-tools.sh swiftformat
if [[ "$scope" != "ios" ]]; then
swiftformat --lint apps/macos/Sources \
--config config/swiftformat \
--exclude '**/OpenClawProtocol,**/HostEnvSecurityPolicy.generated.swift,**/BrowserInspectScript.generated.swift,**/BrowserFaviconScript.generated.swift'
swiftformat --lint \
apps/macos-mlx-tts/Sources \
apps/shared/OpenClawKit/Sources/OpenClawNativeState \
apps/shared/OpenClawMLXTTSProtocol/Sources \
apps/swabble/Sources \
--config config/swiftformat
fi
if [[ "$scope" == "macos" ]]; then
exit 0
fi
node scripts/ios-write-swift-filelist.mjs
(
cd apps/ios
swiftformat --lint \
--config ../../config/swiftformat \
--unexclude "$PWD/Sources,$PWD/ShareExtension,$PWD/ActivityWidget,$PWD/WatchApp,$PWD/../shared/OpenClawKit/Sources/OpenClawChatUI,$PWD/../shared/OpenClawKit/Sources/OpenClawKit,$PWD/../shared/OpenClawKit/Sources/OpenClawNativeState,$PWD/../shared/OpenClawKit/Sources/OpenClawProtocol,$PWD/../swabble/Sources/SwabbleKit" \
--filelist SwiftSources.input.xcfilelist
)