Repository: Chainlit/chainlit (language: python)

Issue:
Incorrect message ordering in UI after 1.1.400
**Describe the bug**
Assistant messages (including AskUserMessages) are stacked at the top of the chat window, with user messages at the bottom, instead of being in the order they were posted.

**To Reproduce**
Steps to reproduce the behavior:

Update to chainlit 1.1.400 or later. Emit >1 turns of AskUserMessage/user input events to UI.

**Expected behavior**
Messages are displayed in the order they were posted, with user input below the corresponding AskUserMessage.

**Screenshots**
<img width="977" alt="Screenshot 2024-08-16 at 9 58 56 PM" src="https://github.com/user-attachments/assets/f60bd818-7c37-4271-8b66-61c8de3ba18d">

**Desktop (please complete the following information):**

Mac, Chrome 127
Update starlette >=0.40.0 due to CVE-2024-47874
**Describe the bug**
starlette < 0.40.0 is vulnerable to CVE-2024-47874

https://github.com/encode/starlette/security/advisories/GHSA-f96h-pmfr-66vw

**To Reproduce**
```
from starlette.applications import Starlette
from starlette.routing import Route

async def poc(request):
    async with request.form():
        pass

app = Starlette(routes=[
    Route('/', poc, methods=["POST"]),
])
```

`curl http://localhost:8000 -F 'big=</dev/urandom'`

**Expected behavior**
Server should not be vulnerable to easy to reproduce DOS attack.



Discussion / hints:
+1 also seeing this problem
x2, also here!
I have the same issue
back to 1.3
I thought it was intentional ;) But it seams is an error.
Confirming that this is still not fixed in 1.2.0.
any news with this? 
agree this is broken .. If you refresh page, it reorders correctly.  Downgrading to 1.1.306 works.
same issue. 

## Version: 1.1.306
<img width="967" alt="Screenshot 2024-10-11 at 09 32 30" src="https://github.com/user-attachments/assets/a848b054-890b-4987-a607-56144e86b880">

## Version: 1.2
<img width="874" alt="Screenshot 2024-10-11 at 09 33 39" src="https://github.com/user-attachments/assets/81e71b1e-0c56-4371-b92b-e0d8e5dda9f8">



