From 743401f15199a116b1777bced843c774c5a59fba Mon Sep 17 00:00:00 2001
From: HsiangNianian <i@jyunko.cn>
Date: Fri, 16 Jan 2026 20:20:19 +0800
Subject: feat: add InstancesView component and integrate instance management
 into the UI

Introduced a new InstancesView component for managing game instances, allowing users to create, edit, delete, and duplicate instances. Updated the App.svelte to include the InstancesView and modified various components to ensure instance selection is handled correctly. Enhanced the ModLoaderSelector and VersionsView to check for active instances before performing actions. Updated the Sidebar to include navigation to the new InstancesView.
---
 ui/src/components/VersionsView.svelte | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

(limited to 'ui/src/components/VersionsView.svelte')

diff --git a/ui/src/components/VersionsView.svelte b/ui/src/components/VersionsView.svelte
index 2e8b028..d4d36d5 100644
--- a/ui/src/components/VersionsView.svelte
+++ b/ui/src/components/VersionsView.svelte
@@ -2,6 +2,7 @@
   import { invoke } from "@tauri-apps/api/core";
   import { listen, type UnlistenFn } from "@tauri-apps/api/event";
   import { gameState } from "../stores/game.svelte";
+  import { instancesState } from "../stores/instances.svelte";
   import ModLoaderSelector from "./ModLoaderSelector.svelte";
 
   let searchQuery = $state("");
@@ -18,11 +19,17 @@
 
   // Load installed modded versions with Java version info (both Fabric and Forge)
   async function loadInstalledModdedVersions() {
+    if (!instancesState.activeInstanceId) {
+      installedFabricVersions = [];
+      isLoadingModded = false;
+      return;
+    }
     isLoadingModded = true;
     try {
       // Get all installed versions and filter for modded ones (Fabric and Forge)
       const allInstalled = await invoke<Array<{ id: string; type: string }>>(
-        "list_installed_versions"
+        "list_installed_versions",
+        { instanceId: instancesState.activeInstanceId }
       );
       
       // Filter for Fabric and Forge versions
@@ -36,7 +43,10 @@
           try {
             const javaVersion = await invoke<number | null>(
               "get_version_java_version",
-              { versionId: id }
+              {
+                instanceId: instancesState.activeInstanceId!,
+                versionId: id,
+              }
             );
             return {
               id,
-- 
cgit v1.2.3-70-g09d2

