From 1fee2252315a9ecc7e73da68eb3759994324b728 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 17:23:29 +1030 Subject: [PATCH 01/17] Enable iPad support in NativePHP config --- config/nativephp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nativephp.php b/config/nativephp.php index e65e83d7..d5716718 100644 --- a/config/nativephp.php +++ b/config/nativephp.php @@ -454,7 +454,7 @@ | support you cannot revoke this action. | */ - 'ipad' => false, + 'ipad' => true, /* |-------------------------------------------------------------------------- From d44eae7c5ef528d36e52dca3b1ae41dab719e5e2 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:35:54 +1030 Subject: [PATCH 02/17] Let the two-column host split an iPad in portrait, behind a sidebar or a collapsed view --- packages/adaptive-layout/nativephp.json | 7 ++ .../resources/ios/AdaptiveFeedRenderer.swift | 75 +++++++++++++++++-- .../src/Components/AdaptiveCollapsed.php | 13 ++++ .../src/Elements/AdaptiveBar.php | 15 ++++ .../src/Elements/AdaptiveCollapsed.php | 28 +++++++ .../src/Elements/AdaptiveFeed.php | 42 ++++++++++- tests/Feature/AdaptiveLayoutElementsTest.php | 50 +++++++++++++ 7 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 packages/adaptive-layout/src/Components/AdaptiveCollapsed.php create mode 100644 packages/adaptive-layout/src/Elements/AdaptiveCollapsed.php create mode 100644 tests/Feature/AdaptiveLayoutElementsTest.php diff --git a/packages/adaptive-layout/nativephp.json b/packages/adaptive-layout/nativephp.json index 4adab811..50c08942 100644 --- a/packages/adaptive-layout/nativephp.json +++ b/packages/adaptive-layout/nativephp.json @@ -29,6 +29,13 @@ "ios_renderer": "AdaptiveDetailRenderer", "self_closing": false }, + { + "type": "adaptive_collapsed", + "element": "Devnull\\AdaptiveLayout\\Elements\\AdaptiveCollapsed", + "blade": "Devnull\\AdaptiveLayout\\Components\\AdaptiveCollapsed", + "ios_renderer": "AdaptiveDetailRenderer", + "self_closing": false + }, { "type": "adaptive_bar", "element": "Devnull\\AdaptiveLayout\\Elements\\AdaptiveBar", diff --git a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift index bd6b10a3..1e946ea5 100644 --- a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift +++ b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift @@ -369,6 +369,10 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC private let divider = UIView() private var pages: [Int: AdaptivePageController] = [:] private var placeholder: AdaptivePageController? + /// What the host shows on one column instead of the primary column and its details, when PHP sends one. + private var collapsed: AdaptivePageController? + /// Whether PHP has been told the last mode applied, so it hears each change once. + private var reportedWide: Bool? private var appliedFoldGap: CGRect? private var latest: NativeUINode? private var inherited: EnvironmentValues? @@ -449,6 +453,9 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC if let placeholderNode = node.children.first(where: { $0.type == "adaptive_placeholder" }) { placeholder?.update(placeholderNode, detail: false, environment: environment) } + if let collapsedNode = node.children.first(where: { $0.type == "adaptive_collapsed" }) { + collapsed?.update(collapsedNode, detail: false, environment: environment) + } reconcile() } @@ -530,8 +537,14 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC primary.view.frame = bounds return } - let fold = foldGap(in: bounds) + var fold = foldGap(in: bounds) appliedFoldGap = fold + // A sidebar width only applies with no fold across the split: the Duo + // always parts at its hinge. + let sidebar = CGFloat(latest?.props.getFloat("primary_width") ?? 0) + if sidebar > 0, !hasFold(in: bounds), sidebar < bounds.width { + fold = CGRect(x: bounds.minX + sidebar, y: bounds.minY, width: 0, height: bounds.height) + } primary.view.frame = CGRect(x: bounds.minX, y: bounds.minY, width: max(0, fold.minX - bounds.minX), height: bounds.height) secondary.view.frame = CGRect(x: fold.maxX, y: bounds.minY, width: max(0, bounds.maxX - fold.maxX), height: bounds.height) let hairline = 1 / max(1, view.traitCollection.displayScale) @@ -543,6 +556,12 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC view.setNeedsLayout() } + /// Whether a fold runs down the window, so the columns must part on it. + private func hasFold(in bounds: CGRect) -> Bool { + let middle = CGRect(x: bounds.minX + (bounds.width / 2).rounded(), y: bounds.minY, width: 0, height: bounds.height) + return foldGap(in: bounds) != middle + } + /// Where the columns part: the fold, for an even split around the hinge. /// Flat, they meet on it. Partly folded, its division region is active /// and they stop at its margins, keeping controls out of the crease. @@ -564,7 +583,7 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC guard !reconciling, !applying, !transitioning, primary.transitionCoordinator == nil, secondary.transitionCoordinator == nil, let latest, let inherited, view.bounds.width > 0, view.bounds.height > 0, - let feed = latest.children.first(where: { $0.type != "adaptive_detail" && $0.type != "adaptive_placeholder" }) else { return } + let feed = latest.children.first(where: { !["adaptive_detail", "adaptive_placeholder", "adaptive_collapsed"].contains($0.type) }) else { return } // Regular width alone would split the inner display in portrait into // two skinny columns. Like Apple's arrangements, also weigh the aspect // ratio: only a window wider than it is tall gets two columns. The @@ -572,8 +591,12 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC // A workspace with nothing to open beside its primary column (Remotes // while it's off) asks to keep one column. let window = view.window?.bounds ?? view.bounds + // The pad-or-landscape rule also splits an iPad in portrait, as iPad + // Settings does, but still not the Duo's inner display. + let padSplits = latest.props.getString("split_rule", default: "landscape") == "pad-or-landscape" + && traitCollection.userInterfaceIdiom == .pad let wantsWide = latest.props.getBool("split", default: true) - && traitCollection.horizontalSizeClass == .regular && window.width > window.height + && traitCollection.horizontalSizeClass == .regular && (window.width > window.height || padSplits) // Root-view assignment can schedule another UIKit layout. A bounds-only // layout in the same mode must not assign all hosting roots again. guard appliedRevision != revision || wide != wantsWide else { return } @@ -617,10 +640,18 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC if let placeholderNode = latest.children.first(where: { $0.type == "adaptive_placeholder" }), placeholder == nil { placeholder = AdaptivePageController(node: placeholderNode, detail: false, environment: inherited) } + let collapsedNode = latest.children.first(where: { $0.type == "adaptive_collapsed" }) + if let collapsedNode, collapsed == nil { + collapsed = AdaptivePageController(node: collapsedNode, detail: false, environment: inherited) + } + if collapsedNode == nil { collapsed = nil } guard let feedPage = pages[feed.id] else { return } let detailPages: [UIViewController] = activeDetails.compactMap { pages[$0.id] } let emptyDetail: [UIViewController] = placeholder.map { [$0] } ?? [] - let primaryStack: [UIViewController] = wantsWide ? [feedPage] : [feedPage] + detailPages + // On one column a collapsed view, when PHP sends one, stands alone in + // place of the primary column and its details. + let collapsedStack: [UIViewController]? = wantsWide ? nil : collapsed.map { [$0] } + let primaryStack: [UIViewController] = wantsWide ? [feedPage] : (collapsedStack ?? [feedPage] + detailPages) let secondaryStack: [UIViewController] = wantsWide ? (detailPages.isEmpty ? emptyDetail : detailPages) : [] // One column on screen that only gains or loses levels at the top is a @@ -664,11 +695,19 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC for page in pages.values { page.navigationItem.titleView = nil } } configureBars(feed: feed, details: details, environment: inherited) + // The collapsed view sits under the screen's own bar, so the host + // draws none over it. + primary.setNavigationBarHidden(collapsedStack != nil, animated: false) primary.view.layoutIfNeeded() secondary.view.layoutIfNeeded() updateHorizontalInsets() applying = false updateTabBar(top: primary.topViewController) + if reportedWide != wantsWide { + reportedWide = wantsWide + send("layout", extra: ["wide": wantsWide]) + } + updateBackSwipe() let validIDs = Set([feed.id] + currentHistory) pages = pages.filter { validIDs.contains($0.key) } @@ -753,6 +792,9 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC } feedPage.navigationItem.titleView = titleImage(for: primaryBar, environment: environment) ?? titleView(for: primaryBar, on: feedPage, tokens: tokens) + feedPage.navigationItem.leftBarButtonItem = wide == true && primaryBar?.props.getBool("back") == true + ? backButton() + : nil let actionsOnDetail = feedActionsOnDetail placedFeedActionsOnDetail = actionsOnDetail setRightItems(actionsOnDetail ? [] : feedActions(for: feedPage), on: feedPage) @@ -981,7 +1023,29 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC NativeElementBridge.sendLongPressEvent(titleLongPress.callback, nodeId: titleLongPress.node) } - private func send(_ action: String, depth: Int? = nil) { + /// The chevron a pushed host's primary bar shows, in place of the bar of + /// the screen it hides. PHP takes it back a screen. + private func backButton() -> UIBarButtonItem { + let item = UIBarButtonItem(image: UIImage(systemName: "chevron.backward"), primaryAction: UIAction { [weak self] _ in + self?.send("dismiss") + }) + item.accessibilityLabel = "Back" + return item + } + + /// The screen's bar is hidden while a pushed host is wide, which also + /// turns off its edge swipe back. Turn the swipe back on then, so the + /// host goes back as any pushed screen does. + private func updateBackSwipe() { + guard let outer = navigationController, outer !== primary, outer !== secondary, + outer.viewControllers.count > 1, + let swipe = outer.interactivePopGestureRecognizer else { return } + if wide == true, latest?.children.contains(where: { $0.type == "adaptive_collapsed" }) == true { + swipe.isEnabled = true + } + } + + private func send(_ action: String, depth: Int? = nil, extra: [String: Any] = [:]) { guard let latest else { return } let callback = latest.props.getCallbackId("on_change") guard callback != 0 else { return } @@ -996,6 +1060,7 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC "expected_node_ids": history, ] if let depth { payload["depth"] = depth } + payload.merge(extra) { _, new in new } guard let bytes = try? JSONSerialization.data(withJSONObject: payload), let text = String(data: bytes, encoding: .utf8) else { return } NativeElementBridge.sendTextChangeEvent(callback, nodeId: latest.id, text: text) diff --git a/packages/adaptive-layout/src/Components/AdaptiveCollapsed.php b/packages/adaptive-layout/src/Components/AdaptiveCollapsed.php new file mode 100644 index 00000000..5cbd6f16 --- /dev/null +++ b/packages/adaptive-layout/src/Components/AdaptiveCollapsed.php @@ -0,0 +1,13 @@ +componentProps['back'] = $back; + + return $this; + } + /** * An image from the app's public folder in place of the title, with its dark appearance's own. */ @@ -89,6 +100,10 @@ public function applyAttributes(array $attrs): void $this->titleImage((string) $attrs['title-image'], isset($attrs['title-image-dark']) ? (string) $attrs['title-image-dark'] : null); } + if (array_key_exists('back', $attrs)) { + $this->back((bool) $attrs['back']); + } + if (($attrs['options'] ?? null) instanceof NavBarOptions) { $this->options($attrs['options']); } diff --git a/packages/adaptive-layout/src/Elements/AdaptiveCollapsed.php b/packages/adaptive-layout/src/Elements/AdaptiveCollapsed.php new file mode 100644 index 00000000..ab7ee7e5 --- /dev/null +++ b/packages/adaptive-layout/src/Elements/AdaptiveCollapsed.php @@ -0,0 +1,28 @@ +componentProps; + } +} diff --git a/packages/adaptive-layout/src/Elements/AdaptiveFeed.php b/packages/adaptive-layout/src/Elements/AdaptiveFeed.php index e8caca7e..ac768756 100644 --- a/packages/adaptive-layout/src/Elements/AdaptiveFeed.php +++ b/packages/adaptive-layout/src/Elements/AdaptiveFeed.php @@ -2,6 +2,7 @@ namespace Devnull\AdaptiveLayout\Elements; +use InvalidArgumentException; use Native\Mobile\Edge\CallbackRegistry; use Native\Mobile\Edge\Element; @@ -9,7 +10,13 @@ class AdaptiveFeed extends Element { protected string $type = 'adaptive_feed'; - protected array $componentProps = ['depth' => 0, 'intent_revision' => 0, 'split' => true]; + /** + * The rules a wide window can split by. Landscape splits a regular-width window that is wider than it is tall. + * Pad-or-landscape also splits an iPad's in portrait, as iPad Settings does. + */ + public const array SplitRules = ['landscape', 'pad-or-landscape']; + + protected array $componentProps = ['depth' => 0, 'intent_revision' => 0, 'split' => true, 'split_rule' => 'landscape', 'primary_width' => 0.0]; public static function make(): static { @@ -33,6 +40,31 @@ public function split(bool $split = true): static return $this; } + /** + * Which windows get two columns: one of SplitRules. + */ + public function splitRule(string $rule): static + { + if (! in_array($rule, self::SplitRules, true)) { + throw new InvalidArgumentException("Unknown split rule [{$rule}]. Use one of: ".implode(', ', self::SplitRules).'.'); + } + + $this->componentProps['split_rule'] = $rule; + + return $this; + } + + /** + * How wide the primary column is when the window splits, in points, like a sidebar. Zero splits it evenly. A + * display with a fold always splits at the fold, whatever this says. + */ + public function primaryWidth(float $points): static + { + $this->componentProps['primary_width'] = max(0.0, $points); + + return $this; + } + public function onChange(string $method): static { $this->componentProps['on_change'] = $method; @@ -54,6 +86,14 @@ public function applyAttributes(array $attrs): void $this->split((bool) $attrs['split']); } + if (isset($attrs['split-rule'])) { + $this->splitRule((string) $attrs['split-rule']); + } + + if (isset($attrs['primary-width'])) { + $this->primaryWidth((float) $attrs['primary-width']); + } + if (isset($attrs['_change'])) { $this->onChange($attrs['_change']); } diff --git a/tests/Feature/AdaptiveLayoutElementsTest.php b/tests/Feature/AdaptiveLayoutElementsTest.php new file mode 100644 index 00000000..103f78ab --- /dev/null +++ b/tests/Feature/AdaptiveLayoutElementsTest.php @@ -0,0 +1,50 @@ + + */ +function adaptiveProps(Element $element): array +{ + return $element->toArray(new CallbackRegistry)['props'] ?? []; +} + +it('defaults to the landscape rule and an even split', function () { + $props = adaptiveProps(AdaptiveFeed::make()); + + expect($props['split_rule'])->toBe('landscape') + ->and($props['primary_width'])->toBe(0.0); +}); + +it('takes the pad-or-landscape rule and a sidebar width', function () { + $feed = AdaptiveFeed::make(); + $feed->applyAttributes(['split-rule' => 'pad-or-landscape', 'primary-width' => '320']); + + $props = adaptiveProps($feed); + + expect($props['split_rule'])->toBe('pad-or-landscape') + ->and($props['primary_width'])->toBe(320.0); +}); + +it('refuses an unknown split rule', function () { + AdaptiveFeed::make()->applyAttributes(['split-rule' => 'portrait']); +})->throws(InvalidArgumentException::class); + +it('marks a bar with back', function () { + $bar = AdaptiveBar::make(); + $bar->applyAttributes(['title' => 'Account', 'back' => true]); + + expect(adaptiveProps($bar)['back'])->toBeTrue() + ->and(adaptiveProps(AdaptiveBar::make()->title('Account'))['back'] ?? false)->toBeFalse(); +}); + +it('renders a collapsed child', function () { + expect(AdaptiveCollapsed::make()->toArray(new CallbackRegistry)['type'])->toBe('adaptive_collapsed'); +}); From b76c92f7fcf3ac4060ccb1ef3f189ad957e3fb6e Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:35:54 +1030 Subject: [PATCH 03/17] Share the two-column host's back-report check --- .../Concerns/FollowsAdaptiveHost.php | 45 +++++++++++++++++++ app/NativeComponents/Workspace.php | 19 +++----- 2 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 app/NativeComponents/Concerns/FollowsAdaptiveHost.php diff --git a/app/NativeComponents/Concerns/FollowsAdaptiveHost.php b/app/NativeComponents/Concerns/FollowsAdaptiveHost.php new file mode 100644 index 00000000..fced086f --- /dev/null +++ b/app/NativeComponents/Concerns/FollowsAdaptiveHost.php @@ -0,0 +1,45 @@ +|null + */ + protected function hostReport(string $event): ?array + { + $change = json_decode($event, true); + + return is_array($change) && is_string($change['action'] ?? null) ? $change : null; + } + + /** + * How deep the history should be after a back report: the depth to keep, or null when the report is about a + * history other than the one PHP has now. + * + * @param array $change + * @param list $identities The history PHP has now, oldest first. + */ + protected function backDepthFrom(array $change, array $identities, int $revision): ?int + { + $expected = $change['expected_history'] ?? null; + + if (! is_array($expected) + || ($change['expected_revision'] ?? null) !== $revision + || ($change['expected_depth'] ?? null) !== count($expected) + || array_slice($expected, 0, count($identities)) !== $identities) { + return null; + } + + $depth = $change['depth'] ?? count($identities) - 1; + + return is_int($depth) && $depth >= 0 && $depth < count($identities) ? $depth : null; + } +} diff --git a/app/NativeComponents/Workspace.php b/app/NativeComponents/Workspace.php index 64afccbf..afeef549 100644 --- a/app/NativeComponents/Workspace.php +++ b/app/NativeComponents/Workspace.php @@ -3,6 +3,7 @@ namespace App\NativeComponents; use App\Models\PendingWrite; +use App\NativeComponents\Concerns\FollowsAdaptiveHost; use App\NativeComponents\Concerns\OpensPushedScreen; use Native\Mobile\Attributes\On; use Native\Mobile\Edge\CallbackRegistry; @@ -23,6 +24,7 @@ */ abstract class Workspace extends NativeComponent { + use FollowsAdaptiveHost; use OpensPushedScreen; protected bool $forceFullFrames = true; @@ -195,25 +197,16 @@ public function conversationDeleted(string $id): void */ public function hostChanged(string $event): void { - $change = json_decode($event, true); + $change = $this->hostReport($event); - if (! is_array($change) || ($change['action'] ?? null) !== 'back') { + if ($change === null || $change['action'] !== 'back') { return; } $identities = array_map(fn (array $conversation): string => 'conversation-'.$conversation['slot'], $this->conversations); - $expected = $change['expected_history'] ?? null; + $depth = $this->backDepthFrom($change, $identities, $this->navigationRevision); - if (! is_array($expected) - || ($change['expected_revision'] ?? null) !== $this->navigationRevision - || ($change['expected_depth'] ?? null) !== count($expected) - || array_slice($expected, 0, count($identities)) !== $identities) { - return; - } - - $depth = $change['depth'] ?? count($this->conversations) - 1; - - if (is_int($depth) && $depth >= 0 && $depth < count($this->conversations)) { + if ($depth !== null) { $this->conversations = array_slice($this->conversations, 0, $depth); $this->foregroundPane()?->onResume(); } From ddefb01e5b2b8f276c4b6b49ede46ffbacec342f Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:36:23 +1030 Subject: [PATCH 04/17] Split the Account screen into a partial per section --- .../native/partials/account/apple.blade.php | 27 ++ .../native/partials/account/color.blade.php | 56 +++ .../native/partials/account/delete.blade.php | 10 + .../native/partials/account/pasteis.blade.php | 19 + .../native/partials/account/profile.blade.php | 43 ++ .../native/partials/account/push.blade.php | 33 ++ .../native/partials/account/remotes.blade.php | 51 +++ .../native/partials/account/safety.blade.php | 12 + .../native/partials/account/scroll.blade.php | 41 ++ .../partials/account/sign-out.blade.php | 4 + .../native/partials/account/terms.blade.php | 10 + .../partials/account/this-phone.blade.php | 27 ++ .../partials/account/timezone.blade.php | 54 +++ .../partials/account/who-to-follow.blade.php | 12 + .../partials/settings-heading.blade.php | 9 +- resources/views/native/this-device.blade.php | 366 +----------------- 16 files changed, 407 insertions(+), 367 deletions(-) create mode 100644 resources/views/native/partials/account/apple.blade.php create mode 100644 resources/views/native/partials/account/color.blade.php create mode 100644 resources/views/native/partials/account/delete.blade.php create mode 100644 resources/views/native/partials/account/pasteis.blade.php create mode 100644 resources/views/native/partials/account/profile.blade.php create mode 100644 resources/views/native/partials/account/push.blade.php create mode 100644 resources/views/native/partials/account/remotes.blade.php create mode 100644 resources/views/native/partials/account/safety.blade.php create mode 100644 resources/views/native/partials/account/scroll.blade.php create mode 100644 resources/views/native/partials/account/sign-out.blade.php create mode 100644 resources/views/native/partials/account/terms.blade.php create mode 100644 resources/views/native/partials/account/this-phone.blade.php create mode 100644 resources/views/native/partials/account/timezone.blade.php create mode 100644 resources/views/native/partials/account/who-to-follow.blade.php diff --git a/resources/views/native/partials/account/apple.blade.php b/resources/views/native/partials/account/apple.blade.php new file mode 100644 index 00000000..190ba85e --- /dev/null +++ b/resources/views/native/partials/account/apple.blade.php @@ -0,0 +1,27 @@ +@use('App\Icons\Ios') + + + @include('native.partials.settings-heading', ['title' => 'Apple ID']) + + + + apple id + {{ $appleStatus }} + + + + + A quicker way back in on a new phone. The account is still your GitHub one. + + + @if ($appleLinked === false) + {{-- Apple's black button (white in dark mode, the theme's accent) with its logo, as Apple's guidelines ask. --}} + + Sign in with Apple + + @elseif ($appleLinked === true) + + Unlink Apple ID + + @endif + diff --git a/resources/views/native/partials/account/color.blade.php b/resources/views/native/partials/account/color.blade.php new file mode 100644 index 00000000..6c8b7208 --- /dev/null +++ b/resources/views/native/partials/account/color.blade.php @@ -0,0 +1,56 @@ +@use('App\Devnull\Lane') + + + @include('native.partials.settings-heading', [ + 'title' => 'Color', + 'description' => 'Your lane on the graph: the rail and nodes beside your commits, the ring around your avatar, and the dot before your handle. Automatic picks one from your account id.', + ]) + + {{-- You on the rail in the colour picked, as the web's preview draws you. --}} + + + + {{ $user->name }} + + + {{ $user->handle() }} + + + @include('native.partials.rail', ['previous' => $previewLane, 'tail' => $previewLane, 'node' => 'avatar', 'user' => $user, 'lane' => $previewLane]) + + + {{-- + Automatic, the six lanes, then Custom. The one picked wears a ring in its colour. Automatic is a dashed + ring round a dot, in the lane it gives you. Custom is your custom colour, or a spectrum until you mix + one, and opens the sheet that mixes it. No press-* feedback: it would keep the screen from scrolling. + --}} + + @foreach ($lanes as $option) + + + + @if ($option['auto']) + + @include('native.partials.dashed-ring', ['size' => 28, 'lane' => $option['lane']]) + + + @elseif ($option['lane'] === null) + + @else + + @endif + + {{ $option['label'] }} + + + @endforeach + + + {{-- In the colour picked, so you see it on a button before saving it. --}} + + Save color + @if ($laneError) + {{ $laneError }} + @endif + + diff --git a/resources/views/native/partials/account/delete.blade.php b/resources/views/native/partials/account/delete.blade.php new file mode 100644 index 00000000..5623682f --- /dev/null +++ b/resources/views/native/partials/account/delete.blade.php @@ -0,0 +1,10 @@ + + @include('native.partials.settings-heading', [ + 'title' => 'Delete account', + 'description' => "Removes your /dev/null account, every commit and reply you've made, and everyone you follow. Replies others left under your commits go too. Replies under your replies stay, hanging off a [deleted] tombstone. Your GitHub account is not touched.", + ]) + + + Delete account + + diff --git a/resources/views/native/partials/account/pasteis.blade.php b/resources/views/native/partials/account/pasteis.blade.php new file mode 100644 index 00000000..e52b1a8f --- /dev/null +++ b/resources/views/native/partials/account/pasteis.blade.php @@ -0,0 +1,19 @@ +{{-- + The web's pastéis mode section, word for word: its heading and two lines, with the switch beside them. + The switch is the system's own (a UISwitch on iOS), which takes taps since NativePHP/mobile-air#545. +--}} + + + + @unless ($inPane ?? false) + Pastéis mode + @endunless + A little appreciation, fresh daily. Get 10 pastéis to give to other people’s commits, one per click. Your allowance resets at 00:00 UTC. + When off, all pastéis controls and counters are hidden. You still receive pastéis from others. + + + + @if ($pasteisModeError) + {{ $pasteisModeError }} + @endif + diff --git a/resources/views/native/partials/account/profile.blade.php b/resources/views/native/partials/account/profile.blade.php new file mode 100644 index 00000000..c878a094 --- /dev/null +++ b/resources/views/native/partials/account/profile.blade.php @@ -0,0 +1,43 @@ +@use('App\Icons\Lucide') + + + @include('native.partials.settings-heading', [ + 'title' => 'Profile information', + 'description' => 'Mirrored from GitHub when you sign in. To change any of it, change it on GitHub, then sync it here.', + ]) + + + @include('native.partials.rail-avatar', ['user' => $user, 'lane' => $savedLane, 'size' => 56]) + + {{ $user->name }} + {{ $user->handle() }} + + + + {{-- The web's hairline table: mono labels, and null in muted mono for what GitHub doesn't have. --}} + + @foreach ($fields as $field) + @if (! $loop->first) + + @endif + + {{ $field['label'] }} + @if ($field['value'] === null) + null + @else + {{ $field['value'] }} + @endif + + @endforeach + + + + Edit on GitHub + {{-- The label stays put while it spins, so the button keeps its size. --}} + Sync from GitHub + {{ $syncedAt }} + @if ($syncError) + {{ $syncError }} + @endif + + diff --git a/resources/views/native/partials/account/push.blade.php b/resources/views/native/partials/account/push.blade.php new file mode 100644 index 00000000..3852abf6 --- /dev/null +++ b/resources/views/native/partials/account/push.blade.php @@ -0,0 +1,33 @@ +@use('App\Icons\Lucide') + + + @include('native.partials.settings-heading', [ + 'title' => 'Push notifications', + 'description' => 'What devnull tells you about when the app is closed, on every phone you sign in on.', + ]) + + {{-- Always here, even once the tabs' prompt is dismissed. The phone only asks once: after a no, they come back on in its own Settings, so the button goes there. --}} + + @if ($pushPermission === 'denied') + Turn on in Settings + Notifications are off for devnull on this phone. + @else + {{ $pushOn ? 'Notifications are on' : 'Turn on notifications' }} + @endif + + + {{-- Which kinds devnull sends, for you on every phone. Only once this phone gets them, and devnull has said. --}} + @if ($pushOn && $pushPreferences !== []) + + @foreach (\App\NativeComponents\ThisDevice::PushKinds as $kind => $label) + + {{ $label }} + + + @endforeach + @if ($pushPreferencesError) + {{ $pushPreferencesError }} + @endif + + @endif + diff --git a/resources/views/native/partials/account/remotes.blade.php b/resources/views/native/partials/account/remotes.blade.php new file mode 100644 index 00000000..511096e2 --- /dev/null +++ b/resources/views/native/partials/account/remotes.blade.php @@ -0,0 +1,51 @@ +@use('App\Icons\Lucide') + +{{-- + The web's Remotes switch, word for word, with the settings its Remotes page keeps in a menu under it + while Remotes are on: who can push to you, only while devnull offers Everyone, and Share pulls. +--}} + + + + @unless ($inPane ?? false) + Remotes + @endunless + One-to-one messages with other developers. People you follow can push to you, and you can push to people who follow you. Whether you share pulls (read receipts) is up to you, from Remotes. + When off, nobody can message you and Remotes is hidden. Your conversations are kept for when you turn it back on. + + + + @if ($remotesError) + {{ $remotesError }} + @endif + + @if ($remotes) + @if ($remotes->everyone) + + who can push to you + @foreach (['following' => 'People you follow', 'everyone' => 'Everyone'] as $from => $label) + + + {{ $label }} + @if ($remotes->from === $from) + + @endif + + + @endforeach + {{ $remotes->requests ? 'Anyone else lands in Fetched until you merge them. Requests already fetched stay there.' : 'Anyone else can push to you once you follow them.' }} + + @endif + + + + Share pulls + When off, nobody sees when you pull their messages, and you don't see when they pull yours. + + + + @if ($remotePreferencesError) + {{ $remotePreferencesError }} + @endif + @endif + diff --git a/resources/views/native/partials/account/safety.blade.php b/resources/views/native/partials/account/safety.blade.php new file mode 100644 index 00000000..98805ca3 --- /dev/null +++ b/resources/views/native/partials/account/safety.blade.php @@ -0,0 +1,12 @@ +@use('App\Icons\Lucide') + + + @include('native.partials.settings-heading', [ + 'title' => 'Safety', + 'description' => 'Everyone you mute or block, and a way to undo it.', + ]) + + + Muted and blocked people + + diff --git a/resources/views/native/partials/account/scroll.blade.php b/resources/views/native/partials/account/scroll.blade.php new file mode 100644 index 00000000..188750ad --- /dev/null +++ b/resources/views/native/partials/account/scroll.blade.php @@ -0,0 +1,41 @@ +{{-- Account's long scroll: every section, one after another, as one column shows it. --}} + + + @include('native.partials.error') + @include('native.partials.refresh-failed') + + @if ($user !== null) + @include('native.partials.account.profile') + + @include('native.partials.account.color') + + @include('native.partials.account.timezone') + + @include('native.partials.account.pasteis') + @endif + + @if ($user) + @include('native.partials.account.remotes') + @endif + + @if ($user) + @include('native.partials.account.who-to-follow') + @endif + + @include('native.partials.account.safety') + + @if ($offersApple) + @include('native.partials.account.apple') + @endif + + @include('native.partials.account.push') + + @include('native.partials.account.this-phone') + + @include('native.partials.account.sign-out') + + @include('native.partials.account.terms') + + @include('native.partials.account.delete') + + diff --git a/resources/views/native/partials/account/sign-out.blade.php b/resources/views/native/partials/account/sign-out.blade.php new file mode 100644 index 00000000..9704c275 --- /dev/null +++ b/resources/views/native/partials/account/sign-out.blade.php @@ -0,0 +1,4 @@ + + Sign out + Deletes the key from this phone and signs you out. + diff --git a/resources/views/native/partials/account/terms.blade.php b/resources/views/native/partials/account/terms.blade.php new file mode 100644 index 00000000..68ec867a --- /dev/null +++ b/resources/views/native/partials/account/terms.blade.php @@ -0,0 +1,10 @@ +@use('App\Icons\Lucide') + + + @include('native.partials.settings-heading', ['title' => 'Terms and privacy', 'description' => $terms]) + + + Terms of service + Privacy policy + + diff --git a/resources/views/native/partials/account/this-phone.blade.php b/resources/views/native/partials/account/this-phone.blade.php new file mode 100644 index 00000000..e12c2d80 --- /dev/null +++ b/resources/views/native/partials/account/this-phone.blade.php @@ -0,0 +1,27 @@ +@use('App\Icons\Lucide') + + + @include('native.partials.settings-heading', [ + 'title' => 'This phone', + 'description' => 'Signed in with a key that stays on this phone. dev-null.sh lists it by this fingerprint.', + ]) + + {{-- dev-null.sh lists each phone by name and fingerprint, so this is how you tell which one is this phone. --}} + + + fingerprint + {{ $fingerprint ?: 'null' }} + + @if ($remote !== null) + + + remote + {{ $remote }} + + @endif + + + + Your devices on dev-null.sh + + diff --git a/resources/views/native/partials/account/timezone.blade.php b/resources/views/native/partials/account/timezone.blade.php new file mode 100644 index 00000000..26996e46 --- /dev/null +++ b/resources/views/native/partials/account/timezone.blade.php @@ -0,0 +1,54 @@ +@use('App\Icons\Lucide') + +{{-- + The web's Timezone section: the timezone picked, or null while it's unset and the phone's is used, + the web's "Show my local time on my profile" once there is one, then Choose timezone, which opens + the list, the web's "Use … from this browser" with the phone's, and Unset. Nothing changes on + devnull until Save timezone, in your colour. +--}} + + @include('native.partials.settings-heading', [ + 'title' => 'Timezone', + 'description' => "Tap a commit's time on its page to see it in your timezone. On the web, people who hover a time see it in yours as well as theirs. Leave it unset to use this phone's timezone without sharing it. Your local time only shows on your profile if you turn that on below.", + ]) + + + + timezone + @if ($chosenTimezone === null) + null + @else + {{ \App\Devnull\Timezone::offset($chosenTimezone) }} {{ $chosenTimezone }} + @endif + + @if ($phoneTimezone !== null) + + + this phone + {{ \App\Devnull\Timezone::offset($phoneTimezone) }} {{ $phoneTimezone }} + + @endif + + + {{-- The web's checkbox, as the system's switch, which only counts with a timezone. --}} + @if ($chosenTimezone !== null) + + Show my local time on my profile + + + @endif + + + Choose timezone + @if ($phoneTimezone !== null && $phoneTimezone !== $chosenTimezone) + Use {{ $phoneTimezone }} from this phone + @endif + @if ($chosenTimezone !== null) + Unset + @endif + Save timezone + @if ($timezoneError) + {{ $timezoneError }} + @endif + + diff --git a/resources/views/native/partials/account/who-to-follow.blade.php b/resources/views/native/partials/account/who-to-follow.blade.php new file mode 100644 index 00000000..5e1ff950 --- /dev/null +++ b/resources/views/native/partials/account/who-to-follow.blade.php @@ -0,0 +1,12 @@ +{{-- The web's Who to follow setting, in its words, as a switch like the others here. --}} + + + + @unless ($inPane ?? false) + Who to follow + @endunless + Three people you might want to follow, in your log. + + + + diff --git a/resources/views/native/partials/settings-heading.blade.php b/resources/views/native/partials/settings-heading.blade.php index 18fcbf4d..5f836f5c 100644 --- a/resources/views/native/partials/settings-heading.blade.php +++ b/resources/views/native/partials/settings-heading.blade.php @@ -1,7 +1,12 @@ -{{-- A settings section's heading, as the web's: its title, and a line on what it's for. --}} +{{-- + A settings section's heading, as the web's: its title, and a line on what it's for. In Account's right-hand + column the bar above already says the title, so only the line shows there. +--}} @php($description ??= null) - {{ $title }} + @unless ($inPane ?? false) + {{ $title }} + @endunless @if ($description) {{ $description }} @endif diff --git a/resources/views/native/this-device.blade.php b/resources/views/native/this-device.blade.php index f71a111b..986c8089 100644 --- a/resources/views/native/this-device.blade.php +++ b/resources/views/native/this-device.blade.php @@ -1,7 +1,3 @@ -@use('App\Devnull\Lane') -@use('App\Icons\Ios') -@use('App\Icons\Lucide') - {{-- Laid out like the web's profile settings: a section each, with its heading, on the surface. The full-width buttons are large, as Sign in on dev-null.sh is, and the main ones wear your colour. @@ -9,367 +5,7 @@ @include('native.partials.colour-sheet') - - - @include('native.partials.error') - @include('native.partials.refresh-failed') - - @if ($user !== null) - - @include('native.partials.settings-heading', [ - 'title' => 'Profile information', - 'description' => 'Mirrored from GitHub when you sign in. To change any of it, change it on GitHub, then sync it here.', - ]) - - - @include('native.partials.rail-avatar', ['user' => $user, 'lane' => $savedLane, 'size' => 56]) - - {{ $user->name }} - {{ $user->handle() }} - - - - {{-- The web's hairline table: mono labels, and null in muted mono for what GitHub doesn't have. --}} - - @foreach ($fields as $field) - @if (! $loop->first) - - @endif - - {{ $field['label'] }} - @if ($field['value'] === null) - null - @else - {{ $field['value'] }} - @endif - - @endforeach - - - - Edit on GitHub - {{-- The label stays put while it spins, so the button keeps its size. --}} - Sync from GitHub - {{ $syncedAt }} - @if ($syncError) - {{ $syncError }} - @endif - - - - - @include('native.partials.settings-heading', [ - 'title' => 'Color', - 'description' => 'Your lane on the graph: the rail and nodes beside your commits, the ring around your avatar, and the dot before your handle. Automatic picks one from your account id.', - ]) - - {{-- You on the rail in the colour picked, as the web's preview draws you. --}} - - - - {{ $user->name }} - - - {{ $user->handle() }} - - - @include('native.partials.rail', ['previous' => $previewLane, 'tail' => $previewLane, 'node' => 'avatar', 'user' => $user, 'lane' => $previewLane]) - - - {{-- - Automatic, the six lanes, then Custom. The one picked wears a ring in its colour. Automatic is a dashed - ring round a dot, in the lane it gives you. Custom is your custom colour, or a spectrum until you mix - one, and opens the sheet that mixes it. No press-* feedback: it would keep the screen from scrolling. - --}} - - @foreach ($lanes as $option) - - - - @if ($option['auto']) - - @include('native.partials.dashed-ring', ['size' => 28, 'lane' => $option['lane']]) - - - @elseif ($option['lane'] === null) - - @else - - @endif - - {{ $option['label'] }} - - - @endforeach - - - {{-- In the colour picked, so you see it on a button before saving it. --}} - - Save color - @if ($laneError) - {{ $laneError }} - @endif - - - - {{-- - The web's Timezone section: the timezone picked, or null while it's unset and the phone's is used, - the web's "Show my local time on my profile" once there is one, then Choose timezone, which opens - the list, the web's "Use … from this browser" with the phone's, and Unset. Nothing changes on - devnull until Save timezone, in your colour. - --}} - - @include('native.partials.settings-heading', [ - 'title' => 'Timezone', - 'description' => "Tap a commit's time on its page to see it in your timezone. On the web, people who hover a time see it in yours as well as theirs. Leave it unset to use this phone's timezone without sharing it. Your local time only shows on your profile if you turn that on below.", - ]) - - - - timezone - @if ($chosenTimezone === null) - null - @else - {{ \App\Devnull\Timezone::offset($chosenTimezone) }} {{ $chosenTimezone }} - @endif - - @if ($phoneTimezone !== null) - - - this phone - {{ \App\Devnull\Timezone::offset($phoneTimezone) }} {{ $phoneTimezone }} - - @endif - - - {{-- The web's checkbox, as the system's switch, which only counts with a timezone. --}} - @if ($chosenTimezone !== null) - - Show my local time on my profile - - - @endif - - - Choose timezone - @if ($phoneTimezone !== null && $phoneTimezone !== $chosenTimezone) - Use {{ $phoneTimezone }} from this phone - @endif - @if ($chosenTimezone !== null) - Unset - @endif - Save timezone - @if ($timezoneError) - {{ $timezoneError }} - @endif - - - - {{-- - The web's pastéis mode section, word for word: its heading and two lines, with the switch beside them. - The switch is the system's own (a UISwitch on iOS), which takes taps since NativePHP/mobile-air#545. - --}} - - - - Pastéis mode - A little appreciation, fresh daily. Get 10 pastéis to give to other people’s commits, one per click. Your allowance resets at 00:00 UTC. - When off, all pastéis controls and counters are hidden. You still receive pastéis from others. - - - - @if ($pasteisModeError) - {{ $pasteisModeError }} - @endif - - @endif - - @if ($user) - {{-- - The web's Remotes switch, word for word, with the settings its Remotes page keeps in a menu under it - while Remotes are on: who can push to you, only while devnull offers Everyone, and Share pulls. - --}} - - - - Remotes - One-to-one messages with other developers. People you follow can push to you, and you can push to people who follow you. Whether you share pulls (read receipts) is up to you, from Remotes. - When off, nobody can message you and Remotes is hidden. Your conversations are kept for when you turn it back on. - - - - @if ($remotesError) - {{ $remotesError }} - @endif - - @if ($remotes) - @if ($remotes->everyone) - - who can push to you - @foreach (['following' => 'People you follow', 'everyone' => 'Everyone'] as $from => $label) - - - {{ $label }} - @if ($remotes->from === $from) - - @endif - - - @endforeach - {{ $remotes->requests ? 'Anyone else lands in Fetched until you merge them. Requests already fetched stay there.' : 'Anyone else can push to you once you follow them.' }} - - @endif - - - - Share pulls - When off, nobody sees when you pull their messages, and you don't see when they pull yours. - - - - @if ($remotePreferencesError) - {{ $remotePreferencesError }} - @endif - @endif - - @endif - - @if ($user) - {{-- The web's Who to follow setting, in its words, as a switch like the others here. --}} - - - - Who to follow - Three people you might want to follow, in your log. - - - - - @endif - - - @include('native.partials.settings-heading', [ - 'title' => 'Safety', - 'description' => 'Everyone you mute or block, and a way to undo it.', - ]) - - - Muted and blocked people - - - - @if ($offersApple) - - @include('native.partials.settings-heading', ['title' => 'Apple ID']) - - - - apple id - {{ $appleStatus }} - - - - - A quicker way back in on a new phone. The account is still your GitHub one. - - - @if ($appleLinked === false) - {{-- Apple's black button (white in dark mode, the theme's accent) with its logo, as Apple's guidelines ask. --}} - - Sign in with Apple - - @elseif ($appleLinked === true) - - Unlink Apple ID - - @endif - - @endif - - - @include('native.partials.settings-heading', [ - 'title' => 'Push notifications', - 'description' => 'What devnull tells you about when the app is closed, on every phone you sign in on.', - ]) - - {{-- Always here, even once the tabs' prompt is dismissed. The phone only asks once: after a no, they come back on in its own Settings, so the button goes there. --}} - - @if ($pushPermission === 'denied') - Turn on in Settings - Notifications are off for devnull on this phone. - @else - {{ $pushOn ? 'Notifications are on' : 'Turn on notifications' }} - @endif - - - {{-- Which kinds devnull sends, for you on every phone. Only once this phone gets them, and devnull has said. --}} - @if ($pushOn && $pushPreferences !== []) - - @foreach (\App\NativeComponents\ThisDevice::PushKinds as $kind => $label) - - {{ $label }} - - - @endforeach - @if ($pushPreferencesError) - {{ $pushPreferencesError }} - @endif - - @endif - - - - @include('native.partials.settings-heading', [ - 'title' => 'This phone', - 'description' => 'Signed in with a key that stays on this phone. dev-null.sh lists it by this fingerprint.', - ]) - - {{-- dev-null.sh lists each phone by name and fingerprint, so this is how you tell which one is this phone. --}} - - - fingerprint - {{ $fingerprint ?: 'null' }} - - @if ($remote !== null) - - - remote - {{ $remote }} - - @endif - - - - Your devices on dev-null.sh - - - - - Sign out - Deletes the key from this phone and signs you out. - - - - @include('native.partials.settings-heading', ['title' => 'Terms and privacy', 'description' => $terms]) - - - Terms of service - Privacy policy - - - - - @include('native.partials.settings-heading', [ - 'title' => 'Delete account', - 'description' => "Removes your /dev/null account, every commit and reply you've made, and everyone you follow. Replies others left under your commits go too. Replies under your replies stay, hanging off a [deleted] tombstone. Your GitHub account is not touched.", - ]) - - - Delete account - - - - + @include('native.partials.account.scroll') {{-- After the page, so the rows it adds and takes away never change the ids of the page's own nodes, which would scroll it back to the top. --}} From e865a75196d75f726ea78842bae4f574213401a7 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:36:23 +1030 Subject: [PATCH 05/17] List the rows of Account's sidebar and the sections each opens --- app/Devnull/AccountSection.php | 102 ++++++++++++++++++++++ tests/Unit/Devnull/AccountSectionTest.php | 48 ++++++++++ 2 files changed, 150 insertions(+) create mode 100644 app/Devnull/AccountSection.php create mode 100644 tests/Unit/Devnull/AccountSectionTest.php diff --git a/app/Devnull/AccountSection.php b/app/Devnull/AccountSection.php new file mode 100644 index 00000000..a77c6b45 --- /dev/null +++ b/app/Devnull/AccountSection.php @@ -0,0 +1,102 @@ + 'Profile', + self::Timezone => 'Timezone', + self::Features => 'Features', + self::Notifications => 'Notifications', + self::Safety => 'Safety', + self::Devices => 'Devices', + self::Terms => 'Terms and privacy', + self::Delete => 'Delete account', + self::SignOut => 'Sign out', + }; + } + + public function icon(): Lucide + { + return match ($this) { + self::Profile => Lucide::UserRound, + self::Timezone => Lucide::Clock3, + self::Features => Lucide::Sparkles, + self::Notifications => Lucide::Bell, + self::Safety => Lucide::Shield, + self::Devices => Lucide::TabletSmartphone, + self::Terms => Lucide::Bookmark, + self::Delete => Lucide::Trash2, + self::SignOut => Lucide::LogOut, + }; + } + + /** + * The long scroll's sections this row opens, in order, by their partial's name. Apple ID only shows where Apple + * is offered. Safety and Sign out open no sections. + * + * @return list + */ + public function sections(bool $offersApple): array + { + return match ($this) { + self::Profile => ['profile', 'color'], + self::Timezone => ['timezone'], + self::Features => ['pasteis', 'remotes', 'who-to-follow'], + self::Notifications => ['push'], + self::Devices => $offersApple ? ['apple', 'this-phone'] : ['this-phone'], + self::Terms => ['terms'], + self::Delete => ['delete'], + self::Safety, self::SignOut => [], + }; + } + + public function setApart(): bool + { + return in_array($this, [self::Terms, self::Delete, self::SignOut], true); + } + + public function hasPane(): bool + { + return $this !== self::SignOut; + } + + /** + * The rows that are about your profile, which the screen only shows once it has loaded. + */ + public function needsProfile(): bool + { + return in_array($this, [self::Profile, self::Timezone, self::Features], true); + } + + /** + * The rows the screen can show now, in order. + * + * @return list + */ + public static function available(bool $hasProfile): array + { + return array_values(array_filter(self::cases(), fn (self $section): bool => $hasProfile || ! $section->needsProfile())); + } +} diff --git a/tests/Unit/Devnull/AccountSectionTest.php b/tests/Unit/Devnull/AccountSectionTest.php new file mode 100644 index 00000000..2eb5d7db --- /dev/null +++ b/tests/Unit/Devnull/AccountSectionTest.php @@ -0,0 +1,48 @@ + $section->title(), AccountSection::cases()))->toBe([ + 'Profile', + 'Timezone', + 'Features', + 'Notifications', + 'Safety', + 'Devices', + 'Terms and privacy', + 'Delete account', + 'Sign out', + ]); +}); + +it('groups the long scroll sections under their rows', function () { + expect(AccountSection::Profile->sections(offersApple: true))->toBe(['profile', 'color']) + ->and(AccountSection::Features->sections(offersApple: true))->toBe(['pasteis', 'remotes', 'who-to-follow']) + ->and(AccountSection::Devices->sections(offersApple: true))->toBe(['apple', 'this-phone']) + ->and(AccountSection::Safety->sections(offersApple: true))->toBe([]); +}); + +it('leaves Apple ID out of Devices when Apple is not offered', function () { + expect(AccountSection::Devices->sections(offersApple: false))->toBe(['this-phone']); +}); + +it('leaves out profile rows without a profile', function () { + $available = AccountSection::available(hasProfile: false); + + expect($available[0])->toBe(AccountSection::Notifications) + ->and(array_filter($available, fn (AccountSection $section): bool => $section->needsProfile()))->toBeEmpty() + ->and(AccountSection::available(hasProfile: true))->toBe(AccountSection::cases()); +}); + +it('sets apart terms, delete and sign out', function () { + $setApart = array_values(array_filter(AccountSection::cases(), fn (AccountSection $section): bool => $section->setApart())); + + expect($setApart)->toBe([AccountSection::Terms, AccountSection::Delete, AccountSection::SignOut]); +}); + +it('gives sign out no pane', function () { + $withoutPane = array_values(array_filter(AccountSection::cases(), fn (AccountSection $section): bool => ! $section->hasPane())); + + expect($withoutPane)->toBe([AccountSection::SignOut]); +}); From 82d010a3b6c4ce72bcd7ce92a2953f9125d8527a Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:36:30 +1030 Subject: [PATCH 06/17] Show Account as a sidebar and a pane on wide iOS windows --- app/NativeComponents/ThisDevice.php | 112 ++++++++++++ .../native/partials/account/sidebar.blade.php | 24 +++ resources/views/native/this-device.blade.php | 47 ++++- tests/Feature/Screens/AccountColumnsTest.php | 166 ++++++++++++++++++ 4 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 resources/views/native/partials/account/sidebar.blade.php create mode 100644 tests/Feature/Screens/AccountColumnsTest.php diff --git a/app/NativeComponents/ThisDevice.php b/app/NativeComponents/ThisDevice.php index dd17af64..35d73748 100644 --- a/app/NativeComponents/ThisDevice.php +++ b/app/NativeComponents/ThisDevice.php @@ -3,6 +3,7 @@ namespace App\NativeComponents; use App\Devnull\Account; +use App\Devnull\AccountSection; use App\Devnull\AppleSignIn; use App\Devnull\Client; use App\Devnull\Data\CurrentUser; @@ -16,6 +17,7 @@ use App\Devnull\ResponseCache; use App\Devnull\Timezone; use App\Devnull\WhoToFollow; +use App\NativeComponents\Concerns\FollowsAdaptiveHost; use App\NativeComponents\Concerns\LeavesDevnull; use App\NativeComponents\Concerns\OpensLegalPages; use App\NativeComponents\Concerns\RefreshesInBackground; @@ -27,6 +29,7 @@ use Carbon\CarbonImmutable; use Illuminate\View\View; use Native\Mobile\Attributes\On; +use Native\Mobile\Edge\Layouts\Builders\NavBarOptions; use Native\Mobile\Edge\NativeComponent; use Native\Mobile\Events\Alert\ButtonPressed; use Native\Mobile\Events\PushNotification\TokenGenerated; @@ -52,9 +55,14 @@ * * On iOS it also links an Apple ID to your account, as a second way in on a * new phone. The account stays the GitHub one: Apple only signs you into it. + * + * On a wide iOS window (an iPad, or a phone that is wide in landscape) the sections are grouped into a sidebar, and + * the row you pick opens beside it, as iPad Settings lays them out. Safety there opens the muted and blocked lists + * themselves. Everywhere else, and always on Android, it stays the one long scroll. The native host says which. */ class ThisDevice extends NativeComponent { + use FollowsAdaptiveHost; use LeavesDevnull; use OpensLegalPages; use RefreshesInBackground; @@ -208,6 +216,22 @@ class ThisDevice extends NativeComponent */ public bool $pushOn = false; + /** + * Whether the native host shows two columns. Only its own report sets this. + */ + public bool $wide = false; + + /** + * The section open beside the sidebar while wide, as an AccountSection value. + */ + public ?string $selectedSection = null; + + /** + * Goes up with each change of the right-hand column's history PHP makes, so the host's reports about an older + * one are dropped. + */ + public int $navigationRevision = 0; + public function mount(): void { if (($kept = $this->cached('me')) !== null) { @@ -481,6 +505,90 @@ public function openSafety(): void $this->navigate('/profile/safety'); } + /** + * Opens a sidebar row's sections beside it. Sign out opens nothing: it asks you to confirm, as its button does. + */ + public function selectSection(string $section): void + { + $chosen = AccountSection::tryFrom($section); + + if ($chosen === null) { + return; + } + + if (! $chosen->hasPane()) { + $this->confirmSignOut(); + + return; + } + + $this->selectedSection = $chosen->value; + $this->navigationRevision++; + } + + /** + * What the native host reports: whether it shows two columns, or the sidebar's back to your profile. The right + * column is one page deep, so it never reports a back of its own. + */ + public function hostChanged(string $event): void + { + $change = $this->hostReport($event); + + if ($change === null) { + return; + } + + match ($change['action']) { + 'layout' => $this->wide = ($change['wide'] ?? false) === true, + 'dismiss' => $this->back(), + default => null, + }; + } + + /** + * The sections the screen can show now, in order. + * + * @return list + */ + public function availableSections(): array + { + return AccountSection::available($this->current !== null); + } + + /** + * Whether the native two-column host draws the screen. Android has no host, so it keeps the long scroll. + */ + public function usesHost(): bool + { + return System::isIos(); + } + + /** + * While wide, the screen's own bar gives way to the host's, which carry the titles and the way back. + */ + public function navigationOptions(): ?NavBarOptions + { + return $this->usesHost() && $this->wide ? NavBarOptions::make()->hidden() : null; + } + + /** + * Keeps the selection on a row the screen can show: the first one when it becomes wide, and again if the one open + * goes away, such as your profile failing to load while Features is open. + */ + private function keepSelectionShown(): void + { + if (! $this->wide) { + return; + } + + $available = array_map(fn (AccountSection $section): string => $section->value, $this->availableSections()); + + if ($this->selectedSection === null || ! in_array($this->selectedSection, $available, true)) { + $this->selectedSection = $available[0] ?? null; + $this->navigationRevision++; + } + } + /** * Switches pastéis mode, as the web's switch does. The switch, and every * screen's commits, take it at once, and devnull is told from the @@ -727,6 +835,7 @@ public function onAlertButton(string $label = '', ?string $id = null): void public function render(): View { + $this->keepSelectionShown(); $current = $this->current; return view('native.this-device', [ @@ -752,6 +861,9 @@ public function render(): View null => 'unknown', }, 'terms' => $current === null ? null : self::terms($current), + 'usesHost' => $this->usesHost(), + 'sections' => $this->availableSections(), + 'selected' => AccountSection::tryFrom((string) $this->selectedSection), ]); } diff --git a/resources/views/native/partials/account/sidebar.blade.php b/resources/views/native/partials/account/sidebar.blade.php new file mode 100644 index 00000000..91a36712 --- /dev/null +++ b/resources/views/native/partials/account/sidebar.blade.php @@ -0,0 +1,24 @@ +{{-- + Account's sidebar on a wide window: a row for each section it can show, in the long scroll's order, and Terms and + privacy, Delete account and Sign out apart at the bottom. The open section takes the wash, as the Log marks its + open commit. Sign out opens nothing beside it: it asks you to confirm. +--}} + + + @include('native.partials.error') + @include('native.partials.refresh-failed') + + @foreach ($sections as $section) + @if ($section->setApart() && ! ($sections[$loop->index - 1] ?? $section)->setApart()) + + @endif + @php($open = $selected === $section) + + + + {{ $section->title() }} + + + @endforeach + + diff --git a/resources/views/native/this-device.blade.php b/resources/views/native/this-device.blade.php index 986c8089..b16a2cc2 100644 --- a/resources/views/native/this-device.blade.php +++ b/resources/views/native/this-device.blade.php @@ -1,11 +1,56 @@ {{-- Laid out like the web's profile settings: a section each, with its heading, on the surface. The full-width buttons are large, as Sign in on dev-null.sh is, and the main ones wear your colour. + + On iOS the two-column host draws it. On one column it shows the long scroll alone, under the screen's own bar. + Wide, the sidebar sits on the left and the row picked on the right: its sections, each with its own title when + there are several, or for Safety the muted and blocked lists themselves. Only the layout the host reports is + drawn, so no ref is ever on screen twice. --}} @include('native.partials.colour-sheet') - @include('native.partials.account.scroll') + @if ($usesHost) + + {{-- The host always needs a primary page. On one column it never shows it, so it's left empty. --}} + + @if ($wide) + @include('native.partials.account.sidebar') + @endif + + + + + + @if ($wide) + @if ($selected !== null) + + @if ($selected === \App\Devnull\AccountSection::Safety) + + @else + @php($paneSections = $selected->sections($offersApple)) + + + @foreach ($paneSections as $paneSection) + @include('native.partials.account.'.$paneSection, ['inPane' => count($paneSections) === 1]) + @endforeach + + + @endif + + + @endif + @else + + + @include('native.partials.account.scroll') + + + @endif + + @else + @include('native.partials.account.scroll') + @endif {{-- After the page, so the rows it adds and takes away never change the ids of the page's own nodes, which would scroll it back to the top. --}} diff --git a/tests/Feature/Screens/AccountColumnsTest.php b/tests/Feature/Screens/AccountColumnsTest.php new file mode 100644 index 00000000..9ea63b81 --- /dev/null +++ b/tests/Feature/Screens/AccountColumnsTest.php @@ -0,0 +1,166 @@ + 'http://devnull.test']); + serveApi(['GET /api/v1/me' => [currentUserJson()]]); + signIn(); +}); + +/** + * Account on an iPhone or iPad, or on Android. + */ +function visitAccount(string $platform = 'ios'): TestableComponent +{ + return Native::visit('/profile/device', platform: $platform); +} + +/** + * Account, as the native host reports it laid out: wide in two columns, or not. + */ +function reportLayout(TestableComponent $screen, bool $wide): TestableComponent +{ + return $screen->call('hostChanged', json_encode(['action' => 'layout', 'wide' => $wide])); +} + +/** + * The right column's history, as the host's detail pages name it, oldest first. + * + * @return list + */ +function accountPanes(TestableComponent $screen): array +{ + return array_map( + fn (array $node): string => $node['props']['identity'], + findNodes($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'adaptive_detail'), + ); +} + +it('shows the long scroll until the host reports wide', function () { + $screen = visitAccount(); + + expect(accountPanes($screen))->toBe([]) + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'adaptive_collapsed'))->not->toBeNull(); + + $screen->assertSee('Pastéis mode')->assertSee('Delete account'); +}); + +it('selects the first section when it becomes wide', function () { + $screen = reportLayout(visitAccount(), true); + + $screen->assertSet('selectedSection', 'profile'); + + expect(accountPanes($screen))->toBe(['section-profile']) + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'adaptive_collapsed'))->toBeNull(); +}); + +it('swaps the pane when another section is chosen', function () { + $screen = reportLayout(visitAccount(), true)->tap('section-timezone'); + + $screen->assertSet('selectedSection', 'timezone'); + + expect(accountPanes($screen))->toBe(['section-timezone']); + nodeByRef($screen, 'choose-timezone'); +}); + +it('draws a section without its title in a pane', function () { + $screen = reportLayout(visitAccount(), true)->tap('section-delete'); + + $screen->assertSee('Removes your /dev/null account'); + + $titles = findNodes(nodeByRef($screen, 'delete-section'), fn (array $node): bool => ($node['type'] ?? null) === 'text' && ($node['props']['text'] ?? null) === 'Delete account'); + expect($titles)->toBe([]); +}); + +it('opens the muted and blocked lists straight in the Safety pane', function () { + $screen = reportLayout(visitAccount(), true)->tap('section-safety'); + + $screen->assertNoNavigation()->assertSee('Blocked'); + + expect(accountPanes($screen))->toBe(['section-safety']) + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'muted-and-blocked'))->toBeNull(); +}); + +it('still opens muted and blocked over the screen on one column', function () { + visitAccount() + ->tap('muted-and-blocked') + ->assertNavigatedTo('/profile/safety'); +}); + +it("shows each section's title in a grouped pane", function () { + $screen = reportLayout(visitAccount(), true)->tap('section-features'); + + $screen->assertSee('Pastéis mode')->assertSee('Remotes')->assertSee('Who to follow'); + + expect(accountPanes($screen))->toBe(['section-features']) + ->and(workspaceBar($screen, 'section-features')['props']['title'])->toBe('Features'); + nodeByRef($screen, 'pasteis-mode-switch'); + nodeByRef($screen, 'who-to-follow-switch'); +}); + +it('leaves Apple ID out of Devices when Apple is not offered', function () { + config(['devnull.apple_sign_in' => false]); + + $screen = reportLayout(visitAccount(), true)->tap('section-devices'); + + nodeByRef($screen, 'fingerprint'); + + expect(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'apple'))->toBeNull(); +}); + +it('asks to confirm sign out from the sidebar', function () { + $screen = reportLayout(visitAccount(), true)->tap('section-sign-out'); + + $screen->assertNativeCalled('Dialog.Alert', fn (array $params): bool => $params['title'] === 'Sign out?') + ->assertSet('selectedSection', 'profile') + ->emitNative(ButtonPressed::class, ['index' => 0, 'label' => 'Cancel', 'id' => 'sign-out']) + ->assertNoNavigation(); + + expect(app(Account::class)->user())->not->toBeNull(); +}); + +it('goes back to Profile from the sidebar', function () { + // With a platform set, back from the root screen is ignored, as the phone would; without one the harness keeps it. + reportLayout(Native::test(ThisDevice::class), true) + ->call('hostChanged', json_encode(['action' => 'dismiss'])) + ->assertWentBack(); +}); + +it('falls back to the first section when the profile goes away', function () { + $screen = reportLayout(visitAccount(), true)->tap('section-features'); + + $screen->set('current', null)->assertSet('selectedSection', 'notifications'); + + expect(accountPanes($screen))->toBe(['section-notifications']); +}); + +it('keeps an open sheet through a layout change', function () { + $screen = visitAccount()->set('pickingTimezone', true); + + reportLayout($screen, true)->assertSet('pickingTimezone', true); + + expect(nodeByRef($screen, 'timezone-sheet')['props']['visible'])->toBeTrue(); +}); + +it('hides the outer bar only when wide', function () { + $screen = visitAccount(); + + expect($screen->instance()->navigationOptions()?->hidden)->not->toBeTrue(); + + reportLayout($screen, true); + + expect($screen->instance()->navigationOptions()?->hidden)->toBeTrue(); +}); + +it('leaves Android as the long scroll', function () { + $screen = reportLayout(visitAccount('android'), true); + + expect(findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'adaptive_feed'))->toBeNull() + ->and($screen->instance()->navigationOptions()?->hidden)->not->toBeTrue(); + $screen->assertSee('Pastéis mode'); +}); From 91ca4fe2daf156799406681703606bbc21f7a1d0 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:36:30 +1030 Subject: [PATCH 07/17] Say device instead of phone on the Account screen --- app/NativeComponents/ThisDevice.php | 2 +- resources/views/native/partials/account/apple.blade.php | 2 +- resources/views/native/partials/account/push.blade.php | 4 ++-- resources/views/native/partials/account/sign-out.blade.php | 2 +- .../views/native/partials/account/this-phone.blade.php | 4 ++-- resources/views/native/partials/account/timezone.blade.php | 6 +++--- tests/Feature/Screens/AccountProfileTest.php | 4 ++-- tests/Feature/Screens/AccountTimezoneTest.php | 6 +++--- tests/Feature/Screens/ThisDeviceAppleTest.php | 2 +- tests/Feature/Screens/ThisDevicePushTest.php | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/NativeComponents/ThisDevice.php b/app/NativeComponents/ThisDevice.php index 35d73748..9b450617 100644 --- a/app/NativeComponents/ThisDevice.php +++ b/app/NativeComponents/ThisDevice.php @@ -795,7 +795,7 @@ public function confirmUnlinkApple(): void { Dialog::alert( 'Unlink your Apple ID?', - 'Sign in with Apple stops working for your account until you link it again. Your GitHub sign-in and this phone stay as they are.', + 'Sign in with Apple stops working for your account until you link it again. Your GitHub sign-in and this device stay as they are.', [ ['label' => 'Cancel', 'style' => 'cancel'], ['label' => 'Unlink', 'style' => 'destructive'], diff --git a/resources/views/native/partials/account/apple.blade.php b/resources/views/native/partials/account/apple.blade.php index 190ba85e..25abb580 100644 --- a/resources/views/native/partials/account/apple.blade.php +++ b/resources/views/native/partials/account/apple.blade.php @@ -11,7 +11,7 @@ - A quicker way back in on a new phone. The account is still your GitHub one. + A quicker way back in on a new device. The account is still your GitHub one. @if ($appleLinked === false) diff --git a/resources/views/native/partials/account/push.blade.php b/resources/views/native/partials/account/push.blade.php index 3852abf6..cc197201 100644 --- a/resources/views/native/partials/account/push.blade.php +++ b/resources/views/native/partials/account/push.blade.php @@ -3,14 +3,14 @@ @include('native.partials.settings-heading', [ 'title' => 'Push notifications', - 'description' => 'What devnull tells you about when the app is closed, on every phone you sign in on.', + 'description' => 'What devnull tells you about when the app is closed, on every device you sign in on.', ]) {{-- Always here, even once the tabs' prompt is dismissed. The phone only asks once: after a no, they come back on in its own Settings, so the button goes there. --}} @if ($pushPermission === 'denied') Turn on in Settings - Notifications are off for devnull on this phone. + Notifications are off for devnull on this device. @else {{ $pushOn ? 'Notifications are on' : 'Turn on notifications' }} @endif diff --git a/resources/views/native/partials/account/sign-out.blade.php b/resources/views/native/partials/account/sign-out.blade.php index 9704c275..b7529cbe 100644 --- a/resources/views/native/partials/account/sign-out.blade.php +++ b/resources/views/native/partials/account/sign-out.blade.php @@ -1,4 +1,4 @@ Sign out - Deletes the key from this phone and signs you out. + Deletes the key from this device and signs you out. diff --git a/resources/views/native/partials/account/this-phone.blade.php b/resources/views/native/partials/account/this-phone.blade.php index e12c2d80..6845dda5 100644 --- a/resources/views/native/partials/account/this-phone.blade.php +++ b/resources/views/native/partials/account/this-phone.blade.php @@ -2,8 +2,8 @@ @include('native.partials.settings-heading', [ - 'title' => 'This phone', - 'description' => 'Signed in with a key that stays on this phone. dev-null.sh lists it by this fingerprint.', + 'title' => 'This device', + 'description' => 'Signed in with a key that stays on this device. dev-null.sh lists it by this fingerprint.', ]) {{-- dev-null.sh lists each phone by name and fingerprint, so this is how you tell which one is this phone. --}} diff --git a/resources/views/native/partials/account/timezone.blade.php b/resources/views/native/partials/account/timezone.blade.php index 26996e46..122e29bb 100644 --- a/resources/views/native/partials/account/timezone.blade.php +++ b/resources/views/native/partials/account/timezone.blade.php @@ -9,7 +9,7 @@ @include('native.partials.settings-heading', [ 'title' => 'Timezone', - 'description' => "Tap a commit's time on its page to see it in your timezone. On the web, people who hover a time see it in yours as well as theirs. Leave it unset to use this phone's timezone without sharing it. Your local time only shows on your profile if you turn that on below.", + 'description' => "Tap a commit's time on its page to see it in your timezone. On the web, people who hover a time see it in yours as well as theirs. Leave it unset to use this device's timezone without sharing it. Your local time only shows on your profile if you turn that on below.", ]) @@ -24,7 +24,7 @@ @if ($phoneTimezone !== null) - this phone + this device {{ \App\Devnull\Timezone::offset($phoneTimezone) }} {{ $phoneTimezone }} @endif @@ -41,7 +41,7 @@ Choose timezone @if ($phoneTimezone !== null && $phoneTimezone !== $chosenTimezone) - Use {{ $phoneTimezone }} from this phone + Use {{ $phoneTimezone }} from this device @endif @if ($chosenTimezone !== null) Unset diff --git a/tests/Feature/Screens/AccountProfileTest.php b/tests/Feature/Screens/AccountProfileTest.php index d91cd9de..39bc4d0d 100644 --- a/tests/Feature/Screens/AccountProfileTest.php +++ b/tests/Feature/Screens/AccountProfileTest.php @@ -54,9 +54,9 @@ function mutedMono(array $node): bool ->assertDontSee('Embed your activity graph') ->assertDontSee('Export your data'); - $headings = array_values(array_intersect(shownText($screen), ['Profile information', 'Color', 'Apple ID', 'This phone', 'Deletes the key from this phone and signs you out.', 'Delete account'])); + $headings = array_values(array_intersect(shownText($screen), ['Profile information', 'Color', 'Apple ID', 'This device', 'Deletes the key from this device and signs you out.', 'Delete account'])); - expect($headings)->toBe(['Profile information', 'Color', 'Apple ID', 'This phone', 'Deletes the key from this phone and signs you out.', 'Delete account']) + expect($headings)->toBe(['Profile information', 'Color', 'Apple ID', 'This device', 'Deletes the key from this device and signs you out.', 'Delete account']) ->and(nodeByRef($screen, 'delete-account')['props'])->toMatchArray(['label' => 'Delete account', 'variant' => 'destructive']); }); diff --git a/tests/Feature/Screens/AccountTimezoneTest.php b/tests/Feature/Screens/AccountTimezoneTest.php index c5bd28e1..e3414cb6 100644 --- a/tests/Feature/Screens/AccountTimezoneTest.php +++ b/tests/Feature/Screens/AccountTimezoneTest.php @@ -63,9 +63,9 @@ function timezoneRows(TestableComponent $screen): array $screen = Native::visit('/profile/device') ->assertSee('Timezone') - ->assertSee("Leave it unset to use this phone's timezone without sharing it. Your local time only shows on your profile if you turn that on below.") + ->assertSee("Leave it unset to use this device's timezone without sharing it. Your local time only shows on your profile if you turn that on below.") ->assertSee('GMT+01:00 Atlantic/Canary') - ->assertSee('Use Atlantic/Canary from this phone') + ->assertSee('Use Atlantic/Canary from this device') ->assertDontSee('Show my local time on my profile'); expect(shownText($screen))->toContain('null') @@ -101,7 +101,7 @@ function timezoneRows(TestableComponent $screen): array ->assertSet('savingTimezone', false) ->assertSet('timezoneError', null) ->assertSet('savedTimezone', 'Atlantic/Canary') - ->assertDontSee('Use Atlantic/Canary from this phone'); + ->assertDontSee('Use Atlantic/Canary from this device'); // The web's form sends whether to show your local time with it, which devnull would otherwise turn off. expect(timezoneSaves())->toBe(['{"timezone":"Atlantic/Canary","show_local_time":false}']) diff --git a/tests/Feature/Screens/ThisDeviceAppleTest.php b/tests/Feature/Screens/ThisDeviceAppleTest.php index e24f47fc..ab6a0416 100644 --- a/tests/Feature/Screens/ThisDeviceAppleTest.php +++ b/tests/Feature/Screens/ThisDeviceAppleTest.php @@ -43,7 +43,7 @@ function meWithApple(bool $linked): array $screen = Native::visit('/profile/device', platform: 'ios') ->assertSee('apple id') - ->assertSee('A quicker way back in on a new phone. The account is still your GitHub one.') + ->assertSee('A quicker way back in on a new device. The account is still your GitHub one.') ->assertSet('appleLinked', false) ->assertDontSee('Unlink Apple ID'); diff --git a/tests/Feature/Screens/ThisDevicePushTest.php b/tests/Feature/Screens/ThisDevicePushTest.php index 6f41b524..cf3772d0 100644 --- a/tests/Feature/Screens/ThisDevicePushTest.php +++ b/tests/Feature/Screens/ThisDevicePushTest.php @@ -44,7 +44,7 @@ Native::visit('/profile/device') ->assertSee('Turn on in Settings') - ->assertSee('Notifications are off for devnull on this phone.') + ->assertSee('Notifications are off for devnull on this device.') ->assertDontSee('Notifications are on') ->tap('open-push-settings'); From bf2c9b5be12a667a121508994a225c68757a631e Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:47:30 +1030 Subject: [PATCH 08/17] Move the Safety list test helpers into Pest.php with clearer names --- tests/Feature/Screens/SafetyTest.php | 77 ++++++++++------------------ tests/Pest.php | 21 ++++++++ 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tests/Feature/Screens/SafetyTest.php b/tests/Feature/Screens/SafetyTest.php index 1f9c25e2..6bce48ba 100644 --- a/tests/Feature/Screens/SafetyTest.php +++ b/tests/Feature/Screens/SafetyTest.php @@ -10,27 +10,6 @@ signIn(); }); -/** - * Someone you mute or block, as devnull lists them. - * - * @return array - */ -function listedJson(string $id, string $username, string $name): array -{ - return userJson(['id' => $id, 'handle' => $username, 'name' => $name, 'lane' => 2]); -} - -/** - * A page of the people you mute or block. - * - * @param list> $people - * @return array - */ -function peopleJson(array $people, ?string $cursor = null, string $path = 'me/muted'): array -{ - return pageJson($people, $cursor, path: "http://devnull.test/api/v1/{$path}"); -} - function safetyRequests(string $method, string $path): int { return count(Http::recorded(fn (Request $request): bool => $request->method() === $method && parse_url($request->url(), PHP_URL_PATH) === "/api/v1/{$path}")); @@ -38,8 +17,8 @@ function safetyRequests(string $method, string $path): int it("lists the people you mute and block in the web's words, beneath the Profile tab", function () { fakeApi([ - 'GET /api/v1/me/muted' => [peopleJson([listedJson('u2', 'ada', 'Ada Lovelace'), listedJson('u3', 'grace', 'Grace Hopper')])], - 'GET /api/v1/me/blocked' => [peopleJson([listedJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')], + 'GET /api/v1/me/muted' => [safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace'), safetyPersonJson('u3', 'grace', 'Grace Hopper')])], + 'GET /api/v1/me/blocked' => [safetyPageJson([safetyPersonJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')], ]); $screen = Native::visit('/profile/safety', platform: 'ios') @@ -62,7 +41,7 @@ function safetyRequests(string $method, string $path): int }); it("says so in the web's words when you mute or block no one", function () { - fakeApi(['GET /api/v1/me/muted' => [peopleJson([])], 'GET /api/v1/me/blocked' => [peopleJson([], path: 'me/blocked')]]); + fakeApi(['GET /api/v1/me/muted' => [safetyPageJson([])], 'GET /api/v1/me/blocked' => [safetyPageJson([], path: 'me/blocked')]]); $screen = Native::visit('/profile/safety') ->assertSee("You haven't muted anyone.") @@ -75,8 +54,8 @@ function safetyRequests(string $method, string $path): int it('shows skeleton rows until devnull answers, with nothing kept', function () { holdRefreshes(); serveApi([ - 'GET /api/v1/me/muted' => [peopleJson([listedJson('u2', 'ada', 'Ada Lovelace')])], - 'GET /api/v1/me/blocked' => [peopleJson([], path: 'me/blocked')], + 'GET /api/v1/me/muted' => [safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])], + 'GET /api/v1/me/blocked' => [safetyPageJson([], path: 'me/blocked')], ]); $screen = Native::visit('/profile/safety')->assertDontSee('Ada Lovelace')->assertDontSee("You haven't"); @@ -94,11 +73,11 @@ function safetyRequests(string $method, string $path): int it('shows the lists as they were last time at once, then takes what devnull says behind them', function () { holdRefreshes(); - keep('me/muted', peopleJson([listedJson('u2', 'ada', 'Ada Lovelace')])); - keep('me/blocked', peopleJson([listedJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')); + keep('me/muted', safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])); + keep('me/blocked', safetyPageJson([safetyPersonJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')); serveApi([ - 'GET /api/v1/me/muted' => [peopleJson([listedJson('u3', 'grace', 'Grace Hopper')])], - 'GET /api/v1/me/blocked' => [peopleJson([], path: 'me/blocked')], + 'GET /api/v1/me/muted' => [safetyPageJson([safetyPersonJson('u3', 'grace', 'Grace Hopper')])], + 'GET /api/v1/me/blocked' => [safetyPageJson([], path: 'me/blocked')], ]); $screen = Native::visit('/profile/safety')->assertSee('Ada Lovelace')->assertSee('Mallory'); @@ -114,8 +93,8 @@ function safetyRequests(string $method, string $path): int }); it('says quietly that it could not refresh, and keeps showing the kept lists', function () { - keep('me/muted', peopleJson([listedJson('u2', 'ada', 'Ada Lovelace')])); - keep('me/blocked', peopleJson([], path: 'me/blocked')); + keep('me/muted', safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])); + keep('me/blocked', safetyPageJson([], path: 'me/blocked')); fakeOffline(); Native::visit('/profile/safety') @@ -135,9 +114,9 @@ function safetyRequests(string $method, string $path): int it('unmutes straight away, as the web does, and they leave the list and their kept profile', function () { keep('users/ada', ['data' => userWithCountsJson(['id' => 'u2', 'handle' => 'ada']), 'is_muting' => true]); serveApi([ - 'GET /api/v1/me/muted' => [peopleJson([listedJson('u2', 'ada', 'Ada Lovelace'), listedJson('u3', 'grace', 'Grace Hopper')])], - 'GET /api/v1/me/blocked' => [peopleJson([], path: 'me/blocked')], - 'DELETE /api/v1/users/ada/mute' => [['data' => listedJson('u2', 'ada', 'Ada Lovelace'), 'is_muting' => false]], + 'GET /api/v1/me/muted' => [safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace'), safetyPersonJson('u3', 'grace', 'Grace Hopper')])], + 'GET /api/v1/me/blocked' => [safetyPageJson([], path: 'me/blocked')], + 'DELETE /api/v1/users/ada/mute' => [['data' => safetyPersonJson('u2', 'ada', 'Ada Lovelace'), 'is_muting' => false]], ]); Native::visit('/profile/safety') @@ -153,9 +132,9 @@ function safetyRequests(string $method, string $path): int it('unblocks straight away, and they leave the list', function () { serveApi([ - 'GET /api/v1/me/muted' => [peopleJson([])], - 'GET /api/v1/me/blocked' => [peopleJson([listedJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')], - 'DELETE /api/v1/users/mallory/block' => [['data' => listedJson('u4', 'mallory', 'Mallory'), 'is_blocking' => false]], + 'GET /api/v1/me/muted' => [safetyPageJson([])], + 'GET /api/v1/me/blocked' => [safetyPageJson([safetyPersonJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')], + 'DELETE /api/v1/users/mallory/block' => [['data' => safetyPersonJson('u4', 'mallory', 'Mallory'), 'is_blocking' => false]], ]); Native::visit('/profile/safety') @@ -169,8 +148,8 @@ function safetyRequests(string $method, string $path): int it('puts them back, and says why, when devnull says no', function (string $route, string $button, string $name) { serveApi([ - 'GET /api/v1/me/muted' => [peopleJson([listedJson('u2', 'ada', 'Ada Lovelace')])], - 'GET /api/v1/me/blocked' => [peopleJson([listedJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')], + 'GET /api/v1/me/muted' => [safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])], + 'GET /api/v1/me/blocked' => [safetyPageJson([safetyPersonJson('u4', 'mallory', 'Mallory')], path: 'me/blocked')], $route => [['message' => 'Too Many Attempts.', 'code' => 'rate_limited'], 429], ]); @@ -184,7 +163,7 @@ function safetyRequests(string $method, string $path): int ]); it('ignores Unmute for someone it no longer lists', function () { - fakeApi(['GET /api/v1/me/muted' => [peopleJson([])], 'GET /api/v1/me/blocked' => [peopleJson([], path: 'me/blocked')]]); + fakeApi(['GET /api/v1/me/muted' => [safetyPageJson([])], 'GET /api/v1/me/blocked' => [safetyPageJson([], path: 'me/blocked')]]); Native::visit('/profile/safety')->call('unmute', 'ada'); @@ -197,9 +176,9 @@ function safetyRequests(string $method, string $path): int parse_str((string) parse_url($request->url(), PHP_URL_QUERY), $query); return match (true) { - $path === '/api/v1/me/muted' && ($query['cursor'] ?? null) === 'page2' => Http::response(peopleJson([listedJson('u3', 'grace', 'Grace Hopper')])), - $path === '/api/v1/me/muted' => Http::response(peopleJson([listedJson('u2', 'ada', 'Ada Lovelace')], 'page2')), - default => Http::response(peopleJson([], path: 'me/blocked')), + $path === '/api/v1/me/muted' && ($query['cursor'] ?? null) === 'page2' => Http::response(safetyPageJson([safetyPersonJson('u3', 'grace', 'Grace Hopper')])), + $path === '/api/v1/me/muted' => Http::response(safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')], 'page2')), + default => Http::response(safetyPageJson([], path: 'me/blocked')), }; }); @@ -223,8 +202,8 @@ function safetyRequests(string $method, string $path): int it('opens their profile beneath the tab it was opened in', function () { fakeApi([ - 'GET /api/v1/me/muted' => [peopleJson([listedJson('u2', 'ada', 'Ada Lovelace')])], - 'GET /api/v1/me/blocked' => [peopleJson([], path: 'me/blocked')], + 'GET /api/v1/me/muted' => [safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])], + 'GET /api/v1/me/blocked' => [safetyPageJson([], path: 'me/blocked')], ]); Native::visit('/profile/safety')->tap('Ada Lovelace')->assertNavigatedTo('/profile/users/ada'); @@ -233,14 +212,14 @@ function safetyRequests(string $method, string $path): int it('comes back from a profile showing the mute made there', function () { holdRefreshes(); - keep('me/muted', peopleJson([])); - keep('me/blocked', peopleJson([listedJson('u2', 'ada', 'Ada Lovelace')], path: 'me/blocked')); + keep('me/muted', safetyPageJson([])); + keep('me/blocked', safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')], path: 'me/blocked')); keep('users/grace', [ 'data' => userWithCountsJson(['id' => 'u3', 'handle' => 'grace', 'name' => 'Grace Hopper']), 'is_following' => false, 'is_muting' => false, ]); - serveApi(['POST /api/v1/users/grace/mute' => [['data' => listedJson('u3', 'grace', 'Grace Hopper'), 'is_muting' => true]]]); + serveApi(['POST /api/v1/users/grace/mute' => [['data' => safetyPersonJson('u3', 'grace', 'Grace Hopper'), 'is_muting' => true]]]); $safety = Native::visit('/profile/safety')->assertSee("You haven't muted anyone."); diff --git a/tests/Pest.php b/tests/Pest.php index 90aeece3..926035be 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -310,6 +310,27 @@ function fakeKeychain(?string $seed = null): FakeBridge */ const AppleIdentityToken = 'eyJhbGciOiJSUzI1NiJ9.apple-identity-token.signature'; +/** + * Someone you mute or block, as devnull lists them. + * + * @return array + */ +function safetyPersonJson(string $id, string $username, string $name): array +{ + return userJson(['id' => $id, 'handle' => $username, 'name' => $name, 'lane' => 2]); +} + +/** + * A page of the people you mute or block. + * + * @param list> $people + * @return array + */ +function safetyPageJson(array $people, ?string $cursor = null, string $path = 'me/muted'): array +{ + return pageJson($people, $cursor, path: "http://devnull.test/api/v1/{$path}"); +} + /** * An iPhone with its key in the Keychain, whose Apple sheet opens. */ From abf7ba68a6bf8611abf3133455ba558ad984e4af Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:47:30 +1030 Subject: [PATCH 09/17] Fix Account's Safety pane not updating when you come back to it --- app/NativeComponents/ThisDevice.php | 11 +++++++++++ tests/Feature/Screens/AccountColumnsTest.php | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/NativeComponents/ThisDevice.php b/app/NativeComponents/ThisDevice.php index 9b450617..4192e965 100644 --- a/app/NativeComponents/ThisDevice.php +++ b/app/NativeComponents/ThisDevice.php @@ -545,6 +545,17 @@ public function hostChanged(string $event): void }; } + /** + * Back on Account, from a profile opened in the Safety pane for one: the muted and blocked lists there take any + * change made on it. Only the screen hears it, so it passes it on, as the workspaces do. + */ + public function onResume(): void + { + foreach ($this->nativeChildComponents as $child) { + $child->onResume(); + } + } + /** * The sections the screen can show now, in order. * diff --git a/tests/Feature/Screens/AccountColumnsTest.php b/tests/Feature/Screens/AccountColumnsTest.php index 9ea63b81..06edb84e 100644 --- a/tests/Feature/Screens/AccountColumnsTest.php +++ b/tests/Feature/Screens/AccountColumnsTest.php @@ -164,3 +164,21 @@ function accountPanes(TestableComponent $screen): array ->and($screen->instance()->navigationOptions()?->hidden)->not->toBeTrue(); $screen->assertSee('Pastéis mode'); }); + +it('brings the Safety pane up to date when you come back to Account', function () { + holdRefreshes(); + keep('me/muted', safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])); + keep('me/blocked', safetyPageJson([], path: 'me/blocked')); + serveApi([ + 'GET /api/v1/me' => [currentUserJson()], + 'GET /api/v1/me/muted' => [safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])], + 'GET /api/v1/me/blocked' => [safetyPageJson([], path: 'me/blocked')], + ]); + + $screen = reportLayout(visitAccount(), true)->tap('section-safety')->assertSee('Ada Lovelace'); + + // A profile opened from the pane unmutes Ada, which leaves the kept list without her. + keep('me/muted', safetyPageJson([safetyPersonJson('u3', 'grace', 'Grace Hopper')])); + + $screen->call('onResume')->assertSee('Grace Hopper')->assertDontSee('Ada Lovelace'); +}); From 5d15672298b3dc78b6ade0b00d5a3e1cbea599e9 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:47:30 +1030 Subject: [PATCH 10/17] Fix the sidebar width splitting across the Duo's hinge --- .../resources/ios/AdaptiveFeedRenderer.swift | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift index 1e946ea5..bb3e1b46 100644 --- a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift +++ b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift @@ -558,8 +558,17 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC /// Whether a fold runs down the window, so the columns must part on it. private func hasFold(in bounds: CGRect) -> Bool { - let middle = CGRect(x: bounds.minX + (bounds.width / 2).rounded(), y: bounds.minY, width: 0, height: bounds.height) - return foldGap(in: bounds) != middle + guard #available(iOS 27.1, *) else { return false } + return division(in: bounds) != nil + } + + /// The fold running down the window, if it has one: the division region + /// nearest its middle, active or not. + @available(iOS 27.1, *) + private func division(in bounds: CGRect) -> UIView.ReservedRegion? { + view.reservedRegions(kind: .division, options: .includeInactive) + .filter { $0.frame.height > $0.frame.width && $0.frame.minX > bounds.minX && $0.frame.maxX < bounds.maxX } + .min(by: { abs($0.frame.midX - bounds.midX) < abs($1.frame.midX - bounds.midX) }) } /// Where the columns part: the fold, for an even split around the hinge. @@ -570,12 +579,7 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC /// applies the same rule; keep the two alike. private func foldGap(in bounds: CGRect) -> CGRect { let middle = CGRect(x: bounds.minX + (bounds.width / 2).rounded(), y: bounds.minY, width: 0, height: bounds.height) - guard #available(iOS 27.1, *) else { return middle } - let divisions = view.reservedRegions(kind: .division, options: .includeInactive) - .filter { $0.frame.height > $0.frame.width && $0.frame.minX > bounds.minX && $0.frame.maxX < bounds.maxX } - guard let division = divisions.min(by: { abs($0.frame.midX - bounds.midX) < abs($1.frame.midX - bounds.midX) }) else { - return middle - } + guard #available(iOS 27.1, *), let division = division(in: bounds) else { return middle } return division.isActive ? division.frame : CGRect(x: division.frame.midX, y: bounds.minY, width: 0, height: bounds.height) } From dceddf97c66e73bc14a40c54c58587dccff0d036 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 18:47:30 +1030 Subject: [PATCH 11/17] Fix swiping back from Account while it shows two columns --- .../resources/ios/AdaptiveFeedRenderer.swift | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift index bb3e1b46..a30592a0 100644 --- a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift +++ b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift @@ -363,6 +363,16 @@ private final class AdaptiveNavigationBar: UINavigationBar { } } +/// Lets a pushed host's screen be swiped back while its bar is hidden, as +/// long as there is a screen to go back to. +private final class AdaptiveBackSwipe: NSObject, UIGestureRecognizerDelegate { + weak var navigation: UINavigationController? + + func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + (navigation?.viewControllers.count ?? 0) > 1 && navigation?.transitionCoordinator == nil + } +} + private final class AdaptiveWorkspaceController: UIViewController, UINavigationControllerDelegate { private let primary = UINavigationController(navigationBarClass: AdaptiveNavigationBar.self, toolbarClass: nil) private let secondary = UINavigationController(navigationBarClass: AdaptiveNavigationBar.self, toolbarClass: nil) @@ -373,6 +383,9 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC private var collapsed: AdaptivePageController? /// Whether PHP has been told the last mode applied, so it hears each change once. private var reportedWide: Bool? + /// The back swipe's delegate while a pushed host is wide, and the one it stood in for. + private let backSwipe = AdaptiveBackSwipe() + private weak var replacedSwipeDelegate: UIGestureRecognizerDelegate? private var appliedFoldGap: CGRect? private var latest: NativeUINode? private var inherited: EnvironmentValues? @@ -466,6 +479,7 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC } reconcile() layoutColumns() + updateBackSwipe() updateBottomBarClearance() updateHorizontalInsets() } @@ -1042,13 +1056,38 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC /// host goes back as any pushed screen does. private func updateBackSwipe() { guard let outer = navigationController, outer !== primary, outer !== secondary, - outer.viewControllers.count > 1, let swipe = outer.interactivePopGestureRecognizer else { return } - if wide == true, latest?.children.contains(where: { $0.type == "adaptive_collapsed" }) == true { + let feedBar = latest?.children + .first(where: { !["adaptive_detail", "adaptive_placeholder", "adaptive_collapsed"].contains($0.type) })? + .children.first(where: { $0.type == "adaptive_bar" }) + let wants = wide == true && feedBar?.props.getBool("back") == true && outer.viewControllers.count > 1 + if wants { + // UIKit and SwiftUI stop the swipe through its delegate while the + // screen's bar is hidden, so stand in for that delegate, and set + // it again whenever they have put their own back. + if swipe.delegate !== backSwipe { + if !(swipe.delegate is AdaptiveBackSwipe) { replacedSwipeDelegate = swipe.delegate } + backSwipe.navigation = outer + swipe.delegate = backSwipe + } swipe.isEnabled = true + } else { + restoreBackSwipe() } } + /// Hands the swipe back to the delegate it had before. + private func restoreBackSwipe() { + guard let swipe = navigationController?.interactivePopGestureRecognizer, swipe.delegate === backSwipe else { return } + swipe.delegate = replacedSwipeDelegate + replacedSwipeDelegate = nil + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + restoreBackSwipe() + } + private func send(_ action: String, depth: Int? = nil, extra: [String: Any] = [:]) { guard let latest else { return } let callback = latest.props.getCallbackId("on_change") From 7ff2a770e82e22052124785eea45a4284a79fc5e Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 19:24:38 +1030 Subject: [PATCH 12/17] Fix Profile menu needing two taps on an iPad in portrait --- app/NativeComponents/Profile.php | 58 +++++++++++++++++++--- tests/Feature/Screens/ProfileShareTest.php | 16 ++++++ 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/app/NativeComponents/Profile.php b/app/NativeComponents/Profile.php index bafdcc21..ab2986a2 100644 --- a/app/NativeComponents/Profile.php +++ b/app/NativeComponents/Profile.php @@ -35,6 +35,7 @@ use Native\Mobile\Edge\NativeComponent; use Native\Mobile\Events\Alert\ButtonPressed; use Native\Mobile\Facades\Browser; +use Native\Mobile\Facades\Device; use Native\Mobile\Facades\Dialog; use Native\Mobile\Facades\Share; @@ -153,12 +154,20 @@ class Profile extends NativeComponent */ public ?string $unavailable = null; + /** + * Whether the app runs on an iPad, read once when the screen opens. See navigationOptions(). + */ + public bool $onIpad = false; + public function mount(): void { if ($this->username === '') { $this->username = $this->me()?->username ?? ''; } + $info = json_decode((string) Device::getInfo(), true); + $this->onIpad = is_array($info) && ($info['model'] ?? null) === 'iPad'; + if ($this->isMe()) { $this->tab = app(ShownTabs::class)->get($this->me()?->id, 'profile', self::Tabs, 'commits'); } @@ -181,8 +190,33 @@ public function navTitle(): string return '@'.$this->username; } + /** + * Your own profile puts Scheduled commits and Starred in the bar, then a ⋯ with Share profile + * and Account. On an iPad in portrait the top tab bar leaves too little room for all three, + * so iPadOS folds them into its own overflow menu, and Account ends up in a menu inside a + * menu. So on an iPad they all go in the one ⋯, which always fits. + */ public function navigationOptions(): ?NavBarOptions { + if ($this->isMe() && $this->onIpad) { + return NavBarOptions::make()->action( + NavAction::make('more') + ->icon(ios: Lucide::Ellipsis->ios(), android: Lucide::Ellipsis->android()) + ->a11yLabel('More options') + ->items([ + NavAction::make('scheduled') + ->label('Scheduled commits') + ->icon(ios: Lucide::CalendarDays->ios(), android: Lucide::CalendarDays->android()) + ->press('openScheduledCommits'), + NavAction::make('starred') + ->label('Starred') + ->icon(ios: Lucide::Star->ios(), android: Lucide::Star->android()) + ->press('openStarred'), + ...$this->ownMenuItems(), + ]), + ); + } + if ($this->isMe()) { return NavBarOptions::make() ->action( @@ -201,13 +235,7 @@ public function navigationOptions(): ?NavBarOptions NavAction::make('more') ->icon(ios: Lucide::Ellipsis->ios(), android: Lucide::Ellipsis->android()) ->a11yLabel('More options') - ->items([ - $this->shareAction()->label('Share profile'), - NavAction::make('account') - ->label('Account') - ->icon(ios: Lucide::Settings2->ios(), android: Lucide::Settings2->android()) - ->press('openAccount'), - ]), + ->items($this->ownMenuItems()), ); } @@ -219,6 +247,22 @@ public function navigationOptions(): ?NavBarOptions ); } + /** + * Share profile and Account, which end the ⋯ of your own profile. + * + * @return list + */ + private function ownMenuItems(): array + { + return [ + $this->shareAction()->label('Share profile'), + NavAction::make('account') + ->label('Account') + ->icon(ios: Lucide::Settings2->ios(), android: Lucide::Settings2->android()) + ->press('openAccount'), + ]; + } + /** * Share profile, under the share shape each phone uses (Lucide's share on * iOS, share-2 on Android), first in the ⋯ of every profile. It's always diff --git a/tests/Feature/Screens/ProfileShareTest.php b/tests/Feature/Screens/ProfileShareTest.php index b0e08243..1485445a 100644 --- a/tests/Feature/Screens/ProfileShareTest.php +++ b/tests/Feature/Screens/ProfileShareTest.php @@ -70,6 +70,22 @@ function shareMenuIds(TestableComponent $screen): ?array ->assertNoNavigation(); }); +it('folds Scheduled commits and Starred into the ⋯ of your own profile on an iPad', function () { + fakeApi([ + 'GET /api/v1/users/local_dev' => [shareProfileJson('local_dev', 'https://dev-null.sh/@local_dev')], + 'GET /api/v1/users/local_dev/commits' => [pageJson([])], + ]); + Native::fakeBridge()->respondTo('Device.GetInfo', ['info' => json_encode(['model' => 'iPad', 'platform' => 'ios'])]); + + $screen = Native::visit('/profile', platform: 'ios'); + $actions = array_map(fn (array $node): string => $node['props']['id'], findNodes($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'top_bar_action')); + + expect(array_values(array_diff($actions, shareMenuIds($screen) ?? [])))->toBe(['more']) + ->and(shareMenuIds($screen))->toBe(['scheduled', 'starred', 'share', 'account']); + + $screen->press('openScheduledCommits')->assertNavigatedTo('/profile/scheduled'); +}); + it('shares the profile link devnull sends', function () { fakeApi(['GET /api/v1/users/ada' => [shareProfileJson()], 'GET /api/v1/users/ada/commits' => [pageJson([])]]); From cb27b5864bd1b106d7bc03c9cd783870a2a057c6 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 19:36:37 +1030 Subject: [PATCH 13/17] Fix the back swipe stopping after a cancelled swipe on Account --- .../resources/ios/AdaptiveFeedRenderer.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift index a30592a0..8586d68c 100644 --- a/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift +++ b/packages/adaptive-layout/resources/ios/AdaptiveFeedRenderer.swift @@ -1088,6 +1088,14 @@ private final class AdaptiveWorkspaceController: UIViewController, UINavigationC restoreBackSwipe() } + /// Takes the swipe again when the host comes back into view, as after a + /// swipe back that was let go of halfway, or a switch to another tab and + /// back. Neither always lays the view out again, so nothing else would. + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + updateBackSwipe() + } + private func send(_ action: String, depth: Int? = nil, extra: [String: Any] = [:]) { guard let latest else { return } let callback = latest.props.getCallbackId("on_change") From 86fa58142e1b9dfad46332e1adfa3272b2afde27 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 19:36:37 +1030 Subject: [PATCH 14/17] Say device in the Sign out confirmation --- app/NativeComponents/Concerns/LeavesDevnull.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/NativeComponents/Concerns/LeavesDevnull.php b/app/NativeComponents/Concerns/LeavesDevnull.php index 5dfb31b4..3699187e 100644 --- a/app/NativeComponents/Concerns/LeavesDevnull.php +++ b/app/NativeComponents/Concerns/LeavesDevnull.php @@ -30,7 +30,7 @@ public function confirmSignOut(): void { Dialog::alert( 'Sign out?', - 'This deletes the key from this phone. The phone stays listed on dev-null.sh until you remove it there, and signing in again makes a new key.', + 'This deletes the key from this device. The device stays listed on dev-null.sh until you remove it there, and signing in again makes a new key.', [ ['label' => 'Cancel', 'style' => 'cancel'], ['label' => 'Sign out', 'style' => 'destructive'], From 29dcab14943b3a29204f0065a4d7bbd75e0d8f00 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 19:39:16 +1030 Subject: [PATCH 15/17] Open Account in two columns straight away on an iPad --- app/Devnull/DeviceModel.php | 22 ++++++++++++++++++++ app/NativeComponents/Profile.php | 5 ++--- app/NativeComponents/ThisDevice.php | 6 +++++- tests/Feature/Screens/AccountColumnsTest.php | 11 ++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 app/Devnull/DeviceModel.php diff --git a/app/Devnull/DeviceModel.php b/app/Devnull/DeviceModel.php new file mode 100644 index 00000000..b8e28131 --- /dev/null +++ b/app/Devnull/DeviceModel.php @@ -0,0 +1,22 @@ +username = $this->me()?->username ?? ''; } - $info = json_decode((string) Device::getInfo(), true); - $this->onIpad = is_array($info) && ($info['model'] ?? null) === 'iPad'; + $this->onIpad = DeviceModel::isIpad(); if ($this->isMe()) { $this->tab = app(ShownTabs::class)->get($this->me()?->id, 'profile', self::Tabs, 'commits'); diff --git a/app/NativeComponents/ThisDevice.php b/app/NativeComponents/ThisDevice.php index 4192e965..c3821354 100644 --- a/app/NativeComponents/ThisDevice.php +++ b/app/NativeComponents/ThisDevice.php @@ -9,6 +9,7 @@ use App\Devnull\Data\CurrentUser; use App\Devnull\Data\Remotes; use App\Devnull\DeviceKey; +use App\Devnull\DeviceModel; use App\Devnull\Display; use App\Devnull\Exceptions\KeychainUnavailable; use App\Devnull\Hsl; @@ -217,7 +218,8 @@ class ThisDevice extends NativeComponent public bool $pushOn = false; /** - * Whether the native host shows two columns. Only its own report sets this. + * Whether the native host shows two columns. Its own report sets this. An iPad starts wide, as its host nearly + * always is, so the first frame isn't the long scroll; the host's first report puts it right if not. */ public bool $wide = false; @@ -234,6 +236,8 @@ class ThisDevice extends NativeComponent public function mount(): void { + $this->wide = $this->usesHost() && DeviceModel::isIpad(); + if (($kept = $this->cached('me')) !== null) { $this->showMe($kept); $this->appleLinked = CurrentUser::fromArray($kept)->appleLinked; diff --git a/tests/Feature/Screens/AccountColumnsTest.php b/tests/Feature/Screens/AccountColumnsTest.php index 06edb84e..deaf3702 100644 --- a/tests/Feature/Screens/AccountColumnsTest.php +++ b/tests/Feature/Screens/AccountColumnsTest.php @@ -182,3 +182,14 @@ function accountPanes(TestableComponent $screen): array $screen->call('onResume')->assertSee('Grace Hopper')->assertDontSee('Ada Lovelace'); }); + +it('opens in two columns on an iPad before the host reports', function () { + Native::fakeBridge()->respondTo('Device.GetInfo', ['info' => json_encode(['model' => 'iPad', 'platform' => 'ios'])]); + + $screen = visitAccount(); + + $screen->assertSet('wide', true)->assertSet('selectedSection', 'profile'); + + expect(accountPanes($screen))->toBe(['section-profile']) + ->and($screen->instance()->navigationOptions()?->hidden)->toBeTrue(); +}); From 0556f3e7dd6caf10f3295678de7e200257497c0b Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 19:39:16 +1030 Subject: [PATCH 16/17] Fix Account opening on Notifications when your profile loads after it goes wide --- app/NativeComponents/ThisDevice.php | 14 ++++++++++++-- tests/Feature/Screens/AccountColumnsTest.php | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/NativeComponents/ThisDevice.php b/app/NativeComponents/ThisDevice.php index c3821354..70278dd2 100644 --- a/app/NativeComponents/ThisDevice.php +++ b/app/NativeComponents/ThisDevice.php @@ -228,6 +228,12 @@ class ThisDevice extends NativeComponent */ public ?string $selectedSection = null; + /** + * Whether you picked the open section from the sidebar. Until you do, the first row stays open, so Account + * moves to Profile once your profile loads. + */ + public bool $sectionChosen = false; + /** * Goes up with each change of the right-hand column's history PHP makes, so the host's reports about an older * one are dropped. @@ -527,6 +533,7 @@ public function selectSection(string $section): void } $this->selectedSection = $chosen->value; + $this->sectionChosen = true; $this->navigationRevision++; } @@ -588,7 +595,8 @@ public function navigationOptions(): ?NavBarOptions /** * Keeps the selection on a row the screen can show: the first one when it becomes wide, and again if the one open - * goes away, such as your profile failing to load while Features is open. + * goes away, such as your profile failing to load while Features is open. Until you pick a row it stays on the + * first, so Profile opens once your profile loads. */ private function keepSelectionShown(): void { @@ -598,7 +606,9 @@ private function keepSelectionShown(): void $available = array_map(fn (AccountSection $section): string => $section->value, $this->availableSections()); - if ($this->selectedSection === null || ! in_array($this->selectedSection, $available, true)) { + $gone = $this->selectedSection === null || ! in_array($this->selectedSection, $available, true); + + if ($gone || (! $this->sectionChosen && $this->selectedSection !== ($available[0] ?? null))) { $this->selectedSection = $available[0] ?? null; $this->navigationRevision++; } diff --git a/tests/Feature/Screens/AccountColumnsTest.php b/tests/Feature/Screens/AccountColumnsTest.php index deaf3702..69c686b5 100644 --- a/tests/Feature/Screens/AccountColumnsTest.php +++ b/tests/Feature/Screens/AccountColumnsTest.php @@ -193,3 +193,19 @@ function accountPanes(TestableComponent $screen): array expect(accountPanes($screen))->toBe(['section-profile']) ->and($screen->instance()->navigationOptions()?->hidden)->toBeTrue(); }); + +it('moves to Profile once your profile loads, unless you chose another section', function (?string $chosen, string $shown) { + $screen = visitAccount(); + $profile = $screen->instance()->current; + + $screen = reportLayout($screen->set('current', null), true)->assertSet('selectedSection', 'notifications'); + + if ($chosen !== null) { + $screen->tap("section-{$chosen}"); + } + + $screen->set('current', $profile)->assertSet('selectedSection', $shown); +})->with([ + 'nothing chosen' => [null, 'profile'], + 'Devices chosen' => ['devices', 'devices'], +]); From 11ddda124d0036cd2122134fff0ef3d2a91144d8 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 1 Dec 2026 19:39:16 +1030 Subject: [PATCH 17/17] Fix the sidebar's banners sharing refs with the Safety pane's --- .../native/partials/account/sidebar.blade.php | 5 +++-- resources/views/native/partials/error.blade.php | 4 +++- .../views/native/partials/refresh-failed.blade.php | 3 ++- tests/Feature/Screens/AccountColumnsTest.php | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/resources/views/native/partials/account/sidebar.blade.php b/resources/views/native/partials/account/sidebar.blade.php index 91a36712..a6c2bc45 100644 --- a/resources/views/native/partials/account/sidebar.blade.php +++ b/resources/views/native/partials/account/sidebar.blade.php @@ -5,8 +5,9 @@ --}} - @include('native.partials.error') - @include('native.partials.refresh-failed') + {{-- Their own refs, as the Safety pane beside them has its own banners. --}} + @include('native.partials.error', ['bannerRef' => 'account-error']) + @include('native.partials.refresh-failed', ['bannerRef' => 'account-refresh-failed']) @foreach ($sections as $section) @if ($section->setApart() && ! ($sections[$loop->index - 1] ?? $section)->setApart()) diff --git a/resources/views/native/partials/error.blade.php b/resources/views/native/partials/error.blade.php index 950cef23..033eafae 100644 --- a/resources/views/native/partials/error.blade.php +++ b/resources/views/native/partials/error.blade.php @@ -1,5 +1,7 @@ +{{-- A screen's error, in red. A second copy on the same screen, like Account's sidebar beside its Safety pane, passes + its own ref as $bannerRef. --}} @if ($error) - + {{ $error }} @endif diff --git a/resources/views/native/partials/refresh-failed.blade.php b/resources/views/native/partials/refresh-failed.blade.php index 310300cf..b53d7b1a 100644 --- a/resources/views/native/partials/refresh-failed.blade.php +++ b/resources/views/native/partials/refresh-failed.blade.php @@ -1,9 +1,10 @@ {{-- A refresh that didn't land, offline or otherwise. What's showing stays put, and this says quietly that it may be out of date, in git's voice, with a way to try again. Only a screen with nothing to show prints the error instead. + A second copy on the same screen passes its own ref as $bannerRef. --}} @if ($refreshFailed) - + warning: couldn't refresh Retry diff --git a/tests/Feature/Screens/AccountColumnsTest.php b/tests/Feature/Screens/AccountColumnsTest.php index 69c686b5..d52d10dd 100644 --- a/tests/Feature/Screens/AccountColumnsTest.php +++ b/tests/Feature/Screens/AccountColumnsTest.php @@ -209,3 +209,17 @@ function accountPanes(TestableComponent $screen): array 'nothing chosen' => [null, 'profile'], 'Devices chosen' => ['devices', 'devices'], ]); + +it('never puts a ref on screen twice when Account and its Safety pane both fail to refresh', function () { + holdRefreshes(); + keep('me', currentUserJson()); + keep('me/muted', safetyPageJson([safetyPersonJson('u2', 'ada', 'Ada Lovelace')])); + keep('me/blocked', safetyPageJson([], path: 'me/blocked')); + fakeOffline(); + + $screen = finishRefreshes(reportLayout(visitAccount(), true)->tap('section-safety')); + $refs = array_map(fn (array $node): string => $node['ref'], findNodes($screen->tree(), fn (array $node): bool => isset($node['ref']))); + + expect(array_count_values($refs)['refresh-failed'] ?? 0)->toBeGreaterThan(0) + ->and(array_filter(array_count_values($refs), fn (int $count): bool => $count > 1))->toBe([]); +});