Skip to content

[codex] Fix Prism startup crashes#92

Merged
kburger merged 10 commits into
mainfrom
codex/prism-white-screen-fix
Jun 22, 2026
Merged

[codex] Fix Prism startup crashes#92
kburger merged 10 commits into
mainfrom
codex/prism-white-screen-fix

Conversation

@hcvdwerf

@hcvdwerf hcvdwerf commented Jun 18, 2026

Copy link
Copy Markdown

What changed

  • Removed the Prism side-effect imports from src/main.ts that could crash the production bundle under the current Vite/Rolldown build.
  • Registered the Turtle and SPARQL grammars locally in src/prism-languages.ts so syntax highlighting still works without relying on a global Prism symbol.
  • Added a safe fallback in PrismEditor and hardened the footer/version info rendering against missing API data.

Why

The latest npm/tooling combination could produce a production bundle that referenced Prism before it existed, which caused the white screen / startup crash.

Validation

  • npm run lint
  • npm run build
  • Local browser check on http://127.0.0.1:8080/ showing the app shell renders without the Prism crash

Summary by Sourcery

Harden Prism-based syntax highlighting and version info rendering to avoid startup crashes and failures when API data or grammars are missing.

Bug Fixes:

  • Prevent Prism editor from crashing when a language grammar is unavailable by falling back to escaped plain text and handling highlight errors gracefully.
  • Avoid footer and version info components throwing when backend info API fails or returns missing fields by defaulting to safe empty values and placeholder text.

Enhancements:

  • Introduce local registration of Turtle and SPARQL Prism grammars to remove reliance on global side effects and ensure syntax highlighting remains functional.

@kburger

kburger commented Jun 18, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sourcery-ai

sourcery-ai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors Prism language registration into a local module, adds defensive highlighting fallbacks in PrismEditor, and makes footer/version info retrieval and rendering resilient to missing or failing API data.

Sequence diagram for resilient footer info loading and version display

sequenceDiagram
  participant FdpFooter
  participant api_info as api.info
  participant VersionInfoTable

  FdpFooter->>FdpFooter: fetchData()
  alt [API ok]
    FdpFooter->>api_info: getInfo()
    api_info-->>FdpFooter: response.data
    FdpFooter->>FdpFooter: info = { version: data.version||"", builtAt: data.builtAt||"" }
  else [API error]
    FdpFooter->>FdpFooter: console.error(...)
  end

  FdpFooter->>VersionInfoTable: props { title, version?, builtAt? }
  VersionInfoTable->>VersionInfoTable: safeVersion = version||""
  VersionInfoTable->>VersionInfoTable: builtAtFormatted()
Loading

File-Level Changes

Change Details Files
Make Prism-based highlighting robust against missing grammars and runtime errors.
  • Import a local registerPrismLanguages helper into PrismEditor and invoke it with the Prism instance so Turtle/SPARQL grammars are always registered at component usage time.
  • Introduce an escapeHtml helper that safely escapes code to plain text HTML when syntax highlighting cannot be performed.
  • Change the highlight function to use a language-specific grammar only when present, falling back to escaped plain text if the grammar is missing or Prism.highlight throws, and log a warning on highlight failures.
src/components/PrismEditor/index.vue
src/prism-languages.ts
Register Turtle and SPARQL Prism grammars locally instead of relying on global side-effect imports.
  • Create a prism-languages module that defines registerTurtle and registerSparql helpers which set up Prism.languages.turtle, .trig, .sparql and .rq only if they are not already defined.
  • Reuse the Turtle grammar for TRIG and extend it for SPARQL, inserting SPARQL-specific keywords and variable tokenization before punctuation in the language definition.
  • Export a registerPrismLanguages function that registers both Turtle and SPARQL grammars so components can explicitly initialize Prism languages without global side effects.
src/prism-languages.ts
Harden footer and version info rendering against missing or failing backend data.
  • Wrap the info API call in FdpFooter in a try/catch and log a descriptive error if it fails, instead of letting the error propagate and crash the app.
  • Normalize the footer info payload by assigning empty strings as defaults when version or builtAt fields are missing from the API response.
  • Relax VersionInfoTable props to make version and builtAt optional with default empty strings, and compute a safeVersion value used in the template to avoid slicing undefined.
  • Update builtAtFormatted to show a formatted timestamp only when builtAt exists, otherwise display 'Unknown' as a fallback label.
src/components/FdpFooter/index.vue
src/components/VersionInfoTable/index.vue

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@hcvdwerf hcvdwerf marked this pull request as ready for review June 18, 2026 09:21

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/components/FdpFooter/index.vue Outdated
Comment thread src/prism-languages.ts Outdated
Comment thread src/components/VersionInfoTable/index.vue Outdated

@kburger kburger 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.

Very clean!

@kburger kburger merged commit beeb34e into main Jun 22, 2026
5 checks passed
@kburger kburger deleted the codex/prism-white-screen-fix branch June 22, 2026 11:49
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