Skip to content

Theme server: an Edit view for theme.json, with a live preview - #364

Open
kloptops wants to merge 2 commits into
PortsMaster:mainfrom
kloptops:theme-json-editor
Open

kloptops wants to merge 2 commits into
PortsMaster:mainfrom
kloptops:theme-json-editor

Conversation

@kloptops

Copy link
Copy Markdown
Member

The page's Edit view edits a theme's theme.json in CodeMirror 5, next to one rendered screen:

  • The preview follows the typing: unsaved text is rendered from a draft (a copy of the theme made of links, "~draft"), so the theme is untouched until Save. About 2.5 seconds behind on an RG35XX-H.
  • Suggestions for keys (with their types), the values a key takes, {tags} and [capabilities], read from pugwash's own code by theme_server/ schema.py (Region's verify* calls, load_regions, set_data), so they match what PortMaster accepts.
  • Checks as you type: JSON mistakes in plain words, unknown keys with "did you mean", wrong value types, colors not in #pallet, missing images and fonts, unknown #element:/parent names, and the render's own errors.
  • Clicking a region box jumps to its place in theme.json, and the cursor in a region lights up its box.
  • Save (Ctrl+S) keeps the previous file as theme.json.bak and refuses to overwrite a theme.json changed on disk without asking. The built-in default theme is read-only: "Copy to a new theme" copies any theme (and the unsaved changes) into the themes folder.

On a device it saves into PortMaster/themes, and copies show up in the theme list. Tried on muOS (exFAT SD card) as well as locally.

CodeMirror 5.65.18 (MIT) is vendored as static/codemirror/ with its LICENSE; the server only serves a fixed list of static files.

The checks found typos in the default theme that PortMaster has always ignored: "barwidth" (bar-width) on the keyboard, "list-spacer" in filter_list, "align": "midcenter" and "parent": "element:background". They're left as they are (fixing them changes how it looks), the unknown keys pinned in tests/test_theme_editor.py.

kloptops and others added 2 commits October 25, 2026 00:50
The page's Edit view edits a theme's theme.json in CodeMirror 5, next to
one rendered screen:
- The preview follows the typing: unsaved text is rendered from a draft
  (a copy of the theme made of links, "<theme>~draft"), so the theme is
  untouched until Save. About 2.5 seconds behind on an RG35XX-H.
- Suggestions for keys (with their types), the values a key takes, {tags}
  and [capabilities], read from pugwash's own code by theme_server/
  schema.py (Region's _verify_* calls, load_regions, set_data), so they
  match what PortMaster accepts.
- Checks as you type: JSON mistakes in plain words, unknown keys with
  "did you mean", wrong value types, colors not in #pallet, missing images
  and fonts, unknown #element:/parent names, and the render's own errors.
- Clicking a region box jumps to its place in theme.json, and the cursor in
  a region lights up its box.
- Save (Ctrl+S) keeps the previous file as theme.json.bak and refuses to
  overwrite a theme.json changed on disk without asking. The built-in
  default theme is read-only: "Copy to a new theme" copies any theme (and
  the unsaved changes) into the themes folder.

On a device it saves into PortMaster/themes, and copies show up in the
theme list. Tried on muOS (exFAT SD card) as well as locally.

CodeMirror 5.65.18 (MIT) is vendored as static/codemirror/ with its
LICENSE; the server only serves a fixed list of static files.

The checks found typos in the default theme that PortMaster has always
ignored: "barwidth" (bar-width) on the keyboard, "list-spacer" in
filter_list, "align": "midcenter" and "parent": "element:background".
They're left as they are (fixing them changes how it looks), the unknown
keys pinned in tests/test_theme_editor.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxABmR1rUUgi4iicVLZchY
Python 3.13 reports a trailing comma as "Illegal trailing comma" at the
comma, where older versions said "Expecting property name" at the } after
it. The exact-position tests use a missing comma, which every version
reports the same; the trailing comma test takes either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxABmR1rUUgi4iicVLZchY
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.

1 participant