FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.
C++ ai-agentsalgorithmic-tradingbloomberg-terminalcppfinancefinancial-marketsfintechgood-first-issueinvestmentinvestment-researchmachine-learningopensourcepythonqtquantitative-financestock-markettrading
refactor(ai_chat): clear pending request context on stream completion and remove unused handle_response
Abhi Kakadiya57660e11857b
diff --git a/fincept-qt/src/screens/ai_chat/AiChatScreen.cpp b/fincept-qt/src/screens/ai_chat/AiChatScreen.cppindex 5f8fd72e4..2f14c6a71 100644--- a/fincept-qt/src/screens/ai_chat/AiChatScreen.cpp+++ b/fincept-qt/src/screens/ai_chat/AiChatScreen.cpp@@ -134,8 +134,11 @@ void AiChatScreen::refresh_theme() {void AiChatScreen::showEvent(QShowEvent* e) {QWidget::showEvent(e);- connect(&ai_chat::LlmService::instance(), &ai_chat::LlmService::finished_streaming, this,- &AiChatScreen::on_streaming_done, Qt::UniqueConnection);+ // Connect LlmService finished_streaming to handle streaming responses using request‑time context+ connect(&ai_chat::LlmService::instance(), &ai_chat::LlmService::finished_streaming,+ this, &AiChatScreen::on_streaming_done, Qt::UniqueConnection);+ // No additional code needed here.+connect(&ai_chat::LlmService::instance(), &ai_chat::LlmService::config_changed, this,&AiChatScreen::on_provider_changed, Qt::UniqueConnection);// Phase 7: rehydrate the linked symbol from SymbolContext on everydiff --git a/fincept-qt/src/screens/ai_chat/AiChatScreen.h b/fincept-qt/src/screens/ai_chat/AiChatScreen.hindex f77b1ab17..52cb96092 100644--- a/fincept-qt/src/screens/ai_chat/AiChatScreen.h+++ b/fincept-qt/src/screens/ai_chat/AiChatScreen.h@@ -64,11 +64,6 @@ class AiChatScreen : public QWidget, public IStatefulScreen, public fincept::IGrvoid on_rename_session();void on_stream_chunk(const QString& chunk, bool done);void on_streaming_done(ai_chat::LlmResponse response);- // New helper that receives the LLM response together with the request snapshot- void handle_response(const ai_chat::LlmResponse &response,- const QString &req_session,- const QString &req_provider,- const QString &req_model);void on_provider_changed();void on_search_changed(const QString& text);void on_typing_indicator_tick();diff --git a/fincept-qt/src/screens/ai_chat/AiChatScreen_Messaging.cpp b/fincept-qt/src/screens/ai_chat/AiChatScreen_Messaging.cppindex 5f4d650a4..6f9062356 100644--- a/fincept-qt/src/screens/ai_chat/AiChatScreen_Messaging.cpp+++ b/fincept-qt/src/screens/ai_chat/AiChatScreen_Messaging.cpp@@ -215,8 +215,18 @@ void AiChatScreen::on_stream_chunk(const QString& chunk, bool done) {void AiChatScreen::on_streaming_done(ai_chat::LlmResponse response) {streaming_ = false;+ // Clear pending request context early to avoid stale data on error paths+ pending_req_session_.clear();+ pending_req_provider_.clear();+ pending_req_model_.clear();show_typing(false);-++ // Ensure a bubble exists for any terminal state (success + content,+ // failure with an error message, or success-but-empty). Without this,+ // a kimi/openai response that arrives via the non-streaming fallback+ // with no per-chunk emission, or fails before any chunk lands, would+ // be silently dropped — the typing indicator hides and the input is+ // re-enabled but nothing is shown.// Ensure a bubble exists for any terminal state (success + content,// failure with an error message, or success-but-empty). Without this,// a kimi/openai response that arrives via the non-streaming fallback