Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ interface NativeInputHost {
fun showModelPicker(showing: Boolean)
fun showReasoningPicker(showing: Boolean)

/** Return focus and the keyboard to the input field after a plugin handed control to another screen. */
fun restoreInputFocus()

fun attachmentChanged(hasAttachments: Boolean, limitExceeded: Boolean, supportsUpload: Boolean)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,13 @@ class AttachmentView(
private fun buildImagePickerCallback(source: AttachmentViewModel.ImageSource): ValueCallback<Array<Uri>> = ValueCallback { uris ->
val list = uris?.toList()
if (!list.isNullOrEmpty()) viewModel?.onImagesPicked(list, source)
host?.restoreInputFocus()
}

private fun buildFilePickerCallback(): ValueCallback<Array<Uri>> = ValueCallback { uris ->
val list = uris?.toList()
if (!list.isNullOrEmpty()) viewModel?.onFilesPicked(list)
host?.restoreInputFocus()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,15 @@ class NativeInputModeWidget @JvmOverloads constructor(
onAttachmentChooserStateChanged?.invoke(showing)
}

override fun restoreInputFocus() {
// Picker results are delivered in onActivityResult, before the host activity resumes, and the IME
// ignores a show request until then. Posting runs this once that transaction completes.
post {
requestInputFocus()
showKeyboard()
}
}

override fun attachmentChanged(
hasAttachments: Boolean,
limitExceeded: Boolean,
Expand Down
Loading