Refactor: move model config parsing from renderer to main process via IPC

The renderer was reading config/models.json via workspace:readFile and
manually parsing the provider/model structure. This moves that logic into
a dedicated models:getConfiguredModels IPC handler backed by a new
getAllConfiguredModels() method on the model config repo, matching the
existing models:saveConfig pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
tusharmagar 2026-03-16 11:37:47 +05:30
parent 16b8975b00
commit bfb6702dc9
5 changed files with 77 additions and 47 deletions

View file

@ -2,7 +2,7 @@ import { z } from 'zod';
import { RelPath, Encoding, Stat, DirEntry, ReaddirOptions, ReadFileResult, WorkspaceChangeEvent, WriteFileOptions, WriteFileResult, RemoveOptions } from './workspace.js';
import { ListToolsResponse } from './mcp.js';
import { AskHumanResponsePayload, CreateRunOptions, Run, ListRunsResponse, ToolPermissionAuthorizePayload } from './runs.js';
import { LlmModelConfig } from './models.js';
import { LlmModelConfig, ConfiguredModelsResult } from './models.js';
import { AgentScheduleConfig, AgentScheduleEntry } from './agent-schedule.js';
import { AgentScheduleState } from './agent-schedule-state.js';
import { ServiceEvent } from './service-events.js';
@ -219,6 +219,10 @@ const ipcSchemas = {
success: z.literal(true),
}),
},
'models:getConfiguredModels': {
req: z.null(),
res: ConfiguredModelsResult,
},
'oauth:connect': {
req: z.object({
provider: z.string(),