@dokterbob  the issue is clear in this commit "e3a42ba377cf70bc851c3bea2aa65f161602a634" for version [1.1.400rc1](https://github.com/Chainlit/chainlit/releases/tag/1.1.400rc1)

It seems something is wrong with the Messages.tsx file where the sequence of messages is not being properly handled

@willydouhard I have seen you are the developer for this change. I would appreciate if you can jump in and have a look
thanks
The flag isLast has been removed from the Message class and not being used anymore after version 1.1.306
The problem remains in v1.3.0 [2024-10-22]. Long live v1.1.306!!!!
+1 here. It would seem to me that showing messages in the correct order is a must have for a chat application.
Samen problem.
+1 Facing the same problem here with v1.3.1 too.

Tested different code version to confirm that it's front related:

* Using 1.1.306 for front and back : No problem
* Using 1.1.400 for front and back : Incorrect sequencing
* Using 1.1.306 frontend code with 1.3.1 backend : No problem
* Using 1.1.400 frontend code with 1.3.1 backend : Incorrect sequencing

Looking in changelog / code / debugging :

* Between 1.1.306 and 1.1.400, the step notion was added.
* Before 1.1.400, all messages was stored sequentially in frontend memory.
* After 1.1.400, they are stored as step in their parent.

When activating data persistency, if we reload the chat with a good old F5, whatever code version, the messages are displayed in proper order.
With persistency and this code: 

```python
async def main(msg: cl.Message):
        await cl.AskUserMessage(content="Hello, give me an answer that'll ignore.").send()
        await cl.Message(content="Don't care am happy !").send()
```

I've this when chatting :
![image](https://github.com/user-attachments/assets/038c8c72-ee4b-423d-b580-c0008383fd7a)

And when reloading the conversation i've : 

![image](https://github.com/user-attachments/assets/00bfe0f8-3f51-4255-950a-1df70c349e8d)

The message memory is different before and after the refresh.

Message memory before the refresh : 
```json
[
  {
    "threadId": "",
    "id": "0652bb75-c9e9-42d5-ba97-d27f1762cfd3",
    "name": "admin",
    "type": "user_message",
    "output": "case h3",
    "createdAt": "2024-11-05T11:22:29.671Z",
    "steps": [
      {
        "steps": [
          {
            "id": "5eab16ab-c331-4c1d-98c0-41311404bf9c",
            "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
            "parentId": "00f10720-879a-404c-9358-d62509dfb02f",
            "createdAt": "2024-11-05T11:22:31.362621Z",
            "start": "2024-11-05T11:22:31.362621Z",
            "end": "2024-11-05T11:22:31.362621Z",
            "output": "Hello, give me an answer that'll ignore.",
            "name": "Assistant",
            "type": "assistant_message",
            "language": null,
            "streaming": false,
            "isError": false,
            "waitForAnswer": true,
            "indent": null,
            "metadata": {},
            "tags": null,
            "showInput": null
          },
          {
            "id": "144ab8f7-cf9d-487b-aea2-ddc158b03376",
            "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
            "parentId": "00f10720-879a-404c-9358-d62509dfb02f",
            "createdAt": "2024-11-05T11:22:42.479838Z",
            "start": "2024-11-05T11:22:42.479838Z",
            "end": "2024-11-05T11:22:42.479838Z",
            "output": "Don't care am happy !",
            "name": "Assistant",
            "type": "assistant_message",
            "language": null,
            "streaming": false,
            "isError": false,
            "waitForAnswer": false,
            "indent": null,
            "metadata": {},
            "tags": null
          }
        ],
        "name": "on_message",
        "type": "run",
        "id": "00f10720-879a-404c-9358-d62509dfb02f",
        "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
        "parentId": "0652bb75-c9e9-42d5-ba97-d27f1762cfd3",
        "streaming": false,
        "metadata": {},
        "tags": null,
        "input": "case h3",
        "isError": false,
        "output": "",
        "createdAt": "2024-11-05T11:22:31.355751Z",
        "start": "2024-11-05T11:22:31.355773Z",
        "end": "2024-11-05T11:22:42.481253Z",
        "language": null,
        "showInput": "json",
        "generation": null
      }
    ]
  },
  {
    "threadId": "",
    "id": "1446cf15-52ef-4bda-b09a-0193ae45a0e4",
    "name": "admin",
    "type": "user_message",
    "output": "test",
    "createdAt": "2024-11-05T11:22:40.050Z"
  }
]
```

Chat memory after the reload : 

```json
[
  {
    "id": "0652bb75-c9e9-42d5-ba97-d27f1762cfd3",
    "name": "admin",
    "type": "user_message",
    "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
    "parentId": null,
    "streaming": false,
    "waitForAnswer": false,
    "isError": false,
    "metadata": {},
    "tags": null,
    "input": "",
    "output": "case h3",
    "createdAt": "2024-11-05T11:22:31.353220Z",
    "start": "2024-11-05T11:22:31.353220Z",
    "end": "2024-11-05T11:22:31.353220Z",
    "generation": {},
    "showInput": null,
    "language": null,
    "indent": null,
    "feedback": null,
    "steps": [
      {
        "id": "00f10720-879a-404c-9358-d62509dfb02f",
        "name": "on_message",
        "type": "run",
        "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
        "parentId": "0652bb75-c9e9-42d5-ba97-d27f1762cfd3",
        "streaming": false,
        "waitForAnswer": null,
        "isError": false,
        "metadata": {},
        "tags": null,
        "input": "case h3",
        "output": "",
        "createdAt": "2024-11-05T11:22:31.355751Z",
        "start": "2024-11-05T11:22:31.355773Z",
        "end": "2024-11-05T11:22:42.481253Z",
        "generation": null,
        "showInput": "json",
        "language": null,
        "indent": null,
        "feedback": null,
        "steps": [
          {
            "id": "5eab16ab-c331-4c1d-98c0-41311404bf9c",
            "name": "Assistant",
            "type": "assistant_message",
            "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
            "parentId": "00f10720-879a-404c-9358-d62509dfb02f",
            "streaming": false,
            "waitForAnswer": true,
            "isError": false,
            "metadata": {},
            "tags": null,
            "input": "",
            "output": "Hello, give me an answer that'll ignore.",
            "createdAt": "2024-11-05T11:22:31.362621Z",
            "start": "2024-11-05T11:22:31.362621Z",
            "end": "2024-11-05T11:22:31.362621Z",
            "generation": {},
            "showInput": null,
            "language": null,
            "indent": null,
            "feedback": null
          },
          {
            "id": "1446cf15-52ef-4bda-b09a-0193ae45a0e4",
            "name": "admin",
            "type": "user_message",
            "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
            "parentId": "00f10720-879a-404c-9358-d62509dfb02f",
            "streaming": false,
            "waitForAnswer": false,
            "isError": false,
            "metadata": {},
            "tags": null,
            "input": "",
            "output": "test",
            "createdAt": "2024-11-05T11:22:42.475248Z",
            "start": "2024-11-05T11:22:42.475248Z",
            "end": "2024-11-05T11:22:42.475248Z",
            "generation": {},
            "showInput": null,
            "language": null,
            "indent": null,
            "feedback": null
          },
          {
            "id": "144ab8f7-cf9d-487b-aea2-ddc158b03376",
            "name": "Assistant",
            "type": "assistant_message",
            "threadId": "730b0b55-b4b9-4589-b1c8-3a95735cb323",
            "parentId": "00f10720-879a-404c-9358-d62509dfb02f",
            "streaming": false,
            "waitForAnswer": false,
            "isError": false,
            "metadata": {},
            "tags": null,
            "input": "",
            "output": "Don't care am happy !",
            "createdAt": "2024-11-05T11:22:42.479838Z",
            "start": "2024-11-05T11:22:42.479838Z",
            "end": "2024-11-05T11:22:42.479838Z",
            "generation": {},
            "showInput": null,
            "language": null,
            "indent": null,
            "feedback": null
          }
        ]
      }
    ]
  }
]
```

We can clearly see that AskUserMessage  don't store the parentId during a chat session but it'll send it to the persistency layer.
Have it working correctly now. It'll make a PR .
For those who need it, the patch can be back ported to 1.1.400 if you package your own frontend.
@dokterbob @willydouhard Please review the pull request ;)
<!-- Answer -->
The Chainlit codebase currently specifies a dependency on Starlette with the version constraint `^0.37.2`, which means it is compatible with versions `>=0.37.2, <0.38.0` <sup>[[1]](https://github.com/Chainlit/chainlit/blob/main/backend/pyproject.toml)</sup>. To address the CVE-2024-47874 vulnerability, you will need to update the Starlette version to `0.40.0` or higher. However, this update will conflict with the current version constraint specified in the `pyproject.toml` file. You will need to modify the version constraint to allow for Starlette `0.40.0` or higher and ensure that there are no other dependencies that might conflict with this update.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

Darn! Thanks for the head's up! 

Very much appreciate a PR on this one (or else we'll role one, for sure).

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb58059a0d..d6a8c34e0c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,12 +4,92 @@ All notable changes to Chainlit will be documented in this file.
 
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
+## [1.3.2] - 2024-11-08
+
+### Security Advisory
+**IMPORTANT**:
+- This release drops support for FastAPI versions before 0.115.3 and Starlette versions before 0.41.2 due to a severe security vulnerability (CVE-2024-47874). We strongly encourage all downstream dependencies to upgrade as well.
+- This release still contains a known security vulnerability in the element feature that could allow unauthorized file access. We strongly recommend against using elements in production environments until a comprehensive fix is implemented in an upcoming release.
+
+### Security
+- **[breaking]** Updated dependencies to address critical issues (#1493):
+  - Upgraded fastapi to 0.115.3 to address CVE-2024-47874 in Starlette
+  - Upgraded starlette to 0.41.2 (required for security fix)
+  - Upgraded werkzeug to 3.0.6
+
+Note: This is a breaking change as older FastAPI versions are no longer supported.
+To prioritize security, we opted to break with semver on this particular occasion.
+
+### Fixed
+- Resolved incorrect message ordering in UI (#1501)
+
+## [2.0rc0] - 2024-11-08
+
+### Security Advisory
+**IMPORTANT**:
+- This release drops support for FastAPI versions before 0.115.3 and Starlette versions before 0.41.2 due to a severe security vulnerability (CVE-2024-47874). We strongly encourage all downstream dependencies to upgrade as well.
+- The element feature currently contains a known security vulnerability that could allow unauthorized file access. We strongly recommend against using elements in production environments until a comprehensive fix is implemented in an upcoming release.
+
+### Changed
+- **[breaking]**: Completely revamped audio implementation:
+  - Replaced `AudioChunk` with `InputAudioChunk` and `OutputAudioChunk`
+  - Changed audio sampling rate from 44100 to 24000
+  - Removed several audio configuration options (`min_decibels`, `initial_silence_timeout`, `silence_timeout`, `chunk_duration`, `max_duration`)
+  - Modified `on_audio_end` callback
+  - Removed `RecordScreen` componenta
+  - Removed several audio-related configuration options from `config.toml`
+
+### Security
+- Comprehensive security updates:
+  - **[breaking]** Upgraded fastapi to 0.115.3 and starlette to 0.41.2 to address severe security vulnerability CVE-2024-47874 (#1493)
+    - Note: This is a breaking change as older FastAPI versions are no longer supported
+  - Added authentication for file uploads (#1441, #1472)
+  - Updated starlette, werkzeug, and frontend dependencies (#1431, #1414)
+
+### Added
+- Realtime audio streaming and processing (#1401, #1406, #1409):
+  - New `AudioPresence` component for visual representation
+  - Implemented `WavRecorder` and `WavStreamPlayer` classes
+  - Introduced new `on_audio_start` callback
+  - Added audio interruption functionality
+  - New audio connection signaling with `on` and `off` states
+- Interactive DataFrame display with auto-fit content using MUI Data Grid (#1373, #1467)
+- Optional websocket connection in react-client (#1379)
+- Enhanced image interaction with popup view and download option (#1402)
+- Configurable user session timeout and OAuth prompt settings (#1032, #1456)
+- Support for IETF BCP 47 language tags (e.g., es-419) (#1399)
+- Current URL included in message payload (#1403)
+
+### Fixed
+- Enhanced UI interactions:
+  - Allow empty chat input when submitting attachments (#1261)
+  - Fixed dialog boxes extending beyond window bounds (#1446)
+  - Fixed spaces in avatar filenames (#1418)
+- Improved messaging and displays:
+  - Resolved incorrect message ordering (#1501)
+  - Fixed tasklist functionality when Chainlit is submounted (#1433)
+  - Fixed display_name copying during authentication (#1425)
+  - Fixed step argument input and concurrency issues (#1409)
+- Fixed SQLAlchemy identifier quoting (#1395)
+
+### Development
+- Comprehensive build and CI improvements:
+  - Implemented ruff for linting and formatting (#1495)
+  - Added mypy daemon for faster type-checking (#1495)
+  - Added GitHub Actions linting (#1445)
+  - Enabled direct installation from GitHub (#1423)
+  - Various build script improvements (#1462)
+- Enhanced codebase organization:
+  - Factored storage clients into separate modules (#1363)
+  - Extended package metadata (#1413)
+  - Various backend fixes and cleanup (#1432)
+
 ## [1.3.1] - 2024-10-25
 
 ### Security Advisory
 
 - **IMPORTANT**: This release temporarily reverts the file access security improvements from 1.3.0 to restore element functionality. The element feature currently has a known security vulnerability that could allow unauthorized access to files. We strongly recommend against using elements in production environments until the next release.
-- A comprehensive security fix using HTTP-only cookie authentication will be implemented in an upcoming release.
+- A comprehensive security fix will be implemented in an upcoming release.
 
 ### Changed
 
@@ -59,91 +139,6 @@ override oauth prompt parameter. Enabling users to explicitly enable login/conse
 - Improved Python code style and linting (#1353)
 - Resolved various small text and documentation issues (#1347, #1348)
 
-## [2.0.dev2] - 2024-10-25
-
-### Security Advisory
-
-- **IMPORTANT**: This release temporarily reverts the file access security improvements from 2.0.dev1 to restore element functionality. The element feature currently has a known security vulnerability that could allow unauthorized access to files. We strongly recommend against using elements in production environments until the next release.
-- A comprehensive security fix using HTTP-only cookie authentication will be implemented in an upcoming release.
-
-### Changed
-
-- Reverted authentication requirements for file access endpoints to restore element functionality (#1474)
-
-### Development
-
-- Work in progress on implementing HTTP-only cookie authentication for proper security (#1472)
-
-## [2.0.dev1] - 2024-10-22
-
-### Added
-
-- Interactive DataFrame display component using MUI Data Grid (#1373)
-- Optional websocket connection in react-client (#1379)
-- Current URL in message payload (#1403)
-- Improved image interaction - clicking opens popup with download option (#1402)
-- Configurable user session timeout (#1032)
-
-### Security
-
-- Fixed file access vulnerability in get_file and upload_file endpoints (#1441)
-- Added authentication to /project/file endpoint (#1441)
-- Addressed security vulnerabilities in frontend dependencies (#1431, #1414)
-
-### Fixed
-
-- Dialog boxes extending beyond window (#1446)
-- Allow empty chat input when submitting attachments (#1261)
-- Tasklist when Chainlit is submounted (#1433)
-- Spaces in avatar filenames (#1418)
-- Step argument input and concurrency issues (#1409)
-- Display_name copying to PersistentUser during authentication (#1425)
-
-### Development
-
-- Refactored storage clients into separate modules (#1363)
-- Support for IETF BCP 47 language tags (#1399)
-- Improved GitHub Actions workflows and build process (#1445)
-- Direct installation from GitHub support (#1423)
-- Extended package metadata with homepage and documentation links (#1413)
-- Various backend fixes and code cleanup (#1432)
-
-## [2.0.dev0] - 2024-10-08
-
-### Breaking Changes
-
-- Completely revamped audio implementation:
-  - Removed `AudioChunk` type, replaced with `InputAudioChunk` and `OutputAudioChunk`
-  - Changed audio sampling rate from 44100 to 24000
-  - Removed several audio configuration options (`min_decibels`, `initial_silence_timeout`, `silence_timeout`, `chunk_duration`, `max_duration`)
-  - Introduced new `on_audio_start` callback
-  - Modified `on_audio_end` callback to no longer accept file elements as arguments
-
-### Added
-
-- New audio connection signaling with `on` and `off` states
-- Introduced `AudioPresence` component for visual representation of audio state
-- Added `WavRecorder` and `WavStreamPlayer` classes for improved audio handling
-- New `startConversation` and `endConversation` methods in `useAudio` hook
-- Implemented audio interruption functionality
-
-### Changed
-
-- Updated `useChatInteract` hook to include `startAudioStream` method
-- Modified `useChatSession` to handle new audio streaming functionality
-- Updated UI components to reflect new audio implementation, including new microphone icons and audio presence indicators
-- Refactored `InputBoxFooter` to display audio presence when active
-
-### Removed
-
-- Eliminated `RecordScreen` component
-- Removed several audio-related configuration options from `config.toml`
-
-### Development
-
-- Added new wavtools directory with various audio processing utilities
-- Implemented new AudioWorklet processors for more efficient audio handling
-
 ## [1.2.0] - 2024-09-16
 
 ### Security
diff --git a/backend/poetry.lock b/backend/poetry.lock
index 194005096e..8dce05834b 100644
--- a/backend/poetry.lock
+++ b/backend/poetry.lock
@@ -1258,18 +1258,18 @@ weaviate = ["weaviate-client (>2)"]
 
 [[package]]
 name = "fastapi"
-version = "0.112.4"
+version = "0.115.4"
 description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
 optional = false
 python-versions = ">=3.8"
 files = [
-    {file = "fastapi-0.112.4-py3-none-any.whl", hash = "sha256:6d4f9c3301825d4620665cace8e2bc34e303f61c05a5382d1d61a048ea7f2f37"},
-    {file = "fastapi-0.112.4.tar.gz", hash = "sha256:b1f72e1f72afe7902ccd639ba320abb5d57a309804f45c10ab0ce3693cadeb33"},
+    {file = "fastapi-0.115.4-py3-none-any.whl", hash = "sha256:0b504a063ffb3cf96a5e27dc1bc32c80ca743a2528574f9cdc77daa2d31b4742"},
+    {file = "fastapi-0.115.4.tar.gz", hash = "sha256:db653475586b091cb8b2fec2ac54a680ac6a158e07406e1abae31679e8826349"},
 ]
 
 [package.dependencies]
 pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0"
-starlette = ">=0.37.2,<0.39.0"
+starlette = ">=0.40.0,<0.42.0"
 typing-extensions = ">=4.8.0"
 
 [package.extras]
@@ -4772,13 +4772,13 @@ files = [
 
 [[package]]
 name = "starlette"
-version = "0.37.2"
+version = "0.41.2"
 description = "The little ASGI library that shines."
 optional = false
 python-versions = ">=3.8"
 files = [
-    {file = "starlette-0.37.2-py3-none-any.whl", hash = "sha256:6fe59f29268538e5d0d182f2791a479a0c64638e6935d1c6989e63fb2699c6ee"},
-    {file = "starlette-0.37.2.tar.gz", hash = "sha256:9af890290133b79fc3db55474ade20f6220a364a0402e0b556e7cd5e1e093823"},
+    {file = "starlette-0.41.2-py3-none-any.whl", hash = "sha256:fbc189474b4731cf30fcef52f18a8d070e3f3b46c6a04c97579e85e6ffca942d"},
+    {file = "starlette-0.41.2.tar.gz", hash = "sha256:9834fd799d1a87fd346deb76158668cfa0b0d56f85caefe8268e2d97c3468b62"},
 ]
 
 [package.dependencies]
@@ -5556,4 +5556,4 @@ type = ["pytest-mypy"]
 [metadata]
 lock-version = "2.0"
 python-versions = ">=3.9,<4.0.0"
-content-hash = "1d1e98dcff0e799bcd08a88a20b1507025895b9447b26e6bde08fe2cc98374e8"
+content-hash = "ef722a9ee44523a03a61e2d41549a24aae5712f3eef11f1fc450043f22b027b7"
diff --git a/backend/pyproject.toml b/backend/pyproject.toml
index e5221d2b35..471c116cfb 100644
--- a/backend/pyproject.toml
+++ b/backend/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "chainlit"
-version = "1.3.1"
+version = "1.3.2"
 keywords = [
     'LLM',
     'Agents',
@@ -40,8 +40,8 @@ python = ">=3.9,<4.0.0"
 httpx = ">=0.23.0"
 literalai = "0.0.623"
 dataclasses_json = "^0.6.7"
-fastapi = ">=0.110.1,<0.113"
-starlette = "^0.37.2"
+fastapi = ">=0.115.3,<0.116"
+starlette = "^0.41.2"
 uvicorn = "^0.25.0"
 python-socketio = "^5.11.0"
 aiofiles = "^23.1.0"
diff --git a/libs/react-client/src/types/file.ts b/libs/react-client/src/types/file.ts
index af3fde1eba..9099a4163d 100644
--- a/libs/react-client/src/types/file.ts
+++ b/libs/react-client/src/types/file.ts
@@ -22,4 +22,5 @@ export interface IAsk {
     timeout: number;
   } & FileSpec &
     ActionSpec;
+  parentId?: string;
 }
diff --git a/libs/react-client/src/useChatInteract.ts b/libs/react-client/src/useChatInteract.ts
index 5aeb34be3c..1c6306f8ed 100644
--- a/libs/react-client/src/useChatInteract.ts
+++ b/libs/react-client/src/useChatInteract.ts
@@ -112,6 +112,7 @@ const useChatInteract = () => {
   const replyMessage = useCallback(
     (message: IStep) => {
       if (askUser) {
+        if (askUser.parentId) message.parentId = askUser.parentId;
         setMessages((oldMessages) => addMessage(oldMessages, message));
         askUser.callback(message);
       }
diff --git a/libs/react-client/src/useChatSession.ts b/libs/react-client/src/useChatSession.ts
index ffa817c586..d8c17d7bb8 100644
--- a/libs/react-client/src/useChatSession.ts
+++ b/libs/react-client/src/useChatSession.ts
@@ -196,7 +196,7 @@ const useChatSession = () => {
       );
 
       socket.on('ask', ({ msg, spec }, callback) => {
-        setAskUser({ spec, callback });
+        setAskUser({ spec, callback, parentId: msg.parentId });
         setMessages((oldMessages) => addMessage(oldMessages, msg));
 
         setLoading(false);


Test patch:
diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml
index 71c72a07f7..b78823d1c2 100644
--- a/.github/workflows/pytest.yaml
+++ b/.github/workflows/pytest.yaml
@@ -10,7 +10,7 @@ jobs:
     strategy:
       matrix:
         python-version: ['3.9', '3.10', '3.11', '3.12']
-        fastapi-version: ['0.110', '0.111', '0.112']
+        fastapi-version: ['0.115']
     env:
       BACKEND_DIR: ./backend
     steps: