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
// src/screens/agent_config/AgenticTasksPanel.h
//
// AGENTIC view — durable, long-running tasks with per-step progress.
// Visible while Settings > Developer > "Enable Agentic Mode" is on (the default).
//
// Subscribes to AgentService::task_event for live updates; on show, requests
// list_tasks() to populate the list. Provides Pause/Resume/Cancel/Delete
// controls and an editable plan view (read-only in Phase 1; editable in Phase 2).
#pragma once
#include <QEvent>
#include <QJsonArray>
#include <QJsonObject>
#include <QWidget>
class QComboBox;
class QFrame;
class QLabel;
class QLineEdit;
class QListWidget;
class QListWidgetItem;
class QPlainTextEdit;
class QProgressBar;
class QPushButton;
class QTimer;
namespace fincept::screens {
class AgenticTasksPanel : public QWidget {
Q_OBJECT
public:
explicit AgenticTasksPanel(QWidget* parent = nullptr);
protected:
void showEvent(QShowEvent* event) override;
void changeEvent(QEvent* event) override;
private slots:
void refresh_list();
void on_filter_changed(int idx);
void on_task_selected(QListWidgetItem* item);
void on_pause_clicked();
void on_resume_clicked();
void on_cancel_clicked();
void on_delete_clicked();
void on_reply_clicked();
void on_schedule_clicked();
void on_schedules_clicked();
void on_libraries_clicked();
private:
void build_ui();
void wire_service();
void apply_task_event(const QString& task_id, const QJsonObject& event);
void render_task_detail(const QJsonObject& task);
void render_plan(const QJsonObject& plan);
void render_budget(const QJsonObject& budget);
void render_question(const QString& question);
void clear_question();
/// Rate-limited refresh_list(): task events arrive in bursts and every list
/// refresh spawns a Python process. Defers while the tab is hidden.
void request_refresh();
static QString status_color_for(const QString& status);
/// Re-apply tr() lookups to every widget whose text we keep a handle to.
/// Called from changeEvent() on QEvent::LanguageChange.
void retranslateUi();
QLabel* filter_title_ = nullptr;
QComboBox* filter_combo_ = nullptr;
QPushButton* refresh_btn_ = nullptr;
QListWidget* task_list_ = nullptr;
QLabel* detail_header_ = nullptr;
QLabel* detail_meta_ = nullptr;
QLabel* plan_title_ = nullptr;
QPlainTextEdit* plan_view_ = nullptr;
QLabel* step_log_title_ = nullptr;
QPlainTextEdit* step_log_ = nullptr;
QPushButton* pause_btn_ = nullptr;
QPushButton* resume_btn_ = nullptr;
QPushButton* cancel_btn_ = nullptr;
QPushButton* delete_btn_ = nullptr;
QPushButton* schedule_btn_ = nullptr;
QPushButton* schedules_btn_ = nullptr;
QPushButton* libraries_btn_ = nullptr;
// Budget meter (per-task, updated from task_event.budget snapshot).
QLabel* budget_label_ = nullptr;
QLabel* budget_tokens_label_ = nullptr;
QLabel* budget_cost_label_ = nullptr;
QLabel* budget_wall_label_ = nullptr;
QLabel* budget_steps_label_ = nullptr;
QProgressBar* budget_tokens_bar_ = nullptr;
QProgressBar* budget_cost_bar_ = nullptr;
QProgressBar* budget_wall_bar_ = nullptr;
QProgressBar* budget_steps_bar_ = nullptr;
// HITL banner: only visible when task.status == paused_for_input.
QFrame* question_banner_ = nullptr;
QLabel* question_title_ = nullptr;
QLabel* question_label_ = nullptr;
QLineEdit* reply_edit_ = nullptr;
QPushButton* reply_btn_ = nullptr;
QString selected_task_id_;
QJsonObject selected_task_config_; // stored agent config of the selected task (no secrets)
bool first_show_ = true;
bool stale_ = false; // events arrived while hidden — refresh on next show
QTimer* refresh_throttle_ = nullptr; // single-shot, armed by request_refresh()
};
} // namespace fincept::screens