Replace plugin Action callback with NativeInputHost#8498
Merged
Conversation
12bfd56 to
32f0af6
Compare
NativeInputPlugin.createView previously took an opaque (Action) -> Unit callback whose only payload was Action.StartChat. That shape doesn't extend cleanly: every new plugin-to-host signal needs another sealed subclass, and plugins had no way to read the host's state at all. Replace it with a NativeInputHost interface exposing submit() and getInputState(). The host (NativeInputModeWidget) implements it and passes itself to plugins. StartChatNativeInputPlugin now calls host.submit(); ModelPickerNativeInputPlugin takes the new param without needing host calls yet. Action and PromptContribution are unchanged otherwise; persistence work continues on the existing branch and will build on this interface.
32f0af6 to
cb5b18e
Compare
joshliebe
approved these changes
May 11, 2026
Contributor
joshliebe
left a comment
There was a problem hiding this comment.
Looks good, let’s get this merged so me can migrate to using this pattern
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ve_input_host_interface # Conflicts: # duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/ui/nativeinput/views/AttachmentView.kt
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.

Task/Issue URL: https://app.asana.com/1/137249556945/project/1214157224317277/task/1214636594411870?focus=true
Description
Splits the interface part out of #8488 so it can land independently of the per-tab persistence work.
NativeInputPlugin.createViewpreviously took an opaque(Action) -> Unitcallback whose only payload wasAction.StartChat. That shape didn't extend cleanly: every new plugin → host signal needed another sealed subclass, and plugins had no way to read the host's state at all.This PR replaces the callback with a
NativeInputHostinterface exposingsubmit()andgetInputState(). The host (NativeInputModeWidget) implements it and passes itself to plugins.StartChatNativeInputPluginnow callshost.submit()instead ofonAction(Action.StartChat).ModelPickerNativeInputPlugintakes the new param without usinghostyet — the persistence PR will usehost.getTabId()once that field is added.Action(sealed class) is removed;PromptContributionis unchanged.The persistence/provider track (#8488) will rebase on this and add
getTabId()toNativeInputHost, deprecategetPromptContribution(), and wireMutableNativeInputStateProvider.Steps to test this PR
Start chat icon
Model picker
UI changes
Note
Medium Risk
Medium risk because it changes the plugin↔host communication contract and rewires submit/attachment signals, which could affect core input/attachment UX if any plugin or host path is missed.
Overview
Replaces the native input plugin callback-based
ActionAPI with a typedNativeInputHostinterface, so plugins can invoke host behaviour (e.g.submit, attachment chooser/state updates) and querygetInputState().Updates
NativeInputModeWidgetto implementNativeInputHostand pass itself intoNativeInputPlugin.createView, and migrates the start-chat and attachment flows (includingAttachmentViewnotifications) to call host methods instead of emittingActionevents. Tests and plugins are adjusted to the new signature;PromptContributionbehaviour remains unchanged.Reviewed by Cursor Bugbot for commit a82e0ef. Bugbot is set up for automated code reviews on this repo. Configure here.