Skip to content

add file transfer - #3

Open
gkgoat1 wants to merge 8 commits into
abndnce:mainfrom
gkgoat1:pr/fileio
Open

add file transfer#3
gkgoat1 wants to merge 8 commits into
abndnce:mainfrom
gkgoat1:pr/fileio

Conversation

@gkgoat1

@gkgoat1 gkgoat1 commented Jun 23, 2026

Copy link
Copy Markdown

Adds file transfer to the Cod VM

Comment thread src/cod/App.svelte
</button>
{#each launcherApps as app (app.id)}
{#if app.isInstalled() && !app.isRunning()}
<DropFile onDrop={onDrop}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a window-level event listener (<svelte:window>) instead so that we don't add a layer of indentation to everything and don't need another dep

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this run in another window, so <svelte:window> targets the wrong window?

https://svelte.dev/docs/svelte/svelte-window

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good point. can add listeners in app.ts then

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up vendoring svelte-parts's DropFile, is that okay?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, diff fail

@gkgoat1 gkgoat1 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me to look at once back on my Mac

Comment thread src/cod/App.svelte Outdated
const transferFiles: Record<string,string> = {};
let script = '';
for(const file of files){
transferFiles[file.name + '._'] = btoa(String.fromCharCode(...new Uint8Array(await file.arrayBuffer())));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably use Uint8Array.toBase64 if supported

Comment thread src/cod/App.svelte
</button>
{#each launcherApps as app (app.id)}
{#if app.isInstalled() && !app.isRunning()}
<DropFile onDrop={onDrop}>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, diff fail

@KTibow

KTibow commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

nuances:

  • the most you can ever send in one frame is 1mb
  • of course you can stack this
  • the most you can send in a command is 128kb
  • you can't use data: urls when transferring that implicitly unwrap
  • you can receive http via scalinghub, this requires same cookies you use to connect to graphics
  • but atp you might as well do p2p

@gkgoat1

gkgoat1 commented Aug 2, 2026

Copy link
Copy Markdown
Author

nuances:

  • the most you can ever send in one frame is 1mb
  • of course you can stack this
  • the most you can send in a command is 128kb
  • you can't use data: urls when transferring that implicitly unwrap
  • you can receive http via scalinghub, this requires same cookies you use to connect to graphics
  • but atp you might as well do p2p

Maybe you (or an agent) could port https://github.com/n0-computer/iroh to the web (Pulsar is meant for proxying, but iroh is perfect for p2p) ;L

  • wait... it uses QUIC, not WebRTC. Still has an HTTP fallback though

Still, exposing a server from the cod VM would be effective to get large amounts of information in and out quickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants