Skip to content

perf: reduce client bundle size 37.9% (-1007KB) - #219

Merged
tonythethompson merged 15 commits into
mainfrom
perf/bundle-size-optimization
Aug 10, 2026
Merged

tonythethompson merged 15 commits into
mainfrom
perf/bundle-size-optimization

Conversation

@tonythethompson

@tonythethompson tonythethompson commented Aug 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Reduces production client JS bundle from 2,655,341 → 1,648,669 bytes (-1,006,672 bytes, -37.9%).

Changes

Bundle optimization

  • Externalize @huggingface/transformers (551K) and onnxruntime-web (395K) — loaded from esm.sh CDN on-demand via import map, only when Playground panels open
  • Lazy-load ExecutionWorkspace, IHVIntegrationPanel, ReportIssueModal via React.lazy()
  • Replace jszip (96K) with fflate (8K) for OWR bundle zip generation
  • Remove phantom motion dependency (zero imports)
  • Add "sideEffects": ["*.css"] for better tree-shaking
  • Remove dead getPassesByCategory() (zero callers)
  • Dynamic import passes.json instead of static inline (62K → separate chunk)

Reliability improvements (from review feedback)

  • Added import map in index.html for CDN-loaded externals
  • Added esm.sh to CSP script-src in helmet config
  • Fixed async KB loading: graceful degradation while pending, retry on failure
  • Wrapped ReportIssueModal in ErrorBoundary for chunk load resilience
  • Separated module-load vs archive-generation error handling in OWR export
  • Fixed tests to await kbReady() before synchronous validation

Verification

  • ✅ tsc --noEmit — zero type errors
  • ✅ 1,025 unit tests pass (1,018 existing + 7 new OWR regression tests)
  • ✅ 389 server tests pass
  • ✅ validate-recipe-builder.ts script passes
  • ✅ Production build succeeds
  • ✅ Vercel deployment succeeds
  • ✅ CodeFactor clean
  • ✅ All review threads resolved

Risk Assessment

  • Low risk: Externalized deps have graceful offline fallbacks (Arena tokenizer, Playground inference)
  • Import map pins CDN versions — no floating dependencies
  • KB loading is optimistic during pending, only rejects on actual failure

- Lazy-load ExecutionWorkspace, IHVIntegrationPanel, ReportIssueModal (React.lazy)
- Externalize @huggingface/transformers and onnxruntime-web (CDN on-demand)
- Convert passes.json from static import to async dynamic import
- Remove dead getPassesByCategory() export (zero callers)
- Add sideEffects: false to package.json for better tree-shaking
- Remove phantom motion dependency (zero imports)
- Remove unused vendor-motion chunk config

Metric: client_js_bytes 2,655,341 → 1,712,620 (-942,721 bytes)
Initial chunk: 289,710 → 137,468 (-152,242 bytes, -53%)
All 1,407 tests pass (1,018 unit + 389 server)
@vercel

vercel Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
olive-studio Ready Ready Preview Aug 10, 2026 7:40am

@sourcery-ai sourcery-ai Bot left a comment

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.

Sorry @tonythethompson, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change lazy-loads three application components and the schema knowledge base. It adds loading and knowledge-base availability states, replaces JSZip with fflate for OWR archive generation, and updates package and Vite bundling metadata.

Changes

Lazy loading pipeline

Layer / File(s) Summary
Lazy-loaded application panels
src/App.tsx
IHVIntegrationPanel, ExecutionWorkspace, and ReportIssueModal now use lazy imports and Suspense boundaries.
Asynchronous knowledge-base readiness
src/lib/schemaEngine.ts
The knowledge base loads through a cached dynamic import. kbReady() exposes readiness. Validators return availability errors when loading is incomplete or failed.
fflate OWR archive generation
src/components/features/execute/ExecutionWorkspace.tsx, package.json
OWR files are encoded into an in-memory map and compressed with fflate and zipSync.
Browser bundle configuration
package.json, vite.config.ts
CSS side effects are declared, jszip and motion are removed, optional dependencies remain in Rollup’s module graph, and the vendor-motion chunk rule is removed.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: greptile-apps

