Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Merge remote-tracking branch 'origin/main' into feat/mobile-ios-android

bubu-dudu3c38a4f7f8d9
diff --cc cli/src/lib/e2ee/core.test.ts
index 634c4fb52,ec4b30003..b9441a126
--- a/cli/src/lib/e2ee/core.test.ts
+++ b/cli/src/lib/e2ee/core.test.ts
@@@ -205,6 -203,6 +207,6 @@@ describe('e2ee core — interop keyston
it('core.ts still hashes to the pinned value shared with the other implementations', () => {
const here = dirname(fileURLToPath(import.meta.url))
const actual = createHash('sha256').update(readFileSync(join(here, 'core.ts'))).digest('hex')
- expect(actual).toBe('ea9395d253a6c1896f264509d18eef1a8e6072b5f5a55ed2e7dea69944d06776')
- expect(actual).toBe('f4bc05b2ee97b2a6b014bbf38728b4e4c76e4156d48180ff3bf63eb6a2d96d4d')
++ expect(actual).toBe('d3c8e0a38615d188502946d10330884eb2ca85a10f0d1f5ecb1f74a5fa2af1fe')
})
})
diff --cc desktop/lib/auth/cli_login.dart
index 1fbb3af82,2a19b5667..4a3690c94
--- a/desktop/lib/auth/cli_login.dart
+++ b/desktop/lib/auth/cli_login.dart
@@@ -40,9 -39,10 +40,10 @@@ class CliNotAvailableException implemen
/// signed-in session, and driving `harness login --json`'s NDJSON event stream when it does not. The
/// CLI owns the SSO session end to end (`~/.harness/auth/session.json`) — this app never sees, stores,
/// or refreshes an access token itself.
-class CliLogin {
+class CliLogin implements SignInClient {
final HarnessCliRunner _runner;
Process? _activeProcess;
+ int _loginRevision = 0;
CliLogin({HarnessCliRunner? runner}) : _runner = runner ?? HarnessCliRunner();
@@@ -120,13 -131,14 +134,17 @@@
}
}
- /// Aborts an in-flight [login] — used by the embedded sign-in webview's close button.
- /// Aborts this attempt even if its process has not finished starting yet.
++ /// Aborts this attempt even if its process has not finished starting yet —
++ /// reached from the embedded sign-in webview's close button.
+ @override
void cancel() {
- _activeProcess?.kill();
+ ++_loginRevision;
+ final process = _activeProcess;
+ _activeProcess = null;
+ process?.kill();
}
+ @override
Future<void> logout() async {
try {
await _run(['logout']);
diff --cc desktop/lib/screens/login_screen.dart
index 84ce70ffd,7a0f74987..b1f7b45d6
--- a/desktop/lib/screens/login_screen.dart
+++ b/desktop/lib/screens/login_screen.dart
@@@ -1,7 -1,6 +1,8 @@@
import 'package:flutter/material.dart';
+ import 'package:flutter/services.dart';
+import '../core/asset_owner.dart';
+
import '../shared/theme/app_theme.dart' as grid;
import '../state/app_state.dart';
import '../widgets/login_relay_diagram.dart';
diff --cc desktop/lib/state/app_state.dart
index bb833c923,e2d2346ef..a83f6d648
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@@ -2124,13 -2159,14 +2209,15 @@@ class AppNotifier extends ChangeNotifie
await cliLogin.login(
onAuthorizeUrl: (url) {
if (!_authWorkCurrent(revision)) return;
+ if (pendingAuthorizeUrl == url) return;
+ _resetLoginBrowser();
pendingAuthorizeUrl = url;
notifyListeners();
- // Which browser, and why, is decided in `viewer/sign_in_browser.dart`:
- // the system browser on a desktop, an in-app browser view on a phone,
- // where handing the person to Safari would suspend this app and with
- // it the loopback listener the page redirects back to.
- unawaited(openSignInPage(Uri.parse(url)));
- // Must be the system browser, not an embedded webview: this SSO page's Google button uses
- // Google's popup-based Identity Services flow (a real popup window posts the result back to
- // its opener), which only a real browser can satisfy.
++ // Through [openLoginBrowser] rather than straight to the launcher, so
++ // the first handoff is the same one the login screen's retry button
++ // takes and reports its outcome the same way. WHICH browser it opens
++ // is decided in `viewer/sign_in_browser.dart`.
+ unawaited(openLoginBrowser());
},
);
if (!_authWorkCurrent(revision)) return;
@@@ -2169,8 -2208,59 +2262,69 @@@
if (_authWorkCurrent(revision)) notifyListeners();
}
- /// Aborts an in-flight [login] — the embedded sign-in webview's close button calls this.
- void cancelLogin() => cliLogin.cancel();
+ void _resetLoginBrowser() {
+ ++_loginBrowserRevision;
+ openingLoginBrowser = false;
+ loginBrowserError = null;
+ }
+
+ /// Reopens the current authorization URL without creating another login.
+ Future<void> openLoginBrowser() async {
+ final url = pendingAuthorizeUrl;
+ if (_disposed || !signingIn || url == null || openingLoginBrowser) return;
+ final authRevision = _authRevision;
+ final browserRevision = ++_loginBrowserRevision;
+ openingLoginBrowser = true;
+ loginBrowserError = null;
+ notifyListeners();
+ var opened = false;
+ try {
+ final uri = Uri.tryParse(url);
+ if (uri != null &&
+ uri.hasAuthority &&
+ (uri.scheme == 'https' || uri.scheme == 'http')) {
- opened = await launchUrl(uri, mode: LaunchMode.externalApplication);
++ // Not `launchUrl(..., externalApplication)` directly: on a desktop
++ // [openSignInPage] IS that call, and on a phone it must not be. Handing
++ // a phone to Safari suspends this app, and with it the loopback listener
++ // the page redirects back to — the sign-in could then never land.
++ // ⚠️ The reason the desktop insists on a real browser survives here: this
++ // SSO page's Google button uses Google's popup-based Identity Services
++ // flow, where a popup window posts the result back to its opener. Whether
++ // an in-app browser view can satisfy that is open, and flagged in
++ // `sign_in_browser.dart`; it is why the phone case is confined to phones
++ // rather than made the rule.
++ opened = await openSignInPage(uri);
+ }
+ } catch (_) {
+ // Browser handoff failure is recoverable within the same sign-in. Never
+ // put a credential-bearing URL or a raw platform exception in the UI.
+ }
+ if (!_authWorkCurrent(authRevision) ||
+ browserRevision != _loginBrowserRevision ||
+ pendingAuthorizeUrl != url) {
+ return;
+ }
+ openingLoginBrowser = false;
+ if (!opened) {
+ loginBrowserError =
+ 'Couldn’t open your browser. Open it again or copy the sign-in link.';
+ }
+ notifyListeners();
+ }
+
+ /// Return immediately; late URLs, results and browser replies belong to the
+ /// cancelled attempt and cannot change a subsequent sign-in.
+ void cancelLogin() {
+ if (_disposed || !canCancelLogin) return;
+ _invalidateAuthWork();
+ signingIn = false;
+ pendingAuthorizeUrl = null;
+ status = AppStatus.unauthenticated;
+ _lastError = null;
+ _lastErrorRetryable = false;
+ cliLogin.cancel();
+ notifyListeners();
+ }
Future<void> logout() async {
final revision = _invalidateAuthWork();
diff --cc desktop/lib/widgets/terminal_panel.dart
index 3b86f4baf,8279cfa3c..8aef35d1d
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@@ -61,12 -60,8 +61,13 @@@ class TerminalPanel extends StatefulWid
/// Only the focused grid tile may claim keyboard focus on mount/rebuild.
final bool focused;
final bool visible;
+ final Size? viewportSize;
final bool compactHeader;
+
+ /// The tile's own header strip — engine, title, status, pin, close. Off on a
+ /// phone, whose page draws its own header and has no tile to pin, close or
+ /// drag (`phone/terminal_page.dart`).
+ final bool showHeader;
final int focusRequest;
/// Whether this tile's composer textbox is showing. Only consulted for a remote machine.
@@@ -91,8 -86,8 +92,9 @@@
required this.session,
required this.focused,
this.visible = true,
+ this.viewportSize,
this.compactHeader = false,
+ this.showHeader = true,
this.focusRequest = 0,
this.composerVisible = false,
this.readOnly = false,