feat(html): add --data-url flag to decouple benchmark UI#119
Merged
Conversation
Adds `vizb html --api <url>` mode so the generated HTML fetches benchmark JSON from a URL at runtime instead of embedding it. This keeps the output file at a fixed ~765KB regardless of benchmark data size. - `file` arg is now optional; `--api` alone produces a viewer HTML - URL must be http(s)://; validated before generation - Dashboard shows loading state while fetching and a clear error message on fetch failure (including CORS hint) - Default embed path (no --api) is byte-for-byte unchanged
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…tate - URL validation extracted to flagValidationRules (validateAPIURL) so it follows the same warn-and-reset pattern as all other flag validators; manual strings.HasPrefix check removed from runHTML - Loading state replaced with animate-pulse skeleton matching real layout (title, badge, description, chart card placeholders)
Exposes the --data-url/-U flag so CI workflows can generate an HTML that fetches benchmark JSON from a remote URL instead of embedding it. Resolve step now accepts data-url as a standalone input source.
.Version strips the v prefix; .Tag preserves it, matching the format returned by debug.ReadBuildInfo().
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.
Summary
vizb html --data-url <url>/-U— generated HTML fetches benchmark JSON from a URL at runtime instead of embedding it[file]arg becomes optional —--data-urlalone is sufficient, no file parse neededvizb html bench.json) is unchangedChanges
Go:
shared/flag_state.go: newDataURL stringfieldpkg/template/generate-ui.go: extractedrenderPagehelper, addedGenerateRemoteHTMLBenchmarkUIcmd/html.go:--data-url/-Uflag,MaximumNArgs(1), branches on remote vs embed pathcmd/flag_validation_rules.go: URL validation viavalidateAPIURL(must behttp(s)://), consistent with existing flag validation patterncmd/html_test.go: updatedTestHtmlCmd_NoArgs, addedTestHtmlCmd_APIFlagandTestHtmlCmd_APIFlag_InvalidURLUI:
ui/vite.config.ts: injectswindow.VIZB_DATA_URL = {{ .DataURL }};into template scriptui/src/global.d.ts:VIZB_DATA_URL?: stringon Windowui/src/composables/useBenchmarkData.ts: fetch branch +loading/loadErrorrefs exportedui/src/views/Dashboard.vue: animate-pulse skeleton loading state + error state with CORS hintpkg/template/vizb-ui.gen.go: regeneratedDocs:
docs/src/content/docs/commands/html.mdxupdated with new flag, when-to-use guidance, CORS noteUsage
Test plan
go test ./...passesvizb html --data-url https://... -o lean.html→ ~784 KB HTML, no data inlined, URL presentvizb html bench.json -o embed.html→ unchanged embed behaviourvizb html(no args, no flag) → clear errorvizb html --data-url not-a-url→ validation warning, falls through to no-args error