feat(dialog): code-editor caret protocol for cursor-aware completion (0.5.1)#107
Merged
Conversation
…5.1) Re-applies the additive caret protocol (cherry-pick of the 0.4.x change; the dialog-protocol headers are byte-identical between 0.4.2 and 0.5.0 so it grafts cleanly): codeChanged(code,cursor) + WidgetEvent::codeCursor; onCodeChangedWithCursor (distinct-name, defaults to onCodeChanged); setCodeCursor + WidgetDataView::codeCursor. Lets a plugin drive caret-aware completion. Patch bump 0.5.0 -> 0.5.1 (fully additive). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The host emits the caret offset on every cursor move for caret-aware completion, but firing that for *every* code editor regresses editors that only validate code (e.g. the reactive-scripts Lua editor re-ran its validation/terminal logic on each arrow-key press). Make it opt-in: - WidgetData::setCodeCaretTracking(name, enabled=true) — request cursor-move reporting for one editor - WidgetDataView::codeCaretTracking(name) — host reads the request - onCodeChangedWithCursor doc clarified: caret is reported (and cursor-only moves fire at all) only for opted-in editors; otherwise it's text-change only with cursor < 0, i.e. the pre-caret behavior Folded into the still-unreleased 0.5.1 (additive). Docs updated. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
facontidavide
approved these changes
May 29, 2026
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.
Summary
Adds an additive code-editor caret channel to the dialog protocol so hosts can
deliver a caret offset alongside code content, and plugins can react to cursor
moves (not just text edits). This is what drives Mosaico's cursor-aware Key/Op/Value
query-assist dropdowns.
WidgetEventBuilder::codeChanged(code, cursor = -1)— writescode_cursorwhen ≥ 0WidgetEvent::codeCursor()— reads it backDialogPluginTyped::onCodeChangedWithCursor(name, code, cursor)— new virtual,defaults to
onCodeChanged(name, code)(distinct name to avoid-Werror=overloaded-virtual); dispatched viaevent.codeCursor().value_or(-1)WidgetData::setCodeCursor/WidgetDataView::codeCursor— round-trip the caretAll additions are tail-appended / new symbols — no existing struct layout, vtable
slot, or signature changes. PATCH bump
0.5.0 -> 0.5.1(version synced inconanfile.py+PJ_PACKAGE_VERSION).Test plan
widget_event_builder_test,widget_event_test,widget_data_test,widget_data_view_test,dialog_plugin_typed_testextended + green+ publish is a separate, explicitly-authorized step (coordinate w/ Davide).
Downstream
toolbox_mosaicoPR feat(pj_base): AssetVideo clip-window (start_ns/end_ns) #97 needs 0.5.1 on the remote to build in CI.🤖 Generated with Claude Code