11import { useState } from 'react'
22import { ResponsePreview } from './ResponsePreview'
3+ import { ItemInPreview } from '@shared/types/file-in-preview'
34
45export default {
56 component : ResponsePreview
@@ -59,8 +60,10 @@ const log_action =
5960 }
6061
6162const InteractiveResponsePreview = ( props : any ) => {
62- const [ files , set_files ] = useState (
63- props . files . map ( ( f : any ) => ( { ...f , is_checked : true } ) )
63+ const [ items , set_items ] = useState (
64+ props . items . map ( ( f : any ) =>
65+ 'file_path' in f ? { ...f , is_checked : true } : f
66+ )
6467 )
6568
6669 const handle_toggle_file = ( {
@@ -72,9 +75,11 @@ const InteractiveResponsePreview = (props: any) => {
7275 workspace_name ?: string
7376 is_checked : boolean
7477 } ) => {
75- set_files (
76- files . map ( ( f : any ) =>
77- f . file_path === file_path && f . workspace_name === workspace_name
78+ set_items (
79+ items . map ( ( f : any ) =>
80+ 'file_path' in f &&
81+ f . file_path === file_path &&
82+ f . workspace_name === workspace_name
7883 ? { ...f , is_checked }
7984 : f
8085 )
@@ -85,7 +90,7 @@ const InteractiveResponsePreview = (props: any) => {
8590 return (
8691 < ResponsePreview
8792 { ...props }
88- files = { files }
93+ items = { items }
8994 on_toggle_file = { handle_toggle_file }
9095 on_discard = { log_action ( 'on_undo' ) }
9196 on_approve = { log_action ( 'on_keep' ) }
@@ -96,21 +101,21 @@ const InteractiveResponsePreview = (props: any) => {
96101 )
97102}
98103
99- export const Default = ( ) => < InteractiveResponsePreview files = { base_files } />
104+ export const Default = ( ) => < InteractiveResponsePreview items = { base_files } />
100105
101106export const WithSingleFile = ( ) => (
102- < InteractiveResponsePreview files = { [ base_files [ 0 ] ] } />
107+ < InteractiveResponsePreview items = { [ base_files [ 0 ] ] } />
103108)
104109
105110export const WithFallbacks = ( ) => (
106111 < InteractiveResponsePreview
107- files = { [ ...base_files , ...files_using_fallbacks ] }
112+ items = { [ ...base_files , ...files_using_fallbacks ] }
108113 />
109114)
110115
111116export const WithMultipleWorkspaces = ( ) => (
112117 < InteractiveResponsePreview
113- files = { [
118+ items = { [
114119 {
115120 ...base_files [ 0 ] ,
116121 workspace_name : 'project-a'
@@ -127,3 +132,17 @@ export const WithMultipleWorkspaces = () => (
127132 has_multiple_workspaces = { true }
128133 />
129134)
135+
136+ export const WithText = ( ) => (
137+ < InteractiveResponsePreview
138+ items = { [
139+ { type : 'text' , content : 'This is a text item.' } ,
140+ ...base_files ,
141+ {
142+ type : 'text' ,
143+ content : 'Another text item explaining something.'
144+ } ,
145+ ...files_using_fallbacks
146+ ] }
147+ />
148+ )
0 commit comments