From 6c68f1d3c74d68f3642dd9a19ab9a686611cfeb3 Mon Sep 17 00:00:00 2001 From: Siddhesh Sonar <67579112+Siddhesh2377@users.noreply.github.com> Date: Sun, 13 Sep 2026 22:48:23 +0530 Subject: [PATCH 1/2] ide: name the chat model for AI Assistant, and stop refusing the editor at the proxy --- src/ide/jetbrains_profile.cpp | 507 +++++++++++++++++---- src/ide/jetbrains_profile.h | 30 +- src/ide/openai_proxy.cpp | 121 ++++- src/ide/openai_proxy.h | 7 +- tests/CMakeLists.txt | 13 + tests/test_wally_ide_proxy_auth.cpp | 489 ++++++++++++++++++++ tests/test_wally_jetbrains_profile.cpp | 591 +++++++++++++++++++++++++ 7 files changed, 1628 insertions(+), 130 deletions(-) create mode 100644 tests/test_wally_ide_proxy_auth.cpp create mode 100644 tests/test_wally_jetbrains_profile.cpp diff --git a/src/ide/jetbrains_profile.cpp b/src/ide/jetbrains_profile.cpp index eb66d8ee..2821518a 100644 --- a/src/ide/jetbrains_profile.cpp +++ b/src/ide/jetbrains_profile.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include #include @@ -30,7 +32,6 @@ constexpr const char* kSettingsFile = "llm.provider.openai.like.xml"; constexpr const char* kComponent = "OpenAILikeLlmProviderSettings"; /// The provider selection, behind `@State(name = "LlmCustomModelsSettings")`. constexpr const char* kModelsFile = "llm.custom.models.xml"; -constexpr const char* kModelsComponent = "LlmCustomModelsSettings"; /// The set of providers the IDE will talk to at all. constexpr const char* kProvidersFile = "llm.third.party.ai.providers.xml"; constexpr const char* kProvidersComponent = "LLMThirdPartyAIProvidersSettings"; @@ -41,6 +42,16 @@ constexpr const char* kAcknowledgementKey = "llm.third.party.ai.services.acknowledgement.accepted"; /// Application properties, kept as a JSON blob inside a CDATA section. constexpr const char* kPropertiesFile = "other.xml"; + +/// AI Assistant's own settings, which is where Chat mode reads its model from. +/// +/// Separate from the provider files on purpose: the provider list decides which +/// endpoints the IDE may talk to, and this decides which model each feature +/// uses. A configured provider whose model is not named here leaves Chat mode +/// with "No compatible model is available", while the picker still lists the +/// model, because the picker reads the provider and Chat mode reads this. +constexpr const char* kChatFile = "llm.for.code.xml"; +constexpr const char* kChatComponent = "LLMSettings"; /// `OPEN_AI_API_PROVIDER_ID`, which is also the credential's key. constexpr const char* kProviderID = "OpenAIAPI"; /// The subsystem the platform prefixes credentials with. @@ -85,21 +96,7 @@ std::string SettingsXML(const std::string& base_url) { " \n\n"; } -/// Which model each of the IDE's three roles should use. -/// -/// One model answers all three because that is what wally is serving. The id is -/// `/`, the separator being `ThirdPartyLLMProfileId.DELIM`. -std::string ModelsXML(const std::string& model) { - const std::string id = std::string(kProviderID) + "/" + model; - return std::string("\n \n" + - " \n\n"; -} -/// The one provider the IDE is allowed to talk to. /// /// The members are nested directly, with no element naming the collection. /// A `` wrapper — the shape most IntelliJ collections serialize to — is @@ -111,6 +108,319 @@ std::string ProvidersXML() { " \n \n\n"; } +std::string ReadFile(const fs::path& path); + +/// Where a run of markup sits in a document. +struct Span { + std::size_t start = 0; + std::size_t end = 0; +}; + +/// One start tag, as written. +struct Tag { + Span span; ///< `<` through `>`, inclusive of both. + std::string name; ///< The element name. + std::string attribute; ///< The value of the attribute asked for, if present. + bool has_attribute = false; + bool self_closing = false; + bool closing = false; ///< A `` tag. +}; + +/// Past the end of a comment, CDATA section, doctype or processing instruction +/// beginning at `at`, or npos when `at` does not begin one. +/// +/// These are skipped rather than searched, which is the whole reason this file +/// scans rather than pattern-matches. A commented-out `