@@ -21,35 +21,34 @@ class OutputParser {
2121 this . callback = callback ;
2222 }
2323 updateOutput = ( line : any ) => {
24- let output = [ ...this . output ] ;
2524 if ( line . method === 'functions' ) {
2625 const functions = line . params ;
2726 for ( const func of functions ) {
2827 const functionId = func . id ;
29- const existingFunction = output . find ( o =>
28+ const existingFunction = this . output . find ( o =>
3029 o . method === 'functions'
3130 &&
3231 o . params . find ( ( p : { id : string } ) => p . id === functionId )
3332 ) ;
3433 if ( existingFunction ) {
3534 const existingFunctionParamsIndex = existingFunction . params . findIndex ( ( p : { id : string } ) => p . id === functionId ) ;
3635 existingFunction . params [ existingFunctionParamsIndex ] = { ...existingFunction . params [ existingFunctionParamsIndex ] , ...func } ;
37- output = output . map (
36+ this . output = this . output . map (
3837 o => o . method === 'functions'
3938 ?
4039 { ...o , params : o . params . map ( ( p : { id : string } ) => p . id === functionId ? { ...p , ...func } : p ) }
4140 :
4241 o
4342 ) ;
4443 } else {
45- output = [ ...output , line ] ;
44+ this . output = [ ... this . output , line ] ;
4645 }
4746 }
4847 }
4948 else {
50- output = [ ...output , line ] ;
49+ this . output = [ ... this . output , line ] ;
5150 }
52- this . callback ( output ) ;
51+ this . callback ( this . output ) ;
5352 }
5453}
5554
@@ -76,12 +75,14 @@ export function App() {
7675
7776 const [ runOut , setRunOut ] = React . useState < any [ ] > ( [ ] ) ;
7877
78+ const runOutput = new OutputParser ( setRunOut ) ;
79+
7980 const scrollRef = React . useRef < HTMLDivElement > ( null ) ;
8081
8182 const [ showDebug , setShowDebug ] = React . useState ( false ) ;
8283
8384 useEffect ( ( ) => {
84- const runOutput = new OutputParser ( setRunOut ) ;
85+
8586 try {
8687 client . docker . cli . exec ( "pull" , [ "vonwig/function_write_files" ] ) . then ( ( ) => {
8788 client . docker . cli . exec ( "run" , [
@@ -167,8 +168,6 @@ export function App() {
167168
168169 const startPrompt = async ( ) => {
169170 track ( 'start-prompt' ) ;
170-
171- const runOutput = new OutputParser ( setRunOut ) ;
172171 runOutput . updateOutput ( { method : 'message' , params : { debug : 'Pulling images' } } )
173172
174173 runOutput . updateOutput ( { method : 'message' , params : { debug : 'Running prompts...' } } )
0 commit comments