The UI Aptitude provides access to the Olive Helps search bar and global search.
Starting with the v0.25 release of Olive Helps, if a Loop utilizes listenSearchbar or listenGlobalSearch, the Search Bar will focus when the Loop is selected from the dropdown. If a Loop does not use these methods, the Search Bar will not focus when the Loop is selected from the dropdown.
listenGlobalSearch
Creates a listener receiving updates whenever the user enters a search in the Olive Helps Global Search. The Global Search is different from the search bar at the top of Olive Helps, and is triggered by using Command+Shift+O on Mac or Ctrl+Shift+O on Windows.
import { ui } from'@oliveai/ldk';ui.listenGlobalSearch((text) => {// Code to run using the text that the user// entered into the Global Search})
listenSearchbar
Creates a listener receiving updates whenever the user enters a search in the Olive Helps Search bar. The Search Bar can be found at the top of Olive Helps, by clicking the magnifying glass icon.
import { ui } from'@oliveai/ldk';ui.listenSearchbar((text) => {// Code to run using the text that the user// entered into the Searchbar})
loopOpenHandler
Registers a handler function for the Olive Helps Loop Open Button. This function runs when you open the Search bar, click All, and select your Loop. This will also run when a user first installs, restarts, or unpauses your Loop. Click here for more detail.
import { ui } from'@oliveai/ldk';ui.loopOpenHandler(() => {// Code to run when the user selects your loop// from the Searchbar list})
In this example, we trigger a whisper to show when the user selects your Loop from the Search bar list.
import { ui } from'@oliveai/ldk';ui.loopOpenHandler(() =>whisper.create({ label:'Start Whisper', components: [ { type:whisper.WhisperComponentType.Markdown, body:"I'm a whisper that only opens when loopOpenHandler is called", }, ], }));
In this example, we open a Whisper when the user enters "/example" in either the Global Search or the Search bar.
import { ui } from'@oliveai/ldk';constsearchHandler= (text) => {if (text ==='/example') {whisper.create({ label:'Start Whisper', components: [ { type:whisper.WhisperComponentType.Markdown, body:"I'm a whisper that only opens when loopOpenHandler is called", }, ], }) }};ui.listenGlobalSearch(text =>handler(text));ui.listenSearchbar(text =>handler(text));
To use the UI aptitude, simply set the following permissions in your package.json under the ldk object.
Please see our Permissions page for more information.