From 9eb1ddbf1b65cedb17992c2c88d1568979fbef5b Mon Sep 17 00:00:00 2001 From: Martico2432 Date: Tue, 2 Jun 2026 18:37:10 +0200 Subject: [PATCH 1/3] Add toml refresh --- frontend/src/components/BotList.svelte | 36 ++++++++++++++++++++++++-- frontend/src/pages/Home.svelte | 30 +++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/BotList.svelte b/frontend/src/components/BotList.svelte index 7086e6a..50a19c2 100644 --- a/frontend/src/components/BotList.svelte +++ b/frontend/src/components/BotList.svelte @@ -32,6 +32,8 @@ let { orangePlayers = $bindable(), map, duplicateAgentIds = new Set(), + getLatestBotInfo, + getLatestScriptInfo, }: { bots: DraggablePlayer[]; scripts: ToggleableScript[]; @@ -43,6 +45,8 @@ let { orangePlayers: DraggablePlayer[]; map: string; duplicateAgentIds: Set; + getLatestBotInfo?: (tomlPath: string) => Promise; + getLatestScriptInfo?: (tomlPath: string) => Promise; } = $props(); const flipDurationMs = 100; @@ -250,14 +254,42 @@ function toggleScript(id: string) { enabledScripts[id] = !enabledScripts[id]; } -function handleBotInfoClick(bot: DraggablePlayer) { +async function handleBotInfoClick(bot: DraggablePlayer) { if (bot.info instanceof BotInfo) { + + try { + if (getLatestBotInfo) { + const refreshed = await getLatestBotInfo(bot.info.tomlPath); + if (refreshed) { + selectedAgent = [refreshed, refreshed.config?.settings?.name ?? bot.displayName, (refreshed as any).icon ?? bot.icon]; + showInfoModal = true; + return; + } + } + } catch (err) { + toast.error("Failed to get latest bot info: " + err, { duration: 10000 }); + } + selectedAgent = [bot.info, bot.displayName, bot.icon]; showInfoModal = true; } } -function handleScriptInfoClick(script: ToggleableScript) { +async function handleScriptInfoClick(script: ToggleableScript) { + + try { + if (getLatestScriptInfo) { + const refreshed = await getLatestScriptInfo(script.info.tomlPath); + if (refreshed) { + selectedAgent = [refreshed, refreshed.config?.settings?.name ?? script.displayName, (refreshed as any).icon ?? script.icon]; + showInfoModal = true; + return; + } + } + } catch (err) { + toast.error("Failed to get latest script info: " + err, { duration: 10000 }); + } + selectedAgent = [script.info, script.displayName, script.icon]; showInfoModal = true; } diff --git a/frontend/src/pages/Home.svelte b/frontend/src/pages/Home.svelte index 435f7bb..dab1410 100644 --- a/frontend/src/pages/Home.svelte +++ b/frontend/src/pages/Home.svelte @@ -317,6 +317,31 @@ async function updateScripts() { loadingScripts = false; } +async function getLatestBotInfo(tomlPath: string): Promise { + try { + await updateBots(); + const found = players.find( + (p) => p.info instanceof BotInfo && p.info.tomlPath === tomlPath, + ); + return found ? (found.info as BotInfo) : null; + } catch (err) { + console.error("Failed to get latest bot info: ", err); + return null; + } +} + +async function getLatestScriptInfo(tomlPath: string): Promise { + try { + await updateScripts(); + const found = scripts.find((s) => s.info.tomlPath === tomlPath); + return found ? (found.info as BotInfo) : null; + } catch (err) { + console.error("Failed to get latest script info: ", err); + return null; + } +} + + $effect(() => { localStorage.setItem("BOT_SEARCH_PATHS", JSON.stringify(paths)); updateBots(); @@ -373,6 +398,9 @@ async function onMatchStart(randomizeMap: boolean) { ]; } + await updateBots(); + await updateScripts(); + const options: StartMatchOptions = { map: $mapStore, gameMode: mode, @@ -476,6 +504,8 @@ function handleSearch(event: Event) { selectedTeam={selectedTeam} map={$mapStore} {duplicateAgentIds} + getLatestBotInfo={getLatestBotInfo} + getLatestScriptInfo={getLatestScriptInfo} /> From c4f30a0fd6cc37a0517777402dbbc4fe3f8cfb72 Mon Sep 17 00:00:00 2001 From: Martico2432 Date: Thu, 4 Jun 2026 18:21:02 +0200 Subject: [PATCH 2/3] Update relevant bots/scripts on info --- frontend/src/pages/Home.svelte | 64 +++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/Home.svelte b/frontend/src/pages/Home.svelte index dab1410..4b8b714 100644 --- a/frontend/src/pages/Home.svelte +++ b/frontend/src/pages/Home.svelte @@ -319,29 +319,77 @@ async function updateScripts() { async function getLatestBotInfo(tomlPath: string): Promise { try { - await updateBots(); - const found = players.find( + const result = await App.GetBots([tomlPath]); + + const found = result.find((b) => b.tomlPath === tomlPath); + if (!found) return null; // No bot found + + const botInfo = new BotInfo(found); + + const index = players.findIndex( (p) => p.info instanceof BotInfo && p.info.tomlPath === tomlPath, ); - return found ? (found.info as BotInfo) : null; + + if (index !== -1) { + players[index] = { + ...players[index], + displayName: found.config.settings.name, + icon: found.icon, + info: botInfo, + tags: found.config.details.tags, + }; + + players = [...players]; + bluePlayers = updateTeam(bluePlayers); + orangePlayers = updateTeam(orangePlayers); + } + + return botInfo; } catch (err) { console.error("Failed to get latest bot info: ", err); return null; } } -async function getLatestScriptInfo(tomlPath: string): Promise { +async function getLatestScriptInfo(tomlPath: string): Promise { try { - await updateScripts(); - const found = scripts.find((s) => s.info.tomlPath === tomlPath); - return found ? (found.info as BotInfo) : null; + const result = await App.GetScripts([tomlPath]); + + const found = result.find((s) => s.tomlPath === tomlPath); + if (!found) return null; // No script found + + const index = scripts.findIndex((s) => s.info.tomlPath === tomlPath); + + if (index !== -1) { + const oldAgentId = scripts[index].info.config.settings.agentId; + const newAgentId = found.config.settings.agentId; + + scripts[index] = { + ...scripts[index], + displayName: found.config.settings.name, + icon: found.config.settings.logoFile, + info: found, + tags: found.config.details.tags, + }; + + scripts = [...scripts]; + + if (enabledScripts[newAgentId] === undefined) { + enabledScripts[newAgentId] = false; + } + + if (oldAgentId !== newAgentId && enabledScripts[oldAgentId] === undefined) { + enabledScripts[oldAgentId] = false; + } + } + + return found; } catch (err) { console.error("Failed to get latest script info: ", err); return null; } } - $effect(() => { localStorage.setItem("BOT_SEARCH_PATHS", JSON.stringify(paths)); updateBots(); From 8cbcd399c2207889c0ec23a0a09606019adbbec9 Mon Sep 17 00:00:00 2001 From: Martico2432 Date: Thu, 4 Jun 2026 18:30:08 +0200 Subject: [PATCH 3/3] Refresh relevant bots/scripts on match start --- frontend/src/pages/Home.svelte | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/Home.svelte b/frontend/src/pages/Home.svelte index 4b8b714..598367b 100644 --- a/frontend/src/pages/Home.svelte +++ b/frontend/src/pages/Home.svelte @@ -446,8 +446,27 @@ async function onMatchStart(randomizeMap: boolean) { ]; } - await updateBots(); - await updateScripts(); + // Update bots and scripts + const botsInMatch = [ + ...new Set( + [...bluePlayers, ...orangePlayers] + .filter((p) => p.info instanceof BotInfo) + .map((p) => (p.info as BotInfo).tomlPath), + ), + ]; + + const scriptsInMatch = [ + ...new Set( + scripts // We could reuse this for StartMatchOptions, and not map twice + .filter((x) => enabledScripts[x.info.config.settings.agentId]) + .map((x) => x.info.tomlPath), + ), + ]; + + await Promise.all([ + ...botsInMatch.map((tomlPath) => getLatestBotInfo(tomlPath)), + ...scriptsInMatch.map((tomlPath) => getLatestScriptInfo(tomlPath)), + ]); const options: StartMatchOptions = { map: $mapStore,