Show a chat turn's changed files as a chip that opens its diff
The answer footer shows '3 files changed +9 -2'; tapping opens the turn's files in the sheet (wide) or a full-screen page (narrow), and a file opens the run Changes diff viewer. Patches load through the chat's own gateway.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/servers/chat/chat_identity.dart';
|
||||
import 'package:pipelines_app/core/servers/chat/chat_server_gateway.dart';
|
||||
import 'package:pipelines_app/core/servers/chat/federated_chat_gateway.dart';
|
||||
import 'package:pipelines_app/core/servers/server_catalog.dart';
|
||||
|
||||
class _Machine implements ApiGateway {
|
||||
final events = StreamController<JsonMap>.broadcast();
|
||||
final calls = <(String, JsonMap)>[];
|
||||
@override
|
||||
Stream<JsonMap> get frames => events.stream;
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
|
||||
calls.add((type, fields));
|
||||
return {
|
||||
'type': type,
|
||||
'chat_turn_diff': {
|
||||
'session_id': 'native',
|
||||
'turn_id': 'turn_1',
|
||||
'changes': {'status': 'complete', 'files': <JsonMap>[]},
|
||||
},
|
||||
'chat_turn_diffs': {'session_id': 'native', 'turn_diffs': <JsonMap>[]},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
SavedServer _server(String id) => SavedServer.validated(
|
||||
id: id,
|
||||
name: 'Machine $id',
|
||||
endpoints: ['ws://$id.test/connect'],
|
||||
);
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'turn diffs go to the chat\'s own machine and come back namespaced',
|
||||
() async {
|
||||
final a = _Machine(), b = _Machine();
|
||||
final sources = {
|
||||
'a': ChatServerGateway(_server('a'), a),
|
||||
'b': ChatServerGateway(_server('b'), b),
|
||||
};
|
||||
final all = FederatedChatGateway(
|
||||
() => sources,
|
||||
() => 'a',
|
||||
const Stream.empty(),
|
||||
);
|
||||
final remote = federatedChatId('b', 'native');
|
||||
final reply = await all.call('chat_turn_diff', {
|
||||
'chat_turn_diff': {'session_id': remote, 'turn_id': 'turn_1'},
|
||||
});
|
||||
expect(a.calls, isEmpty);
|
||||
expect(b.calls.single.$2['chat_turn_diff'], {
|
||||
'session_id': 'native',
|
||||
'turn_id': 'turn_1',
|
||||
});
|
||||
expect((reply['chat_turn_diff'] as Map)['session_id'], remote);
|
||||
expect((reply['chat_turn_diffs'] as Map)['session_id'], remote);
|
||||
|
||||
// A pushed summary list is re-keyed to the machine's namespaced id.
|
||||
final pushed = sources['b']!.frames.first;
|
||||
b.events.add({
|
||||
'type': 'chat_turn_diffs',
|
||||
'chat_turn_diffs': {'session_id': 'native', 'turn_diffs': <JsonMap>[]},
|
||||
});
|
||||
expect(((await pushed)['chat_turn_diffs'] as Map)['session_id'], remote);
|
||||
await a.events.close();
|
||||
await b.events.close();
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user