feat(platform): unify canvas file viewers under one action card#2135
Merged
Conversation
The highlighter (engine + themes + eager grammars) inits lazily on the first highlightCode call, so the first code file a surface opens flashes un-highlighted while the dynamic imports resolve. Expose a fire-and-forget preloadHighlighter() that warms the cached singleton ahead of first use; idempotent and safe to call on mount. Translations: N/A (no user-facing strings) Docs: N/A | Migrations: N/A | a11y: N/A | Storybook: N/A Tests: covered by existing shiki usage + typecheck
Hoist the floating bottom-right action card out of renderable-file-viewer into a shared CanvasViewerFrame, so the code/markdown/html/svg/mermaid/ image viewers all present one identical control surface (the code viewer previously used a full-width top strip). Wrap and the per-file Source/ Preview choice move into a CanvasPreferencesProvider mounted above the viewers, so they survive switching files and viewer kinds. CodeViewer becomes a pure content renderer; a new CodeFileViewer wraps it with the shared card. Per-viewer download (shared download.ts helpers) replaces the canvas header download button. Shiki is preloaded on canvas mount so the first file highlights without the lazy cold-start. Translations: en/de/fr - added canvas.copy/copied/toggleWrap/ fileActionsAriaLabel; removed the now-unused viewToggleAriaLabel Docs: N/A (no user-facing docs for canvas internals) Migrations: N/A (no data-model change) a11y: action buttons carry title/aria-label; frame is role="group" with canvas.fileActionsAriaLabel; size keeps canvas.fileSizeAriaLabel Storybook: N/A (feature components, not ui primitives) Tests: typecheck + existing platform test:ui green; refactor preserves already-covered viewer behavior
Pre-existing oxfmt breakage on main (merged via #2122) that fails the repo-wide Format CI check; unrelated to this PR but blocks its gate. Pure formatting, no content change.
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.
What & why
Unifies every canvas file viewer — code, markdown, html, svg, mermaid, image — around one shared control surface, replacing the inconsistent chrome (the code viewer used a full-width top strip; renderables used a floating card).
CanvasViewerFrame— hoists the floating bottom-right action card, thepb-14content gutter, and the size label into one shell; each viewer passes its own buttons asactions.CanvasPreferencesProvider— line-wrap and the per-file Source/Preview choice now live above the viewers, so they survive switching files and viewer kinds (previously a remount reset them and shifted the layout).CodeViewerbecomes a pure content renderer (no chrome); a newCodeFileViewerwraps it with the shared card.download.ts— shareddownloadTextFile/downloadUrlFilehelpers replace the duplicated inline blob-download logic; per-viewer download replaces the canvas header button.preloadHighlighter()(@tale/ui) — warmed on canvas mount so the first code file highlights without the lazy shiki cold-start flash.Commits:
feat(ui): add preloadHighlighter+feat(platform): unify canvas file viewers under one action card.Verification
typecheck+lint(platform + ui) green against latestmainlint:sast(Opengrep) — 0 findings in changed filesparity+usageenforce checks greendeploy-simand piitokenizerfailures seen duringbun run checkare pre-existing flakes under concurrent CPU load (both pass in isolation; neither file is touched here)Definition of Done
canvas.copy/copied/toggleWrap/fileActionsAriaLabel, removed the now-unusedcanvas.viewToggleAriaLabel. de-CH falls back to de (no ß / Swiss-specific divergence).title/aria-label; the frame isrole="group"labelled bycanvas.fileActionsAriaLabel; the size label keepscanvas.fileSizeAriaLabel.test:uigreen; this is a refactor that preserves the behaviour of already-covered viewers. No new e2e spec (no new user-facing behaviour; CI e2e covers the canvas).services/platform, notpackages/uiprimitives).