Skip to content

Replace plugin Action callback with NativeInputHost#8498

Merged
malmstein merged 3 commits into
developfrom
feature/david/native_input_host_interface
May 11, 2026
Merged

Replace plugin Action callback with NativeInputHost#8498
malmstein merged 3 commits into
developfrom
feature/david/native_input_host_interface

Conversation

@malmstein
Copy link
Copy Markdown
Contributor

@malmstein malmstein commented May 8, 2026

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.createView previously took an opaque (Action) -> Unit callback whose only payload was Action.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 NativeInputHost interface exposing submit() and getInputState(). The host (NativeInputModeWidget) implements it and passes itself to plugins.

  • StartChatNativeInputPlugin now calls host.submit() instead of onAction(Action.StartChat).
  • ModelPickerNativeInputPlugin takes the new param without using host yet — the persistence PR will use host.getTabId() once that field is added.
  • Action (sealed class) is removed; PromptContribution is unchanged.

The persistence/provider track (#8488) will rebase on this and add getTabId() to NativeInputHost, deprecate getPromptContribution(), and wire MutableNativeInputStateProvider.

Steps to test this PR

Start chat icon

  • Tap the start-chat icon with no text — should open a new chat session
  • Tap the start-chat icon with a query — should submit it as a chat message

Model picker

  • Open the model picker, select a model, send a chat — selected modelId should still be applied (no behaviour change vs develop)

UI changes

Before After
(No UI changes) (No 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 Action API with a typed NativeInputHost interface, so plugins can invoke host behaviour (e.g. submit, attachment chooser/state updates) and query getInputState().

Updates NativeInputModeWidget to implement NativeInputHost and pass itself into NativeInputPlugin.createView, and migrates the start-chat and attachment flows (including AttachmentView notifications) to call host methods instead of emitting Action events. Tests and plugins are adjusted to the new signature; PromptContribution behaviour remains unchanged.

Reviewed by Cursor Bugbot for commit a82e0ef. Bugbot is set up for automated code reviews on this repo. Configure here.

@malmstein malmstein force-pushed the feature/david/native_input_host_interface branch from 12bfd56 to 32f0af6 Compare May 8, 2026 20:22
Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

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.
@malmstein malmstein force-pushed the feature/david/native_input_host_interface branch from 32f0af6 to cb5b18e Compare May 11, 2026 10:55
Copy link
Copy Markdown
Contributor

@joshliebe joshliebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, let’s get this merged so me can migrate to using this pattern

malmstein and others added 2 commits May 11, 2026 21:20
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
@malmstein malmstein merged commit d5d2ecf into develop May 11, 2026
13 checks passed
@malmstein malmstein deleted the feature/david/native_input_host_interface branch May 11, 2026 20:16
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