Skip to content

Fixes#890

Merged
hatemhosny merged 7 commits intodevelopfrom
fixes
Oct 4, 2025
Merged

Fixes#890
hatemhosny merged 7 commits intodevelopfrom
fixes

Conversation

@hatemhosny
Copy link
Copy Markdown
Collaborator

@hatemhosny hatemhosny commented Oct 4, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Sandbox now falls back to the latest version’s index page when a file is missing, reducing unexpected 404s and improving reliability.
    • Streamlined file serving behavior to handle missing assets more gracefully.
  • Style

    • Improved theme color selector gradient for better visual coverage.
  • Chores

    • Upgraded Node.js runtime to 24.4.1 and updated Docker base images.
    • Added configurable NODE_OPTIONS and LOCAL_MODULES flags; propagated NODE_OPTIONS to services.
    • Minor docker-compose formatting adjustments (no functional impact).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 4, 2025

Walkthrough

Node.js version bumped to v24.4.1 across env and Docker. docker-compose adds LOCAL_MODULES and NODE_OPTIONS flags and propagates NODE_OPTIONS. Server code shifts key handlers to async I/O, adjusts sandbox static serving with latest-version resolution and index fallback. Minor SCSS gradient tweak.

Changes

Cohort / File(s) Summary of Changes
Environment & Containerization
\.nvmrc, Dockerfile, docker-compose.yml
Bump Node base from 24.1.0-alpine3.21 to 24.4.1-alpine3.22; add ARG NODE_OPTIONS; add LOCAL_MODULES and NODE_OPTIONS flags; propagate NODE_OPTIONS to services; string quoting normalized.
Server Async I/O & Sandbox Flow
server/src/broadcast/index.ts, server/src/sandbox.ts, server/src/utils.ts
Convert sync file reads to async; sandbox becomes async, computes latest version dir, normalizes paths, and falls back to latest index.html on missing files; simplify getFileContent with try/catch fallback to 404.html.
Styles
src/livecodes/styles/inc-menu.scss
Adjust conic-gradient stop for theme-color-custom label (red coverage extended).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant S as Server
  participant FS as FileSystem

  rect rgb(240,248,255)
  note over C,S: GET /channels/:id (broadcast page)
  C->>S: GET /channels/:id
  S->>FS: readFile(channelHtmlPath)
  alt file found
    FS-->>S: HTML content
    S-->>C: 200 HTML
  else not found
    S-->>C: 404
  end
  end

  %% Sandbox static serving with latest-version fallback
  rect rgb(245,255,245)
  note over C,S: GET /sandbox/* (async, latest-version resolution)
  C->>S: GET /sandbox/{path}
  S->>FS: readdir(sandboxRoot) to find latest vN
  S->>FS: readFile(resolvedPath)
  alt file found
    FS-->>S: Content
    S-->>C: 200 (content-type per file)
  else not found
    note right of S: onError fallback
    S->>FS: readFile(latestVersion/index.html)
    FS-->>S: HTML content
    S-->>C: 200 text/html
  end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

I thump my paws: new Node to run,
Async winds, the files all spun.
Sandbox paths find “v”s in line,
Fallbacks bloom—index will shine.
Gradients swirl a brighter hue—
Ship it swift, with carrots too! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “Fixes” is overly generic and does not convey the main changes in the pull request, making it unclear what has been updated or why the PR exists. Please revise the title to briefly summarize the primary change—such as “Upgrade Node to v24.4.1 and convert file operations to async”—so reviewers can immediately understand the PR’s purpose.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fixes

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 and usage tips.

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 4, 2025

Deploy Preview for livecodes ready!

Name Link
🔨 Latest commit f9e6adf
🔍 Latest deploy log https://app.netlify.com/projects/livecodes/deploys/68e165a49ecee30008cee6e3
😎 Deploy Preview https://deploy-preview-890--livecodes.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 4, 2025

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 4, 2025

Size Change: -215 B (-0.02%)

Total Size: 955 kB

ℹ️ View Unchanged
Filename Size Change
./build/404.html 1 kB 0 B
./build/app.html 250 B 0 B
./build/index.html 2.46 kB +1 B (+0.04%)
./build/livecodes/app.js 111 kB -26 B (-0.02%)
./build/livecodes/app.css 22.4 kB -4 B (-0.02%)
./build/livecodes/assets.js 8.62 kB -9 B (-0.1%)
./build/livecodes/assets/noop.js 18 B 0 B
./build/livecodes/assets/templates/diagrams-starter.html 2.19 kB 0 B
./build/livecodes/backup.js 3.73 kB +17 B (+0.46%)
./build/livecodes/blockly.js 13.3 kB 0 B
./build/livecodes/broadcast.js 1.19 kB +1 B (+0.08%)
./build/livecodes/bundle-types.js 4.37 kB 0 B
./build/livecodes/code-to-image.js 9.11 kB +17 B (+0.19%)
./build/livecodes/codejar.js 17.6 kB 0 B
./build/livecodes/codemirror.js 6.33 kB 0 B
./build/livecodes/compile.page.js 2.39 kB 0 B
./build/livecodes/compile.worker.js 14.2 kB 0 B
./build/livecodes/compiler-utils.js 3.16 kB 0 B
./build/livecodes/custom-editor-utils.js 198 B 0 B
./build/livecodes/deploy.js 6.87 kB -30 B (-0.43%)
./build/livecodes/editor-settings.js 17.7 kB -42 B (-0.24%)
./build/livecodes/embed-ui.js 5.55 kB +2 B (+0.04%)
./build/livecodes/embed.js 89.4 kB +24 B (+0.03%)
./build/livecodes/export.js 3.89 kB 0 B
./build/livecodes/firebase.js 22.7 kB 0 B
./build/livecodes/format.worker.js 13.4 kB 0 B
./build/livecodes/google-fonts.js 7.12 kB 0 B
./build/livecodes/headless.js 78.2 kB -140 B (-0.18%)
./build/livecodes/i18n-ar-language-info.json 5.23 kB 0 B
./build/livecodes/i18n-ar-translation.json 9.33 kB 0 B
./build/livecodes/i18n-de-language-info.json 5.25 kB 0 B
./build/livecodes/i18n-de-translation.json 9.44 kB 0 B
./build/livecodes/i18n-en-language-info.json 4.53 kB 0 B
./build/livecodes/i18n-en-translation.json 8.03 kB 0 B
./build/livecodes/i18n-es-language-info.json 5 kB 0 B
./build/livecodes/i18n-es-translation.json 9.17 kB 0 B
./build/livecodes/i18n-fa-language-info.json 5.35 kB 0 B
./build/livecodes/i18n-fa-translation.json 9.48 kB 0 B
./build/livecodes/i18n-fr-language-info.json 5.17 kB 0 B
./build/livecodes/i18n-fr-translation.json 9.42 kB 0 B
./build/livecodes/i18n-hi-language-info.json 5.78 kB 0 B
./build/livecodes/i18n-hi-translation.json 9.95 kB 0 B
./build/livecodes/i18n-it-language-info.json 5.04 kB 0 B
./build/livecodes/i18n-it-translation.json 9.26 kB 0 B
./build/livecodes/i18n-ja-language-info.json 5.57 kB 0 B
./build/livecodes/i18n-ja-translation.json 9.61 kB 0 B
./build/livecodes/i18n-pt-language-info.json 5.05 kB 0 B
./build/livecodes/i18n-pt-translation.json 9.35 kB 0 B
./build/livecodes/i18n-ru-language-info.json 5.56 kB 0 B
./build/livecodes/i18n-ru-translation.json 10.3 kB 0 B
./build/livecodes/i18n-ur-language-info.json 5.81 kB 0 B
./build/livecodes/i18n-ur-translation.json 9.78 kB 0 B
./build/livecodes/i18n-zh-CN-language-info.json 4.9 kB 0 B
./build/livecodes/i18n-zh-CN-translation.json 8.64 kB 0 B
./build/livecodes/i18n.js 20.2 kB -20 B (-0.1%)
./build/livecodes/import-src.js 16 kB 0 B
./build/livecodes/import.js 14.5 kB -29 B (-0.2%)
./build/livecodes/index.js 5.35 kB +4 B (+0.07%)
./build/livecodes/lang-art-template-compiler.js 1.65 kB 0 B
./build/livecodes/lang-assemblyscript-compiler.js 290 B 0 B
./build/livecodes/lang-assemblyscript-script.js 386 B 0 B
./build/livecodes/lang-astro-compiler.js 2.34 kB 0 B
./build/livecodes/lang-clio-compiler.js 1.55 kB 0 B
./build/livecodes/lang-commonlisp-script.js 123 B 0 B
./build/livecodes/lang-cpp-script.js 1.75 kB 0 B
./build/livecodes/lang-cpp-wasm-script.js 2.84 kB 0 B
./build/livecodes/lang-csharp-wasm-script.js 2.18 kB 0 B
./build/livecodes/lang-diagrams-compiler-esm.js 5.09 kB 0 B
./build/livecodes/lang-dot-compiler.js 1.66 kB 0 B
./build/livecodes/lang-ejs-compiler.js 1.63 kB 0 B
./build/livecodes/lang-eta-compiler.js 1.65 kB 0 B
./build/livecodes/lang-fennel-compiler.js 1.61 kB 0 B
./build/livecodes/lang-gleam-compiler.js 3.09 kB 0 B
./build/livecodes/lang-go-wasm-script.js 3.26 kB 0 B
./build/livecodes/lang-haml-compiler.js 1.65 kB 0 B
./build/livecodes/lang-handlebars-compiler.js 1.92 kB 0 B
./build/livecodes/lang-imba-compiler.js 147 B 0 B
./build/livecodes/lang-java-script.js 4.05 kB 0 B
./build/livecodes/lang-jinja-compiler.js 1.65 kB 0 B
./build/livecodes/lang-julia-script.js 3.3 kB 0 B
./build/livecodes/lang-liquid-compiler.js 1.68 kB 0 B
./build/livecodes/lang-lua-wasm-script.js 205 B 0 B
./build/livecodes/lang-malina-compiler.js 2.96 kB 0 B
./build/livecodes/lang-mustache-compiler.js 1.65 kB 0 B
./build/livecodes/lang-nunjucks-compiler.js 1.93 kB 0 B
./build/livecodes/lang-perl-script.js 268 B 0 B
./build/livecodes/lang-php-wasm-script.js 347 B 0 B
./build/livecodes/lang-postgresql-compiler-esm.js 1.73 kB 0 B
./build/livecodes/lang-prolog-script.js 204 B 0 B
./build/livecodes/lang-pug-compiler.js 371 B 0 B
./build/livecodes/lang-python-wasm-script.js 1.86 kB 0 B
./build/livecodes/lang-r-script-esm.js 2.44 kB 0 B
./build/livecodes/lang-rescript-compiler-esm.js 2.16 kB 0 B
./build/livecodes/lang-rescript-formatter.js 1.52 kB 0 B
./build/livecodes/lang-riot-compiler.js 2.81 kB 0 B
./build/livecodes/lang-ruby-wasm-script.js 1.71 kB 0 B
./build/livecodes/lang-scss-compiler.js 1.71 kB 0 B
./build/livecodes/lang-solid-compiler.js 263 B 0 B
./build/livecodes/lang-sql-compiler.js 1.64 kB 0 B
./build/livecodes/lang-sql-script.js 1.95 kB 0 B
./build/livecodes/lang-svelte-compiler.js 4.69 kB 0 B
./build/livecodes/lang-tcl-script.js 1.82 kB 0 B
./build/livecodes/lang-teal-compiler.js 1.72 kB 0 B
./build/livecodes/lang-twig-compiler.js 1.64 kB 0 B
./build/livecodes/lang-vento-compiler.js 1.68 kB 0 B
./build/livecodes/lang-vue-compiler.js 6.09 kB 0 B
./build/livecodes/lang-vue2-compiler.js 3.47 kB 0 B
./build/livecodes/lang-wat-compiler.js 348 B 0 B
./build/livecodes/lang-wat-script.js 1.58 kB 0 B
./build/livecodes/language-info.js 7.72 kB +13 B (+0.17%)
./build/livecodes/monaco-lang-astro.js 947 B 0 B
./build/livecodes/monaco-lang-clio.js 639 B 0 B
./build/livecodes/monaco-lang-imba.js 7.35 kB 0 B
./build/livecodes/monaco-lang-wat.js 2.46 kB 0 B
./build/livecodes/monaco.js 10.1 kB 0 B
./build/livecodes/open.js 6.2 kB -1 B (-0.02%)
./build/livecodes/processor-lightningcss-compiler.js 1.88 kB 0 B
./build/livecodes/processor-postcss-compiler.js 2.02 kB 0 B
./build/livecodes/processor-tailwindcss-compiler.js 5.19 kB 0 B
./build/livecodes/processor-unocss-compiler.js 355 B 0 B
./build/livecodes/processor-windicss-compiler.js 450 B 0 B
./build/livecodes/quill.css 697 B 0 B
./build/livecodes/quill.js 5.76 kB 0 B
./build/livecodes/resources.js 3.45 kB +15 B (+0.44%)
./build/livecodes/result-utils.js 1.17 kB 0 B
./build/livecodes/share.js 3.81 kB -2 B (-0.05%)
./build/livecodes/snippets.js 6.05 kB -5 B (-0.08%)
./build/livecodes/sync-ui.js 3.25 kB -1 B (-0.03%)
./build/livecodes/sync.js 3.52 kB 0 B
./build/livecodes/sync.worker.js 29.7 kB 0 B
./build/livecodes/templates.js 25.4 kB 0 B
./build/sdk/livecodes.js 3.96 kB 0 B
./build/sdk/livecodes.umd.js 4.02 kB 0 B
./build/sdk/package.json 293 B 0 B
./build/sdk/react.js 4.24 kB 0 B
./build/sdk/vue.js 4.36 kB 0 B

compressed-size-action

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b94bd82 and f9e6adf.

📒 Files selected for processing (7)
  • .nvmrc (1 hunks)
  • Dockerfile (2 hunks)
  • docker-compose.yml (3 hunks)
  • server/src/broadcast/index.ts (1 hunks)
  • server/src/sandbox.ts (1 hunks)
  • server/src/utils.ts (2 hunks)
  • src/livecodes/styles/inc-menu.scss (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
server/src/broadcast/index.ts (1)
server/src/app.ts (1)
  • app (13-13)
server/src/sandbox.ts (1)
server/src/utils.ts (1)
  • dirname (10-10)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Redirect rules - livecodes
  • GitHub Check: Header rules - livecodes
  • GitHub Check: Pages changed - livecodes
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: tests (18.x, 2)
  • GitHub Check: tests (18.x, 4)
  • GitHub Check: tests (18.x, 1)
  • GitHub Check: tests (18.x, 5)
  • GitHub Check: tests (18.x, 3)
  • GitHub Check: build
  • GitHub Check: build (18.x)
  • GitHub Check: Cloudflare Pages

Comment thread Dockerfile
Comment on lines +24 to 25
ARG NODE_OPTIONS

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

NODE_OPTIONS build arg is never applied

Declaring ARG NODE_OPTIONS alone doesn’t expose it to the build environment, so npm ci/npm run build still run with the default heap limit. If the goal was to avoid Node OOMs during the build, this change has no effect. Please export it (or drop the arg). Example fix:

 ARG NODE_OPTIONS
+ENV NODE_OPTIONS=${NODE_OPTIONS}
🤖 Prompt for AI Agents
In Dockerfile around lines 24-25, ARG NODE_OPTIONS is declared but never applied
to the image environment so build steps still use default Node heap; change to
export the value by adding ENV NODE_OPTIONS=${NODE_OPTIONS} (or set a default
ARG and then ENV) so subsequent RUN npm ci / npm run build inherit the intended
NODE_OPTIONS, or remove the ARG if not needed.

Comment thread server/src/sandbox.ts
Comment on lines +16 to +24
const version =
dirs
.filter((v) => v.startsWith('v'))
.map((v) => Number(v.slice(1)))
.filter((v) => !Number.isNaN(v))
.sort((a, b) => b - a)
.map((v) => 'v' + v)
.pop() || '';
const sandboxVersionDir = path.resolve(sandboxDir, version);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Latest sandbox version detection is inverted

After sorting versions in descending order, calling .pop() returns the smallest entry, so the sandbox now serves the oldest bundle whenever multiple v* folders exist. Use .shift() (or grab index 0) to keep the newest directory.

-  const version =
-    dirs
-      .filter((v) => v.startsWith('v'))
-      .map((v) => Number(v.slice(1)))
-      .filter((v) => !Number.isNaN(v))
-      .sort((a, b) => b - a)
-      .map((v) => 'v' + v)
-      .pop() || '';
+  const version =
+    dirs
+      .filter((v) => v.startsWith('v'))
+      .map((v) => Number(v.slice(1)))
+      .filter((v) => !Number.isNaN(v))
+      .sort((a, b) => b - a)
+      .map((v) => 'v' + v)[0] || '';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const version =
dirs
.filter((v) => v.startsWith('v'))
.map((v) => Number(v.slice(1)))
.filter((v) => !Number.isNaN(v))
.sort((a, b) => b - a)
.map((v) => 'v' + v)
.pop() || '';
const sandboxVersionDir = path.resolve(sandboxDir, version);
const version =
dirs
.filter((v) => v.startsWith('v'))
.map((v) => Number(v.slice(1)))
.filter((v) => !Number.isNaN(v))
.sort((a, b) => b - a)
.map((v) => 'v' + v)[0] || '';
const sandboxVersionDir = path.resolve(sandboxDir, version);
🤖 Prompt for AI Agents
In server/src/sandbox.ts around lines 16 to 24, the code sorts version numbers
in descending order but then calls .pop(), which returns the smallest (oldest)
version; change that to .shift() (or use [0]) so the newest version is selected,
and keep the existing fallback to '' for the sandboxVersionDir resolution.

@hatemhosny hatemhosny merged commit 7f93fb4 into develop Oct 4, 2025
21 checks passed
@hatemhosny hatemhosny deleted the fixes branch October 4, 2025 18:47
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