Skip to content

feat(widget_protocol): notify_config_changed, so a host learns of a widget's own state change (1.1.0) - #246

Merged
Alvvalencia merged 1 commit into
mainfrom
feat/widget-notify-config-changed
Nov 17, 2026
Merged

Alvvalencia merged 1 commit into
mainfrom
feat/widget-notify-config-changed

Conversation

@facontidavide

Copy link
Copy Markdown
Contributor

Proposal (draft): the SDK half of a fix for a bug the PlotJuggler QA agent found with the Log widget.

Problem

A Widget plugin keeps state of its own that the host persists through save_config: the Log widget's level, source and text filters, its splitter and column widths. The host never learns that this state changed, because the widget host vtable only has query_history, notify_inputs_changed and report_widget_message. PlotJuggler snapshots a panel for undo (and marks the layout modified) only on changes it makes itself, so:

  1. add a Log panel, wire /rosout, turn Info off and type a text filter;
  2. close the panel, press Ctrl+Z;
  3. the panel comes back wired, but with default filters.

A saved layout is right only because saving calls save_config directly.

Change

  • PJ_widget_host_vtable_t gains a tail slot notify_config_changed(ctx) (the struct is ABI-APPENDABLE).
  • WidgetHostView::notifyConfigChanged(), gated with PJ_HAS_TAIL_SLOT: a no-op on a host built before the slot.
  • WidgetHostBridge::config_changed callback (exceptions swallowed like the other callbacks); FakeWidgetHost::config_changed_calls.
  • Contract: call it when the user changed persisted state through the widget's UI; never from inside save_config, load_config or on_update (a host that reacts at once calls save_config back into the plugin); block the controls' change signals while load_config fills them. The host should defer its save_config (queued) rather than call it inside the callback.
  • feature_floors.json: floor 1.1.0, runtime-negotiated, so a plugin that uses it keeps its min_sdk_required. VERSION 1.1.0, CHANGELOG with the Host contract: line, widget guide, ARCHITECTURE, widget_protocol CLAUDE.md and the plugin skill reference updated.

Tests

  • ABI sentinel pins the new offset (32) and size (40).
  • The bridge forwards the call, ignores an unset callback, and contains a throwing one.
  • On a host vtable whose struct_size ends before the slot (ASan-poisoned tail, as in the existing tail-slot tests) the call does nothing; with the PJ_HAS_TAIL_SLOT gate replaced by a null check ASan reports the read.
  • Full ./test.sh: 110/110, both the ASan (--debug) and the default build; feature_floors_check passes. The abi_check target (libabigail) was not run.

Follow-ups after a release (not in this PR)

  • PlotJuggler: CustomWidgetDockWidget connects config_changed to a deferred workspaceChanged, so the undo stack and the layout's modified flag pick the change up.
  • widget_log: call widgetHost().notifyConfigChanged() when a filter, the splitter or a column width changes (suggested_sdk_version 1.1.0).

🤖 Generated with Claude Code

https://claude.ai/code/session_019HWZVMwHkCoZxMRkq9puKw

…idget's own state change (1.1.0)

A widget keeps state of its own that the host persists through save_config (a log widget's filters,
a splitter). The host had no way to learn that this state changed: it snapshots a panel for undo, or
marks the layout modified, only on changes it makes itself. Closing such a panel and undoing brought
it back with the state of its last load_config.

The widget host vtable gains a tail slot, notify_config_changed, and WidgetHostView gains
notifyConfigChanged(), gated with PJ_HAS_TAIL_SLOT so it does nothing on an older host.
WidgetHostBridge forwards it to a config_changed callback, and FakeWidgetHost counts the calls.
The slot is runtime-negotiated (floor 1.1.0 in feature_floors.json): a plugin that uses it keeps its
min_sdk_required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019HWZVMwHkCoZxMRkq9puKw
@Alvvalencia
Alvvalencia marked this pull request as ready for review November 17, 2026 08:34
@Alvvalencia
Alvvalencia merged commit 0f08cf8 into main Nov 17, 2026
11 checks passed
@Alvvalencia
Alvvalencia deleted the feat/widget-notify-config-changed branch November 17, 2026 09:01
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.

2 participants