Skip to content

Keep the desktop shell and the Files screen out of the first download - #1191

Open
CG-8663 wants to merge 1 commit into
MyOwnDataCenter:mainfrom
CG-8663:perf/split-desktop-bundle
Open

CG-8663 wants to merge 1 commit into
MyOwnDataCenter:mainfrom
CG-8663:perf/split-desktop-bundle

Conversation

@CG-8663

@CG-8663 CG-8663 commented Nov 30, 2026 •

Copy link
Copy Markdown

What this changes

The first download gets smaller: the desktop shell and the Files screen are no longer part of the main bundle.

Main bundle gzip
main (4b99950) 1,092 kB 336.7 kB
this change 789 kB 239.8 kB
  • App.tsx loads Desktop with lazy(), like the other screens. A phone never downloads it.
  • That alone did nothing, because other modules imported small pieces of Desktop.tsx and Files.tsx. Those pieces move to their own modules:
    • desktop/context.ts: DesktopApi, DesktopContext, useDesktop
    • desktop/AppFrame.tsx: AppFrame, useAppFrame and the app-window gates
    • fileUpload.ts: uploadOne and the chunked upload
  • Desktop becomes its own 102 kB chunk and Files its own 141 kB chunk.

No behaviour change: the code is moved, not rewritten.

How you tested it

  • npm run typecheck and npm run build pass, rebased on main (4b99950).
  • New test/bundle-split.test.mjs fails on main and passes here. It stops a static import from pulling either file back into the main bundle. It passes with signed-in-shell.test.mjs (7 of 7).
  • Looked at in a browser against the stand-in backend: the desktop layout loads and opens the Files window; the phone layout opens Files and never requests the Desktop chunk.
  • I did not run the whole suite locally (it stalls on my Mac at test/api-proxy.test.mjs, on unchanged main too), so the full run is the one GitHub does here.

Anything to know

  • Sizes are from vite build. The main bundle is still over Vite's 500 kB warning; this is the first cut, not the last.

Built with Chronara AI

@calledtoconstruct

Copy link
Copy Markdown
Collaborator

This is a great idea! A lot of UI work is about to drop, but after that, this can be validated. Hopefully, it will flow smoothly!

@CG-8663
CG-8663 force-pushed the perf/split-desktop-bundle branch from e17fbdb to 760e881 Compare November 30, 2026 05:59
@CG-8663

CG-8663 commented Nov 30, 2026

Copy link
Copy Markdown
Author

Thank you. Rebased on main after the Files list and the viewer landed, so it merges cleanly again: 1,092 kB down to 789 kB now. Two new screens (Plugins, Transfers) were importing from Desktop.tsx and now use desktop/context. I will rebase again once the rest of the UI work is in, so it is ready when you want to validate it.

@CG-8663
CG-8663 force-pushed the perf/split-desktop-bundle branch from 760e881 to d8b39be Compare December 5, 2026 10:02
App.tsx now loads Desktop with lazy(), like the other screens. That alone
did nothing: other modules imported small pieces of Desktop.tsx
(useDesktop, AppFrame), and AddFile and ImportDiskImage imported uploadOne
from Files.tsx, which kept both files in the main bundle. Those pieces
move to their own modules:

- desktop/context.ts: DesktopApi, DesktopContext, useDesktop
- desktop/AppFrame.tsx: AppFrame, useAppFrame and the app-window gates
- fileUpload.ts: uploadOne and the chunked upload

Main bundle on 4b99950: 1,092 kB / 336.7 kB gzip -> 789 kB / 239.8 kB gzip.
Desktop is now its own 102 kB chunk, loaded only in the desktop layout,
and Files its own 141 kB chunk. No behaviour change.
test/bundle-split.test.mjs fails on main and guards against a static
import pulling either file back in.

Co-Authored-By: Chronara AI <info@chronara.io>
@CG-8663
CG-8663 force-pushed the perf/split-desktop-bundle branch from d8b39be to 57f4360 Compare December 5, 2026 10:10
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