fix: Volcengine model list pollution + missing by-cwd route

- provider-catalog: getDefaultModelsForProvider() now returns preset's
  defaultModels even when empty, instead of falling through to
  ANTHROPIC_DEFAULT_MODELS. Fixes Volcengine (defaultModels: []) incorrectly
  showing Sonnet/Opus/Haiku.
- providers/models route: remove DEFAULT_MODELS fallback when both DB and
  catalog are empty — providers like Volcengine that require user-specified
  model names should show only those models.
- Add missing src/app/api/chat/sessions/by-cwd/route.ts that was untracked;
  without it worktree switching would 404 in release builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7418andClaude Opus 4.6 committed 2026-03-13 00:47:03 +08:00
1 parent 0eabed8c27
commit 4e01902368
3 files changed
+23 -6

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
import { NextRequest, NextResponse } from 'next/server';
import { getLatestSessionByWorkingDirectory } from '@/lib/db';
export async function GET(req: NextRequest) {
const cwd = req.nextUrl.searchParams.get('cwd');
if (!cwd) {
return NextResponse.json({ error: 'cwd is required' }, { status: 400 });
}
const session = getLatestSessionByWorkingDirectory(cwd);
if (session) {
return NextResponse.json({ sessionId: session.id });
}
return NextResponse.json({ sessionId: null });
}
+4 -4
View File
@@ -128,14 +128,14 @@ export async function GET() {
capabilities: m.capabilities as Record<string, unknown> | undefined,
}));
// Start with DB models + catalog defaults
// Start with DB models + catalog defaults.
// If both are empty (e.g. Volcengine where user must specify model names),
// leave rawModels empty — do NOT fall back to DEFAULT_MODELS (Sonnet/Opus/Haiku).
if (dbModels.length > 0) {
const dbIds = new Set(dbModels.map(m => m.value));
rawModels = [...dbModels, ...catalogRaw.filter(m => !dbIds.has(m.value))];
} else if (catalogRaw.length > 0) {
rawModels = [...catalogRaw];
} else {
rawModels = [...DEFAULT_MODELS];
rawModels = [...catalogRaw];
}
// Inject role_models_json.default into the list if not already present
+4 -2
View File
@@ -540,11 +540,13 @@ export function getDefaultModelsForProvider(
): CatalogModel[] {
// Try to find a preset by base_url
const preset = VENDOR_PRESETS.find(p => p.baseUrl && p.baseUrl === baseUrl);
if (preset && preset.defaultModels.length > 0) {
if (preset) {
// Preset matched — return its models even if empty (e.g. Volcengine
// requires users to specify their own model names, so defaultModels is []).
return preset.defaultModels;
}
// Protocol-based defaults
// Protocol-based defaults (only when no preset matched)
if (protocol === 'anthropic' || protocol === 'openrouter' || protocol === 'bedrock' || protocol === 'vertex') {
return ANTHROPIC_DEFAULT_MODELS;
}