Fixture: push a shown item after a chat subscribes (?shownpush=N)
Lets captures check that an item pushed mid-turn appears without a reload, as show_diff does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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<String, String> _pushParams = const {};
|
||||
|
||||
/// Keeps the launch URL's parameters: the app rewrites the address bar to its
|
||||
/// route before any chat subscribes.
|
||||
void configureChatShownPush(Map<String, String> 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',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ void configurePerfFixture(Map<String, String> params) {
|
||||
const Duration(minutes: 4, seconds: 40),
|
||||
);
|
||||
configureChatScrollFixture(params);
|
||||
configureChatShownPush(params);
|
||||
configureChatQuestionFixture(params);
|
||||
configureChatShellFixture(params);
|
||||
configureTerminalFixture(params);
|
||||
|
||||
@@ -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<void>.delayed(const Duration(milliseconds: 120), () {
|
||||
|
||||
Reference in New Issue
Block a user