@@ -62,7 +62,7 @@ pub(super) async fn handle(
6262) -> super :: Result < impl IntoResponse > {
6363 let query_id = uuid:: Uuid :: new_v4 ( ) ;
6464 let response = _handle (
65- Query ( params) ,
65+ Query ( params. clone ( ) ) ,
6666 Extension ( app. clone ( ) ) ,
6767 Extension ( user. clone ( ) ) ,
6868 query_id,
@@ -74,6 +74,8 @@ pub(super) async fn handle(
7474 & user,
7575 & QueryEvent {
7676 query_id,
77+ thread_id : params. thread_id ,
78+ repo_ref : Some ( params. repo_ref . clone ( ) ) ,
7779 data : EventData :: output_stage ( "error" )
7880 . with_payload ( "status" , err. status . as_u16 ( ) )
7981 . with_payload ( "message" , err. message ( ) ) ,
@@ -108,6 +110,7 @@ pub(super) async fn _handle(
108110 let ctx = AppContext :: new ( app, user)
109111 . map_err ( |e| super :: Error :: user ( e) . with_status ( StatusCode :: UNAUTHORIZED ) ) ?
110112 . with_query_id ( query_id)
113+ . with_thread_id ( params. thread_id )
111114 . with_repo_ref ( params. repo_ref . clone ( ) ) ;
112115
113116 // confirm client compatibility with answer-api
@@ -1137,8 +1140,9 @@ impl Action {
11371140struct AppContext {
11381141 app : Application ,
11391142 llm_gateway : llm_gateway:: Client ,
1140- query_id : uuid:: Uuid ,
11411143 user : User ,
1144+ query_id : uuid:: Uuid ,
1145+ thread_id : uuid:: Uuid ,
11421146 repo_ref : Option < RepoRef > ,
11431147}
11441148
@@ -1151,8 +1155,9 @@ impl AppContext {
11511155 Ok ( Self {
11521156 app,
11531157 llm_gateway,
1154- query_id : uuid:: Uuid :: nil ( ) ,
11551158 user,
1159+ query_id : uuid:: Uuid :: nil ( ) ,
1160+ thread_id : uuid:: Uuid :: nil ( ) ,
11561161 repo_ref : None ,
11571162 } )
11581163 }
@@ -1162,6 +1167,11 @@ impl AppContext {
11621167 self
11631168 }
11641169
1170+ fn with_thread_id ( mut self , thread_id : uuid:: Uuid ) -> Self {
1171+ self . thread_id = thread_id;
1172+ self
1173+ }
1174+
11651175 fn with_repo_ref ( mut self , repo_ref : RepoRef ) -> Self {
11661176 self . repo_ref = Some ( repo_ref) ;
11671177 self
@@ -1180,6 +1190,8 @@ impl AppContext {
11801190 fn track_query ( & self , data : EventData ) {
11811191 let event = QueryEvent {
11821192 query_id : self . query_id ,
1193+ thread_id : self . thread_id ,
1194+ repo_ref : self . repo_ref . clone ( ) ,
11831195 data,
11841196 } ;
11851197 self . app . track_query ( & self . user , & event) ;
0 commit comments