Skip to content

Widgets on links' tiles, with Uptime Kuma's monitor widget (Phase 5b2) - #50

Merged
cerebrate merged 7 commits into
masterfrom
feature/phase5b2-widgets
Oct 17, 2026
Merged

cerebrate merged 7 commits into
masterfrom
feature/phase5b2-widgets

Conversation

@cerebrate

Copy link
Copy Markdown
Member

Widgets end to end, as designed in the 5b discussion: roles, storage, a shared fetcher, polling, editing in the link dialog, Undo, backups, and Uptime Kuma's monitor widget as the first kind.

What's in it

  • Contracts (h2s.Widgets.Abstractions):
    • An integration offers WidgetKinds. Each IWidgetKind declares a key, a name, a role, an option schema and a default refresh interval.
    • FetchAsync returns a WidgetResult: a status (Unknown, Ok, Warning, Error or Inactive), a few WidgetStats, and a Description sentence, which is both the tooltip and what screen readers hear.
    • Kinds never write HTML.
  • Roles and layout:
    • An App widget goes on the left of the tile's widget row, at most one per link.
    • Status widgets are compact pills, right-aligned as one group. On a narrow tile the whole group moves to the next line instead of splitting, which covers the "move them deliberately" request without measuring widths in script.
  • Storage: a Widgets table (AddWidgets migration) that cascades from both the link and the connection, so removing a connection deletes its widgets. Settings' Remove confirmation says how many.
  • Runtime:
    • WidgetFetcher (singleton) keeps each result for the widget's interval, under a key that hashes the widget's and the connection's settings so changes show at once. It shares one read among concurrent requests and turns exceptions and a 10-second timeout into "unknown".
    • WidgetService renders pages from cached results only, so a slow service never holds up the dashboard. GET /widgets/{id} reads a widget fresh.
    • widgets.js reads placeholders immediately, then refreshes each widget on its interval and pauses while the tab is hidden.
  • Link dialog: a Widgets section (widget-editor.js) to add, edit, reorder and remove widgets, with fields built from the kind's schema by option-fields.js.
    • Widgets are posted with the link and checked by WidgetForm: kind known, integration set up, valid options, refresh 15 s to a day, one app widget, at most ten.
    • So they save and cancel with the link, and Undo snapshots bring them back.
  • Uptime Kuma's monitor widget (uptime-kuma/monitor, refreshes every 60 s):
    • The monitor's status sets the pill's colour, with response time and uptime for a chosen window, read from /metrics.
    • Uptime shows two decimals from 99%, truncated so it never rounds up to 100%.
  • Backup format version 7: each link carries its widgets, naming their connection. Import checks the connection exists in the file.

Unchanged until 5c/5b3

  • Today's badge images stay. A link with both a monitor ID and a Kuma widget shows both.
  • The monitor is typed as an ID; 5b3 adds the picker and a Test preview.

Checked

  • 590 tests pass. The new ones cover:
    • the Kuma kind against a stubbed /metrics
    • WidgetForm (validation and apply)
    • WidgetFetcher (shared read, caching, failures)
    • the editor end to end: save, fetch back, reorder, remove, refusals, and leaving widgets alone when the field isn't posted
    • placeholder, then read, then cached rendering, with /widgets/{id} sending no-store
    • Undo, connection removal and the backup round trip, including refusing an unknown connection
  • Builds: the CI-strict Release build is clean, and jb cleanupcode is stable (a third pass on four files whose braces flipped).
  • Browser, on a fresh prod copy:
    • Added a widget through the dialog. The tile re-rendered, widgets.js read it straight away, and it showed an unknown pill, because that copy predates the soak and has no API key.
    • Checked the pills' look in both themes by substituting sample results.
    • The Remove confirmation counted the widget.
  • Not checked: a widget against your real /metrics, which needs your API key.

🤖 Generated with Claude Code

cerebrate and others added 7 commits October 16, 2026 09:48
… 5b2)

Integrations can now offer widget kinds (IWidgetKind): each declares a
role, an option schema and a default refresh interval, and reads its
service into a WidgetResult (status, a few figures, a description); the
core draws every widget the same way. App widgets (one per link) sit on
the left of a tile's widget row, status widgets as right-aligned pills
that wrap together.

Widgets are stored per link (AddWidgets migration), cascading from their
link and their connection, so removing a connection deletes its widgets;
the Remove confirmation counts them. WidgetFetcher keeps results for each
widget's interval and shares concurrent reads; pages render only cached
results, and widgets.js reads the rest from /widgets/{id} and refreshes
each on its interval, pausing while the tab is hidden.

The link dialog gains a Widgets section (widget-editor.js), posted with
the link and checked by WidgetForm; Undo snapshots carry widgets, and
backups move to format version 7 with each link's widgets naming their
connection. Uptime Kuma's monitor widget shows a monitor's status,
response time and uptime, read from /metrics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: adds braces around every single-line body of if/else, loops,
using, lock and fixed, following the settings change. No behavioral
changes; a second cleanup pass changes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Save didn't save while a widget's form was open, which was confusing, so
Save and Delete are disabled until the widget is finished (Done) or
dropped (Cancel). Also update the .editorconfig comment for the
always-required braces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The older-format CSharpFormat/FORCE_*_BRACES_STYLE keys still said
ONLY_FOR_MULTILINE, contradicting the always-required braces. They didn't
affect cleanup, which settles in one pass with them either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cerebrate
cerebrate merged commit 22e52f5 into master Oct 17, 2026
3 checks passed
@cerebrate
cerebrate deleted the feature/phase5b2-widgets branch October 18, 2026 02:07
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