Skip to main content

Module user_widgets

Module user_widgets 

Source
Expand description

The user’s own widgets.json, next to settings.json — Pane Tab contract v1, Phase 6 (docs/specs/SPEC_PANE_TAB_CONTRACT_V1_2026_09_24.md §4).

The widget bar used to come only from the widgets.json embedded at build time, so there was nowhere to add a third-party (ext:) widget. This file’s entries are merged over the built-ins: a new key adds a widget, a built-in key replaces that widget. Same load-then-watch shape as settings.json (config_watcher_fs) and browser_start_page, on the same fs_watch pool, riding the existing full-config broadcast.

Constants§

USER_WIDGETS_FILE

Functions§

add_section_entry
Adds a section’s entry to the user’s widgets.json (section_entry_in) and applies the file at once, so the widget bar can pin the entry as soon as this returns; the file watcher applies it again a moment later, which changes nothing. Returns the entry’s key. For “Pin this section to the widget bar” (section-pins.ts): the bar pins only an entry that exists.
last_v1_entries
The v1 entries (module set) of the user’s widgets.json as last read.
load_user_widgets_from_disk
merge_widgets
The built-ins with the user’s entries merged over them.
parse_user_widgets
The widgets in a widgets.json’s text (read_user_widgets without the file).
read_user_widgets
The user’s widgets; an absent file, or one with nothing in it but comments, is none. The file is read as JSONC, like settings.json: comments and trailing commas are allowed. A file that does not parse is an error that names its line and column.
recompute
Merge again: the built-ins, then each approved widget package’s entries (SPEC_USER_WIDGETS_AND_WIDGET_API_2026_10_09.md §5.4), then the user’s own widgets.json, which replaces a package’s entry when it uses the same key.
section_entry_in
Where a section’s entry is, or goes, in widgets.json: under base if that key is free or already opens this section, otherwise under the first free base-2, base-3, …, so a key the user reused for something else is never handed back as this section’s. Returns the key and, when the entry has to be added, the file’s new text. An absent or empty file is {}; one that doesn’t parse is an error, so a file the user is halfway through editing is never rewritten.
spawn_user_widgets_watcher
user_widgets_path