Remember last used binary and show environment variables

This commit is contained in:
Shantur Rathore
2025-10-26 11:30:29 +00:00
parent 0b26ffd97d
commit 030fc4986e
7 changed files with 92 additions and 9 deletions

View File

@@ -3,7 +3,7 @@ import type { Instance, LogEntry } from "../types/instance"
import { sdkManager } from "../lib/sdk-manager"
import { sseManager } from "../lib/sse-manager"
import { fetchSessions, fetchAgents, fetchProviders } from "./sessions"
import { preferences } from "./preferences"
import { preferences, updateLastUsedBinary } from "./preferences"
const [instances, setInstances] = createSignal<Map<string, Instance>>(new Map())
const [activeInstanceId, setActiveInstanceId] = createSignal<string | null>(null)
@@ -52,10 +52,16 @@ async function createInstance(folder: string, binaryPath?: string): Promise<stri
status: "starting",
client: null,
logs: [],
environmentVariables: preferences().environmentVariables,
}
addInstance(instance)
// Update last used binary
if (binaryPath) {
updateLastUsedBinary(binaryPath)
}
try {
const {
id: returnedId,

View File

@@ -96,8 +96,13 @@ function updateLastUsedBinary(path: string): void {
updatePreferences({ lastUsedBinary: path })
const binaries = opencodeBinaries()
const binary = binaries.find((b) => 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)]