Release v0.6.26: OpenBao settings synchronization with per-setting conflicts

This commit is contained in:
2026-11-02 00:37:57 +02:00
parent 908985d775
commit 22edece7cf
24 changed files with 1442 additions and 29 deletions
+19 -1
View File
@@ -1,4 +1,5 @@
#include "app.h"
#include "../vendor/json.hpp"
#include "../resources/resource.h"
#include "ocr.h"
#include "configuration.h"
@@ -11,6 +12,7 @@
namespace ks
{
#include "app_sync.inl"
App *App::current = nullptr;
namespace
{
@@ -322,6 +324,7 @@ App::App(HINSTANCE h, bool test, const std::filesystem::path &dataRoot) : instan
}
App::~App()
{
if (syncWorker.joinable()) syncWorker.join();
if (updateWorker.joinable())
updateWorker.join();
if (keyboardHook)
@@ -476,8 +479,16 @@ bool App::registerHotkeys(const Settings &s, bool rollback)
return true;
}
void App::applySettings(const Settings &s)
void App::applySettings(const Settings &requested)
{
Settings s = requested;
std::set<std::wstring> present, removed(s.snippetTombstones.begin(), s.snippetTombstones.end());
removed.insert(settings.snippetTombstones.begin(), settings.snippetTombstones.end());
for (auto &snippet : s.snippets) { snippet.id = snippetId(snippet); present.insert(snippet.id); }
for (const auto &snippet : settings.snippets)
if (!present.contains(snippetId(snippet))) removed.insert(snippetId(snippet));
for (const auto &id : present) removed.erase(id);
s.snippetTombstones.assign(removed.begin(), removed.end());
bool autostartChanged = false;
AutoCorrector predictor;
validateSettings(s);
@@ -525,6 +536,7 @@ void App::applySettings(const Settings &s)
// Clear on the worker so the next check reloads edits to dictionary files.
enqueue([this] { autoCorrector.configure({}, {}); });
scheduleHistoryOcr(s);
nextSync = std::max(GetTickCount64() + 2000, syncRetryAfter);
SetThreadExecutionState(ES_CONTINUOUS |
(settings.awake ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0));
}
@@ -1693,6 +1705,11 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
return TRUE;
}
case WM_TIMER:
if (wp == 6)
{
app->pollSync();
return 0;
}
if (wp == 5)
{
// After the initial 5-second check, repeat while the resident stays open.
@@ -1795,6 +1812,7 @@ int App::execute()
scheduleHistoryOcr(settings);
addTray();
SetTimer(window, 1, 60000, nullptr);
if (!smoke) SetTimer(window, 6, 1000, nullptr);
SetThreadExecutionState(ES_CONTINUOUS |
(settings.awake ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0));
if (!registrationWarning.empty())