@@ -10,13 +10,25 @@ import SwiftUI
1010struct ProgressAgentRound : View {
1111 let rounds : [ AgentRound ]
1212 let chat : StoreOf < Chat >
13+ var isStreaming : Bool = false
1314
1415 var body : some View {
1516 WithPerceptionTracking {
1617 VStack ( alignment : . leading , spacing : 8 ) {
17- ForEach ( rounds , id : \. roundId ) { round in
18+ ForEach ( Array ( rounds . enumerated ( ) ) , id : \. element . roundId ) { roundIndex , round in
19+ let isLastRound = roundIndex == rounds . count - 1
1820 VStack ( alignment : . leading , spacing : 8 ) {
19- ThemedMarkdownText ( text : round . reply , chat : chat )
21+ ForEach ( Array ( round . thinking . enumerated ( ) ) , id : \. offset ) { entryIndex , entry in
22+ ThinkingView (
23+ thinking : entry ,
24+ isStreaming : isStreaming
25+ && isLastRound
26+ && entryIndex == round . thinking . count - 1
27+ )
28+ }
29+ if ! round . reply . isEmpty {
30+ ThemedMarkdownText ( text : round . reply , chat : chat )
31+ }
2032 if let toolCalls = round . toolCalls , ! toolCalls . isEmpty {
2133 ProgressToolCalls ( tools : toolCalls , chat : chat )
2234 }
@@ -42,7 +54,12 @@ struct SubAgentRounds: View {
4254 VStack ( alignment : . leading , spacing : 8 ) {
4355 ForEach ( rounds , id : \. roundId ) { round in
4456 VStack ( alignment : . leading , spacing : 8 ) {
45- ThemedMarkdownText ( text : round . reply , chat : chat )
57+ ForEach ( Array ( round . thinking . enumerated ( ) ) , id : \. offset ) { _ , entry in
58+ ThinkingView ( thinking : entry , isStreaming : false )
59+ }
60+ if ! round . reply . isEmpty {
61+ ThemedMarkdownText ( text : round . reply , chat : chat )
62+ }
4663 if let toolCalls = round . toolCalls , ! toolCalls . isEmpty {
4764 ProgressToolCalls ( tools : toolCalls , chat : chat )
4865 }
@@ -384,23 +401,56 @@ struct GenericToolTitleView: View {
384401struct ProgressAgentRound_Preview : PreviewProvider {
385402 static let agentRounds : [ AgentRound ] = [
386403 . init ( roundId : 1 , reply : " this is agent step " , toolCalls : [
404+ // Completed read file
387405 . init (
388406 id : " toolcall_001 " ,
389- name : " Tool Call 1 " ,
390- progressMessage : " Read Tool Call 1 " ,
391- status : . completed ,
392- error : nil ) ,
407+ name : ServerToolName . readFile . rawValue ,
408+ progressMessage : " Read src/AppDelegate.swift " ,
409+ status : . completed ) ,
410+ // Completed file search with results
393411 . init (
394412 id : " toolcall_002 " ,
395- name : " Tool Call 2 " ,
396- progressMessage : " Running Tool Call 2 " ,
413+ name : ServerToolName . findFiles . rawValue ,
414+ progressMessage : " Searched for files matching query: **/*.swift " ,
415+ status : . completed ,
416+ resultDetails : [
417+ . fileLocation ( . init ( uri : " file:///src/App.swift " , range : . init ( start : . init ( line : 0 , character : 0 ) , end : . init ( line : 10 , character : 0 ) ) ) ) ,
418+ . fileLocation ( . init ( uri : " file:///src/Model.swift " , range : . init ( start : . init ( line : 0 , character : 0 ) , end : . init ( line : 5 , character : 0 ) ) ) ) ,
419+ . fileLocation ( . init ( uri : " file:///src/ViewModel.swift " , range : . init ( start : . init ( line : 0 , character : 0 ) , end : . init ( line : 8 , character : 0 ) ) ) ) ,
420+ ] ) ,
421+ // Completed create file (expandable)
422+ . init (
423+ id : " toolcall_003 " ,
424+ name : ToolName . createFile . rawValue ,
425+ progressMessage : " Created src/NewFeature.swift " ,
426+ status : . completed ,
427+ result : [ . text ( " ```swift \n struct NewFeature { \n var name: String \n } \n ``` " ) ] ) ,
428+ // Completed replace string (expandable)
429+ . init (
430+ id : " toolcall_004 " ,
431+ name : ServerToolName . replaceString . rawValue ,
432+ progressMessage : " Edited src/Config.swift " ,
433+ status : . completed ,
434+ result : [ . text ( " ```diff \n - let version = \" 1.0 \" \n + let version = \" 2.0 \" \n ``` " ) ] ) ,
435+ // Running tool
436+ . init (
437+ id : " toolcall_005 " ,
438+ name : ServerToolName . codebase . rawValue ,
439+ progressMessage : " Searching codebase for references " ,
397440 status : . running ) ,
441+ // Error tool
442+ . init (
443+ id : " toolcall_006 " ,
444+ name : ServerToolName . readFile . rawValue ,
445+ progressMessage : " Read missing_file.swift " ,
446+ status : . error ,
447+ error : " File not found " ) ,
398448 ] ) ,
399449 ]
400450
401451 static var previews : some View {
402452 let chatTabInfo = ChatTabInfo ( id : " id " , workspacePath : " path " , username : " name " )
403453 ProgressAgentRound ( rounds : agentRounds , chat : . init ( initialState : . init ( ) , reducer : { Chat ( service : ChatService . service ( for : chatTabInfo ) ) } ) )
404- . frame ( width : 300 , height : 300 )
454+ . frame ( width : 400 , height : 500 )
405455 }
406456}
0 commit comments