@@ -285,7 +285,7 @@ browseImagesButton.addEventListener('click', async e => {
285
285
286
286
for ( const file of files ) {
287
287
imagesToStore . push ( {
288
- file, // <-- The original file object keeps its name
288
+ file,
289
289
fsHandlePromise : Promise . resolve ( null )
290
290
} ) ;
291
291
resolve ( ) ;
@@ -365,7 +365,7 @@ saveImagesButton.addEventListener('click', async e => {
365
365
}
366
366
367
367
// If the input images were cloned, we can't save the new images
368
- // back to disk. They don't have a handle. Bail out for now.
368
+ // back to disk. They don't have a handle. Just bail out for now.
369
369
if ( currentImages . length !== outputImages . length ) {
370
370
return ;
371
371
}
@@ -422,7 +422,7 @@ viewImagesButton.addEventListener('click', async e => {
422
422
imageViewer . show ( ) ;
423
423
424
424
// 2 modes: either we matching inputs and outputs in which case we can
425
- // go into the swipe mode. Or we don't, in which case we show the
425
+ // go into the swipe mode. Or we don't, in which case we just show the
426
426
// output images.
427
427
if ( input . length === output . length ) {
428
428
imageViewer . populateFromInputAndOutput ( input , output ) ;
@@ -478,9 +478,7 @@ async function processShareTargetData() {
478
478
window . history . replaceState ( { } , document . title , window . location . pathname ) ;
479
479
}
480
480
481
- /**
482
- * Determines the flow configuration (title and steps) based on shared data
483
- */
481
+ // Determines the flow configuration (title and steps) based on shared data
484
482
function determineFlowConfiguration ( shareData ) {
485
483
// Default flow title and steps
486
484
let flowTitle = shareData . title || 'Shared Images Flow' ;
@@ -508,9 +506,7 @@ function determineFlowConfiguration(shareData) {
508
506
return { flowTitle, flowSteps } ;
509
507
}
510
508
511
- /**
512
- * Parses a web+wami:// URL to extract flow configuration
513
- */
509
+ // Parses a web+wami:// URL to extract flow configuration
514
510
function parseWebWamiUrl ( url ) {
515
511
// Extract the part after web+wami://
516
512
const urlPath = url . substring ( 'web+wami://' . length ) ;
@@ -560,9 +556,7 @@ function parseWebWamiUrl(url) {
560
556
return { title, steps } ;
561
557
}
562
558
563
- /**
564
- * Creates a new flow or navigates to an existing flow with the same name
565
- */
559
+ // Creates a new flow or navigates to an existing flow with the same name
566
560
async function createOrNavigateToFlow ( flowTitle , flowSteps ) {
567
561
// Only auto-process if title contains ai-action
568
562
const shouldAutoProcess = true ;
@@ -603,9 +597,7 @@ async function createOrNavigateToFlow(flowTitle, flowSteps) {
603
597
return targetFlow ;
604
598
}
605
599
606
- /**
607
- * Loads shared images from the cache and processes them if needed
608
- */
600
+ // Loads shared images from the cache and processes them if needed
609
601
async function loadAndProcessSharedImages ( shareCache , shareData ) {
610
602
const imagesToStore = [ ] ;
611
603
@@ -615,17 +607,23 @@ async function loadAndProcessSharedImages(shareCache, shareData) {
615
607
if ( fileResponse ) {
616
608
const blob = await fileResponse . blob ( ) ;
617
609
618
- // Get the original file name from the shareData.fileNames array
619
- // This is more reliable than trying to extract it from the blob
620
- const fileName = ( shareData . fileNames && shareData . fileNames [ i ] ) ||
621
- `shared-${ i + 1 } .${ getFileExtension ( blob . type ) } ` ;
610
+ // Use the exact original filename stored in the shareData
611
+ let fileName ;
612
+
613
+ if ( shareData . fileNames && shareData . fileNames [ i ] ) {
614
+ fileName = shareData . fileNames [ i ] ;
615
+ console . log ( `Using original file name: ${ fileName } ` ) ;
616
+ } else {
617
+ // Only fall back if absolutely necessary
618
+ fileName = `shared-${ i + 1 } .${ getFileExtension ( blob . type ) } ` ;
619
+ console . log ( `No filename found, using fallback: ${ fileName } ` ) ;
620
+ }
622
621
623
- // Create a File object with the original name
624
622
const file = new File ( [ blob ] , fileName , { type : blob . type } ) ;
625
623
626
624
imagesToStore . push ( {
627
625
file,
628
- name : file . name ,
626
+ name : fileName ,
629
627
fsHandlePromise : Promise . resolve ( null )
630
628
} ) ;
631
629
}
@@ -650,9 +648,7 @@ async function loadAndProcessSharedImages(shareCache, shareData) {
650
648
}
651
649
}
652
650
653
- /**
654
- * Cleans up the share cache after processing
655
- */
651
+ // Cleans up the share cache after processing
656
652
async function cleanupShareCache ( shareCache , shareData ) {
657
653
await shareCache . delete ( 'shareData' ) ;
658
654
for ( let i = 0 ; i < shareData . fileCount ; i ++ ) {
0 commit comments