h2oai / h2oai/wave

Triggers interrupting Chat Value

Open
#2,368 0 comments 0 reactions 0 assignees View on GitHub
bug ui
Dominant language
Python
Stars
4.3k
Forks
371
Avg merge
26d 1h
Merged PRs (30d)
1

Description

#### Wave SDK Version, OS
Wave 1.1.1
Apple M3 Max Sonoma 14.1 (also seen on a Windows machine)
Safari (also tested in Chrome)

#### Actual behavior
When users type into a chatbot but do not click enter, and then interact with another element, the Submitted element is incorrect.

#### Expected behavior
Users can type into a chatbot, do other stuff, and then submit later and the chatbot knows it was submitted.

#### Steps To Reproduce

While running the following app:
1. type into the chatbot but do not submit
2. Click the filter button to open the side panel which has a trigger element.
3. Click away from the side panel to close it - do not click on the trigger element.
4. Click submit on the chatbot.

The value of `__wave_submission_name__` will be the trigger element instead of the chatbot.

```py
from h2o_wave import main, app, Q, ui, data, on, run_on

@app('/')
async def serve(q: Q):

if not q.client.initialize:

q.page["meta"] = ui.meta_card("")
q.page["filter"] = ui.form_card(
box="6 1 1 1",
items=[ui.button(name="filter_button", label="Click Me!", primary=True)]
)
q.page['chatbot_card'] = ui.chatbot_card(
box='1 1 5 5',
name='chatbot',
data=data(fields='content from_user', t='list', rows=[q.client.chat_history]),
)

q.client.agency_list = ["test1", "test2"]
q.client.selected_agency = None

q.client.initialize = True

if q.args.filter_button:
# The user wants to do some filtering
q.page["meta"].side_panel = ui.side_panel(
title="Filter",
items=[
ui.choice_group(
name="agency_filter", label="Agency Filter",
choices=[ui.choice(a, a) for a in q.client.agency_list],
value=q.client.selected_agency, trigger=True
),
]
)

if q.args.agency_filter:
# This is on a trigger and calls when someone has clicked any agency option
q.client.selected_agency = q.args.agency_filter
q.page["meta"].notification_bar = ui.notification_bar(
text="Your option was saved!"
)

if q.args.__wave_submission_name__ == "chatbot":
q.page['chatbot_card'].data += ["👤" + q.args.chatbot, True]
q.page['chatbot_card'].data += ["🤖 I am just a demo", False]

await q.page.save()
```

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Python reproduction in Wave 1.1.1 and tracing how __wave_submission_name__ is set for chatbot submission and triggered elements. Reproduce the filter-panel sequence, then verify that submitting the chatbot reports "chatbot" rather than the trigger element without breaking agency_filter triggers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.