#2780·taipy

Clarify temporary updates to frontend components

Author: FabienLelaquaisCreated Dec 8, 2025Updated Aug 21, 2026
Labels🟧 Priority: HighGui: Back-End💬 Discussion

Feature Description

A situation where clarification (meaning documentation, samples or even APIs) is needed is in the context of mimicking a conversational (chat) UI with streaming responses. One want to create a response message that is temporary (such as the "Thinking..." string), updated on the fly when new response string (or string fragments) come back from an external system that provide them in an asynchronous manner.

Here is an example that @arcanaxion has provided:

python
import time

import taipy.gui.builder as tgb
from taipy.gui import Gui

message_list = []
user_list = ["Human", "Assistant"]
sender_id = user_list[0]


def busy_wait(seconds: int):
    start_time = time.time()
    while time.time() - start_time < seconds:
        pass


def get_assistant_message(user_message: str) -> str:
    wait_time_seconds = 3
    busy_wait(wait_time_seconds)

    return f"Acknowledged: {user_message}"


def send_chat_message(state, var_name: str, payload: dict):
    (_, _, message, sender_id) = payload.get("args", [])

    # Approach 1. With context manager
    # with state as s:
    #     s.message_list = s.message_list + [[str(len(s.message_list)), message, sender_id]]
    #     s.message_list = s.message_list + [[str(len(s.message_list)), "Thinking...", s.user_list[1]]]

    # Approach 2: Without context manager
    state.message_list = state.message_list + [[str(len(state.message_list)), message, sender_id]]
    state.message_list = state.message_list + [[str(len(state.message_list)), "Thinking...", state.user_list[1]]]

    # Approach 3: 1 list
    # state.message_list = state.message_list + [
    #     [str(len(state.message_list)), message, sender_id],
    #     [str(len(state.message_list) + 1), "Thinking...", state.user_list[1]],
    # ]

    message_list = state.message_list
    message_list[-1][1] = get_assistant_message(message)
    # state.message_list = message_list
    state.refresh("message_list")


with tgb.Page() as page:
    tgb.chat("{message_list}", users="{user_list}", sender_id="{sender_id}", on_action=send_chat_message)

Gui(page).run(run_browser=False)

The send_chat_message() callback adds a response with a temporary content, that is updated after some period of time. Depending on the approach, the update is performed only after the waiting period has expired, or the first update of message_list appears properly... then the final message.

Note that the asynchronous dialog is replaced by the busy_wait() function that behaves as if the application was waiting for a response. The behaviour is different if this is replaced by a raw sleep(), when the server has some time to spare to send value updates though the web socket.

We want an implementation that delivers the expected result (content and delay) and an explanation on how this works, so different scenarios can be taken care of in a deterministic manner.

Code of Conduct

  • I have checked the existing issues to avoid duplicates.
  • I am willing to work on this issue (optional)

✅ Acceptance Criteria

  • A working demo or example code (if applicable) is provided.
  • Integration tests demonstrate the new functionality.
  • Any new code is covered by unit tests.
  • Code coverage remains at least 90%.
  • Related documentation updates and release notes are created.