feat(daemon): select the active editor profile over the socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 22s

This commit is contained in:
faumaray committed 2026-12-03 21:57:47 +03:00
1 parent 343e03c27c
commit 502f2b0c51
9 files changed
+120 -2

No files matched your search

+28
View File
@@ -810,6 +810,23 @@ std::string compdb_export_project(const DaemonOptions &options, std::string_view
return serialize_response(JsonValue{std::move(object)});
}
// Switches the active editor profile to an already-published compilation database.
std::string compdb_use_project(const DaemonOptions &options, std::string_view profile_name) {
auto state =
Editor::select_editor_profile(options.project_root, options.build_root, profile_name);
if (!state) {
return error_response(std::format("compdb_use: {}", state.error().format()));
}
JsonValue::Object object;
object.emplace("ok", JsonValue{true});
object.emplace("op", JsonValue{std::string{"compdb_use"}});
object.emplace("profile", JsonValue{state->selected_profile});
object.emplace("generation_id", JsonValue{state->selected_generation_id});
object.emplace("ticket", JsonValue{static_cast<std::int64_t>(state->ticket)});
object.emplace("compdb", JsonValue{state->selected_compdb_path.string()});
return serialize_response(JsonValue{std::move(object)});
}
// Reports the active editor selection and the published compilation database state.
std::string editor_status_project(const DaemonOptions &options) {
auto selection = Editor::read_selection_state(options.project_root);
@@ -1179,6 +1196,17 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
if (*name == "editor_status") {
return {editor_status_project(options), false};
}
if (*name == "compdb_use") {
const auto entry = object->find("profile");
if (entry == object->end()) {
return {error_response("compdb_use requires \"profile\""), false};
}
const auto *value = std::get_if<std::string>(&entry->second.value);
if (value == nullptr || value->empty() || value->size() > kMaxDescribeProfileBytes) {
return {error_response("\"profile\" must be a bounded non-empty string"), false};
}
return {compdb_use_project(options, *value), false};
}
if (*name == "watch_wait") {
std::int64_t timeout_ms = kDefaultWatchWaitMs;
if (const auto entry = object->find("timeout_ms"); entry != object->end()) {