feat(viewer): dark theme and syntax highlighting for tool content - #1098
Open
Benjamin-eecs wants to merge 2 commits into
Open
feat(viewer): dark theme and syntax highlighting for tool content#1098Benjamin-eecs wants to merge 2 commits into
Benjamin-eecs wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| _PAYLOAD_PLACEHOLDER = "__BENCHFLOW_PAYLOAD__" | ||
| _TITLE_PLACEHOLDER = "__BENCHFLOW_TITLE__" | ||
| _SCRIPT_ASSETS = ("viewer.js", "detail.js", "catalog.js", "boot.js") | ||
| _SCRIPT_ASSETS = ("theme.js", "viewer.js", "detail.js", "catalog.js", "boot.js") |
Contributor
There was a problem hiding this comment.
🔴 Every trajectory viewer fails during startup
The combined script reaches BF.theme before const BF initializes. A ReferenceError aborts startup, leaving every trajectory and catalog unrendered.
Suggested change
| _SCRIPT_ASSETS = ("theme.js", "viewer.js", "detail.js", "catalog.js", "boot.js") | |
| _SCRIPT_ASSETS = ("viewer.js", "theme.js", "detail.js", "catalog.js", "boot.js") |
Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment.
Fixed in 1cd670a: theme.js now loads after viewer.js and test_viewer_theme asserts the order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a dark theme and syntax highlighting to the interactive trajectory viewer.
theme.css: the existing light tokens stay the unconditional default; ahtml[data-theme="dark"]block overrides the same tokens (canonical, viewer aliases, tool-kind accents) and setscolor-scheme: dark. A page without the attribute renders exactly as before.template.html: a head script applies the stored choice (localStoragekeybf-theme) or the system preference before the stylesheet, so there is no flash; a toggle sits in the wordmark.theme.js(new): the toggle, plusBF.highlight, which colors a tool content block only when its language is known: a markdown fence tag, a diff signature, the first block of anexecutecard (bash, withpython - <<EOFheredoc bodies as Python), or the file extension in a read/edit title. Nothing is auto-detected, so plain logs stay plain. Blocks carrying redaction markers are left untouched.viewer.css: token color rules driven by--hl-*theme tokens; terminal blocks keep the dark palette in both themes.assets/vendor/highlight.min.js: highlight.js 11.9.0 common bundle (BSD-3, license file alongside), inlined byrender.pylike the other assets, so the page stays self-contained.Motivation and Context
Closes #1097. Reviewing long trajectories on the light page is tiring, and a multi-hundred-line heredoc inside an
executecard reads as one grey block. Both features are running on the FrontierPhysics deployment of this viewer.How Has This Been Tested?
tests/trajectories/test_viewer_theme.py: light-first token order, dark override contents, head script before the stylesheet, toggle present, vendored highlighter inlined before the app scripts, no CDN reference, rendered shell carries both themes.pytest tests/trajectories: 293 passed, 29 skipped (playwright absent).Types of changes
Checklist