Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/addons/addons/ai-integration/_manifest_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
}
],
Expand Down
32 changes: 18 additions & 14 deletions src/addons/addons/ai-integration/userscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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
Expand All @@ -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 }) {
Expand All @@ -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, "");
});
Expand All @@ -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 => {
Expand Down Expand Up @@ -166,6 +169,7 @@ export default async function ({ addon, console }) {
}
});

// TODO: dont use global events
window.addEventListener('ai-button-clicked', function () {
main.createBasePopup(2, "");
});
Expand Down
23 changes: 12 additions & 11 deletions src/addons/settings/settings.jsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -428,23 +428,24 @@ const Setting = ({
/>
</React.Fragment>
)}
{(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') && (
<React.Fragment>
{label}
<TextInput
id={uniqueId}
type="text"
type={setting.type === 'password' || setting.type === 'long_password' ? 'password' : 'text'}
value={value}
className={setting.type === 'long_string' ? styles.longStringSetting : ''}
className={setting.type === 'long_string' || setting.type === 'long_password' ? styles.longStringSetting : ''}
onChange={newValue => SettingsStore.setAddonSetting(addonId, settingId, newValue)}
/>
{setting.type !== 'long_string' && (
<ResetButton
addonId={addonId}
settingId={settingId}
forTextInput
/>
)}
{setting.type !== 'long_string' && setting.type !== 'long_password' && (
<ResetButton
addonId={addonId}
settingId={settingId}
forTextInput
/>
)}
</React.Fragment>
)}
{setting.type === 'color' && (
Expand Down