diff --git a/electron/main/process-manager.ts b/electron/main/process-manager.ts index fdacc31d..d1360aa3 100644 --- a/electron/main/process-manager.ts +++ b/electron/main/process-manager.ts @@ -57,15 +57,29 @@ class ProcessManager { environmentVariables?: Record, ): Promise { this.validateFolder(folder) - const actualBinaryPath = binaryPath ? this.validateCustomBinary(binaryPath) : this.validateOpenCodeBinary() + const actualBinaryPath = + binaryPath && binaryPath !== "opencode" ? this.validateCustomBinary(binaryPath) : this.validateOpenCodeBinary() - this.sendLog(instanceId, "info", `Starting OpenCode server for ${folder} using ${actualBinaryPath}...`) + this.sendLog( + instanceId, + "info", + `Starting OpenCode server for ${folder} using ${binaryPath || "opencode"} (${actualBinaryPath})...`, + ) // Merge environment variables with process environment const env = { ...process.env } if (environmentVariables) { Object.assign(env, environmentVariables) - this.sendLog(instanceId, "info", `Using ${Object.keys(environmentVariables).length} custom environment variables`) + this.sendLog( + instanceId, + "info", + `Using ${Object.keys(environmentVariables).length} custom environment variables:`, + ) + + // Log each environment variable + for (const [key, value] of Object.entries(environmentVariables)) { + this.sendLog(instanceId, "info", ` ${key}=${value}`) + } } return new Promise((resolve, reject) => { diff --git a/src/components/folder-selection-view.tsx b/src/components/folder-selection-view.tsx index dbb00ee8..3689de06 100644 --- a/src/components/folder-selection-view.tsx +++ b/src/components/folder-selection-view.tsx @@ -1,6 +1,6 @@ -import { Component, createSignal, Show, For, onMount, onCleanup } from "solid-js" +import { Component, createSignal, Show, For, onMount, onCleanup, createEffect } from "solid-js" import { Folder, Clock, Trash2, FolderPlus, Settings, ChevronDown, ChevronUp } from "lucide-solid" -import { recentFolders, removeRecentFolder, preferences } from "../stores/preferences" +import { recentFolders, removeRecentFolder, preferences, updateLastUsedBinary } from "../stores/preferences" import OpenCodeBinarySelector from "./opencode-binary-selector" import EnvironmentVariablesEditor from "./environment-variables-editor" @@ -17,6 +17,14 @@ const FolderSelectionView: Component = (props) => { const folders = () => recentFolders() + // Update selected binary when preferences change + createEffect(() => { + const lastUsed = preferences().lastUsedBinary + if (lastUsed && lastUsed !== selectedBinary()) { + setSelectedBinary(lastUsed) + } + }) + function scrollToIndex(index: number) { const element = document.querySelector(`[data-folder-index="${index}"]`) if (element) { @@ -115,13 +123,19 @@ const FolderSelectionView: Component = (props) => { } function handleFolderSelect(path: string) { + updateLastUsedBinary(selectedBinary()) props.onSelectFolder(path, selectedBinary()) } function handleBrowse() { + updateLastUsedBinary(selectedBinary()) props.onSelectFolder(undefined, selectedBinary()) } + function handleBinaryChange(binary: string) { + setSelectedBinary(binary) + } + function handleRemove(path: string, e?: Event) { e?.stopPropagation() removeRecentFolder(path) @@ -271,7 +285,7 @@ const FolderSelectionView: Component = (props) => {
OpenCode Binary
diff --git a/src/components/instance-info.tsx b/src/components/instance-info.tsx index 196a2c4c..d6d44ac5 100644 --- a/src/components/instance-info.tsx +++ b/src/components/instance-info.tsx @@ -142,6 +142,28 @@ const InstanceInfo: Component = (props) => { + 0}> +
+
+ Environment Variables ({Object.keys(props.instance.environmentVariables!).length}) +
+
+ + {([key, value]) => ( +
+ + {key} + + + {value} + +
+ )} +
+
+
+
+ 0}>
diff --git a/src/components/logs-view.tsx b/src/components/logs-view.tsx index d0917856..795469de 100644 --- a/src/components/logs-view.tsx +++ b/src/components/logs-view.tsx @@ -82,6 +82,27 @@ const LogsView: Component = (props) => {

Server Logs

+ 0}> +
+
+ Environment Variables ({Object.keys(instance()?.environmentVariables!).length}) +
+
+ + {([key, value]) => ( +
+ {key} + = + + {value} + +
+ )} +
+
+
+
+
>(new Map()) const [activeInstanceId, setActiveInstanceId] = createSignal(null) @@ -52,10 +52,16 @@ async function createInstance(folder: string, binaryPath?: string): Promise b.path === path) - if (binary) { + let binary = binaries.find((b) => b.path === path) + + // If binary not found in list, add it (for system PATH "opencode") + if (!binary) { + addOpenCodeBinary(path) + binary = { path, lastUsed: Date.now() } + } else { binary.lastUsed = Date.now() // Move to front const sorted = [binary, ...binaries.filter((b) => b.path !== path)] diff --git a/src/types/instance.ts b/src/types/instance.ts index 446ccaf7..3bb21457 100644 --- a/src/types/instance.ts +++ b/src/types/instance.ts @@ -38,4 +38,5 @@ export interface Instance { logs: LogEntry[] metadata?: InstanceMetadata binaryPath?: string + environmentVariables?: Record }