mirror of
https://github.com/block/buzz.git
synced 2026-11-12 20:31:12 +00:00
Neither mobile app offers a way to reach Builderlab's web-only account features: GitHub linking, billing and creating a community. This adds a **Builderlab account** row to Settings that opens the build's Builderlab origin (app.builderlab.xyz on public builds) in the system browser. The row shows only on public builds. An internal build's Builderlab is its organization's tenant, where billing and the single community are managed by the organization, so the link wouldn't lead anywhere useful. Nostr-only builds have no Builderlab. Sign-in uses a non-ephemeral `ASWebAuthenticationSession`, which shares Safari's cookies, so Safari can reuse the Builderlab web session. A browser other than Safari, or Android, may still ask the user to sign in. | Before | After | | --- | --- | | <img alt="before" src="https://github.com/user-attachments/assets/a8f2157b-5a54-41fc-8937-013638b3347e" width="300"> | <img alt="after" src="https://github.com/user-attachments/assets/f1161f3b-c926-4a8c-b6a1-7532ef72749c" width="300"> | Nothing else gets worse. The change adds one row and one browser launch on tap, and does no work at startup or in the background. A failure stays inside this row: if the browser doesn't open, a toast says so. ### Validation - Added tests: `builderlab_account_row_test.dart` checks that the row opens `HostedEnvironment.origin` and shows a toast when the browser fails to open (public build), and that the row is absent otherwise. It is added to the CI public-build lane. - `settings_page_test.dart`: the version-footer scroll check now finds the footer after it scrolls just offscreen. The extra row pushed it there under public-build defines. - Settings tests pass under both public and Nostr-only defines, and `flutter analyze` is clean. - iOS simulator (public build, signed in to the public Builderlab): the row appears below Connection, and tapping it opens Safari at Builderlab. This simulator's session came from an identity import, not the in-app browser sign-in, so Safari was signed out. I haven't yet verified that Safari arrives signed in after a real in-app sign-in. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: Tom Brow <tomb@squareup.com> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
50 lines
1.7 KiB
Dart
50 lines
1.7 KiB
Dart
part of '../settings_page.dart';
|
||
|
||
/// Opens a Builderlab web page outside the app. Overridable in tests.
|
||
final builderlabWebLauncherProvider = Provider<Future<bool> Function(Uri)>(
|
||
(ref) =>
|
||
(uri) => launchUrl(uri, mode: LaunchMode.externalApplication),
|
||
);
|
||
|
||
/// Links a public build to its Builderlab web dashboard, for the account
|
||
/// features mobile doesn't have: GitHub linking, billing and creating
|
||
/// communities. Sign-in's web session is not ephemeral, so it shares
|
||
/// Safari's cookies and Safari can reuse that Builderlab web session.
|
||
class _BuilderlabAccountSection extends ConsumerWidget {
|
||
const _BuilderlabAccountSection();
|
||
|
||
@override
|
||
Widget build(BuildContext context, WidgetRef ref) {
|
||
return AppListCard(
|
||
verticalPadding: Grid.twelve,
|
||
children: [
|
||
AppListRow(
|
||
key: const Key('settings-builderlab-account'),
|
||
title: 'Builderlab account',
|
||
trailing: Icon(
|
||
BuzzIcons.externalLink,
|
||
size: 18,
|
||
color: context.colors.onSurfaceVariant,
|
||
),
|
||
onTap: () async {
|
||
bool opened;
|
||
try {
|
||
opened = await ref.read(builderlabWebLauncherProvider)(
|
||
HostedEnvironment.origin,
|
||
);
|
||
} on PlatformException {
|
||
// launchUrl throws instead of returning false on some failures.
|
||
opened = false;
|
||
}
|
||
if (opened || !context.mounted) return;
|
||
ScaffoldMessenger.of(context).showFeedbackSnackBar(
|
||
const SnackBar(content: Text('Couldn’t open Builderlab.')),
|
||
kind: ToastKind.error,
|
||
);
|
||
},
|
||
),
|
||
],
|
||
);
|
||
}
|
||
}
|