fix: support slash-containing model IDs (#1074)
* fix: support slash-containing model IDs * fix: parse worktree default model identifiers --------- Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
f96374c738
commit
d35ff8a2db
@@ -0,0 +1,20 @@
|
||||
export interface ParsedModelIdentifier {
|
||||
providerId: string;
|
||||
modelId: string;
|
||||
}
|
||||
|
||||
export const parseModelIdentifier = (value: string | undefined): ParsedModelIdentifier | null => {
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const separatorIndex = value.indexOf('/');
|
||||
if (separatorIndex <= 0 || separatorIndex >= value.length - 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
providerId: value.slice(0, separatorIndex),
|
||||
modelId: value.slice(separatorIndex + 1),
|
||||
};
|
||||
};
|
||||
@@ -12,6 +12,7 @@ import { useContextStore } from '@/stores/contextStore';
|
||||
import { useDirectoryStore } from '@/stores/useDirectoryStore';
|
||||
import { checkIsGitRepository, previewGitWorktree } from '@/lib/gitApi';
|
||||
import { generateBranchName } from '@/lib/git/branchNameGenerator';
|
||||
import { parseModelIdentifier } from '@/lib/modelIdentifier';
|
||||
import { getRootBranch } from '@/lib/worktrees/worktreeStatus';
|
||||
import { getWorktreeSetupCommands } from '@/lib/openchamberConfig';
|
||||
import {
|
||||
@@ -87,12 +88,12 @@ const applyDefaultAgentAndModelSelection = (sessionId: string, configState = use
|
||||
return;
|
||||
}
|
||||
|
||||
const parts = settingsDefaultModel.split('/');
|
||||
if (parts.length !== 2) {
|
||||
const parsed = parseModelIdentifier(settingsDefaultModel);
|
||||
if (!parsed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [providerId, modelId] = parts;
|
||||
const { providerId, modelId } = parsed;
|
||||
const modelMetadata = configState.getModelMetadata(providerId, modelId);
|
||||
if (!modelMetadata) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user