Repository: TabbyML/tabby
File: ee/tabby-webserver/src/service/answer.rs (Rust)

Code before:
                }
            };

            let mut attachment = MessageAttachment::default();

            // 1. Collect relevant code if needed.
            if let Some(code_query) = options.code_query.as_ref() {
                if let Some(repository) = self.find_repository(&context_info_helper, code_query, policy.clone()).await {
                    let hits = self.collect_relevant_code(
                        &repository,
                        &context_info_helper,
                        code_query,
                        &self.config.code_search_params,
                        options.debug_options.as_ref().and_then(|x| x.code_search_params_override.as_ref()),
                    ).await;
                    attachment.code = hits.iter().map(|x| x.doc.clone().into()).collect::<Vec<_>>();

                    // FIXME(zwpaper): Turn on directory tree in prod when it got stored in index.
                    if !cfg!(feature = "prod") {
                        let need_codebase_directory_tree = pipeline_decide_need_codebase_directory_tree(self.chat.clone(), &query.content).await.unwrap_or_default();
                        if need_codebase_directory_tree {
                            todo!("inject codebase directory structure into MessageAttachment and ThreadRunItem::ThreadAssistantMessageAttachmentsCode");
                        }
                    }

                    // FIXME(zwpaper): Turn on codebase metadata in prod when it got stored in index.
                    if !cfg!(feature = "prod") {
                        let need_codebase_commit_history = pipeline_decide_need_codebase_commit_history(self.chat.clone(), &query.content).await.unwrap_or_default();
                        if need_codebase_commit_history {
                            todo!("inject codebase commit history into MessageAttachment and ThreadRunItem::ThreadAssistantMessageAttachmentsCode");
                        }
                    }

                    if !hits.is_empty() {
                        let hits = hits.into_iter().map(|x| x.into()).collect::<Vec<_>>();
                        yield Ok(ThreadRunItem::ThreadAssistantMessageAttachmentsCode(
                            ThreadAssistantMessageAttachmentsCode { code_source_id: repository.source_id, hits }
                        ));
                    }
                };
            };

            // 2. Collect relevant docs if needed.
            if let Some(doc_query) = options.doc_query.as_ref() {
                let hits = self.collect_relevant_docs(&context_info_helper, doc_query)
                    .await;
                attachment.doc = futures::future::join_all(hits.iter().map(|x| async {
                    Self::new_message_attachment_doc(self.auth.clone(), x.doc.clone()).await
                })).await;

                debug!("doc content: {:?}: {:?}", doc_query.content, attachment.doc.len());

Review comment (suggestion):
```suggestion
                    // FIXME(zwpaper): Turn on codebase commit history in prod when it got stored in index.
```

Code after:
                }
            };

            let mut attachment = MessageAttachment::default();

            // 1. Collect relevant code if needed.
            if let Some(code_query) = options.code_query.as_ref() {
                if let Some(repository) = self.find_repository(&context_info_helper, code_query, policy.clone()).await {
                    let hits = self.collect_relevant_code(
                        &repository,
                        &context_info_helper,
                        code_query,
                        &self.config.code_search_params,
                        options.debug_options.as_ref().and_then(|x| x.code_search_params_override.as_ref()),
                    ).await;
                    attachment.code = hits.iter().map(|x| x.doc.clone().into()).collect::<Vec<_>>();

                    // FIXME(zwpaper): Turn on directory tree in prod when it got stored in index.
                    if !cfg!(feature = "prod") {
                        let need_codebase_directory_tree = pipeline_decide_need_codebase_directory_tree(self.chat.clone(), &query.content).await.unwrap_or_default();
                        if need_codebase_directory_tree {
                            todo!("inject codebase directory structure into MessageAttachment and ThreadRunItem::ThreadAssistantMessageAttachmentsCode");
                        }
                    }

                    // FIXME(zwpaper): Turn on codebase commit history in prod when it got stored in index.
                    if !cfg!(feature = "prod") {
                        let need_codebase_commit_history = pipeline_decide_need_codebase_commit_history(self.chat.clone(), &query.content).await.unwrap_or_default();
                        if need_codebase_commit_history {
                            todo!("inject codebase commit history into MessageAttachment and ThreadRunItem::ThreadAssistantMessageAttachmentsCode");
                        }
                    }

                    if !hits.is_empty() {
                        let hits = hits.into_iter().map(|x| x.into()).collect::<Vec<_>>();
                        yield Ok(ThreadRunItem::ThreadAssistantMessageAttachmentsCode(
                            ThreadAssistantMessageAttachmentsCode { code_source_id: repository.source_id, hits }
                        ));
                    }
                };
            };

            // 2. Collect relevant docs if needed.
            if let Some(doc_query) = options.doc_query.as_ref() {
                let hits = self.collect_relevant_docs(&context_info_helper, doc_query)
                    .await;
                attachment.doc = futures::future::join_all(hits.iter().map(|x| async {
                    Self::new_message_attachment_doc(self.auth.clone(), x.doc.clone()).await
                })).await;

                debug!("doc content: {:?}: {:?}", doc_query.content, attachment.doc.len());