@@ -244,40 +244,10 @@ export class CommonWindowManager extends LitElement {
244244 const onImportLocalData = ( event : CustomEvent ) => {
245245 const data = event . detail . data ;
246246 console . log ( "Importing local data:" , data ) ;
247+ const title = prompt ( "Enter a title for your recipe:" ) ;
248+ if ( ! title ) return ;
247249
248- if ( event . detail . shiftKey && this . focusedCharm ) {
249- const existingData = this . focusedProxy ?. data || { } ;
250- const mergedData = { ...existingData } ;
251-
252- for ( const [ key , value ] of Object . entries ( data ) ) {
253- if ( Array . isArray ( value ) && Array . isArray ( existingData [ key ] ) ) {
254- mergedData [ key ] = [ ...existingData [ key ] , ...value ] ;
255- } else {
256- mergedData [ key ] = value ;
257- }
258- }
259-
260- this . focusedCharm . asCell ( [ "data" ] ) . send ( mergedData ) ;
261-
262- // Update the title to indicate the merge
263- const newTitle = `${ this . focusedProxy ?. [ NAME ] || "Untitled" } (Merged ${ new Date ( ) . toISOString ( ) } )` ;
264- this . focusedCharm . asCell ( [ NAME ] ) . send ( newTitle ) ;
265-
266- // Refresh the UI
267- this . requestUpdate ( ) ;
268- } else {
269- // Create a new charm and query for the imported data
270- const jsonSchema = Schema . inferJsonSchema ( data [ 0 ] ) ;
271- jsonSchema . description = Object . keys ( data [ 0 ] ) . join ( ", " ) ;
272- const src = Schema . generateZodSpell ( jsonSchema ) ;
273- buildRecipe ( src ) . then ( ( { recipe } ) => {
274- if ( recipe ) {
275- addRecipe ( recipe , src , "render data" , [ ] ) ;
276-
277- runPersistent ( recipe , data [ 0 ] ) . then ( ( charm ) => this . openCharm ( charm ) ) ;
278- }
279- } ) ;
280- }
250+ iframeSpellAi . createNewRecipe ( data , title ) ;
281251 } ;
282252
283253 return html `
0 commit comments