puter icon indicating copy to clipboard operation
puter copied to clipboard

fix: improve onLaunchedWithItems to prevent information loss

Open KernelDeimos opened this issue 8 months ago • 1 comments

[ai]

Fix for issue #1226: onLaunchedWithItems implementation to prevent information loss

This PR implements the solution suggested in issue #1226 to fix the problem with onLaunchedWithItems being prone to losing information about fsentries due to property duplication.

Changes:

  1. Modified launch_app.js to only pass the file UUID to apps after granting the app permission to access the file:

    • Instead of passing all file properties through the URL query parameters, we now only pass the file UUID
    • This eliminates the property duplication issue and keeps the URL shorter
  2. Updated UI.js to have onLaunchedWithItems fetch the file information via puter.js:

    • When an app is launched with a file, it now uses puter.fs.stat() to get the complete file information using the UUID
    • This ensures that all file properties are consistently retrieved from a single source

Benefits:

  1. More robust approach that eliminates property duplication
  2. Shorter URLs (avoids hitting URL length limits)
  3. Apps get the most up-to-date file information
  4. Consistent with how the rest of the system accesses file information

Fixes #1226

KernelDeimos avatar Mar 27 '25 21:03 KernelDeimos

Manual test failed. This doesn't work because we are neither using /sign nor granting permission. Actually, we probably need to do both:

  • writeURL, readURL etc provided by /sign need to be present otherwise this is a regression
  • the new permission system should also be used however. Eventually we will migrate /sign so that it provides new endpoints for these URLs that behave the same but rely on the new permission system instead of signatures.

https://github.com/user-attachments/assets/3f468cb9-795c-4c91-9920-5119076aeb33

KernelDeimos avatar Mar 27 '25 21:03 KernelDeimos