Skip to content

Commit b9f1f32

Browse files
committed
fix chat fragment warnings
1 parent 1a81180 commit b9f1f32

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/ui/chat/chat.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,24 @@ def render() -> None:
5959
is_stream_output=assistant_cfg.enable_streaming,
6060
)
6161
agent_placeholder = history_container.agent_placeholder
62+
if chat_state.future_result:
63+
agent_placeholder.show_status()
64+
6265
# TODO: feature - select mode for agent (auto, create, multipurpose)
6366
UserInputField.render(controller) # if user input: save to chat state and rerun
6467

6568
# Handle input and response logic
66-
run_every = 0.5 if chat_state.future_result else None
69+
run_every = 2 if chat_state.future_result else None
6770

6871
@st.fragment(run_every=run_every)
69-
def handle_future_response(placeholder):
72+
def handle_future_response():
7073
state = ChatStateManager.get_or_create_state()
7174
if not state.future_result:
7275
return
7376
if state.future_result.done():
7477
try:
7578
response = state.future_result.result() # get result
7679
state.future_result = None
77-
agent_placeholder.handle_response(response)
7880
ChatStateManager.update_state(response)
7981
except Exception as e:
8082
ChatStateManager.add_message(
@@ -83,10 +85,10 @@ def handle_future_response(placeholder):
8385
content=str(e),
8486
thinking=None,
8587
)
88+
chat_scroll()
8689
finally: # prevent eternal loop
8790
st.rerun()
8891
else:
89-
placeholder.show_status()
90-
chat_scroll()
92+
return
9193

92-
handle_future_response(agent_placeholder)
94+
handle_future_response()

src/ui/chat/elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def handle_response(self, response: ChatResponse) -> None:
174174

175175
def show_status(self) -> None:
176176
"""Show thinking status message."""
177-
self.placeholder.status("Thinking... Please, don't change the page. It may take a while.")
177+
self.placeholder.status("Thinking... ", expanded=False)
178178

179179
def show_error(self, error_msg: str | None) -> None:
180180
"""Show error message.

0 commit comments

Comments
 (0)