Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
235
apps/ios/Sources/Terminal/TerminalHubScreen.swift
Normal file
235
apps/ios/Sources/Terminal/TerminalHubScreen.swift
Normal file
@@ -0,0 +1,235 @@
|
||||
import OpenClawKit
|
||||
import SwiftUI
|
||||
import WebKit
|
||||
|
||||
/// Control-hub Terminal destination: embeds the gateway-served terminal page
|
||||
/// (`/?view=terminal`, the ghostty-web surface shared with the Control UI) in a
|
||||
/// WKWebView, authenticated with the stored gateway credentials.
|
||||
struct TerminalHubScreen: View {
|
||||
@Environment(NodeAppModel.self) private var appModel
|
||||
let headerLeadingAction: OpenClawSidebarHeaderAction?
|
||||
let usesNativeNavigationChrome: Bool
|
||||
let gatewayAction: (() -> Void)?
|
||||
|
||||
init(
|
||||
headerLeadingAction: OpenClawSidebarHeaderAction? = nil,
|
||||
usesNativeNavigationChrome: Bool = false,
|
||||
gatewayAction: (() -> Void)? = nil)
|
||||
{
|
||||
self.headerLeadingAction = headerLeadingAction
|
||||
self.usesNativeNavigationChrome = usesNativeNavigationChrome
|
||||
self.gatewayAction = gatewayAction
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
let config = self.appModel.activeGatewayConnectConfig
|
||||
let storedOperatorToken = config == nil ? nil : Self.storedOperatorToken()
|
||||
ZStack {
|
||||
OpenClawProBackground()
|
||||
if let url = Self.terminalURL(config: config) {
|
||||
TerminalWebView(
|
||||
url: url,
|
||||
authScript: Self.terminalAuthUserScript(
|
||||
config: config,
|
||||
storedOperatorToken: storedOperatorToken))
|
||||
// Recreate the web view only when the connection inputs
|
||||
// change; SwiftUI update passes must not restart live shells.
|
||||
.id(Self.webContentIdentity(
|
||||
config: config,
|
||||
storedOperatorToken: storedOperatorToken))
|
||||
.ignoresSafeArea(.container, edges: .bottom)
|
||||
} else {
|
||||
self.unavailableCard
|
||||
}
|
||||
}
|
||||
.navigationTitle("Terminal")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar(self.usesNativeNavigationChrome ? .visible : .hidden, for: .navigationBar)
|
||||
.toolbar {
|
||||
if self.usesNativeNavigationChrome, let gatewayAction {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
Button(action: gatewayAction) {
|
||||
Image(systemName: "antenna.radiowaves.left.and.right")
|
||||
.font(OpenClawType.subheadSemiBold)
|
||||
}
|
||||
.accessibilityLabel("Gateway settings")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var unavailableCard: some View {
|
||||
VStack(spacing: 12) {
|
||||
ProIconBadge(systemName: "terminal", color: OpenClawBrand.accent)
|
||||
Text("Terminal needs a connected gateway")
|
||||
.font(OpenClawType.subheadSemiBold)
|
||||
Text("Connect to your gateway to open a shell in the agent workspace.")
|
||||
.font(OpenClawType.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
if let gatewayAction {
|
||||
Button(action: gatewayAction) {
|
||||
Text("Open Gateway Settings")
|
||||
.font(OpenClawType.subheadSemiBold)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(OpenClawBrand.accent)
|
||||
}
|
||||
}
|
||||
.padding(24)
|
||||
}
|
||||
|
||||
/// Derives the terminal page URL from the active gateway connection: the
|
||||
/// WS endpoint flips to HTTP(S) and only `view=terminal` rides in the URL.
|
||||
/// Credentials never enter the URL — they are injected as a document-start
|
||||
/// user script (see `terminalAuthUserScript`), matching the macOS Dashboard.
|
||||
static func terminalURL(config: GatewayConnectConfig?) -> URL? {
|
||||
guard let config,
|
||||
var components = URLComponents(url: config.url, resolvingAgainstBaseURL: false)
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
switch components.scheme?.lowercased() {
|
||||
case "wss", "https":
|
||||
components.scheme = "https"
|
||||
default:
|
||||
components.scheme = "http"
|
||||
}
|
||||
components.path = "/"
|
||||
components.queryItems = [URLQueryItem(name: "view", value: "terminal")]
|
||||
return components.url
|
||||
}
|
||||
|
||||
/// Origin-gated document-start script that hands the gateway credentials to
|
||||
/// the Control UI via its `__OPENCLAW_NATIVE_CONTROL_AUTH__` startup contract
|
||||
/// (the same mechanism the macOS Dashboard window uses), so the token never
|
||||
/// appears in the page URL, WebKit history, or gateway request logs.
|
||||
static func terminalAuthUserScript(config: GatewayConnectConfig?) -> String? {
|
||||
self.terminalAuthUserScript(config: config, storedOperatorToken: self.storedOperatorToken())
|
||||
}
|
||||
|
||||
static func terminalAuthUserScript(
|
||||
config: GatewayConnectConfig?,
|
||||
storedOperatorToken: String?) -> String?
|
||||
{
|
||||
guard let config, let pageURL = terminalURL(config: config) else {
|
||||
return nil
|
||||
}
|
||||
var payload: [String: String] = ["gatewayUrl": config.url.absoluteString]
|
||||
let token = config.token?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
let storedToken = storedOperatorToken?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
let password = config.password?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
if !token.isEmpty {
|
||||
payload["token"] = token
|
||||
} else if !storedToken.isEmpty {
|
||||
payload["token"] = storedToken
|
||||
}
|
||||
if !password.isEmpty {
|
||||
payload["password"] = password
|
||||
}
|
||||
guard payload["token"] != nil || payload["password"] != nil else {
|
||||
return nil
|
||||
}
|
||||
guard let data = try? JSONSerialization.data(withJSONObject: payload),
|
||||
let json = String(data: data, encoding: .utf8)
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
let allowedOrigin = Self.jsStringLiteral(Self.originString(for: pageURL))
|
||||
return """
|
||||
(() => {
|
||||
try {
|
||||
if (location.origin !== \(allowedOrigin)) return;
|
||||
Object.defineProperty(window, "__OPENCLAW_NATIVE_CONTROL_AUTH__", {
|
||||
value: \(json),
|
||||
configurable: true,
|
||||
});
|
||||
} catch {}
|
||||
})();
|
||||
"""
|
||||
}
|
||||
|
||||
/// Identity for the embedded web view: recreate it only when the gateway
|
||||
/// endpoint or credentials actually change.
|
||||
static func webContentIdentity(config: GatewayConnectConfig?) -> Int {
|
||||
self.webContentIdentity(config: config, storedOperatorToken: self.storedOperatorToken())
|
||||
}
|
||||
|
||||
static func webContentIdentity(config: GatewayConnectConfig?, storedOperatorToken: String?) -> Int {
|
||||
var hasher = Hasher()
|
||||
hasher.combine(config?.url)
|
||||
hasher.combine(config?.token)
|
||||
hasher.combine(config?.password)
|
||||
hasher.combine(storedOperatorToken?.trimmingCharacters(in: .whitespacesAndNewlines))
|
||||
return hasher.finalize()
|
||||
}
|
||||
|
||||
private static func storedOperatorToken() -> String? {
|
||||
let identity = DeviceIdentityStore.loadOrCreate()
|
||||
return DeviceAuthStore.loadToken(deviceId: identity.deviceId, role: "operator")?
|
||||
.token
|
||||
}
|
||||
|
||||
static func originString(for url: URL) -> String {
|
||||
guard let scheme = url.scheme, let host = url.host else {
|
||||
return ""
|
||||
}
|
||||
let hostPart = host.contains(":") && !host.hasPrefix("[") ? "[\(host)]" : host
|
||||
var origin = "\(scheme)://\(hostPart)"
|
||||
if let port = url.port {
|
||||
origin += ":\(port)"
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
private static func jsStringLiteral(_ value: String) -> String {
|
||||
guard let data = try? JSONSerialization.data(withJSONObject: [value]),
|
||||
let raw = String(data: data, encoding: .utf8),
|
||||
raw.hasPrefix("["),
|
||||
raw.hasSuffix("]")
|
||||
else {
|
||||
return "\"\""
|
||||
}
|
||||
return String(raw.dropFirst().dropLast())
|
||||
}
|
||||
}
|
||||
|
||||
/// Minimal WKWebView host for the terminal page. Unlike the canvas WebView it
|
||||
/// needs no script bridges or deep-link routing — the page is self-contained.
|
||||
private struct TerminalWebView: UIViewRepresentable {
|
||||
let url: URL
|
||||
let authScript: String?
|
||||
|
||||
func makeUIView(context _: Context) -> WKWebView {
|
||||
let config = WKWebViewConfiguration()
|
||||
// Ephemeral store: credentials arrive per load via the auth user
|
||||
// script; nothing needs to persist across loads.
|
||||
config.websiteDataStore = .nonPersistent()
|
||||
if let authScript = self.authScript {
|
||||
config.userContentController.addUserScript(WKUserScript(
|
||||
source: authScript,
|
||||
injectionTime: .atDocumentStart,
|
||||
forMainFrameOnly: true))
|
||||
}
|
||||
|
||||
let webView = WKWebView(frame: .zero, configuration: config)
|
||||
webView.isOpaque = true
|
||||
webView.backgroundColor = .black
|
||||
|
||||
let scrollView = webView.scrollView
|
||||
scrollView.backgroundColor = .black
|
||||
scrollView.contentInsetAdjustmentBehavior = .never
|
||||
scrollView.contentInset = .zero
|
||||
scrollView.verticalScrollIndicatorInsets = .zero
|
||||
scrollView.horizontalScrollIndicatorInsets = .zero
|
||||
scrollView.automaticallyAdjustsScrollIndicatorInsets = false
|
||||
|
||||
webView.load(URLRequest(url: self.url))
|
||||
return webView
|
||||
}
|
||||
|
||||
func updateUIView(_: WKWebView, context _: Context) {
|
||||
// Connection changes recreate the view via `.id(webContentIdentity)`;
|
||||
// reloading here would restart live shell sessions on unrelated passes.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user