diff --git a/src/addons/addons/ai-integration/_manifest_entry.js b/src/addons/addons/ai-integration/_manifest_entry.js index 1f2349c386f..f8eda04b4b0 100644 --- a/src/addons/addons/ai-integration/_manifest_entry.js +++ b/src/addons/addons/ai-integration/_manifest_entry.js @@ -19,13 +19,13 @@ const manifest = { { "id": "GeminiAPIKey", "name": "Gemini API Key", - "type": "long_string", + "type": "long_password", "default": "", }, { "id": "OpenRouterAPIKey", "name": "OpenRouter API Key", - "type": "long_string", + "type": "long_password", "default": "", } ], diff --git a/src/addons/addons/ai-integration/userscript.js b/src/addons/addons/ai-integration/userscript.js index 7e8ea146f3d..a0b81b05665 100644 --- a/src/addons/addons/ai-integration/userscript.js +++ b/src/addons/addons/ai-integration/userscript.js @@ -4,16 +4,7 @@ import Attachment from "./helpers/attachment.js"; import main from "./main.js"; const {API_HOST} = require('../../../lib/brand.js'); -let authToken = {}; - -var mainWorkspace; - - -window.addEventListener('blockError', (event) => { - document.AI_INTEGRATION.errorsDetected.push(event.detail); -}); - -document.AI_INTEGRATION = { //probably the dumbest way to possibly do this, it just make debugging alot easier (will do it properly later) +const AI_INTEGRATION = { AI_currently_blabbering: false, CodeChunks: [], AllCodeChunksEverAdded: [], @@ -24,7 +15,18 @@ document.AI_INTEGRATION = { //probably the dumbest way to possibly do this, it j errorsDetected: [], AIModels: [], }; +// TODO: possibly push this into the addons api? +document.AI_INTEGRATION = AI_INTEGRATION; + +let authToken = {}; +let mainWorkspace; + +// TODO: dont use global events +window.addEventListener('blockError', (event) => { + AI_INTEGRATION.errorsDetected.push(event.detail); +}); +// TODO: find a better way to do this, this may break other monkey-patching and it eats RAM... function workspaceOverride() { if (typeof Blockly !== 'undefined') { Blockly.getMainWorkspace = function () { // I have to do this as the getmainworkspace gets linked to the getSVG parsing one @@ -38,9 +40,10 @@ function workspaceOverride() { } workspaceOverride(); +// TODO: this should use a global hook document.addEventListener("mousemove", (event) => { - document.AI_INTEGRATION.X_COORDINATE = event.clientX; - document.AI_INTEGRATION.Y_COORDINATE = event.clientY; + AI_INTEGRATION.X_COORDINATE = event.clientX; + AI_INTEGRATION.Y_COORDINATE = event.clientY; }); export default async function ({ addon, console }) { @@ -62,7 +65,7 @@ export default async function ({ addon, console }) { document.head.appendChild(style); if (authToken.gemini == "" && authToken.openrouter == "") { - document.AI_INTEGRATION.canUse = false; + AI_INTEGRATION.canUse = false; window.addEventListener('ai-button-clicked', function () { main.createBasePopup(2, ""); }); @@ -84,7 +87,7 @@ export default async function ({ addon, console }) { } }) .then(data => { - document.AI_INTEGRATION.AIModels = data; + AI_INTEGRATION.AIModels = data; helpers.updateAIModels(authToken.gemini, authToken.openrouter); }) .catch(error => { @@ -166,6 +169,7 @@ export default async function ({ addon, console }) { } }); + // TODO: dont use global events window.addEventListener('ai-button-clicked', function () { main.createBasePopup(2, ""); }); diff --git a/src/addons/settings/settings.jsx b/src/addons/settings/settings.jsx index 47591877924..c70c4bddd82 100644 --- a/src/addons/settings/settings.jsx +++ b/src/addons/settings/settings.jsx @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021-2023 Thomas Weber + * Copyright (C) 2021-2025 Thomas Weber * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -428,23 +428,24 @@ const Setting = ({ /> )} - {(setting.type === 'string' || setting.type === 'long_string' || setting.type === 'untranslated') && ( + {(setting.type === 'string' || setting.type === 'long_string' || setting.type === 'untranslated' || + setting.type === 'password' || setting.type === 'long_password') && ( {label} SettingsStore.setAddonSetting(addonId, settingId, newValue)} /> - {setting.type !== 'long_string' && ( - - )} + {setting.type !== 'long_string' && setting.type !== 'long_password' && ( + + )} )} {setting.type === 'color' && (