Skip to content

fix: reduce dashboard JS bundle from 1.7MB to 170KB (#792)#928

Open
ashish921998 wants to merge 10 commits intomainfrom
ashish921998/fix-issue-792
Open

fix: reduce dashboard JS bundle from 1.7MB to 170KB (#792)#928
ashish921998 wants to merge 10 commits intomainfrom
ashish921998/fix-issue-792

Conversation

@ashish921998
Copy link
Copy Markdown
Collaborator

Summary

  • Switch ao start default to production builds — monorepo now runs next build && start:all instead of next dev, reducing JS transferred from ~1.7MB to ~170KB (gzipped). Add --dev flag for HMR when editing dashboard UI.
  • Add @next/bundle-analyzer — run ANALYZE=true pnpm build to inspect chunk composition. Conditionally loaded to avoid crashing production startup.
  • Add server-only guards on 7 server-side lib files to prevent future accidental client bundle leaks.
  • Lazy-load DirectTerminal via next/dynamic in SessionDetail and dev/test pages.

Test plan

  • pnpm --filter @composio/ao-web test — 484 tests pass
  • pnpm --filter @composio/ao-web typecheck — clean
  • pnpm --filter @composio/ao-cli build — CLI compiles
  • pnpm --filter @composio/ao-web build — production build succeeds
  • Manual: ao start builds optimized dashboard, shows mode info
  • Manual: ao start --dev launches HMR dev server as before

Closes #792

🤖 Generated with Claude Code

Switch `ao start` default from `next dev` (7.6MB uncompressed) to optimized
production builds (128KB per route). Add `--dev` flag for HMR when editing
dashboard UI. Add bundle analyzer, server-only guards, and lazy-load
DirectTerminal via next/dynamic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Skip the production build step when .next/BUILD_ID and dist-server/
already exist (e.g. after pnpm build in CI). Add c8 ignore for
untestable process-spawning startup code to fix diff coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…reflight web artifact checks

Extract rebuildDashboardProductionArtifacts into dashboard-rebuild.ts, add
isInstalledUnderNodeModules/assertDashboardRebuildSupported guards, remove
findProcessWebDir, and verify .next/BUILD_ID + dist-server/start-all.js in
preflight. Dashboard command now always uses production server.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d helpers

- Skip preflight.checkBuilt() when --dev is passed (dev mode uses HMR,
  doesn't need .next/BUILD_ID or dist-server/start-all.js)
- Add c8 ignore to dashboard.ts process-spawning code (matches start.ts pattern)
- Add tests for rebuildDashboardProductionArtifacts (success, failure, npm guard)
- Add preflight tests for npm-install web artifact hint paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ashish921998 and others added 2 commits April 6, 2026 00:47
Only skip production artifact preflight when both --dev is passed AND
we're in the monorepo (where dev mode actually works). For npm global
installs, --dev is silently ignored and production server runs, so
preflight must still validate .next/BUILD_ID and dist-server/start-all.js.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ashish921998 and others added 2 commits April 6, 2026 08:57
The @next/* packages follow the Next.js release train. Pin the bundle
analyzer to ^15.1.0 to match the project's next dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e-792

# Conflicts:
#	packages/web/vitest.config.ts
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 50a2c7b. Configure here.

ashish921998 and others added 2 commits April 6, 2026 14:00
…uard

- Change stale-build recovery suggestion from "ao update" (which only
  works in source checkouts) to "npm install -g @composio/ao@latest"
  for npm global installs
- Remove redundant assertDashboardRebuildSupported call in dashboard.ts
  since rebuildDashboardProductionArtifacts already calls it internally

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e-792

# Conflicts:
#	packages/web/src/lib/global-pause.ts
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.

main-app.js is 1.68MB — JS bundle 4x over budget

1 participant