🚥 Pre-merge checks | ✅ 8
✅ Passed checks (8 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Pipeline Stage Enum Ordering ✅ Passed The PR changes no SessionWorkflowStage enum or member comparisons; repository-wide tracked-file searches found no enum, member, or pipeline-stage references requiring this check.
Gpu/Cpu Runtime Boundary ✅ Passed The PR diff changes only frontend files; no inference/ path or managed runtime requirements file is modified, so the GPU/CPU boundary checks are not applicable.
Managed Host Restart Safety ✅ Passed The PR changes only package.json, App.tsx, ExecutionWorkspace.tsx, passCatalog.ts, schemaEngine.ts, and vite.config.ts; no managed-host file or restart/readiness code is modified.
Title check ✅ Passed The title clearly summarizes the main change: reducing the client bundle size by 37.9%.
Description check ✅ Passed The description directly explains the bundle optimizations, reliability changes, verification results, and risk assessment.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/bundle-size-optimization
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch perf/bundle-size-optimization

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. Analyzed tonythethompson/QuickShell, tonythethompson/numan, tonythethompson/dependency-chain-substrate, skipped Trackdubllc/Trackdub.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR reduces the production client bundle by lazy-loading UI modules, externalizing optional browser inference dependencies, asynchronously loading the pass knowledge base, and replacing JSZip with fflate.

  • Adds import-map and CSP support for externalized ONNX Runtime and Transformers modules.
  • Introduces retryable asynchronous knowledge-base loading and updates validation tests and scripts.
  • Splits optional panels and report UI into lazy chunks and removes unused dependencies and exports.

Confidence Score: 4/5

The PR is not yet safe to merge because validation can still run before the pass knowledge base is ready, accepting invalid configurations or rejecting valid KB-only recipes.

The pending knowledge-base state remains observable to synchronous production callers: parameter checks return no errors while the schema map is empty, while KB-only pass recognition reports valid types as unknown.

Files Needing Attention: src/lib/schemaEngine.ts

Important Files Changed

Filename Overview
src/lib/schemaEngine.ts Introduces asynchronous, retryable knowledge-base loading, but synchronous validation still runs against incomplete state and can accept invalid configs or reject valid KB-only passes.
src/App.tsx Converts several panels to React.lazy, although all mapped sections still mount on the initial Dashboard render.
index.html Adds import-map mappings that resolve the two externalized browser dependencies through esm.sh.
server.ts Extends the application CSP to permit scripts from the newly configured esm.sh module origin.
vite.config.ts Externalizes optional browser inference dependencies and retains the existing production chunking and compression setup.
src/components/features/execute/ExecutionWorkspace.tsx Replaces JSZip with a dynamically imported fflate implementation for OWR archive generation.
package.json Marks CSS as side-effectful, replaces JSZip with fflate, and removes the unused motion dependency.

Reviews (11): Last reviewed commit: "fix: don't reject valid recipes while KB..." | Re-trigger Greptile

Comment thread vite.config.ts
Comment thread src/lib/schemaEngine.ts Outdated
Comment thread src/App.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 785322f8dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vite.config.ts
Comment thread package.json
Comment thread src/lib/schemaEngine.ts Outdated
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Reduce client bundle via lazy panels, externalized deps, and async passes KB

✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Lazy-load non-default panels and the report modal to shrink initial UI payload.
• Externalize large optional ML dependencies to load only when needed.
• Move passes knowledge-base JSON to an async chunk and improve tree-shaking hints.
Diagram

graph TD
  Browser["Browser (user)"] --> App["React app shell"] --> Panels["Lazy panels"] --> Chunks["Panel chunks"] --> CDN{{"External deps (CDN/import map)"}}
  App --> Schema["Schema engine"] --> KB[("passes.json chunk")]

  subgraph Legend
    direction LR
    _cmp["Component/module"] ~~~ _data[("Data/chunk")] ~~~ _ext{{"External"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Bundle heavy deps into dedicated lazy chunks (no Rollup external)
  • ➕ Avoids needing CDN/import-map runtime resolution for bare specifiers
  • ➕ Keeps offline/dev environments simpler and more predictable
  • ➖ Client download size increases when those panels are used
  • ➖ Can still bloat intermediate chunks vs true externalization
2. Fetch passes KB via an API endpoint (HTTP cache) instead of bundling JSON
  • ➕ Removes KB JSON from build pipeline entirely
  • ➕ Can version/cache independently and update without a full client rebuild
  • ➖ Adds network dependency and failure modes for validation
  • ➖ Requires server endpoint and caching/versioning strategy
3. Gate validation on KB readiness (await initial import)
  • ➕ Avoids temporary “empty schema” validation behavior early in session
  • ➕ Makes validation deterministic across timing/race conditions
  • ➖ Could introduce a noticeable first-validation delay
  • ➖ Adds async handling complexity to call sites

Recommendation: Current approach is reasonable for a performance-focused PR: lazy UI panels reduce initial bundle cost, and the passes KB is pushed into a separate chunk while prefetching at module eval. The main tradeoff is rollupOptions.external: ensure the runtime environment reliably resolves these packages (CDN + import map or equivalent) and that failure paths remain graceful in the panels that depend on them.

Files changed (5) +63 / -30

Enhancement (2) +55 / -15
App.tsxLazy-load non-default panels and conditionally mount report modal +36/-11

Lazy-load non-default panels and conditionally mount report modal

• Converts 'IHVIntegrationPanel', 'ExecutionWorkspace', and 'ReportIssueModal' to 'React.lazy()' imports. Wraps the panels in 'Suspense' with a shared spinner fallback and only mounts the report modal when open.

src/App.tsx

schemaEngine.tsLoad passes knowledge base JSON asynchronously (separate chunk) +19/-4

Load passes knowledge base JSON asynchronously (separate chunk)

• Replaces the static 'passes.json' import with an async dynamic import started at module evaluation time. Validation functions now proceed with empty KB data until the import completes, then rebuild parameter schemas when available.

src/lib/schemaEngine.ts

Refactor (1) +0 / -10
passCatalog.tsRemove dead pass grouping export +0/-10

Remove dead pass grouping export

• Deletes the unused 'getPassesByCategory()' export to reduce surface area and avoid retaining extra code during bundling.

src/lib/passCatalog.ts

Other (2) +8 / -5
package.jsonEnable stronger tree-shaking and remove unused dependency +1/-1

Enable stronger tree-shaking and remove unused dependency

• Adds a 'sideEffects' hint so bundlers can tree-shake more aggressively while preserving CSS side effects. Removes the unused 'motion' dependency from the dependency list.

package.json

vite.config.tsExternalize heavy optional deps and simplify manual chunking +7/-4

Externalize heavy optional deps and simplify manual chunking

• Marks '@huggingface/transformers' and 'onnxruntime-web' as Rollup externals so they are not bundled into the client. Removes the unused 'vendor-motion' manual chunk rule.

vite.config.ts

@qodo-code-review

qodo-code-review Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. External ORT import breaks ✓ Resolved 🐞 Bug ≡ Correctness
Description
vite.config.ts now externalizes onnxruntime-web, but the app still uses
import("onnxruntime-web") in browser-only panels. In a production browser build this leaves an
unresolved bare specifier (no import map), so ORT-dependent Playground features will fail to load at
runtime.
Code

vite.config.ts[R118-121]

+        external: [
+          '@huggingface/transformers',
+          'onnxruntime-web',
+        ],
Relevance

●●● Strong

Externalizing module while still bare-dynamic-importing likely breaks production runtime; fix is
straightforward and correctness-critical.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR adds Rollup externals for onnxruntime-web, but the code still performs bare dynamic imports
of that module at runtime in multiple browser panels. There is no import map in index.html, so
browsers cannot resolve onnxruntime-web in production output.

vite.config.ts[113-141]
src/components/features/playground/ArenaPanel.tsx[551-564]
src/components/features/playground/InBrowserValidation.tsx[79-106]
src/components/features/playground/WebGpuBenchmarkPanel.tsx[214-227]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`onnxruntime-web` (and `@huggingface/transformers`) are configured as Rollup externals, but the codebase uses bare-specifier dynamic imports like `import("onnxruntime-web")`. In production, browsers cannot resolve bare specifiers unless you provide an import map or rewrite the import to a URL.

## Issue Context
This breaks ORT-dependent Playground functionality (local inference, in-browser validation, WebGPU benchmark). The code currently does not load ORT from a URL; it only sets `wasmPaths` after importing the module.

## Fix Focus Areas
- vite.config.ts[113-141]
- src/components/features/playground/ArenaPanel.tsx[551-564]
- src/components/features/playground/InBrowserValidation.tsx[79-106]
- src/components/features/playground/WebGpuBenchmarkPanel.tsx[214-227]

## Expected fix direction
Choose one:
1) Remove `onnxruntime-web` (and likely `@huggingface/transformers`) from `build.rollupOptions.external` and keep relying on Vite bundling + dynamic import for code-splitting.
2) Keep them external, but add a real resolution mechanism:
  - an `importmap` in `index.html`, or
  - rewrite dynamic imports to a CDN URL using `/* @vite-ignore */` and keep a try/catch fallback path.

Add a quick smoke test or documented manual verification for opening the affected panels in a production build.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. KB load skips validation ✓ Resolved 🐞 Bug ☼ Reliability
Description
schemaEngine.ts no longer loads passes.json synchronously, and ensureKbLoaded() is now a no-op
while validation remains synchronous. Calls to validateRecipeSchema/validatePassConfig can run
before the async import finishes (or forever if it fails), silently skipping required-parameter and
KB-only pass validation; additionally, the async loader updates kbData and PARAM_SCHEMAS
non-atomically.
Code

src/lib/schemaEngine.ts[R93-96]

function ensureKbLoaded(): void {
+  // After the async load completes, this becomes a no-op
  if (kbData !== null) return;
-  kbData = passKnowledgeBase as unknown as PassesJson;
-  PARAM_SCHEMAS = buildParamSchemas(kbData);
+  // If the async load hasn't completed yet, use empty data (validation gracefully degrades)
Relevance

●●● Strong

Team previously accepted atomic KB/schema updates and stricter validation; async no-op loader risks
silent validation skips.

PR-#14

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
ensureKbLoaded() no longer loads anything, but validation functions rely on it and then
immediately read PARAM_SCHEMAS, so requiredParams/KB-only pass recognition can be skipped when
PARAM_SCHEMAS is still empty. The server uses this same validation path during preflight, making
the weakened validation reachable beyond just the client UI. The async loader also assigns kbData
before building PARAM_SCHEMAS, matching a known bug pattern where partial updates leave state
inconsistent if schema build throws.

src/lib/schemaEngine.ts[88-110]
src/lib/schemaEngine.ts[187-216]
src/lib/schemaEngine.ts[269-343]
src/lib/oliveRecipeSchema.ts[1-16]
src/server/services/olive/jobPreflight.ts[11-80]
PR-#14

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`schemaEngine.ts` changed from a synchronous KB import to an async IIFE, but the public validation APIs are still synchronous. During the async window (and permanently on load failure), `PARAM_SCHEMAS` stays empty so validation silently weakens. Also, the loader assigns `kbData` before building `PARAM_SCHEMAS`, so an exception during schema build can leave the module in an inconsistent, unrecoverable state.

## Issue Context
This is particularly risky because server-side recipe preflight calls into `validateOliveRecipeStructure` → `validateRecipeSchema`, so weakened validation can affect job submission.

## Fix Focus Areas
- src/lib/schemaEngine.ts[88-110]
- src/lib/schemaEngine.ts[187-216]
- src/lib/schemaEngine.ts[269-343]
- src/lib/oliveRecipeSchema.ts[1-16]
- src/server/services/olive/jobPreflight.ts[11-80]

## Expected fix direction
- Introduce a retryable `kbLoadPromise` and a `kbReady()` (or similar) API.
- Publish updates atomically:
 - build `nextParamSchemas = buildParamSchemas(data)` first
 - only then assign `kbData = data` and `PARAM_SCHEMAS = nextParamSchemas`
- Decide on a safe behavior for callers before KB is ready:
 - either block (make validation async or gate job submission until ready), or
 - explicitly surface a warning/error that KB validation is unavailable (not silent).
- If the async import fails, record the failure and allow a later retry (don’t permanently degrade with no signal).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context used
✅ Compliance rules (platform): 24 rules
✅ REVIEW.md
Review mode: ⚖️ Balanced: This is a behavior-changing bundle/build optimization across several paths, including lazy loading, async schema initialization, and dependency externalization; it carries real runtime and deployment risk, but not enough dense independent logic to justify extended review.

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread vite.config.ts
Comment thread src/lib/schemaEngine.ts Outdated
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo Fixer

✅ Committed (2) · ☑ Fixed (2)

Grey Divider

Commits pushed directly to this PR — no separate fix PR opened.

Process — 2 fixed
  • ☑ Fixed: External ORT import breaks
  • ☑ Fixed: KB load skips validation

Comment thread src/lib/schemaEngine.ts

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
package.json (1)

74-74: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Regenerate pnpm-lock.yaml before merge.

Line 74 removes motion from package.json, but the lockfile still declares it. pnpm install --frozen-lockfile will reject this manifest and lockfile mismatch before CI can build or test the project.

Regenerate and commit pnpm-lock.yaml with pnpm 11.17. Do not use npm install.

Based on external tooling, pnpm-lock.yaml still declares motion.
As per coding guidelines, use pnpm 11.17 for package management.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 74, Regenerate pnpm-lock.yaml with pnpm 11.17 after
removing motion from the package manifest, ensuring the lockfile no longer
declares motion and matches package.json. Use pnpm rather than npm, and commit
the updated lockfile so frozen-lockfile installs succeed.

Sources: Coding guidelines, MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/App.tsx`:
- Around line 371-386: Update the section rendering in Dashboard’s SECTIONS.map
so IHVIntegrationPanel and ExecutionWorkspace are not mounted for inactive
sections. Keep their section containers and render each lazy panel only when its
section is active or has entered the viewport prefetch boundary, preserving the
existing ErrorBoundary and Suspense wrappers.

In `@src/lib/schemaEngine.ts`:
- Around line 103-113: Update the rejection handler in the KB load promise chain
to set kbLoadPromise to null after retaining kbLoadError, so kbReady() invokes
loadKb() and retries the dynamic import instead of returning the cached rejected
promise.
- Around line 116-123: Update the asynchronous validation and pass-analysis
flows, including validateRecipeSchema(), validatePassConfig(), getPassSchema(),
isKnownPass(), and buildRecipeFromState(), to await kbReady() before producing
validation or pass-chain results. Ensure synchronous-only consumers continue
returning the typed “knowledge base unavailable” state rather than treating
catalog-only data as a valid answer, and preserve the existing initial load
trigger.

---

Outside diff comments:
In `@package.json`:
- Line 74: Regenerate pnpm-lock.yaml with pnpm 11.17 after removing motion from
the package manifest, ensuring the lockfile no longer declares motion and
matches package.json. Use pnpm rather than npm, and commit the updated lockfile
so frozen-lockfile installs succeed.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 647eb97b-7c9c-406e-baae-ffdbccdba585

📥 Commits

Reviewing files that changed from the base of the PR and between 0c41033 and 210d192.

📒 Files selected for processing (5)
  • package.json
  • src/App.tsx
  • src/lib/passCatalog.ts
  • src/lib/schemaEngine.ts
  • vite.config.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • tonythethompson/QuickShell (manual)
  • tonythethompson/numan (manual)
  • tonythethompson/dependency-chain-substrate (manual)
💤 Files with no reviewable changes (1)
  • src/lib/passCatalog.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: olive-pass-availability
  • GitHub Check: python-tests
  • GitHub Check: Greptile Review
⚠️ CI failures not shown inline (1)

Commit Status: Vercel: Vercel

Conclusion: failure

Deployment has failed — run this Vercel CLI command: npx vercel inspect dpl_2EGNrb7FpXYsJUzfkcgmbgLn8k3v --logs
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (CLAUDE.md)

Use pnpm for project package management and commands; do not use npm install, which is blocked by a preinstall guard.

Files:

  • package.json
  • vite.config.ts
  • src/lib/schemaEngine.ts
  • src/App.tsx
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Do not run real Olive jobs in CI or VMs because they download models and CUDA wheels.

**/*: Do not run real Olive GPU workloads or model downloads in CI; use mocks or CPU-only flows.
When changing the threat model or fixing critical findings, update the review snapshot and document the local-trust model in user-facing documentation.

Files:

  • package.json
  • vite.config.ts
  • src/lib/schemaEngine.ts
  • src/App.tsx
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use pnpm 11.17 as the package manager; do not use npm install because the preinstall guard blocks it.

Files:

  • package.json
  • vite.config.ts
  • src/lib/schemaEngine.ts
  • src/App.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx,js,jsx}: Place imports at the top of modules; use inline imports only for a documented circular dependency.
Run linting and ensure typecheck-related CI checks pass before submitting changes.
For UI or server changes, manually smoke-test development startup, recipe loading/building, validation banners, and live execution when execution behavior is touched.

Files:

  • vite.config.ts
  • src/lib/schemaEngine.ts
  • src/App.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Account for React 19 and Vite 8 breaking changes rather than assuming conventions from earlier major versions; consult current documentation when API shapes are uncertain.
Do not trigger live Olive execution or batch runs in CI or virtual machines; limit CI validation to CPU-only recipe building, JSON export, and validation.

Resolve ESLint errors; warnings are acceptable within the configured maximum of 20, but non-zero lint failures and reported errors must not be ignored.

Files:

  • vite.config.ts
  • src/lib/schemaEngine.ts
  • src/App.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

src/**/*.{ts,tsx}: Match existing naming, file layout, and TypeScript patterns in src/.
Put shared recipe logic in src/lib/, especially pipelineValidation.ts, oliveRecipeBuilder.ts, and recipePipeline.ts.

src/**/*.{ts,tsx}: Route every UI state mutation through commitUiStateUpdate in src/lib/pipelineValidation.ts so invariants are enforced; use replaceState for recipe imports and preset loads.
Use usePipelineState() as the shorthand hook for reading pipeline state.
Avoid export * barrel imports; import directly from the actual module file.

Follow the React conventions in docs/REACT_BEST_PRACTICES.md, especially eliminating waterfalls, avoiding barrel imports, and deferring non-critical third-party libraries.

src/**/*.{ts,tsx}: Keep pipeline and recipe validation logic in shared libraries rather than duplicating it in IHV cell helpers or inspectors.
Keep the UI AI provider catalog synchronized with the server registry, preferably through a shared provider ID list or a synchronization test; register new providers in both places.
Add coverage for recipe-graph/ and under-tested libraries including passCatalog, oliveRecipeHub, jobHistoryStore, and vramEstimate.
Confirm whether EnterpriseInfraPanel and PerformanceMetrics are required; remove them if they are orphaned and not mounted.

Files:

  • src/lib/schemaEngine.ts
  • src/App.tsx
src/lib/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Run the relevant targeted unit tests when library code changes rather than unnecessarily running the full slow test suite locally; rely on CI for complete verification.

Files:

  • src/lib/schemaEngine.ts
🧠 Learnings (1)
📚 Learning: 2026-08-10T03:41:03.611Z
Learnt from: tonythethompson
Repo: tonythethompson/Olive-Studio PR: 203
File: src/components/features/input/GitHubRecipeSync.tsx:5-5
Timestamp: 2026-08-10T03:41:03.611Z
Learning: In the Olive-Studio repository, treat imports from the `@/components/ui` barrel as conforming to the established UI import convention. Do not flag these imports solely because a general guideline prefers importing from concrete modules.

Applied to files:

  • vite.config.ts
  • src/lib/schemaEngine.ts
  • src/App.tsx
🔍 Remote MCP Context7, DeepWiki, GitHub Copilot

Additional review context

  • Lockfile mismatch: package.json removes motion, but pnpm-lock.yaml still declares it. CI uses pnpm install --frozen-lockfile; the lockfile should be regenerated.
  • Lazy panels still mount initially: SECTIONS.map renders IHV and execution components regardless of activeView, so their lazy chunks may load on first render. Only the report modal is conditionally mounted.
  • KB readiness is incomplete: validation APIs explicitly report “knowledge base unavailable,” but synchronous getPassSchema, isKnownPass, and getKbMetadata still ignore readiness and can return empty/unknown results. These are used by pipelineValidation, while server preflight calls the synchronous recipe validator.
  • Retry behavior is not implemented: after loadKb() rejects, kbLoadPromise remains a rejected promise, so kbReady() returns it instead of starting a retry.
  • Externalization warning appears resolved: the final config uses external: []; affected browser modules remain bundled, and index.html has no import map. Earlier bot comments referenced a prior commit that externalized these dependencies.
  • DeepWiki: the repository was not indexed, so no additional architectural context was available.
🔇 Additional comments (3)
package.json (1)

8-8: LGTM!

vite.config.ts (1)

115-118: LGTM!

Also applies to: 128-129

src/App.tsx (1)

425-443: 🩺 Stability & Availability

Confirm application-level recovery for report modal chunk failures.

ReportIssueModal is lazy-loaded inside only Suspense; the root mount in src/main.tsx skips an ErrorBoundary. If the modal chunk rejects, the lazy import error can escape and close the report flow. Add a boundary or local recovered-error state that lets the user reopen/dismiss the report UI.

Comment thread src/App.tsx
Comment thread src/lib/schemaEngine.ts
Comment thread src/lib/schemaEngine.ts
jszip (96KB bundled) replaced with fflate (~8KB bundled) for the OWR
deployment bundle zip generation. Same functionality (create zip with
text files, generate blob for download), dramatically smaller.

Metric: client_js_bytes 1,712,620 → 1,625,154 (-87,466 bytes)
Cumulative: 2,655,341 → 1,625,154 (-1,030,187 bytes, -38.8%)
All 1,407 tests pass.
Reverting the bot's revert. These deps are:
- Only used in Playground panels (Arena, InBrowserValidation, WebGpuBenchmark)
- Already behind dynamic imports with graceful offline fallbacks
- 946KB combined that users who never open Playground never need

The app works fully without them — Arena tokenizer falls back to
prompt-derived encoding, Playground panels show loading state.

Metric: client_js_bytes 2,572,726 → 1,625,519 (-947,207 bytes)
Cumulative from baseline: 2,655,341 → 1,625,519 (-38.8%)
All 1,407 tests pass.
@tonythethompson tonythethompson changed the title perf: reduce client bundle size 35.5% (-943KB) perf: reduce client bundle size 38.8% (-1030KB) Aug 10, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/components/features/execute/ExecutionWorkspace.tsx (2)

396-429: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Add regression coverage for archive contents.

The current ExecutionWorkspace.test.tsx coverage checks only that the More menu exposes the OWR export action. It does not invoke asynchronous export or inspect the generated archive. Add tests for web and mobile bundles, including ort_config.json, onnx_model_manifest.json, README.txt, the platform-specific init file, and failure handling.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/features/execute/ExecutionWorkspace.tsx` around lines 396 -
429, Extend ExecutionWorkspace.test.tsx beyond the More-menu assertion by
invoking the asynchronous OWR export flow for both web and mobile targets and
inspecting the generated archive contents. Verify each bundle includes
ort_config.json, onnx_model_manifest.json, README.txt, and the correct
platform-specific web_init.js or mobile_init.kt file, and add coverage for the
export failure-handling path.

397-429: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Separate module-load and archive-generation errors.

The try block covers both await import("fflate") and file encoding/zipSync. If serialization or ZIP creation fails, the catch still displays "Couldn't load the ZIP module. Check your connection and try again." This gives incorrect recovery guidance. Use separate catches for module loading and archive generation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/features/execute/ExecutionWorkspace.tsx` around lines 397 -
429, Separate the dynamic fflate import from archive construction in the
execution flow around zipSync and strToU8. Catch module-load failures with the
existing connection guidance, then wrap file serialization and zipSync in a
second try/catch with an archive-generation-specific error message and recovery
guidance.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 73: Update pnpm-lock.yaml to synchronize the root importer with
package.json: add the fflate@^0.8.3 specifier and remove the unreferenced
jszip@^3.10.1 and motion@^13.0.0 specifiers, using pnpm install --lockfile-only.

In `@src/components/features/execute/ExecutionWorkspace.tsx`:
- Line 398: Document the inline fflate import used in the click-handler
bundle-splitting flow, adding the repository-approved lazy-loading exception
near the import. Alternatively, move zipSync and strToU8 to module scope while
preserving the existing execution behavior.

---

Outside diff comments:
In `@src/components/features/execute/ExecutionWorkspace.tsx`:
- Around line 396-429: Extend ExecutionWorkspace.test.tsx beyond the More-menu
assertion by invoking the asynchronous OWR export flow for both web and mobile
targets and inspecting the generated archive contents. Verify each bundle
includes ort_config.json, onnx_model_manifest.json, README.txt, and the correct
platform-specific web_init.js or mobile_init.kt file, and add coverage for the
export failure-handling path.
- Around line 397-429: Separate the dynamic fflate import from archive
construction in the execution flow around zipSync and strToU8. Catch module-load
failures with the existing connection guidance, then wrap file serialization and
zipSync in a second try/catch with an archive-generation-specific error message
and recovery guidance.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 898aef67-6040-43c9-b42a-e2684abdae7e

📥 Commits

Reviewing files that changed from the base of the PR and between 210d192 and 0e28dfa.

📒 Files selected for processing (2)
  • package.json
  • src/components/features/execute/ExecutionWorkspace.tsx
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • tonythethompson/QuickShell (manual)
  • tonythethompson/numan (manual)
  • tonythethompson/dependency-chain-substrate (manual)
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: Greptile Review
  • GitHub Check: olive-pass-availability
  • GitHub Check: security
  • GitHub Check: python-tests
  • GitHub Check: docker-build
⚠️ CI failures not shown inline (1)

Commit Status: Vercel: Vercel

Conclusion: failure

Deployment has failed — run this Vercel CLI command: npx vercel inspect dpl_3cKrpaN5LmfNVgBSV2ebbjV12aCg --logs
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx,json,md,yaml,yml}

📄 CodeRabbit inference engine (CLAUDE.md)

Use pnpm for project package management and commands; do not use npm install, which is blocked by a preinstall guard.

Files:

  • package.json
  • src/components/features/execute/ExecutionWorkspace.tsx
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Do not run real Olive jobs in CI or VMs because they download models and CUDA wheels.

**/*: Do not run real Olive GPU workloads or model downloads in CI; use mocks or CPU-only flows.
When changing the threat model or fixing critical findings, update the review snapshot and document the local-trust model in user-facing documentation.

Files:

  • package.json
  • src/components/features/execute/ExecutionWorkspace.tsx
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use pnpm 11.17 as the package manager; do not use npm install because the preinstall guard blocks it.

Files:

  • package.json
  • src/components/features/execute/ExecutionWorkspace.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

src/**/*.{ts,tsx}: Match existing naming, file layout, and TypeScript patterns in src/.
Put shared recipe logic in src/lib/, especially pipelineValidation.ts, oliveRecipeBuilder.ts, and recipePipeline.ts.

src/**/*.{ts,tsx}: Route every UI state mutation through commitUiStateUpdate in src/lib/pipelineValidation.ts so invariants are enforced; use replaceState for recipe imports and preset loads.
Use usePipelineState() as the shorthand hook for reading pipeline state.
Avoid export * barrel imports; import directly from the actual module file.

Follow the React conventions in docs/REACT_BEST_PRACTICES.md, especially eliminating waterfalls, avoiding barrel imports, and deferring non-critical third-party libraries.

src/**/*.{ts,tsx}: Keep pipeline and recipe validation logic in shared libraries rather than duplicating it in IHV cell helpers or inspectors.
Keep the UI AI provider catalog synchronized with the server registry, preferably through a shared provider ID list or a synchronization test; register new providers in both places.
Add coverage for recipe-graph/ and under-tested libraries including passCatalog, oliveRecipeHub, jobHistoryStore, and vramEstimate.
Confirm whether EnterpriseInfraPanel and PerformanceMetrics are required; remove them if they are orphaned and not mounted.

Files:

  • src/components/features/execute/ExecutionWorkspace.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx,js,jsx}: Place imports at the top of modules; use inline imports only for a documented circular dependency.
Run linting and ensure typecheck-related CI checks pass before submitting changes.
For UI or server changes, manually smoke-test development startup, recipe loading/building, validation banners, and live execution when execution behavior is touched.

Files:

  • src/components/features/execute/ExecutionWorkspace.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Account for React 19 and Vite 8 breaking changes rather than assuming conventions from earlier major versions; consult current documentation when API shapes are uncertain.
Do not trigger live Olive execution or batch runs in CI or virtual machines; limit CI validation to CPU-only recipe building, JSON export, and validation.

Resolve ESLint errors; warnings are acceptable within the configured maximum of 20, but non-zero lint failures and reported errors must not be ignored.

Files:

  • src/components/features/execute/ExecutionWorkspace.tsx
🧠 Learnings (2)
📚 Learning: 2026-08-04T12:36:02.655Z
Learnt from: tonythethompson
Repo: tonythethompson/Olive-Studio PR: 97
File: src/components/features/BatchProcessingPanel.tsx:0-0
Timestamp: 2026-08-04T12:36:02.655Z
Learning: When updating pipeline state through usePipelineState().setState in React components, do not wrap the update in another commitUiStateUpdate call. PipelineStore.setState already invokes commitUiStateUpdate(store.state, partial) to enforce UI state invariants; a second commit can duplicate the operation and merge against a stale component state snapshot.

Applied to files:

  • src/components/features/execute/ExecutionWorkspace.tsx
📚 Learning: 2026-08-10T03:41:03.611Z
Learnt from: tonythethompson
Repo: tonythethompson/Olive-Studio PR: 203
File: src/components/features/input/GitHubRecipeSync.tsx:5-5
Timestamp: 2026-08-10T03:41:03.611Z
Learning: In the Olive-Studio repository, treat imports from the `@/components/ui` barrel as conforming to the established UI import convention. Do not flag these imports solely because a general guideline prefers importing from concrete modules.

Applied to files:

  • src/components/features/execute/ExecutionWorkspace.tsx
🔍 Remote MCP Context7, GitHub Copilot

Additional review context

  • Knowledge-base retry is not implemented: loadKb() stores its rejected promise in kbLoadPromise; subsequent kbReady() calls return the same rejected promise rather than starting a new load. This contradicts the retry claim in the comment.
  • Synchronous API behavior remains inconsistent: the PR adds unavailable-state handling only to validatePassConfig and validateRecipeSchema, while getPassSchema, isKnownPass, and getKbMetadata still proceed with empty maps before loading completes.
  • ZIP conversion is API-compatible: fflate.zipSync() returns Uint8Array<ArrayBuffer>, matching the new Blob-based download approach.
  • Dependency verification: the PR changes package.json to add fflate and remove jszip/motion; the checked base-file snapshot still contains the old dependencies, so the lockfile should be checked for synchronization.,
🔇 Additional comments (3)
src/components/features/execute/ExecutionWorkspace.tsx (2)

393-394: LGTM!


437-437: LGTM!

package.json (1)

8-10: LGTM!

Comment thread package.json
Comment thread src/components/features/execute/ExecutionWorkspace.tsx Outdated
Comment thread src/lib/schemaEngine.ts
Addresses CodeRabbit finding: if the lazy-loaded modal chunk rejects,
the error now catches in the ErrorBoundary rather than escaping and
breaking the report flow. The onReportError callback closes the modal
state so the user can reopen it.
Addresses CodeRabbit finding: previously both fflate import failure and
zip creation failure showed the same 'Couldn't load ZIP module' message.
Now module-load errors get connection guidance, while archive-generation
errors get their own message.
Addresses Codex review: externalized packages left bare specifiers
(import('onnxruntime-web')) that browsers couldn't resolve. The import
map maps them to esm.sh CDN URLs so Playground panels load correctly.

These only activate when a user opens Arena/Inference/Benchmark panels;
the rest of the app works without any network dependency on esm.sh.
Tests that call synchronous validation now await kbReady() in beforeAll
so the passes.json dynamic import resolves before assertions run.

Also fixed test states that triggered unrelated pass-chain-mismatch
validation by disabling conversion passes when testing provider-specific
behavior (the tests are about provider validation, not pass-chain format
compatibility).

All 1,018 unit tests pass.
Validates the fflate-based archive produces correct, decompressible ZIPs:
- Web platform includes ort_config.json, manifest, web_init.js, README
- Mobile platform includes ort_config.json, manifest, mobile_init.kt, README
- JSON content integrity preserved through zip/unzip round-trip
- Text content preserved through zip/unzip round-trip
- Blob creation works (download flow)
- Edge cases: empty content, unicode characters

7 new tests, all passing.
Comment thread index.html
The validation script calls getPipelineValidation synchronously, which
now requires the KB to be loaded first (async dynamic import). Without
this await, the pass-chain validation fires with empty schemas and
incorrectly reports blocking issues.
The import map resolves @huggingface/transformers and onnxruntime-web to
esm.sh CDN. Without this CSP allowlist entry, the browser blocks the
module load when users open Playground panels.
When the passes.json dynamic import is pending (not failed), synchronous
validation now gracefully skips KB-dependent checks instead of immediately
returning 'knowledge base unavailable'. This prevents rejecting valid
recipes during the brief startup window before the KB load completes.

Only report unavailability when the load has actually FAILED (kbLoadError
is set). Pending loads get optimistic treatment — structural validation
still runs, parameter/schema validation is skipped until ready.
@tonythethompson tonythethompson changed the title perf: reduce client bundle size 38.8% (-1030KB) perf: reduce client bundle size 37.9% (-1007KB) Aug 10, 2026
@tonythethompson
tonythethompson merged commit 91155c3 into main Aug 10, 2026
13 checks passed
@tonythethompson
tonythethompson deleted the perf/bundle-size-optimization branch August 10, 2026 07:52
@linear-code

linear-code Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

OLI-84

tonythethompson added a commit that referenced this pull request Aug 10, 2026
Introduce the data/ruler bundle-size measurement setup, including the calibrated ruler spec in JSON/YAML, baseline and calibration snapshots, a canary script to validate the harness, and design notes documenting guardrails and the chosen metric. Also add discovery reports capturing initial optimization opportunities and a post-PR #219 baseline showing the reduced client bundle size.

This branch was successfully deployed

1 active deployment
Preview — 00f69d9e Deployed Aug 10, 2026 by vercel[bot]
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.

1 participant