feat: add energy-aware scheduling and daily insights

- Learn a per-device 7x24 energy profile from completed tasks\n- Constrain high-energy scheduling and expose energy peaks to AI\n- Add ghost-time overlays, daily review dialog, and proactive suggestions\n- Cover energy/insights logic and local OpenAI-compatible providers with tests\n- Update validation docs and screenshots
This commit is contained in:
Misaki
2026-10-26 19:08:09 +08:00
parent 555371a4e0
commit 9bafa71667
42 changed files with 1588 additions and 47 deletions
+62
View File
@@ -16,6 +16,7 @@
#include "storage/SqliteStore.h"
#include "ui/CompactWindow.h"
#include "ui/MainWindow.h"
#include "ui/dialogs/DailyReviewDialog.h"
#include "ui/dialogs/SettingsDialog.h"
#include "ui/panels/DiffPreviewCard.h"
#include "ui/theme/ThemeManager.h"
@@ -60,6 +61,7 @@ class TestCompactWindow : public QObject
private slots:
void initTestCase();
void compactOpensScheduleAndReturns();
void opensDailyReview();
void aiChatShowsDiffAndAccepts();
void aiChatShowsMultiOperationDiff();
@@ -217,6 +219,13 @@ void TestCompactWindow::compactOpensScheduleAndReturns()
}
saveWindow(scheduleWindow, QStringLiteral("schedule-day.png"));
if (auto* grid = scheduleWindow->findChild<ScheduleGridView*>())
{
grid->scrollToHour(18);
QTest::qWait(80);
}
saveWindow(scheduleWindow, QStringLiteral("schedule-ghost.png"));
scheduleWindow->setView(MainWindow::View::Month);
QTest::qWait(200);
QCOMPARE(scheduleWindow->view(), MainWindow::View::Month);
@@ -266,6 +275,59 @@ void TestCompactWindow::compactOpensScheduleAndReturns()
QTest::mouseClick(settingsButton, Qt::LeftButton);
}
void TestCompactWindow::opensDailyReview()
{
QTemporaryDir databaseDir;
QVERIFY(databaseDir.isValid());
SqliteStore store(databaseDir.filePath(QStringLiteral("schedule.db")));
QString error;
QVERIFY2(store.open(&error), qPrintable(error));
ThemeManager theme(*m_settings);
theme.initialize();
ScheduleService service(store, QStringLiteral("review-test"));
NotificationService notifications(service);
AIService aiService(service, store, *m_settings);
createSampleData(service, QDate::currentDate());
CompactWindow compact(service, notifications, aiService, theme, *m_settings);
compact.show();
QVERIFY(QTest::qWaitForWindowExposed(&compact));
QTest::qWait(300);
ElaToolButton* reviewButton = nullptr;
for (ElaToolButton* button : compact.findChildren<ElaToolButton*>())
{
if (button->toolTip().startsWith(QStringLiteral("今日复盘")))
{
reviewButton = button;
break;
}
}
QVERIFY(reviewButton);
QTimer::singleShot(400, []() {
for (QWidget* widget : QApplication::topLevelWidgets())
{
if (auto* dialog = qobject_cast<DailyReviewDialog*>(widget))
{
saveWindow(dialog, QStringLiteral("review.png"));
dialog->reject();
}
}
});
QTimer::singleShot(2000, []() {
for (QWidget* widget : QApplication::topLevelWidgets())
{
if (auto* dialog = qobject_cast<DailyReviewDialog*>(widget))
{
dialog->reject();
}
}
});
QTest::mouseClick(reviewButton, Qt::LeftButton);
}
void TestCompactWindow::aiChatShowsDiffAndAccepts()
{
QTemporaryDir databaseDir;