hide prompted tool-use payloads from the conversation log

A permission-gated tool or AskUserQuestion already surfaces as a prompt
in the composer zone, so its raw tool-use card was redundant noise. The
session now tracks which tool_use_ids surfaced as a prompt; the
conversation view hides those tool-use cards. AskUserQuestion also hides
its result (the chosen answer is logged separately); permission-tool
results are kept — that's the useful outcome. The pane rebuilds the
view on each prompt change so the payload vanishes the moment its prompt
appears.

T-176, T-177, D-78.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-25 09:50:39 +02:00
co-authored by Claude Opus 4.7
parent de264e7141
commit c30a707b41
5 changed files with 104 additions and 33 deletions
@@ -115,7 +115,7 @@ void main() {
setUp(() async => f = await KernelFixture.create());
tearDown(() => f.dispose());
Future<ConversationController> pumpWith(WidgetTester tester, List<ConversationItem> items) async {
Future<ConversationController> pumpWith(WidgetTester tester, List<ConversationItem> items, {Set<String> hiddenToolUseIds = const {}}) async {
tester.view.physicalSize = const Size(900, 700);
tester.view.devicePixelRatio = 1.0;
addTearDown(() {
@@ -125,7 +125,7 @@ void main() {
final stream = StreamController<ConversationItem>.broadcast();
final c = ConversationController(stream: stream.stream);
addTearDown(c.dispose);
await tester.pumpWidget(harness(f, ConversationView(controller: c)));
await tester.pumpWidget(harness(f, ConversationView(controller: c, hiddenToolUseIds: hiddenToolUseIds)));
for (final it in items) {
stream.add(it);
}
@@ -170,6 +170,32 @@ void main() {
expect(find.text('error'), findsOneWidget);
});
testWidgets('AskUserQuestion tool-use and its result are hidden (it shows as a prompt)', (tester) async {
await pumpWith(tester, [
_asst('let me ask'),
AssistantToolUse(uuid: 'au', timestamp: _t, isSidechain: false, toolUseId: 'auq1', name: 'AskUserQuestion', input: const {'questions': []}),
ToolResultMessage(uuid: 'ar', timestamp: _t, isSidechain: false, toolUseId: 'auq1', content: 'answered', isError: false),
_asst('thanks'),
]);
expect(find.text('AskUserQuestion'), findsNothing);
expect(find.text('let me ask'), findsOneWidget);
expect(find.text('thanks'), findsOneWidget);
});
testWidgets('a permission-prompted tool-use is hidden but its result is kept', (tester) async {
await pumpWith(
tester,
[
_tool('Write', {'file_path': '/tmp/x'}),
_result('done')
],
hiddenToolUseIds: {'x1'}, // _tool + _result both use toolUseId 'x1'
);
expect(find.text('Write'), findsNothing); // payload hidden
expect(find.text('done'), findsOneWidget); // result kept
expect(find.text('result'), findsOneWidget);
});
testWidgets('a one-line tool result renders inline (no collapse caret)', (tester) async {
await pumpWith(tester, [_result('hello-from-spike')]);
expect(find.text('hello-from-spike'), findsOneWidget);