diff --git a/mobile/lib/features/channels/agent_activity/active_agent_turns.dart b/mobile/lib/features/channels/agent_activity/active_agent_turns.dart index 7de03414ae..994ff6f152 100644 --- a/mobile/lib/features/channels/agent_activity/active_agent_turns.dart +++ b/mobile/lib/features/channels/agent_activity/active_agent_turns.dart @@ -89,13 +89,12 @@ List reduceAgentTurnStates( for (final entry in framesByAgent.entries) { final agentPubkey = entry.key.toLowerCase(); - final frames = [...entry.value]..sort(_compareFrames); + final frames = orderObserverFrames(entry.value); final turnsById = {}; - final terminalOrderById = {}; + final terminalSequenceById = {}; for (final frame in frames) { - final frameOrderAt = _frameTimestamp(frame); - final frameAt = frame.receivedAt ?? frameOrderAt; + final frameAt = frame.receivedAt ?? _frameTimestamp(frame); switch (frame.kind) { case 'turn_started': final channelId = frame.channelId; @@ -120,7 +119,7 @@ List reduceAgentTurnStates( : AgentTurnPhase.error; final turnId = frame.turnId; if (turnId != null) { - terminalOrderById[turnId] = frameOrderAt; + terminalSequenceById[turnId] = frame.seq; final existing = turnsById[turnId]; // The harness's generic completion guard can run after its result // handler emits the specific failure outcome. @@ -169,7 +168,7 @@ List reduceAgentTurnStates( : latest, ); if (matching == null) continue; - terminalOrderById[matching.turnId] = frameOrderAt; + terminalSequenceById[matching.turnId] = frame.seq; turnsById[matching.turnId] = matching.withTerminal( phase: terminalPhase, at: frameAt, @@ -191,8 +190,8 @@ List reduceAgentTurnStates( continue; } - final terminalOrder = terminalOrderById[turnId]; - if (terminalOrder != null && !frameOrderAt.isAfter(terminalOrder)) { + final terminalSequence = terminalSequenceById[turnId]; + if (terminalSequence != null && frame.seq <= terminalSequence) { continue; } final channelId = frame.channelId; @@ -374,8 +373,3 @@ Duration _livenessTimeout( : timeoutSeconds, ); } - -int _compareFrames(ObserverFrame a, ObserverFrame b) { - final timestamp = _frameTimestamp(a).compareTo(_frameTimestamp(b)); - return timestamp != 0 ? timestamp : a.seq.compareTo(b.seq); -} diff --git a/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator.dart b/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator.dart index 44ac2c3fdb..b5dae158f8 100644 --- a/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator.dart +++ b/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator.dart @@ -27,7 +27,7 @@ part 'composer_agent_activity_indicator/compact_activity_item.dart'; /// stream without moving or covering the composer itself. class ComposerAgentActivityIndicator extends HookConsumerWidget { static const _compactSurfaceHeight = 52.0; - static const _expandedTargetHeight = 328.0; + static const _baseExpandedTargetHeight = 328.0; static const _surfaceMorphDuration = Duration(milliseconds: 220); static const _surfaceMorphCurve = Cubic(0.77, 0, 0.175, 1); @@ -76,7 +76,7 @@ class ComposerAgentActivityIndicator extends HookConsumerWidget { final activityAnchorKey = useMemoized(GlobalKey.new); final activityOverlayController = useMemoized(OverlayPortalController.new); final compactActivityWidth = useState(0.0); - final expandedHeight = useState(_expandedTargetHeight); + final expandedHeight = useState(_baseExpandedTargetHeight); final expansionController = useAnimationController( duration: _surfaceMorphDuration, ); @@ -88,6 +88,7 @@ class ComposerAgentActivityIndicator extends HookConsumerWidget { final reducedMotion = MediaQuery.disableAnimationsOf(context); final motionDisabled = !animated || reducedMotion; final mediaSize = MediaQuery.sizeOf(context); + final expandedTargetHeight = _expandedPanelTargetHeight(context); final viewInsets = MediaQuery.viewInsetsOf(context); final viewPadding = MediaQuery.viewPaddingOf(context); final platformView = View.of(context); @@ -113,7 +114,7 @@ class ComposerAgentActivityIndicator extends HookConsumerWidget { anchorBottom - topBoundary - Grid.xxs, ); final nextExpandedHeight = math.min( - _expandedTargetHeight, + expandedTargetHeight, availableHeight, ); final nextCompactWidth = renderObject.size.width; @@ -178,6 +179,7 @@ class ComposerAgentActivityIndicator extends HookConsumerWidget { keyboardInsetBottom, viewPadding.top, overlayTopBoundary, + expandedTargetHeight, expanded.value, ], ); @@ -485,6 +487,7 @@ class ComposerAgentActivityIndicator extends HookConsumerWidget { child: ClipRect( child: _InlineActivityPanel( height: panelViewportHeight, + panelWidth: panelWidth, expandedHeight: expandedHeight.value, morphProgress: progress, targetExpanded: expanded.value, @@ -610,9 +613,8 @@ List compactActivityItems(List transcript) { } class _InlineActivityPanel extends StatelessWidget { - static const _footerHeight = 44.0; - final double height; + final double panelWidth; final double expandedHeight; final double morphProgress; final bool targetExpanded; @@ -634,6 +636,7 @@ class _InlineActivityPanel extends StatelessWidget { const _InlineActivityPanel({ required this.height, + required this.panelWidth, required this.expandedHeight, required this.morphProgress, required this.targetExpanded, @@ -667,10 +670,29 @@ class _InlineActivityPanel extends StatelessWidget { expanded: false, ).visibleLabel; final topInset = Grid.xxs * morphProgress; - final panelHeight = math.max(_footerHeight, height - Grid.xxs - topInset); + final labelStyle = context.textTheme.labelSmall?.copyWith( + fontWeight: FontWeight.w600, + ); + final statusLabel = _activityStatusLabel(status); + final contentWidth = math.max( + 0.0, + panelWidth - horizontalInset * 2 - Grid.xxs * 2, + ); + final inlineFooterWidth = + _agentAvatarStackWidth(selectorAgents.length) + + Grid.xxs + + _singleLineTextWidth(context, 'Live activity', labelStyle) + + Grid.xxs + + _singleLineTextWidth(context, statusLabel, labelStyle) + + Grid.xxs * 2 + + Grid.half + + 18; + final stacksFooter = inlineFooterWidth > contentWidth; + final footerHeight = _activityFooterHeight(context, stacked: stacksFooter); + final panelHeight = math.max(footerHeight, height - Grid.xxs - topInset); final expandedDetailHeight = math.max( 0.0, - expandedHeight - Grid.xxs * 2 - _footerHeight, + expandedHeight - Grid.xxs * 2 - footerHeight, ); final detailsOpacity = Curves.easeOut.transform( ((morphProgress - 0.16) / 0.84).clamp(0.0, 1.0), @@ -700,7 +722,7 @@ class _InlineActivityPanel extends StatelessWidget { child: Stack( children: [ Positioned.fill( - bottom: _footerHeight, + bottom: footerHeight, child: ClipRect( child: IgnorePointer( ignoring: morphProgress < 0.95, @@ -730,6 +752,8 @@ class _InlineActivityPanel extends StatelessWidget { alignment: Alignment.centerLeft, child: Text( 'Live activity may be partial.', + maxLines: 2, + overflow: TextOverflow.ellipsis, style: context.textTheme.labelSmall ?.copyWith( color: @@ -776,7 +800,7 @@ class _InlineActivityPanel extends StatelessWidget { left: 0, right: 0, bottom: 0, - height: _footerHeight, + height: footerHeight, child: Semantics( button: true, label: @@ -788,69 +812,76 @@ class _InlineActivityPanel extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric( horizontal: Grid.xxs, + vertical: Grid.half, ), - child: Row( - children: [ - _AgentAvatarStack( - pubkeys: selectorAgents, - profiles: profiles, - ), - const SizedBox(width: Grid.xxs), - Expanded( - child: Stack( - alignment: Alignment.centerLeft, + child: stacksFooter + ? Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - Opacity( - opacity: 1 - morphProgress, - child: Text( - compactLabel, - style: context.textTheme.labelSmall - ?.copyWith( - color: context - .colors - .onSurfaceVariant, - fontWeight: FontWeight.w600, - ), - overflow: TextOverflow.ellipsis, + Row( + children: [ + _AgentAvatarStack( + pubkeys: selectorAgents, + profiles: profiles, + ), + const SizedBox(width: Grid.xxs), + _ActivityFooterLabel( + compactLabel: compactLabel, + morphProgress: morphProgress, + ), + Transform.rotate( + angle: math.pi * morphProgress, + child: Icon( + LucideIcons.chevronUp, + size: 18, + color: + context.colors.onSurfaceVariant, + ), + ), + ], + ), + const SizedBox(height: Grid.half), + Align( + alignment: Alignment.centerLeft, + child: _ActivityStatusBadge( + status: status, ), ), - Opacity( - opacity: morphProgress, - child: Text( - 'Live activity', - style: context.textTheme.labelSmall - ?.copyWith( - color: context - .colors - .onSurfaceVariant, - fontWeight: FontWeight.w600, - ), - overflow: TextOverflow.ellipsis, + ], + ) + : Row( + children: [ + _AgentAvatarStack( + pubkeys: selectorAgents, + profiles: profiles, + ), + const SizedBox(width: Grid.xxs), + _ActivityFooterLabel( + compactLabel: compactLabel, + morphProgress: morphProgress, + ), + ClipRect( + child: Align( + widthFactor: morphProgress, + child: Opacity( + opacity: morphProgress, + child: _ActivityStatusBadge( + status: status, + ), + ), + ), + ), + SizedBox(width: Grid.half * morphProgress), + Transform.rotate( + angle: math.pi * morphProgress, + child: Icon( + LucideIcons.chevronUp, + size: 18, + color: context.colors.onSurfaceVariant, ), ), ], ), - ), - ClipRect( - child: Align( - widthFactor: morphProgress, - child: Opacity( - opacity: morphProgress, - child: _ActivityStatusBadge(status: status), - ), - ), - ), - SizedBox(width: Grid.half * morphProgress), - Transform.rotate( - angle: math.pi * morphProgress, - child: Icon( - LucideIcons.chevronUp, - size: 18, - color: context.colors.onSurfaceVariant, - ), - ), - ], - ), ), ), ), @@ -865,48 +896,6 @@ class _InlineActivityPanel extends StatelessWidget { } } -class _ActivityStatusBadge extends StatelessWidget { - final _ActivityStatus status; - - const _ActivityStatusBadge({required this.status}); - - @override - Widget build(BuildContext context) { - final color = switch (status) { - _ActivityStatus.working => context.appColors.success, - _ActivityStatus.finished => context.colors.onSurfaceVariant, - _ActivityStatus.cancelled => context.colors.onSurfaceVariant, - _ActivityStatus.error => context.colors.error, - _ActivityStatus.waiting => context.appColors.warning, - }; - final label = switch (status) { - _ActivityStatus.working => 'Working', - _ActivityStatus.finished => 'Finished', - _ActivityStatus.cancelled => 'Cancelled', - _ActivityStatus.error => 'Error', - _ActivityStatus.waiting => 'Waiting', - }; - return Container( - key: const ValueKey('composer-agent-activity-status'), - padding: const EdgeInsets.symmetric( - horizontal: Grid.xxs, - vertical: Grid.quarter, - ), - decoration: BoxDecoration( - color: color.withValues(alpha: 0.12), - borderRadius: BorderRadius.circular(12), - ), - child: Text( - label, - style: context.textTheme.labelSmall?.copyWith( - color: color, - fontWeight: FontWeight.w600, - ), - ), - ); - } -} - class _ActivityEmptyState extends StatelessWidget { final _ActivityStatus status; final ObserverState? observerState; diff --git a/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator/agent_activity_controls.dart b/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator/agent_activity_controls.dart index 691a109ba3..45f1046a32 100644 --- a/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator/agent_activity_controls.dart +++ b/mobile/lib/features/channels/agent_activity/composer_agent_activity_indicator/agent_activity_controls.dart @@ -21,7 +21,7 @@ class _AgentSegmentedControl extends StatelessWidget { final isIos = defaultTargetPlatform == TargetPlatform.iOS; return SizedBox( - height: Grid.xl, + height: _agentSelectorHeight(context), child: Padding( padding: const EdgeInsets.symmetric( horizontal: _inset, @@ -361,7 +361,7 @@ class _AgentAvatarStack extends StatelessWidget { Widget build(BuildContext context) { final visible = pubkeys.take(3).toList(); return SizedBox( - width: 24.0 + math.max(0, visible.length - 1) * 14.0, + width: _agentAvatarStackWidth(visible.length), height: 24, child: Stack( children: [ @@ -380,6 +380,178 @@ class _AgentAvatarStack extends StatelessWidget { } } +class _ActivityFooterLabel extends StatelessWidget { + final String compactLabel; + final double morphProgress; + + const _ActivityFooterLabel({ + required this.compactLabel, + required this.morphProgress, + }); + + @override + Widget build(BuildContext context) { + final style = context.textTheme.labelSmall?.copyWith( + color: context.colors.onSurfaceVariant, + fontWeight: FontWeight.w600, + ); + return Expanded( + child: Stack( + alignment: Alignment.centerLeft, + children: [ + Opacity( + opacity: 1 - morphProgress, + child: Text( + compactLabel, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: style, + ), + ), + Opacity( + opacity: morphProgress, + child: Text( + 'Live activity', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: style, + ), + ), + ], + ), + ); + } +} + +class _ActivityStatusBadge extends StatelessWidget { + final _ActivityStatus status; + + const _ActivityStatusBadge({required this.status}); + + @override + Widget build(BuildContext context) { + final color = switch (status) { + _ActivityStatus.working => context.appColors.success, + _ActivityStatus.finished => context.colors.onSurfaceVariant, + _ActivityStatus.cancelled => context.colors.onSurfaceVariant, + _ActivityStatus.error => context.colors.error, + _ActivityStatus.waiting => context.appColors.warning, + }; + return Container( + key: const ValueKey('composer-agent-activity-status'), + padding: const EdgeInsets.symmetric( + horizontal: Grid.xxs, + vertical: Grid.quarter, + ), + decoration: BoxDecoration( + color: color.withValues(alpha: 0.12), + borderRadius: BorderRadius.circular(12), + ), + child: Text( + _activityStatusLabel(status), + maxLines: 1, + style: context.textTheme.labelSmall?.copyWith( + color: color, + fontWeight: FontWeight.w600, + ), + ), + ); + } +} + +String _activityStatusLabel(_ActivityStatus status) => switch (status) { + _ActivityStatus.working => 'Working', + _ActivityStatus.finished => 'Finished', + _ActivityStatus.cancelled => 'Cancelled', + _ActivityStatus.error => 'Error', + _ActivityStatus.waiting => 'Waiting', +}; + +double _scaledTextHeight( + BuildContext context, + TextStyle? style, { + required double fallbackSize, + required double fallbackHeight, +}) { + final fontSize = style?.fontSize ?? fallbackSize; + return MediaQuery.textScalerOf(context).scale(fontSize) * + (style?.height ?? fallbackHeight); +} + +double _agentSelectorHeight(BuildContext context) { + final labelHeight = _scaledTextHeight( + context, + context.textTheme.labelMedium, + fallbackSize: 14, + fallbackHeight: 1.25, + ); + return math.max(Grid.xl, labelHeight + Grid.xs + Grid.half); +} + +double _activityFooterHeight(BuildContext context, {required bool stacked}) { + final labelHeight = _scaledTextHeight( + context, + context.textTheme.labelSmall, + fallbackSize: 11, + fallbackHeight: 1.2, + ); + if (stacked) { + return _stackedActivityFooterHeight(labelHeight); + } + final firstRowHeight = math.max(24.0, labelHeight); + final badgeHeight = labelHeight + Grid.half; + return math.max(44.0, Grid.xxs + math.max(firstRowHeight, badgeHeight)); +} + +double _stackedActivityFooterHeight(double labelHeight) => math.max( + 44.0, + Grid.xxs + + Grid.quarter + + math.max(24.0, labelHeight) + + Grid.half + + labelHeight + + Grid.half, +); + +double _expandedPanelTargetHeight(BuildContext context) { + final labelHeight = _scaledTextHeight( + context, + context.textTheme.labelSmall, + fallbackSize: 11, + fallbackHeight: 1.2, + ); + const baseLabelHeight = 11 * 1.2; + final extraDisclaimerHeight = + math.max(0.0, labelHeight - baseLabelHeight) * 2; + return ComposerAgentActivityIndicator._baseExpandedTargetHeight + + math.max(0.0, _agentSelectorHeight(context) - Grid.xl) + + math.max( + 0.0, + _activityFooterHeight(context, stacked: true) - + _stackedActivityFooterHeight(baseLabelHeight), + ) + + extraDisclaimerHeight; +} + +double _singleLineTextWidth( + BuildContext context, + String text, + TextStyle? style, +) { + final painter = TextPainter( + text: TextSpan(text: text, style: style), + maxLines: 1, + textDirection: Directionality.of(context), + textScaler: MediaQuery.textScalerOf(context), + )..layout(); + return painter.width; +} + +double _agentAvatarStackWidth(int count) { + final visibleCount = math.min(3, count); + return visibleCount == 0 ? 0 : 24.0 + (visibleCount - 1) * 14.0; +} + enum _ActivityStatus { working, finished, cancelled, error, waiting } _ActivityStatus _activityStatus(AgentTurnState? turn, bool isFallbackWorking) { diff --git a/mobile/lib/features/channels/agent_activity/observer_models.dart b/mobile/lib/features/channels/agent_activity/observer_models.dart index 53c4788223..e6fd09d6a0 100644 --- a/mobile/lib/features/channels/agent_activity/observer_models.dart +++ b/mobile/lib/features/channels/agent_activity/observer_models.dart @@ -53,6 +53,68 @@ class ObserverFrame { ); } +/// Orders observer frames by their protocol stream before presentation time. +/// +/// NIP-AO guarantees that [ObserverFrame.seq] increases within one session. +/// Host wall-clock timestamps are only presentation metadata and may jump in +/// either direction. Frames without a session inherit one from another frame +/// for the same turn; unrelated streams use local receipt time to establish +/// their relative epoch. +List orderObserverFrames(Iterable frames) { + final ordered = [...frames]; + final sessionByTurn = {}; + for (final frame in ordered) { + final sessionId = frame.sessionId; + final turnId = frame.turnId; + if (sessionId != null && + sessionId.isNotEmpty && + turnId != null && + turnId.isNotEmpty) { + sessionByTurn[turnId] = sessionId; + } + } + + String streamKey(ObserverFrame frame) { + final sessionId = frame.sessionId; + if (sessionId != null && sessionId.isNotEmpty) return 'session:$sessionId'; + final turnId = frame.turnId; + if (turnId != null && turnId.isNotEmpty) { + final inheritedSession = sessionByTurn[turnId]; + return inheritedSession == null + ? 'turn:$turnId' + : 'session:$inheritedSession'; + } + return 'legacy'; + } + + DateTime presentationTime(ObserverFrame frame) => + frame.receivedAt ?? + DateTime.tryParse(frame.timestamp)?.toUtc() ?? + DateTime.fromMillisecondsSinceEpoch(frame.seq, isUtc: true); + + final epochByStream = {}; + for (final frame in ordered) { + final key = streamKey(frame); + final time = presentationTime(frame); + final current = epochByStream[key]; + if (current == null || time.isBefore(current)) epochByStream[key] = time; + } + + ordered.sort((a, b) { + final aKey = streamKey(a); + final bKey = streamKey(b); + if (aKey == bKey) { + final sequence = a.seq.compareTo(b.seq); + if (sequence != 0) return sequence; + return presentationTime(a).compareTo(presentationTime(b)); + } + final epoch = epochByStream[aKey]!.compareTo(epochByStream[bKey]!); + if (epoch != 0) return epoch; + return aKey.compareTo(bKey); + }); + return ordered; +} + /// A section within prompt context metadata. @immutable class PromptSection { diff --git a/mobile/lib/features/channels/agent_activity/observer_subscription.dart b/mobile/lib/features/channels/agent_activity/observer_subscription.dart index 7cb582ecc2..89a7268cda 100644 --- a/mobile/lib/features/channels/agent_activity/observer_subscription.dart +++ b/mobile/lib/features/channels/agent_activity/observer_subscription.dart @@ -228,7 +228,10 @@ class ObserverRelayNotifier extends Notifier { () => [], ); frames.add(frame); - frames.sort(_compareObserverFrames); + final orderedFrames = orderObserverFrames(frames); + frames + ..clear() + ..addAll(orderedFrames); if (frames.length > _maxObserverEvents) { final removeCount = frames.length - _maxObserverEvents; @@ -267,10 +270,10 @@ class ObserverRelayNotifier extends Notifier { return [frame]; } - final innerFrames = [ + final innerFrames = orderObserverFrames([ for (final inner in events) ObserverFrame.fromJson(inner as Map), - ]..sort(_compareObserverFrames); + ]); return [ for (var index = 0; index < innerFrames.length; index++) _withReceivedAt( @@ -356,13 +359,6 @@ class ObserverRelayNotifier extends Notifier { return 'Observer subscription failed: $error'; } - static int _compareObserverFrames(ObserverFrame a, ObserverFrame b) { - final tsA = DateTime.tryParse(a.timestamp)?.millisecondsSinceEpoch ?? 0; - final tsB = DateTime.tryParse(b.timestamp)?.millisecondsSinceEpoch ?? 0; - if (tsA != tsB) return tsA.compareTo(tsB); - return a.seq.compareTo(b.seq); - } - static ObserverFrame _withReceivedAt( ObserverFrame frame, DateTime receivedAt, diff --git a/mobile/test/features/channels/agent_activity/active_agent_turns_test.dart b/mobile/test/features/channels/agent_activity/active_agent_turns_test.dart index 7700fcf7df..f158ab5625 100644 --- a/mobile/test/features/channels/agent_activity/active_agent_turns_test.dart +++ b/mobile/test/features/channels/agent_activity/active_agent_turns_test.dart @@ -52,6 +52,63 @@ void main() { expect(turns[1].errorMessage, 'Tool permission denied'); }); + test('orders a turn by sequence when the host clock moves backward', () { + final turns = reduceAgentTurnStates({ + 'agent-a': [ + _frame( + seq: 1, + second: 10, + kind: 'turn_started', + sessionId: 'session-1', + receivedSecond: 1, + ), + _frame( + seq: 2, + second: 1, + kind: 'turn_completed', + sessionId: 'session-1', + receivedSecond: 2, + ), + ], + }, now: DateTime.utc(2026, 8, 16, 12, 0, 20)); + + expect(turns, hasLength(1)); + expect(turns.single.phase, AgentTurnPhase.finished); + expect(turns.single.lastActivityAt, DateTime.utc(2026, 8, 16, 12, 0, 2)); + }); + + test('orders a turn by sequence when the host clock jumps forward', () { + final turns = reduceAgentTurnStates({ + 'agent-a': [ + _frame( + seq: 1, + second: 1, + kind: 'turn_started', + sessionId: 'session-1', + receivedSecond: 1, + ), + _frame( + seq: 2, + second: 50, + kind: 'acp_read', + sessionId: 'session-1', + receivedSecond: 2, + ), + _frame( + seq: 3, + second: 3, + kind: 'turn_completed', + sessionId: 'session-1', + receivedSecond: 3, + ), + ], + }, now: DateTime.utc(2026, 8, 16, 12, 0, 20)); + + expect(turns, hasLength(1)); + expect(turns.single.phase, AgentTurnPhase.finished); + expect(turns.single.lastActivityAt, DateTime.utc(2026, 8, 16, 12, 0, 3)); + }); + test('reports cancelled completion separately from a finished turn', () { final turns = reduceAgentTurnStates({ 'agent-a': [ @@ -349,6 +406,7 @@ ObserverFrame _frame({ String? turnId = 'turn-1', String channelId = 'channel-1', String? threadHeadId, + String? sessionId, int? receivedSecond, String? startedAt, dynamic payload = const {}, @@ -359,6 +417,7 @@ ObserverFrame _frame({ kind: kind, channelId: channelId, threadHeadId: threadHeadId, + sessionId: sessionId, turnId: turnId, startedAt: startedAt, receivedAt: receivedSecond == null diff --git a/mobile/test/features/channels/agent_activity/composer_agent_activity_indicator_test.dart b/mobile/test/features/channels/agent_activity/composer_agent_activity_indicator_test.dart index b0d07181e7..81ea4fc0a6 100644 --- a/mobile/test/features/channels/agent_activity/composer_agent_activity_indicator_test.dart +++ b/mobile/test/features/channels/agent_activity/composer_agent_activity_indicator_test.dart @@ -599,6 +599,70 @@ void main() { expect(find.text('Running Read file'), findsNothing); }); + for (final platform in [TargetPlatform.android, TargetPlatform.iOS]) { + for (final textScale in [2.0, 3.0]) { + testWidgets( + 'narrow $platform panel stays operable at ${textScale}x text', + (tester) async { + debugDefaultTargetPlatformOverride = platform; + addTearDown(() => debugDefaultTargetPlatformOverride = null); + tester.view.physicalSize = const Size(220, 600); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + final container = _multiAgentContainer(); + addTearDown(container.dispose); + + await tester.pumpWidget( + _app( + container, + disableAnimations: true, + textScaler: TextScaler.linear(textScale), + ), + ); + await tester.pump(); + expect(tester.takeException(), isNull); + + await tester.tap( + find.byKey(const ValueKey('composer-agent-activity-control')), + ); + await tester.pump(); + + expect(tester.takeException(), isNull); + expect(find.text('Live activity'), findsOneWidget); + expect(find.text('Working'), findsOneWidget); + expect( + find.byKey(const ValueKey('composer-agent-activity-collapse')), + findsOneWidget, + ); + + final sprigSegment = find.byKey( + const ValueKey('composer-agent-segment-agent-b'), + ); + await tester.ensureVisible(sprigSegment); + await tester.tap(sprigSegment); + await tester.pump(); + + expect(tester.takeException(), isNull); + expect(find.text('Sprig'), findsOneWidget); + expect(find.text('Running Search messages'), findsOneWidget); + + await tester.tap( + find.byKey(const ValueKey('composer-agent-activity-collapse')), + ); + await tester.pump(); + await tester.pump(); + + expect(tester.takeException(), isNull); + expect( + find.byKey(const ValueKey('composer-agent-activity-panel')), + findsNothing, + ); + debugDefaultTargetPlatformOverride = null; + }, + ); + } + } + testWidgets('iOS uses the native sliding segmented control', (tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; addTearDown(() => debugDefaultTargetPlatformOverride = null); @@ -1087,6 +1151,7 @@ Widget _app( Animation? composerWidthAnimation, ValueNotifier? composerInteractionLock, ValueNotifier? composerActivationRequests, + TextScaler textScaler = TextScaler.noScaling, }) { Widget activityIndicator = ComposerAgentActivityIndicator( channelId: _channelId, @@ -1130,6 +1195,7 @@ Widget _app( data: MediaQuery.of(context).copyWith( disableAnimations: disableAnimations, viewInsets: viewInsets, + textScaler: textScaler, ), child: Scaffold( resizeToAvoidBottomInset: false,