Files
buzz/mobile/ios/NativeControlTests/SettingMenuSelectionTests.swift
klopez4212 634f48a8bd Mobile: open Solo chats with Bestie and workspace controls (#8884)
Mobile New chat now opens directly with the synced Bestie selected. The
first send creates and names the chat; leaving an empty draft creates
nothing. New and existing Solo chats can select or clear a workspace
from the header popover, with a checkmark for the active choice and a No
Workspace option. Workspace and agent controls have separate iOS glass
surfaces, Bestie stays at the far right, and Back uses a chevron. The
agent sheet fits its list, with scrolling for long lists. Workspace
creation stays in the Home New menu.

The New menu groups Solo above Team. Android expands across the full
control row; iOS keeps its native menu while Search and Bestie merge
into New through Liquid Glass, with synchronized icon motion and the
residual glass fading away. Empty workspaces use a compact, muted
message.

Validation: 4,055 mobile tests passed (34 skipped), static analysis
passed, and native menu checks passed. Earlier physical-device previews
and the iPhone New-menu animation were visually approved before this
consolidation.

This PR consolidates the controls previously developed in #8891 into the
existing draft/first-send implementation. The New menu animations,
attachment handling, and durable retries remain in this PR. The combined
controls have widget interaction coverage; the combined build has not
yet had a new physical-device walkthrough.

Current combined controls below are Android Flutter widget renders with
fixture data, not device screenshots. Images are GitHub attachments
only.

| New conversation | Workspace popover | Compact agent sheet |
| --- | --- | --- |
| ![New chat
composer](https://github.com/user-attachments/assets/f9ea2a16-342e-4cea-a436-0777ff5e37aa)
| ![Checked workspace
popover](https://github.com/user-attachments/assets/80eb7a71-e424-4188-86d7-eb6292b148bf)
| ![Content-sized agent
sheet](https://github.com/user-attachments/assets/be608383-0188-4339-b56b-924085137452)
|

Empty workspace widget preview (unchanged):

![Compact empty workspace
message](https://github.com/user-attachments/assets/387c0729-dea3-4250-bb54-afc4e61b54a7)

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-01 21:40:30 +00:00

99 lines
4.4 KiB
Swift

import Flutter
import UIKit
private final class SettingMenuMessenger: NSObject, FlutterBinaryMessenger {
var selections: [Int] = []
func send(onChannel channel: String, message: Data?) {
guard let message else { return }
let call = FlutterStandardMethodCodec.sharedInstance().decodeMethodCall(message)
if call.method == "menuAction", let index = call.arguments as? Int {
selections.append(index)
}
}
func send(onChannel channel: String, message: Data?, binaryReply callback: FlutterBinaryReply?) {
send(onChannel: channel, message: message)
callback?(nil)
}
func setMessageHandlerOnChannel(
_ channel: String, binaryMessageHandler handler: FlutterBinaryMessageHandler?
) -> FlutterBinaryMessengerConnection { 1 }
func cleanUpConnection(_ connection: FlutterBinaryMessengerConnection) {}
}
@main
struct SettingMenuSelectionTests {
@MainActor static func main() {
let merging = MergingNavigationGlass(frame: CGRect(x: 0, y: 0, width: 256, height: 56))
merging.layoutIfNeeded()
UIView.setAnimationsEnabled(false)
merging.setMenuOpen(true, animator: nil)
precondition(merging.leftSurface.transform.tx == 100)
precondition(merging.rightSurface.transform.tx == -100)
precondition(merging.leftSurface.transform.a == 0.9)
precondition(merging.leftSurface.alpha == 0 && merging.rightSurface.alpha == 0)
precondition(merging.centerSurface.alpha == 1)
merging.setMenuOpen(false, animator: nil)
precondition(merging.leftSurface.transform == .identity)
precondition(merging.rightSurface.transform == .identity)
precondition(merging.leftSurface.alpha == 1 && merging.rightSurface.alpha == 1)
UIView.setAnimationsEnabled(true)
for deferred in [false, true] {
let messenger = SettingMenuMessenger()
let view = NavigationGlassButtonPlatformView(
frame: CGRect(x: 0, y: 0, width: 340, height: 56),
viewIdentifier: 1,
arguments: [
"fillWidth": true, "plain": true, "label": "", "enabled": true,
"deferMenuActions": deferred,
"menu": [
["id": 0, "label": "Low", "enabled": true, "checked": false],
["id": 1, "label": "High", "enabled": true, "checked": true],
],
],
messenger: messenger
)
let button = view.view().subviews.compactMap { $0 as? NavigationGlassButton }.first!
view.view().layoutIfNeeded()
view.view().frame.size.width = 600
view.view().layoutIfNeeded()
precondition(button.bounds.width == 600)
precondition(button.point(inside: CGPoint(x: 570, y: 28), with: nil))
let group = button.menu!.children.first as! UIMenu
let choices = group.children.compactMap { $0 as? UIAction }
precondition(choices[0].state == .off && choices[1].state == .on)
// Invoke the actual menu UIAction through UIKit, without synthesizing a
// Flutter method-channel message or depending on dismissal callback order.
let selection = UIButton(primaryAction: choices[0])
selection.sendActions(for: .touchUpInside)
precondition(messenger.selections == (deferred ? [] : [0]))
if deferred {
precondition(button.pendingMenuAction != nil)
button.pendingMenuAction?()
button.pendingMenuAction = nil
precondition(messenger.selections == [0])
}
}
let messenger = SettingMenuMessenger()
let grouped = NavigationGlassButtonPlatformView(
frame: CGRect(x: 0, y: 0, width: 112, height: 56),
viewIdentifier: 2,
arguments: ["deferMenuActions": false, "menu": [
["id": 0, "label": "New chat", "sectionTitle": "Solo", "enabled": true],
["id": 1, "label": "New workspace", "enabled": true],
["id": 2, "label": "New DM", "sectionTitle": "Team", "dividerBefore": true, "enabled": true],
["id": 3, "label": "New channel", "enabled": true],
]], messenger: messenger
)
let button = grouped.view().subviews.compactMap { $0 as? NavigationGlassButton }.first!
precondition(button.preferredMenuElementOrder == .fixed)
let groups = button.menu!.children.compactMap { $0 as? UIMenu }
precondition(groups.map(\.title) == ["Solo", "Team"])
precondition(groups.map { $0.children.count } == [2, 2])
let teamAction = groups[1].children[0] as! UIAction
UIButton(primaryAction: teamAction).sendActions(for: .touchUpInside)
precondition(messenger.selections == [2])
print("Native setting menu selection checks passed")
}
}