fix(quick-pane): restore model catalog controls
This commit is contained in:
@@ -273,6 +273,7 @@ export function createAgentRegistry({
|
||||
let workspaceSequence = 0;
|
||||
let manifestIssue;
|
||||
let canonicalHomeWorktree;
|
||||
let lastSuccessfulModelCatalog;
|
||||
let stopping = false;
|
||||
|
||||
function publishWorkspace(type, runtime, data = {}) {
|
||||
@@ -307,13 +308,13 @@ export function createAgentRegistry({
|
||||
runtimes: [...runtimesByRuntimeId.values()]
|
||||
.filter((runtime) => !runtime.ephemeral)
|
||||
.map((runtime) => ({
|
||||
runtimeId: runtime.runtimeId,
|
||||
worktreePath: runtime.worktreePath,
|
||||
...(runtime.sessionPath ? { sessionPath: runtime.sessionPath } : {}),
|
||||
...(runtime.sessionId ? { sessionId: runtime.sessionId } : {}),
|
||||
...(runtime.legacyDefault ? { legacyDefault: true } : {}),
|
||||
openedAt: runtime.openedAt,
|
||||
})),
|
||||
runtimeId: runtime.runtimeId,
|
||||
worktreePath: runtime.worktreePath,
|
||||
...(runtime.sessionPath ? { sessionPath: runtime.sessionPath } : {}),
|
||||
...(runtime.sessionId ? { sessionId: runtime.sessionId } : {}),
|
||||
...(runtime.legacyDefault ? { legacyDefault: true } : {}),
|
||||
openedAt: runtime.openedAt,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -986,7 +987,9 @@ export function createAgentRegistry({
|
||||
}
|
||||
if (stopConfirmed) releaseClosedSessionLease(runtime);
|
||||
if (runtime.ephemeral && stopConfirmed)
|
||||
await rm(runtime.sessionDir, { recursive: true, force: true }).catch(() => {});
|
||||
await rm(runtime.sessionDir, { recursive: true, force: true }).catch(
|
||||
() => {},
|
||||
);
|
||||
runtime.state = "stopped";
|
||||
publishWorkspace("runtime_closed", runtime, {
|
||||
runtimeId: runtime.runtimeId,
|
||||
@@ -1160,6 +1163,15 @@ export function createAgentRegistry({
|
||||
});
|
||||
await restoreRecords(records);
|
||||
}
|
||||
if (
|
||||
!loaded.issue &&
|
||||
![...runtimesByAgentId.values()].some((runtime) => runtime.adapter)
|
||||
) {
|
||||
await openRuntime({
|
||||
worktreePath: canonicalHomeWorktree,
|
||||
legacyDefault: true,
|
||||
});
|
||||
}
|
||||
return this.listAgents()[0];
|
||||
},
|
||||
async selectWorktree(worktreePath) {
|
||||
@@ -1206,14 +1218,31 @@ export function createAgentRegistry({
|
||||
return closeRuntime(runtimeId);
|
||||
},
|
||||
async getModelCatalog() {
|
||||
const runtime = [...runtimesByAgentId.values()].find(
|
||||
(candidate) => candidate.adapter,
|
||||
const candidates = [...runtimesByAgentId.values()].filter(
|
||||
(runtime) =>
|
||||
runtime.adapter &&
|
||||
!runtime.stopped &&
|
||||
!["closing", "stopped", "failed"].includes(runtime.state),
|
||||
);
|
||||
if (!runtime?.adapter) return [];
|
||||
const response = await enqueue(runtime, () =>
|
||||
runtime.adapter.send({ type: "get_available_models" }),
|
||||
);
|
||||
return response?.data?.models ?? [];
|
||||
let lastError;
|
||||
for (const runtime of candidates) {
|
||||
const adapter = runtime.adapter;
|
||||
try {
|
||||
const response = await enqueue(runtime, () =>
|
||||
adapter.send({ type: "get_available_models" }),
|
||||
);
|
||||
if (response?.success !== true || !Array.isArray(response?.data?.models)) {
|
||||
continue;
|
||||
}
|
||||
lastSuccessfulModelCatalog = response.data.models;
|
||||
return response.data.models;
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
}
|
||||
}
|
||||
if (lastSuccessfulModelCatalog) return lastSuccessfulModelCatalog;
|
||||
if (lastError) throw lastError;
|
||||
return [];
|
||||
},
|
||||
listAgents() {
|
||||
return [...runtimesByAgentId.values()]
|
||||
|
||||
Reference in New Issue
Block a user