Repository navigation
feat(ui): rebuild the panel UI on a design-token system - #7
Merged
Merged
Conversation
Phase 1 of the UI revamp. Groundwork only -- no redesign yet. All 910 lines of CSS lived in a template literal in webview-content.ts, which had no linting and one silently broken rule. Split into five stylesheets loaded as webview resources: tokens.css design tokens mapped from --vscode-* (unused until phase 3) base.css document shell, buttons, icon sizing components.css toolbar, panes, splitter, overlay controls, notification format.css syntax tokens, gutter, folding, search highlight diff.css diff list, items, actions, resolved states webview-content.ts drops 1155 -> 273 lines. Verified with a rule-by-rule parse of the old stylesheet against the new files: no rule was lost. Removed only dead selectors (.left-preview, .right-preview, .panel-header, empty #format-container, and the stale ul/li/.json-array/.json-object/.json-items rules left over from before the formatter switched to .json-line divs), plus the orphaned declarations where a selector line had gone missing. Four deliberate fixes carried along with the move: - .search-highlight and .current used VS Code's find-match variables backwards, so the active match rendered less prominently than the rest - two hardcoded rgba() values now use --vscode-widget-shadow and --vscode-toolbar-hoverBackground; the latter was invisible in dark themes - dropped -moz-/-ms-user-select prefixes, webviews are Chromium Also: - add .vscode/launch.json and tasks.json; F5 debugging was not set up - ship @vscode/codicons via copy-webpack-plugin into media/codicons/, since .vscodeignore excludes node_modules - localResourceRoots: node_modules (never used) -> media - getNonce uses crypto.randomBytes instead of Math.random - add ui/dom.ts and ui/icons.ts for the phase 2 split style-src keeps 'unsafe-inline' for now: CSP blocks style="..." attributes in parsed markup and 13 of them drive mode visibility. They go away in phase 2 when mode switching becomes attribute-driven. Co-Authored-By: Claude Opus 5 <[email protected]>
Phase 2 of the UI revamp. Structural only -- the UI still looks the same.
controller.ts was a 1592-line god object owning DOM wiring, mode switching,
splitter drag, maximize, search, diff apply/reject, clipboard and folding.
Replaced with:
shell.ts toolbar, mode, shortcuts, host messages
views/format-view.ts input/output panes, format, folding, copy, save
views/diff-view.ts compare, per-row and bulk apply/reject/undo
ui/messaging.ts typed transport + ready handshake
ui/shortcuts.ts the single keydown registry
ui/splitter.ts drag-to-resize between two panes
ui/panels.ts maximize/restore via delegation
ui/search-bar.ts the toolbar search bar
shared/messages.ts message contract, imported by both bundles
Defects fixed along the way:
- Two independent document keydown listeners both claimed Cmd+0 and relied
on mode checks to avoid colliding. One registry now owns every binding and
dispatches exactly one match.
- Maximize re-bound its buttons on every mode switch and cloned each node to
shed the old listener, silently discarding listeners attached to the
button's children. Now a single delegated listener on the container.
- Loading history into a panel that did not exist yet posted the message
after a fixed 100ms, which dropped it on a slow load. The webview now
signals ready and the host queues and flushes.
- reject-all only added a CSS class and never recorded the state, so a later
undo on a row behaved as if it had never been rejected.
- switchMode mutated style.display on six elements across ~75 lines. Mode is
now one data-mode attribute on <body> and CSS decides what each mode shows.
With no style attributes left in generated markup, style-src drops
'unsafe-inline' and is now just ${webview.cspSource}.
Copy is no longer hidden in diff mode; the diff branch of the copy handler
already existed but was unreachable.
Testing: jest now runs two projects, node for the engines and jsdom for
anything touching the DOM. 40 new tests cover the shortcut registry, the
maximize group, diff resolution state and shell wiring -- 174 -> 214.
The shell suite covers the initial-mode regression this refactor introduced
and I caught during verification.
Co-Authored-By: Claude Opus 5 <[email protected]>
Phase 3 of the UI revamp. First phase with a visible change.
The panel read as a web app hosted in VS Code: a 48px toolbar of text
buttons, 8px card radii, 16px page padding, floating action buttons
overlaying pane content, and -apple-system type. This rebuilds the chrome
to match the editor it lives in.
Design tokens
- Every colour, font and metric now resolves through media/tokens.css.
Nothing else references a --vscode-* variable, so retheming happens in
one place and no rule can quietly hardcode a colour. Verified: zero
literal colours anywhere in media/ outside the token file.
- High-contrast themes override the tokens on body.vscode-high-contrast,
which reaches every rule without any of them knowing about the theme.
Chrome
- Toolbar 36px, pane headers 28px, status bar 22px, matching VS Code's
own chrome heights.
- Mode switcher restyled after the panel tabs (Problems/Output/Terminal):
flat labels with an underline on the active one.
- Pane actions moved into per-pane header bars. This retires the absolutely
positioned overlay buttons and the `right: 88px`/`right: 48px` nth-of-type
offsets that had to be renumbered whenever a button was added or hidden.
- New status bar: validity, line count and size in Format; counts by change
kind in Diff. Each view keeps its own model, so switching modes restores
it rather than recomputing.
- Empty state in the output pane with a keyboard legend. The modifier key
is resolved at runtime, so macOS sees the Command symbol rather than Ctrl.
Icons
- @vscode/codicons replaces every hand-drawn SVG. The maximize path had
been duplicated five times in markup plus twice as JS strings, and the
check/close/undo trio three times in diff.ts. Zero inline <svg> remain.
- The panel tab icon is now a light/dark pair. iconPath renders outside the
webview so it cannot pick up theme colours through CSS, which is why
currentColor would not have worked. Also replaced the <text>{}</text>
hack with real paths, since it depended on a monospace font being present.
Two rendering bugs found while reviewing the result:
- Modified diff rows reused --vscode-diffEditor-border, a line colour, as
a background fill. Subtle in dark themes, but a grey band that read as a
selection in light ones. They now carry meaning in the rail and value
chips alone.
- .diff-item-header used space-between across four children, so path,
separator, value and actions spread apart and neighbouring rows' values
landed at different offsets. Actions now push right on their own.
The gutter had 32px of accumulated padding across three rules; now 16px.
Testing: DOM fixtures are now generated from the real
WebviewContentGenerator via a stubbed vscode module, so tests assert
against production markup instead of a hand-copied approximation that
could drift. 223 tests pass.
Co-Authored-By: Claude Opus 5 <[email protected]>
Phase 4 of the UI revamp. Search lived in the toolbar, where opening it made the trigger button disappear and swap places with the input. It now floats over the content it searches, like the editor's own find control. The widget carries a term field, match-case and regex toggles, a match counter, previous/next/close, and a scope row: All, Keys, Values. The term and every option survive close and reopen. Behaviour fixes: - Opening find used to return early when nothing had been formatted, so on a fresh panel with JSON already pasted the button appeared dead. It now formats first and then searches. - The gutter was searchable, so looking for "1" lit up line numbers alongside real hits. Line numbers and folding markers are now excluded from every scope. - Re-rendering the output (toggling line numbers, reformatting) discarded the highlights and left a stale match count. The widget re-runs itself. - An invalid regular expression reports "Invalid pattern" rather than silently reporting no matches. search() takes an options object; every option defaults to the previous behaviour, so nothing else had to change. Scope works by filtering the tree walker to text nodes inside key or value token spans, which means the haystack is the searchable text and offsets still map straight back onto the nodes that produced them. The pattern is no longer lowercased for case-insensitive search -- that would have turned \S into \s once regex support existed. Casing is handled where the match happens instead. Folding was quadratic: each hidden element searched the whole line list for its own index in order to find its gutter entry. The formatter now emits data-line on both, making it a direct lookup. Testing: 20 new find-widget tests covering scope, case, regex, invalid patterns, gutter exclusion and re-render survival. jsdom implements no layout and therefore no scrollIntoView, so that is stubbed in setup rather than making the code defensive about an API browsers always have. 174 -> 243 tests over the four phases. Co-Authored-By: Claude Opus 5 <[email protected]>
Phase 5 of the UI revamp. Layout - The three panes are resizable. Previously only Format had a splitter; Diff's panes were fixed at a third each, which made a deep path or a long value unreadable with no way to give the list more room. - Splitter now sizes relative to its own two neighbours rather than the containing row. That is what lets two of them coexist: dragging one redistributes only the width those two panes already share and leaves every other pane where it is. Verified in the browser -- moving the left sash 80px shifted 80px from pane one to pane two and left pane three untouched. Change rows - Path renders as breadcrumb segments with the leaf emphasised, and array indices show as [0] rather than reading like another key. A dotted path was unreadable once nesting got deep. - Value moved onto its own line under the path. On one line a long value wrapped into the path and neighbouring rows could not be scanned. - Modified rows strike through the old value and point at the new one; add and remove show only the value they carry. The bare "= value" the old markup produced read as an assignment rather than a change. - Each row carries a type glyph tinted to match its rail. Filtering - Chips above the list: All, Added, Removed, Modified, each with a live count. A chip with nothing to show dims and stops responding. - Filtering sets one attribute on the list and every row decides for itself in CSS, so no DOM walking and nothing to keep in sync. Resolution state - Applied and rejected are now a single data-state attribute rather than parallel CSS classes, so what is recorded and what is on screen cannot drift. Resolved rows keep their actions visible so undo is discoverable, and carry a status dot -- dimming alone is hard to read in some themes. Testing: diff-view tests now build from the real panel markup like the other DOM suites, rather than a hand-copied fixture that had already drifted. 23 new tests across change-row rendering, filters and the splitter's pair-relative sizing. 243 -> 266. Co-Authored-By: Claude Opus 5 <[email protected]>
LucianCrainic
added a commit
that referenced
this pull request
Aug 15, 2026
feat(ui): rebuild the panel UI on a design-token system
LucianCrainic
added a commit
that referenced
this pull request
Aug 15, 2026
The work PR #7 shipped without. Panels are serialised, so a window reload no longer throws away whatever was pasted: `registerWebviewPanelSerializer` adopts the panel VS Code offers back, and the webview keeps mode, input and toggles in setState. Writes are coalesced and anything over 512 KB is dropped rather than carried, since the whole state is re-serialised on each write and reformatting is cheaper than stalling every keystroke. Sidebar history moves to globalState. It was a plain array on the tree provider, so every entry a user saved vanished on restart -- which made the feature close to pointless. Entries now carry a timestamp and a size and are described as "3 minutes ago - 12.4 KB" instead of "Entry 1" plus a raw fifty-character slice, which all look alike when they start with `{"`. Documents over 256 KB are stored as a preview and say so, rather than keeping fifty large documents in global state forever. `getChildren` dispatched on the item's *label* matching the string 'Format History', so renaming a heading would have silently emptied the tree under it; items carry a typed kind now. Added a "Clear history" title action. contributes.configuration adds nine settings -- line numbers, indent size, strict diff, pane ratio, format on paste, default search scope, and the three limits the engines now respect. They are pushed to open panels on the ready handshake and again whenever they change. The diff view reports the document-size limit plainly instead of attempting a comparison that will not fit. `jsonbro.loadFormatHistory` and `jsonbro.loadDiffHistory` were registered in code but absent from contributes; they are declared now, and hidden from the palette since they take arguments. Also: .vscodeignore was packaging the preview harness output and .claude/launch.json into the .vsix -- vsce includes untracked files unless they are named there. Verified with `vsce ls`: 60 files, media and out only. README.md untouched, as asked. 400 tests pass, up from 375.
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.
Rebuilds JSONBro's UI to read as a native VS Code surface, and refactors the layer underneath so the next UI change is a small diff.
Why
The panel looked like a web app hosted in VS Code rather than part of it: a 48px toolbar of text buttons, 8px card radii, 16px page padding,
-apple-systemtype, and action buttons floating over pane content positioned by hardcodedright: 88px/right: 48pxoffsets keyed tonth-of-type.Underneath, all 910 lines of CSS lived in a template literal inside
webview-content.ts— unlintable, and one rule was already silently broken (a selector line had gone missing, leaving orphaned declarations).controller.tswas a 1592-line god object owning DOM wiring, mode switching, splitter drag, maximize, search, diff resolution, clipboard and folding.What changed
Design system. Every colour, font and metric resolves through
media/tokens.css. Nothing else references a--vscode-*variable, so retheming happens in one place and no rule can hardcode a colour that breaks in another theme. High-contrast themes override the tokens onbody.vscode-high-contrast, reaching every rule without any of them knowing about the theme.Chrome. Toolbar 36px, pane headers 28px, status bar 22px — VS Code's own heights. Mode switcher restyled after the panel tabs. Pane actions moved into real header bars, retiring the overlay buttons and their offset arithmetic. New status bar (validity, line count, size in Format; counts by change kind in Diff) and an empty state whose keyboard legend resolves the modifier key at runtime, so macOS sees ⌘.
Find. Search moved out of the toolbar — where opening it made the trigger disappear and swap places with the input — into a widget floating over the content it searches. Match-case, regex, and an All/Keys/Values scope row. Term and options survive close and reopen.
Diff. All three panes are now resizable (only Format was before). Change rows render the path as breadcrumb segments with the leaf emphasised and array indices as
[0], with the value on its own line. Filter chips with live counts narrow the list. Resolution state is onedata-stateattribute rather than parallel CSS classes.Icons.
@vscode/codiconsreplaces every hand-drawn SVG — the maximize path had been duplicated five times in markup plus twice as JS strings, and the check/close/undo trio three times. Zero inline<svg>remain. It is the extension's only runtime dependency.Structure.
controller.tsis gone, replaced byshell.ts, two views and nineui/modules, plus ashared/messages.tscontract imported by both bundles.Bugs fixed along the way
documentkeydown listeners both claimedCmd+0and relied on mode checks to avoid colliding. One registry now dispatches exactly one match.1lit up line numbers alongside real hits.diffEditor-border— a line colour — as a background fill, which read as a grey selection band in light themes.data-linenow.rgba()values, one of which was invisible in dark themes; the panel tab icon's hardcoded#FFA500and its<text>{}</text>hack, which depended on a monospace font being installed.getNonceusedMath.random;localResourceRootspointed atnode_modules, which was never read from.Notes for review
style-srcdropped'unsafe-inline'once mode visibility becamedata-modeon<body>plus CSS. Worth confirming nostyle="…"sneaks back into generated markup — it would fail silently in the panel but not in tests.media/at build time rather than referenced fromnode_modules, because.vscodeignoreexcludes the latter. If that copy step breaks, the webview ships with no icons.npx vsce lsshowsmedia/codicons/codicon.ttf.diff.test.tsandjson-parser.test.tsare untouched — the compare, apply and revert engines were not modified, only how their results are rendered.formatter.test.tsneeded updating because it asserts on HTML substrings and the markup changed.WebviewContentGeneratorvia a stubbedvscodemodule, so they cannot drift from production markup — a class of bug that bit once during this work..vscode/launch.jsonandtasks.jsonare new; F5 debugging was not set up in this repo before.Not included
Persistence and settings (webview
setState/getState, a panel serializer,contributes.configuration,contributes.keybindings, and backing the sidebar history withglobalState) were planned as a sixth phase and are not in this PR. Panel content is still lost on reload, and the seven keyboard shortcuts remain undiscoverable outside the empty state's legend.Verification
Both views were checked in dark and light themes by rendering the real webview HTML against transcribed VS Code theme variables, and the interactive behaviour — find scoping, regex, invalid patterns, filter chips, splitter composition, apply/reject/undo — was driven live in a browser. Worth a pass in the Extension Development Host across a high-contrast theme before merge, which I could not do from here.