diff --git a/app/tool/perf/chat_shown_fixture.dart b/app/tool/perf/chat_shown_fixture.dart index fd923ad2..e5e82a42 100644 --- a/app/tool/perf/chat_shown_fixture.dart +++ b/app/tool/perf/chat_shown_fixture.dart @@ -2,6 +2,8 @@ // resolve to tool/capture/fixtures/files copied under capture-files/): the // subscribe reply carries one of each Pipelines tool entry, after the last answer of the // bench transcript's messages (perf-m0..19 at 09:00..09:19 UTC). +import 'dart:async'; + import 'package:pipelines_app/core/api_gateway.dart'; int _at(int minute, int second) => @@ -130,3 +132,54 @@ JsonMap chatShownFixture(Object? sessionId) => { }, ], }; + +/// `?shownpush=N`: N seconds after a chat subscribes, the server pushes one +/// new shown item (a diff) the way `show_diff` does mid-turn, so captures can +/// check that a pushed item appears without a reload. +Map _pushParams = const {}; + +/// Keeps the launch URL's parameters: the app rewrites the address bar to its +/// route before any chat subscribes. +void configureChatShownPush(Map params) => _pushParams = params; + +void chatShownPush(String sessionId, void Function(JsonMap frame) emit) { + final seconds = int.tryParse(_pushParams['shownpush'] ?? '') ?? 0; + if (seconds <= 0) return; + Timer(Duration(seconds: seconds), () { + emit({ + 'type': 'chat_shown', + 'chat_shown': { + 'session_id': sessionId, + 'items': [ + { + 'id': 'shown-pushed-diff', + 'kind': 'diff', + 'created_at': DateTime.now().millisecondsSinceEpoch, + 'title': 'Pushed diff', + 'diff_bytes': 40, + 'diff': { + 'repo': '/srv/probe/pipelines', + 'base': '', + 'base_commit': 'abc123def456', + 'head': 'main', + 'files': 1, + 'additions': 1, + 'deletions': 0, + 'changes': { + 'status': 'complete', + 'skipped': 0, + 'files': [ + { + 'path': 'README.md', + 'kind': 'modified', + 'patch': '@@ -1 +1,2 @@\n line\n+pushed\n', + }, + ], + }, + }, + }, + ], + }, + }); + }); +} diff --git a/app/tool/perf/perf_fixture.dart b/app/tool/perf/perf_fixture.dart index 6b70fd69..a8aa17d4 100644 --- a/app/tool/perf/perf_fixture.dart +++ b/app/tool/perf/perf_fixture.dart @@ -42,6 +42,7 @@ void configurePerfFixture(Map params) { const Duration(minutes: 4, seconds: 40), ); configureChatScrollFixture(params); + configureChatShownPush(params); configureChatQuestionFixture(params); configureChatShellFixture(params); configureTerminalFixture(params); diff --git a/app/tool/search_selection_probe_entry.dart b/app/tool/search_selection_probe_entry.dart index 44cf9810..c44c1da8 100644 --- a/app/tool/search_selection_probe_entry.dart +++ b/app/tool/search_selection_probe_entry.dart @@ -40,6 +40,7 @@ import 'package:web_socket_channel/web_socket_channel.dart'; import 'fixture_host/fixture_host.dart'; import 'perf/chat_search_fixture.dart'; +import 'perf/chat_shown_fixture.dart'; import 'perf/chat_question_fixture.dart'; import 'capture/window_probe.dart'; import 'perf/chat_scroll_fixture.dart'; @@ -820,6 +821,7 @@ class _FixtureChannel implements WebSocketChannel { chatScrollStream('${subscribe['session_id'] ?? ''}', emit); chatQuestionStream('${subscribe['session_id'] ?? ''}', emit); + chatShownPush('${subscribe['session_id'] ?? ''}', emit); } if (reply == null && followUps.isEmpty) return; Future.delayed(const Duration(milliseconds: 120), () {