diff --git a/AGENTS.md b/AGENTS.md index c79ed1f5..037ef643 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -939,7 +939,12 @@ sections can crash only on devices ("Thread stack size exceeded"). (`splitColumnWidth`), and what it opens is pushed on the app's one stack beside it, so `path`, the active chat and every top-of-stack rule work as on iPhone. The list is the shell's own view, drawn again from its stores (`BighelpLiveColumn`); the stack's root shows `BighelpSplitPlaceholder` instead of a second copy of the list. -- Upright with the fold active (`isLaptop`): `ChatView` keeps everything under the fold for the message box. +- Upright with the fold active (`isLaptop`): `ChatView` keeps everything under the fold for the message box. Under + the box, a chat with one bot shows the bot's face, what it's doing, New chat and Bot page (`ChatLaptopDesk`). + Typing, a blank New chat and a group chat keep that half clear. +- The app draws no island of its own on the Duo (`AgentIslandAvailability`): the camera and the status are in the + trailing column, so nothing is across the top to cover. The connection pill and the drive overlay take their + places for a phone without an island there. - The Duo's simulator needs the iOS 27.1 runtime and starts folded; tests can't open or fold it, and DeviceHub's controls don't take scripted clicks. `-bighelp.debug.screen-posture` and `-bighelp.debug.fold-halfway` show the open and half-folded layouts on an iPad simulator (`DuoLayoutUITests`). diff --git a/Bighelp.xcodeproj/project.pbxproj b/Bighelp.xcodeproj/project.pbxproj index 0b270616..78010fe0 100644 --- a/Bighelp.xcodeproj/project.pbxproj +++ b/Bighelp.xcodeproj/project.pbxproj @@ -932,6 +932,7 @@ 6FA50C9ADBD201A9D77B2E1C /* ChatTextMarker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF83F20547EB11C1B2BAB1BD /* ChatTextMarker.swift */; }; 6FB368A14E2F3F813298EDAA /* FleetSettingsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BD21A8FBBCA9AF95D546F15 /* FleetSettingsUITests.swift */; }; 6FE297B76DAD91CF09B8B40A /* BighelpActivityRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69F4FF8F2C5673B2E05F45CE /* BighelpActivityRow.swift */; }; + 7041695D14C809368E35D054 /* ChatLaptopDesk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91BEAC6C4370E624B097BE5A /* ChatLaptopDesk.swift */; }; 7047D95050E74D28B28CB9D6 /* NativeSessionResumeProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFEBF171A2809E675EBF2D40 /* NativeSessionResumeProgress.swift */; }; 70521F46E1A2AA90EC8031B0 /* ChatTimelineBuiltRows.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5925D63EDF3AE6245630FA /* ChatTimelineBuiltRows.swift */; }; 705A1F88DB322FF588173B53 /* PermissionCenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A3548EA837BB0A869121EE7 /* PermissionCenterTests.swift */; }; @@ -3489,6 +3490,7 @@ 916705243B4D5728DB566B02 /* BighelpNotificationErrorCodes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BighelpNotificationErrorCodes.swift; sourceTree = ""; }; 916BA766E72BFBA579E1C614 /* AgentGoalsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgentGoalsView.swift; sourceTree = ""; }; 918B96E497E5895E812E63C3 /* BighelpRealtimeAudioPeer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BighelpRealtimeAudioPeer.swift; sourceTree = ""; }; + 91BEAC6C4370E624B097BE5A /* ChatLaptopDesk.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatLaptopDesk.swift; sourceTree = ""; }; 91CB0EFA808DC2BC808C7B83 /* BighelpNotificationHostTrust.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BighelpNotificationHostTrust.swift; sourceTree = ""; }; 91D2DA6892F98C5DD30FDD10 /* DirectHermesAgentDirectoryClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectHermesAgentDirectoryClient.swift; sourceTree = ""; }; 91D4F8D182EE30C5C7CDB870 /* ChatToolPhrase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatToolPhrase.swift; sourceTree = ""; }; @@ -7256,6 +7258,7 @@ 3B3C1B0A38B1107EC89B232D /* ChatIdentityView.swift */, F01086DE6C5EB56F04C92807 /* ChatImageStack.swift */, 27A0BC27ED7C315F7B5D4FF1 /* ChatInterimReplies.swift */, + 91BEAC6C4370E624B097BE5A /* ChatLaptopDesk.swift */, 0F68F20978C0AB2C937FE171 /* ChatLiveWorkView.swift */, 0E9FCA4F43E5BEE8D4C5207C /* ChatMarkdownDocument.swift */, BC9944B9527C263AE1CAA797 /* ChatMarkdownTableView.swift */, @@ -8361,6 +8364,7 @@ ADD8D85A3D85748C039E35F3 /* ChatIdentityView.swift in Sources */, 7BFD261066C0ABA64B622CC9 /* ChatImageStack.swift in Sources */, A2C28C3449C8F395268E1BF0 /* ChatInterimReplies.swift in Sources */, + 7041695D14C809368E35D054 /* ChatLaptopDesk.swift in Sources */, 4B821EE1EFD8C51E964F110C /* ChatLayoutSettingsView.swift in Sources */, 0F6AB98EDF03574F11ECA589 /* ChatLiveWorkView.swift in Sources */, FF237C3721857F6489DE324D /* ChatMarkdownDocument.swift in Sources */, diff --git a/Bighelp/Chat/ChatLaptopDesk.swift b/Bighelp/Chat/ChatLaptopDesk.swift new file mode 100644 index 00000000..889cc168 --- /dev/null +++ b/Bighelp/Chat/ChatLaptopDesk.swift @@ -0,0 +1,93 @@ +import SwiftUI + +/// The half under the fold of a chat on the iPhone Duo, half-folded like a small laptop +/// (`BighelpScreenGeometry.isLaptop`): the chat's bot, large, with what it is doing now, then New +/// chat and Bot page. `ChatView` shows it under the message box while the keyboard is down, in a +/// one-bot chat that has a message. Typing, a blank New chat and a group chat keep the half clear. +/// +/// A view of its own, so the bot's live step is read here and not in `ChatView`'s body. +struct ChatLaptopDesk: View { + let model: ChatModel + let agentID: String + let name: String + let imageURL: URL? + let onNewChat: () -> Void + let onBotPage: () -> Void + @BighelpThemeReader private var theme + + var body: some View { + let activity = model.liveActivityKind + VStack(spacing: BighelpTokens.space20) { + Spacer(minLength: 0) + // At large text the face moves beside its lines, so the buttons stay on screen. + ViewThatFits(in: .vertical) { + VStack(spacing: BighelpTokens.space8) { + face(activity, size: 112) + lines(activity, alignment: .center) + } + HStack(spacing: BighelpTokens.space12) { + face(activity, size: 56) + lines(activity, alignment: .leading) + } + } + .accessibilityElement(children: .combine) + .accessibilityIdentifier("chat.laptop.status") + // Side by side, or one over the other when the two names don't fit. + ViewThatFits(in: .horizontal) { + HStack(spacing: BighelpTokens.space12) { actions } + VStack(spacing: BighelpTokens.space8) { actions } + } + Spacer(minLength: 0) + } + .frame(maxWidth: .infinity) + .padding(.horizontal, BighelpTokens.space16) + .padding(.top, BighelpTokens.space12) + // A container, so its id doesn't replace the buttons' own. + .accessibilityElement(children: .contain) + .accessibilityIdentifier("chat.laptop.desk") + } + + /// The face the chat's header shows, so the bot looks the same above and below the fold. Its + /// line names the step; the face only shows that it works. + private func face(_ activity: AgentActivityKind, size: CGFloat) -> some View { + SimpleBotFace(agentID: agentID, name: name, imageURL: imageURL, size: size, + activity: activity == .idle ? nil : .working(tool: nil)) + // Its name is in the lines beside it: VoiceOver would say it twice. + .accessibilityHidden(true) + } + + private func lines(_ activity: AgentActivityKind, alignment: HorizontalAlignment) -> some View { + VStack(alignment: alignment, spacing: 2) { + Text(name) + .font(.bighelp(.title3, weight: .semibold)) + .foregroundStyle(theme.primaryText) + // The step it is on, in its own words, else the kind of work. Never a guess. + Text(model.liveStepPhrase ?? activity.label) + .bighelpFont(.label) + .foregroundStyle(theme.secondaryText) + } + .multilineTextAlignment(alignment == .center ? .center : .leading) + } + + @ViewBuilder + private var actions: some View { + action("New chat", systemImage: "square.and.pencil", identifier: "chat.laptop.new-chat", action: onNewChat) + action("Bot page", systemImage: "person.crop.circle", identifier: "chat.laptop.bot-page", action: onBotPage) + } + + private func action(_ title: LocalizedStringKey, systemImage: String, identifier: String, + action: @escaping () -> Void) -> some View { + Button(action: action) { + Label(title, systemImage: systemImage) + .labelStyle(.titleAndIcon) + .bighelpFont(.label, weight: .semibold) + .foregroundStyle(theme.primaryText) + .padding(.horizontal, BighelpTokens.space16) + .frame(minHeight: BighelpTokens.hitTarget) + .contentShape(Capsule()) + .bighelpNavigationGlass(in: Capsule(), isInteractive: true) + } + .buttonStyle(.bighelpTilePress) + .accessibilityIdentifier(identifier) + } +} diff --git a/Bighelp/Chat/ChatView.swift b/Bighelp/Chat/ChatView.swift index e4dba687..8e0009f5 100644 --- a/Bighelp/Chat/ChatView.swift +++ b/Bighelp/Chat/ChatView.swift @@ -546,19 +546,31 @@ struct ChatView: View { // and the bar keep their own height. Spacer(minLength: headerHeight).layoutPriority(laptopDeckHeight > 0 ? 1 : 0) VStack(spacing: 0) { - // Half-folded like a laptop: everything under the fold is the message box's. - // Typing, it rests on the keyboard; otherwise it sits just under the fold. + // Half-folded like a laptop, the half under the fold is the desk: the message box + // sits just under the fold, and the bot with what it's doing fills the rest + // (`ChatLaptopDesk`). Typing, the box rests on the keyboard instead. if laptopDeckHeight > 0, isDraftFocused { Spacer(minLength: 0) } composer .fixedSize(horizontal: false, vertical: !(referenceHub ?? fallbackReferenceHub).isPresented) #if targetEnvironment(macCatalyst) .popover(isPresented: sessionControlsPresented(from: .composer)) { macSessionControls } #endif - if laptopDeckHeight > 0, !isDraftFocused { Spacer(minLength: 0) } + if laptopDeckHeight > 0, !isDraftFocused { + if showsLaptopDesk { + ChatLaptopDesk(model: model, agentID: homeAgentID, name: agentName, + imageURL: resolvedIdentityParticipants.first?.imageURL, + onNewChat: onNewChatTap, + onBotPage: { homeChrome.onProfile(homeAgentID) }) + .frame(maxHeight: .infinity, alignment: .top) + } else { + Spacer(minLength: 0) + } + } newChatChoices } - // The messages stop at the fold: the timeline keeps clear of all of this. - .frame(minHeight: laptopDeckHeight) + // The messages stop at the fold: the timeline keeps clear of all of this, and the + // message box starts at the fold itself. + .frame(minHeight: laptopDeckHeight, alignment: .top) // The Skills and commands list takes the room under the header before the spacer // does. Offered an equal share, a long list showed about two rows. .layoutPriority((referenceHub ?? fallbackReferenceHub).isPresented && laptopDeckHeight == 0 ? 1 : 0) @@ -592,6 +604,12 @@ struct ChatView: View { return max(0, safeBottomInWindow - fold.maxY) } + /// The desk shows for a chat with one bot that the shell pushed. A blank New chat keeps its To + /// row, people list and choices, and a group chat has no one bot to show. + private var showsLaptopDesk: Bool { + homeChrome.isPushedChat && !model.isBotMode && newChat == nil + } + /// One home: the bots to pick from, over a new chat's empty messages until something is sent. private var showsNewChatPeople: Bool { newChat?.people != nil } diff --git a/BighelpUITests/DuoLayoutUITests.swift b/BighelpUITests/DuoLayoutUITests.swift index fe4a2a8a..02a686f8 100644 --- a/BighelpUITests/DuoLayoutUITests.swift +++ b/BighelpUITests/DuoLayoutUITests.swift @@ -149,13 +149,30 @@ final class DuoLayoutUITests: BighelpUITestCase { let window = app.windows.firstMatch.frame XCTAssertGreaterThan(field.frame.minY, window.midY, "The message box sits under the fold") XCTAssertLessThan(field.frame.minY, window.midY + 120, "Just under it") + // The half under the fold is a desk: the bot and what it's doing, then New chat and Bot + // page, under the message box. + XCTAssertTrue(element("chat.laptop.desk", in: app).waitForExistence(timeout: 5), + "The half under the fold carries the desk") + XCTAssertEqual(element("chat.laptop.status", in: app).label, "Avery Park, Here for you", + "It says who the bot is and what it's doing, once") + for id in ["chat.laptop.new-chat", "chat.laptop.bot-page"] { + let button = app.buttons[id] + XCTAssertTrue(button.waitForExistence(timeout: 5), "\(id) is in reach under the fold") + XCTAssertGreaterThan(button.frame.minY, field.frame.maxY, "\(id) sits under the message box") + XCTAssertLessThan(button.frame.maxY, window.maxY, "\(id) is on screen") + } sleep(1) save("laptop-chat-\(appearance)", app) if appearance == "light" { field.tap() XCTAssertTrue(app.keyboards.firstMatch.waitForExistence(timeout: 5)) XCTAssertGreaterThan(field.frame.minY, window.midY, "Typing, it rests on the keyboard, still under the fold") + XCTAssertFalse(element("chat.laptop.desk", in: app).exists, "Typing, the desk gets out of the way") save("laptop-typing-light", app) + } else { + app.buttons["chat.laptop.bot-page"].tap() + XCTAssertTrue(app.buttons["simple-bots.profile.more"].waitForExistence(timeout: 10), + "Bot page opens the bot's page") } app.terminate() }