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
v4.0.2 bug fixes
tilakpatel2209d08deca8f7
diff --git a/.github/scripts/sync_scripts.sh b/.github/scripts/sync_scripts.shindex ea7bef915..29c9fde5a 100644--- a/.github/scripts/sync_scripts.sh+++ b/.github/scripts/sync_scripts.sh@@ -8,9 +8,16 @@# Exclusions (kept in sync with fincept-qt/cmake/prune_scripts_junk.cmake# and the install(DIRECTORY ... REGEX EXCLUDE) rule in CMakeLists.txt):# __pycache__, *.pyc, .pytest_cache, .benchmarks,+# .venv, venv, env,# *.deleted.*, *.bak, *.orig,# *.db, *.sqlite, *.sqlite3,-# .DS_Store, Thumbs.db+# .DS_Store, Thumbs.db,+# .git, .firecrawl+#+# Implementation note: we use `tar --exclude ... | tar -x` instead of rsync+# because rsync is NOT pre-installed on GitHub's windows-2022 runner+# (git-bash omits it, MSYS2 is not on PATH). tar is available on all three+# runner OSes (Windows git-bash, Ubuntu, macOS) out of the box.set -euo pipefail@@ -29,13 +36,17 @@ fimkdir -p "$DEST"-# rsync is present on ubuntu-latest and macos-latest by default. On Windows-# runners it's in git-bash (which is what `shell: bash` uses).-rsync -a \+# Stream tar from SRC → DEST with exclusions applied. The trailing `.` in+# `tar -C "$SRC" -c .` packs SRC's contents (not SRC itself) so files land+# directly under DEST, matching rsync's `SRC/ DEST/` semantics.+tar \--exclude='__pycache__' \--exclude='*.pyc' \--exclude='.pytest_cache' \--exclude='.benchmarks' \+ --exclude='.venv' \+ --exclude='venv' \+ --exclude='env' \--exclude='*.deleted.*' \--exclude='*.deleted' \--exclude='*.bak' \@@ -45,4 +56,6 @@ rsync -a \--exclude='*.sqlite3' \--exclude='.DS_Store' \--exclude='Thumbs.db' \- "${SRC%/}/" "${DEST%/}/"+ --exclude='.git' \+ --exclude='.firecrawl' \+ -C "$SRC" -cf - . | tar -C "$DEST" -xf -diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex d7b568985..d1b2ff8f4 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -182,7 +182,7 @@ jobs:donecp -r resources "${BUILD_DIR}/resources" 2>/dev/null || true- bash .github/scripts/sync_scripts.sh scripts "${BUILD_DIR}/scripts"+ bash "${GITHUB_WORKSPACE}/.github/scripts/sync_scripts.sh" scripts "${BUILD_DIR}/scripts"# qt.conf — pins plugin and data paths relative to the executable.# Without this, Qt falls back to hardcoded build-time paths which# don't exist on a clean machine and cause plugin load failures.@@ -367,7 +367,7 @@ jobs:# App resources + Python analytics scripts live next to the binary# (matches AppPaths resolution on Linux).cp -r resources "${APPDIR}/usr/bin/resources" 2>/dev/null || true- bash .github/scripts/sync_scripts.sh scripts "${APPDIR}/usr/bin/scripts"+ bash "${GITHUB_WORKSPACE}/.github/scripts/sync_scripts.sh" scripts "${APPDIR}/usr/bin/scripts"# Requirements files — PythonSetupManager reads these at first run.mkdir -p "${APPDIR}/usr/bin/resources"@@ -638,7 +638,7 @@ jobs:# Copy app resources + Python analytics scripts into bundlemkdir -p "${APP_BUNDLE}/Contents/Resources"cp -r resources "${APP_BUNDLE}/Contents/Resources/" 2>/dev/null || true- bash .github/scripts/sync_scripts.sh scripts "${APP_BUNDLE}/Contents/Resources/scripts"+ bash "${GITHUB_WORKSPACE}/.github/scripts/sync_scripts.sh" scripts "${APP_BUNDLE}/Contents/Resources/scripts"echo "Bundle staged at: ${APP_BUNDLE}"echo "Pre-sign size: $(du -sh "${APP_BUNDLE}" | cut -f1)"diff --git a/fincept-qt/src/app/MainWindow.cpp b/fincept-qt/src/app/MainWindow.cppindex 60b57896d..98594cf2c 100644--- a/fincept-qt/src/app/MainWindow.cpp+++ b/fincept-qt/src/app/MainWindow.cpp@@ -101,8 +101,28 @@#include <DockWidget.h>#include <FloatingDockContainer.h>+#include <algorithm>+namespace fincept {+int MainWindow::next_window_id() {+ // Seed from the max of (persisted window IDs, live window IDs) so a new+ // window never reuses an ID that already owns saved geometry/dock layout.+ // Live IDs matter too: during a single session we may have deleted a+ // secondary window without clearing its QSettings keys yet, and we still+ // must not collide with any MainWindow currently on screen.+ int max_id = 0;+ const auto saved = SessionManager::instance().load_window_ids();+ for (int id : saved)+ max_id = std::max(max_id, id);+ const auto top_widgets = QApplication::topLevelWidgets();+ for (QWidget* w : top_widgets) {+ if (auto* mw = qobject_cast<MainWindow*>(w))+ max_id = std::max(max_id, mw->window_id());+ }+ return max_id + 1;+}+MainWindow::MainWindow(int window_id, QWidget* parent) : QMainWindow(parent), window_id_(window_id) {// Show active profile in title bar when using a non-default profileconst QString profile = ProfileManager::instance().active();@@ -136,17 +156,49 @@ MainWindow::MainWindow(int window_id, QWidget* parent) : QMainWindow(parent), wi// Secondary windows (id > 0) restore their own saved geometry if available,// otherwise use smart multi-monitor placement (handled by the caller after show()).const QByteArray saved_geom = SessionManager::instance().load_geometry(window_id_);- if (!saved_geom.isEmpty()) {- restoreGeometry(saved_geom);- } else {- QScreen* screen = QApplication::primaryScreen();- if (screen) {- QRect geom = screen->availableGeometry();+ bool geometry_applied = false;+ if (!saved_geom.isEmpty() && restoreGeometry(saved_geom)) {+ // Verify the restored frame actually intersects a currently-connected+ // screen — if the user unplugged a monitor between sessions, Qt will+ // happily hand back off-screen coordinates and the window becomes+ // invisible/unreachable. Guard against that by falling through to+ // smart placement if no intersection exists.+ const QRect frame = frameGeometry();+ bool on_some_screen = false;+ const auto screens = QGuiApplication::screens();+ for (QScreen* s : screens) {+ if (s->availableGeometry().intersects(frame)) {+ on_some_screen = true;+ break;+ }+ }+ geometry_applied = on_some_screen;+ }++ if (!geometry_applied) {+ // Prefer the screen the window lived on last session (by name); fall+ // back to primary if that screen is gone.+ QScreen* target = nullptr;+ const QString saved_screen = SessionManager::instance().load_screen_name(window_id_);+ if (!saved_screen.isEmpty()) {+ for (QScreen* s : QGuiApplication::screens()) {+ if (s->name() == saved_screen) {+ target = s;+ break;+ }+ }+ }+ if (!target)+ target = QApplication::primaryScreen();+ if (target) {+ QRect geom = target->availableGeometry();resize(geom.width() * 9 / 10, geom.height() * 9 / 10);// Only centre-place for the primary window; secondary windows// are positioned by the "new window" action after construction.if (window_id_ == 0)move(geom.center() - rect().center());+ else+ move(geom.center() - rect().center());}}@@ -368,6 +420,47 @@ MainWindow::MainWindow(int window_id, QWidget* parent) : QMainWindow(parent), wiw->show();w->raise();w->activateWindow();+ } else if (action.startsWith("move_to_monitor:")) {+ // Move this window to the named monitor. We resolve by QScreen::name+ // (not index) because index ordering flips on plug/unplug events.+ const QString target_name = action.mid(QStringLiteral("move_to_monitor:").size());+ QScreen* target = nullptr;+ for (QScreen* s : QGuiApplication::screens()) {+ if (s->name() == target_name) {+ target = s;+ break;+ }+ }+ if (!target) {+ LOG_WARN("MainWindow", QString("Move to monitor: screen '%1' not found").arg(target_name));+ return;+ }+ if (screen() == target)+ return; // already there++ // Preserve maximised/fullscreen state across the move: Qt can't+ // directly relocate a maximised window to a different screen, so+ // we restore → move → re-apply the state.+ const bool was_maximised = isMaximized();+ const bool was_fullscreen = isFullScreen();+ if (was_maximised || was_fullscreen)+ showNormal();++ const QRect sg = target->availableGeometry();+ // Keep size if it fits, otherwise clamp to 90% of target screen.+ QSize new_size = size();+ if (new_size.width() > sg.width() || new_size.height() > sg.height())+ new_size = QSize(sg.width() * 9 / 10, sg.height() * 9 / 10);+ resize(new_size);+ move(sg.center() - QPoint(new_size.width() / 2, new_size.height() / 2));++ if (was_fullscreen)+ showFullScreen();+ else if (was_maximised)+ showMaximized();++ LOG_INFO("MainWindow", QString("Moved window %1 to monitor '%2'")+ .arg(window_id_).arg(target_name));} else if (action.startsWith("panel_")) {// Float a screen — in ADS mode, navigate dock_router; in legacy, spawn windowstatic const QMap<QString, QPair<QString, QString>> panel_map = {@@ -1128,12 +1221,37 @@ void MainWindow::schedule_dock_layout_save() {void MainWindow::closeEvent(QCloseEvent* event) {WorkspaceManager::instance().save_workspace();SessionManager::instance().save_geometry(window_id_, saveGeometry(), saveState());+ // Record the monitor this window is currently on so startup can place+ // it back on the same screen even if saveGeometry's absolute coordinates+ // would otherwise land off-screen (e.g. monitor disconnected, DPI changed).+ if (QScreen* scr = screen())+ SessionManager::instance().save_screen_name(window_id_, scr->name());if (dock_manager_) {SessionManager::instance().save_dock_layout(window_id_, dock_manager_->saveState());QSettings tmp;dock_manager_->savePerspectives(tmp);SessionManager::instance().save_perspectives(tmp);}++ // Persist the set of still-open windows (this one minus itself, since+ // we're about to be destroyed). On next launch, main.cpp will iterate+ // this list and restore each secondary window. We also save the count+ // for legacy callers.+ QList<int> open_ids;+ const auto top_widgets = QApplication::topLevelWidgets();+ for (QWidget* w : top_widgets) {+ if (auto* mw = qobject_cast<MainWindow*>(w); mw && mw != this)+ open_ids.append(mw->window_id());+ }+ // Ensure this window is still saved for next run if it's the last one+ // being closed — user would expect to land back in their last layout,+ // including the primary window's dock state.+ if (open_ids.isEmpty())+ open_ids.append(window_id_);+ std::sort(open_ids.begin(), open_ids.end());+ SessionManager::instance().save_window_ids(open_ids);+ SessionManager::instance().save_window_count(open_ids.size());+event->accept();}diff --git a/fincept-qt/src/app/MainWindow.h b/fincept-qt/src/app/MainWindow.hindex ee67e4c20..d2d9e155f 100644--- a/fincept-qt/src/app/MainWindow.h+++ b/fincept-qt/src/app/MainWindow.h@@ -36,10 +36,9 @@ class MainWindow : public QMainWindow {int window_id() const { return window_id_; }/// Returns the next unique window ID (thread-safe via Qt UI thread only).- static int next_window_id() {- static int s_id = 1;- return s_id++;- }+ /// The allocator is seeded from saved state on first call so that IDs+ /// never collide with orphaned saved layouts from a previous session.+ static int next_window_id();protected:void closeEvent(QCloseEvent* event) override;diff --git a/fincept-qt/src/app/main.cpp b/fincept-qt/src/app/main.cppindex 809b5fc2b..4a44d7c1d 100644--- a/fincept-qt/src/app/main.cpp+++ b/fincept-qt/src/app/main.cpp@@ -445,6 +445,23 @@ int main(int argc, char* argv[]) {window->setAttribute(Qt::WA_DeleteOnClose);window->show();+ // Restore any secondary windows that were open at last shutdown so+ // multi-monitor layouts survive across relaunches. Each window+ // restores its own geometry + dock layout from SessionManager.+ {+ const QList<int> saved_ids =+ fincept::SessionManager::instance().load_window_ids();+ for (int id : saved_ids) {+ if (id <= 0) continue; // 0 = primary, already created+ auto* w = new fincept::MainWindow(id);+ w->setAttribute(Qt::WA_DeleteOnClose);+ w->show();+ }+ if (!saved_ids.isEmpty())+ LOG_INFO("App", QString("Restored %1 secondary window(s) from last session")+ .arg(saved_ids.size() > 0 ? saved_ids.size() - 1 : 0));+ }+// Wire new-window handler now that the primary window existsQObject::connect(&app, &SingleApplication::receivedMessage,[](quint32 /*instanceId*/, QByteArray /*message*/) {@@ -473,6 +490,23 @@ int main(int argc, char* argv[]) {fincept::MainWindow window;window.show();+ // Restore any secondary windows that were open at last shutdown. The+ // primary window on the stack owns its own lifetime; restored secondaries+ // use WA_DeleteOnClose and self-remove from QApplication::topLevelWidgets.+ {+ const QList<int> saved_ids =+ fincept::SessionManager::instance().load_window_ids();+ for (int id : saved_ids) {+ if (id <= 0) continue; // 0 = primary, already created+ auto* w = new fincept::MainWindow(id);+ w->setAttribute(Qt::WA_DeleteOnClose);+ w->show();+ }+ if (saved_ids.size() > 1)+ LOG_INFO("App", QString("Restored %1 secondary window(s) from last session")+ .arg(saved_ids.size() - 1));+ }+// ── New-window handler: fires when the user re-launches the exe ──────────// The secondary instance sends "--new-window" and exits. We construct a new// independent MainWindow in this process. WA_DeleteOnClose ensures cleanup.diff --git a/fincept-qt/src/core/session/SessionManager.cpp b/fincept-qt/src/core/session/SessionManager.cppindex 7dcf628f8..c4316e7cc 100644--- a/fincept-qt/src/core/session/SessionManager.cpp+++ b/fincept-qt/src/core/session/SessionManager.cpp@@ -73,6 +73,37 @@ int SessionManager::load_window_count() const {return settings_.value("window_count", 1).toInt();}+void SessionManager::save_window_ids(const QList<int>& ids) {+ QVariantList v;+ v.reserve(ids.size());+ for (int id : ids)+ v.append(id);+ settings_.setValue("window_ids", v);+}++QList<int> SessionManager::load_window_ids() const {+ QList<int> out;+ const QVariantList v = settings_.value("window_ids").toList();+ out.reserve(v.size());+ for (const QVariant& x : v) {+ bool ok = false;+ const int id = x.toInt(&ok);+ if (ok)+ out.append(id);+ }+ return out;+}++void SessionManager::save_screen_name(int window_id, const QString& screen_name) {+ const QString prefix = QString("window_%1/").arg(window_id);+ settings_.setValue(prefix + "screen_name", screen_name);+}++QString SessionManager::load_screen_name(int window_id) const {+ const QString prefix = QString("window_%1/").arg(window_id);+ return settings_.value(prefix + "screen_name").toString();+}+void SessionManager::save_dock_layout(int window_id, const QByteArray& layout) {const QString prefix = QString("window_%1/").arg(window_id);settings_.setValue(prefix + "dock_layout", layout);diff --git a/fincept-qt/src/core/session/SessionManager.h b/fincept-qt/src/core/session/SessionManager.hindex 6a5857d2d..8dc8eafef 100644--- a/fincept-qt/src/core/session/SessionManager.h+++ b/fincept-qt/src/core/session/SessionManager.h@@ -1,7 +1,9 @@#pragma once#include <QElapsedTimer>+#include <QList>#include <QObject>#include <QSettings>+#include <QString>#include <QVariantMap>namespace fincept {@@ -29,6 +31,18 @@ class SessionManager : public QObject {void save_window_count(int count);int load_window_count() const;+ // Track the exact set of window IDs that were open at last shutdown.+ // Used on startup to restore every window (not just window 0) so that+ // multi-monitor layouts survive across app relaunches.+ void save_window_ids(const QList<int>& ids);+ QList<int> load_window_ids() const;++ // Per-window QScreen name — used to restore a window onto the correct+ // monitor when multiple are connected. Empty on first run / fallback+ // to primary screen when the saved screen is no longer available.+ void save_screen_name(int window_id, const QString& screen_name);+ QString load_screen_name(int window_id) const;+// ADS dock layout — scoped per window_idvoid save_dock_layout(int window_id, const QByteArray& layout);QByteArray load_dock_layout(int window_id) const;diff --git a/fincept-qt/src/ui/navigation/ToolBar.cpp b/fincept-qt/src/ui/navigation/ToolBar.cppindex 2fb9abfc8..ee0fc64ff 100644--- a/fincept-qt/src/ui/navigation/ToolBar.cpp+++ b/fincept-qt/src/ui/navigation/ToolBar.cpp@@ -7,9 +7,11 @@#include <QAction>#include <QDateTime>#include <QFontMetrics>+#include <QGuiApplication>#include <QHBoxLayout>#include <QPushButton>#include <QResizeEvent>+#include <QScreen>namespace fincept::ui {@@ -265,6 +267,32 @@ QMenu* ToolBar::build_file_menu() {auto* m = new QMenu("File", this);m->setStyleSheet(popup_ss());m->addAction("New Window", this, [this]() { emit action_triggered("new_window"); });++ // "Move to Monitor" — rebuilt on every popup so plug/unplug events are+ // reflected without restarting the app. Emits "move_to_monitor:<name>"+ // so MainWindow can look the screen up by name (indices are unstable).+ auto* monitors = m->addMenu("Move to Monitor");+ monitors->setStyleSheet(popup_ss());+ connect(monitors, &QMenu::aboutToShow, this, [this, monitors]() {+ monitors->clear();+ const auto screens = QGuiApplication::screens();+ if (screens.size() <= 1) {+ auto* only = monitors->addAction("(single monitor)");+ only->setEnabled(false);+ return;+ }+ int idx = 1;+ for (QScreen* s : screens) {+ const QString name = s->name();+ const QSize size = s->size();+ const QString label =+ QString("%1. %2 (%3×%4)").arg(idx++).arg(name).arg(size.width()).arg(size.height());+ monitors->addAction(label, this, [this, name]() {+ emit action_triggered(QString("move_to_monitor:%1").arg(name));+ });+ }+ });+m->addSeparator();m->addAction("New Workspace", this, [this]() { emit action_triggered("new_workspace"); });m->addAction("Open Workspace", this, [this]() { emit action_triggered("open_workspace"); });