fix(hub,web): query Codex models via machine RPC instead of session cwd (#1186)

SessionChat fetched Codex models through the session-scoped endpoint,
so the CLI listed models in the session process cwd, where a missing
directory or project-level Codex config could skew or break the result.
Use the machine-scoped endpoint (already used by NewSession) and drop
the now-unused session route and RPC plumbing.

Fixes #1072
This commit is contained in:
weishu
2026-07-27 12:58:22 +08:00
committed by GitHub
parent da6f4cc5b0
commit 54bddd9db1
8 changed files with 4 additions and 76 deletions
-6
View File
@@ -653,12 +653,6 @@ export class ApiClient {
)
}
async getSessionCodexModels(sessionId: string): Promise<CodexModelsResponse> {
return await this.request<CodexModelsResponse>(
`/api/sessions/${encodeURIComponent(sessionId)}/codex-models`
)
}
async getSessionOpencodeModels(sessionId: string): Promise<OpencodeModelsResponse> {
return await this.request<OpencodeModelsResponse>(
`/api/sessions/${encodeURIComponent(sessionId)}/opencode-models`
+1 -1
View File
@@ -544,7 +544,7 @@ function SessionChatInner(props: SessionChatProps) {
const codexCollaborationModeSupported = agentFlavor === 'codex' && !controlledByUser
const codexModelsState = useCodexModels({
api: props.api,
sessionId: props.session.id,
machineId: props.session.metadata?.machineId ?? null,
enabled: agentFlavor === 'codex' && props.session.active && !controlledByUser
})
const effectiveCodexServiceTier = agentFlavor === 'codex'
+3 -9
View File
@@ -5,7 +5,6 @@ import { queryKeys } from '@/lib/query-keys'
export function useCodexModels(args: {
api: ApiClient | null
sessionId?: string | null
machineId?: string | null
enabled?: boolean
}): {
@@ -13,11 +12,9 @@ export function useCodexModels(args: {
isLoading: boolean
error: string | null
} {
const { api, sessionId, machineId } = args
const enabled = Boolean(args.enabled && api && (sessionId || machineId))
const queryKey = sessionId
? queryKeys.sessionCodexModels(sessionId)
: queryKeys.machineCodexModels(machineId ?? 'unknown')
const { api, machineId } = args
const enabled = Boolean(args.enabled && api && machineId)
const queryKey = queryKeys.machineCodexModels(machineId ?? 'unknown')
const query = useQuery({
queryKey,
@@ -25,9 +22,6 @@ export function useCodexModels(args: {
if (!api) {
throw new Error('API unavailable')
}
if (sessionId) {
return await api.getSessionCodexModels(sessionId)
}
if (machineId) {
return await api.getMachineCodexModels(machineId)
}
-1
View File
@@ -15,7 +15,6 @@ export const queryKeys = {
staged ? 'staged' : 'unstaged'
] as const,
slashCommands: (sessionId: string) => ['slash-commands', sessionId] as const,
sessionCodexModels: (sessionId: string) => ['session-codex-models', sessionId] as const,
sessionCursorModels: (sessionId: string) => ['session-cursor-models', sessionId] as const,
sessionCursorChatStore: (sessionId: string) => ['session-cursor-chat-store', sessionId] as const,
sessionPiModels: (sessionId: string) => ['session-pi-models', sessionId] as const,