Repository navigation
feat(widget_protocol): notify_config_changed, so a host learns of a widget's own state change (1.1.0) - #246
Merged
Conversation
…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
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.
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 hasquery_history,notify_inputs_changedandreport_widget_message. PlotJuggler snapshots a panel for undo (and marks the layout modified) only on changes it makes itself, so:/rosout, turn Info off and type a text filter;A saved layout is right only because saving calls
save_configdirectly.Change
PJ_widget_host_vtable_tgains a tail slotnotify_config_changed(ctx)(the struct is ABI-APPENDABLE).WidgetHostView::notifyConfigChanged(), gated withPJ_HAS_TAIL_SLOT: a no-op on a host built before the slot.WidgetHostBridge::config_changedcallback (exceptions swallowed like the other callbacks);FakeWidgetHost::config_changed_calls.save_config,load_configoron_update(a host that reacts at once callssave_configback into the plugin); block the controls' change signals whileload_configfills them. The host should defer itssave_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 itsmin_sdk_required.VERSION1.1.0, CHANGELOG with theHost contract:line, widget guide, ARCHITECTURE, widget_protocol CLAUDE.md and the plugin skill reference updated.Tests
struct_sizeends before the slot (ASan-poisoned tail, as in the existing tail-slot tests) the call does nothing; with thePJ_HAS_TAIL_SLOTgate replaced by a null check ASan reports the read../test.sh: 110/110, both the ASan (--debug) and the default build;feature_floors_checkpasses. Theabi_checktarget (libabigail) was not run.Follow-ups after a release (not in this PR)
CustomWidgetDockWidgetconnectsconfig_changedto a deferredworkspaceChanged, so the undo stack and the layout's modified flag pick the change up.widgetHost().notifyConfigChanged()when a filter, the splitter or a column width changes (suggested_sdk_version1.1.0).🤖 Generated with Claude Code
https://claude.ai/code/session_019HWZVMwHkCoZxMRkq9puKw