mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-19 19:50:26 +08:00
Fix/一键配置失效 (#2249)
* style(FailoverQueueManager): 显示供应商备注信息 * style(FailoverQueueItem): 添加供应商备注字段以支持备注信息显示 * style(FailoverQueueManager): 显示供应商备注信息 * style(FailoverQueueItem): 添加供应商备注字段以支持备注信息显示 * style(FailoverQueueManager): 更新供应商备注信息的显示样式 * style(FailoverQueueItem): 添加条件序列化以优化供应商备注字段 * fix: 优化模型状态管理,确保配置更新时正确引用最新设置 * fix(skill): improve error handling for skill source directory resolution Co-authored-by: Copilot <copilot@github.com> * fix(gemini): simplify project directory retrieval in scan_sessions function * fix(useModelState): optimize latestConfigRef assignment in useModelState hook * fix(useModelState): remove unnecessary blank line in useModelState hook --------- Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -672,15 +672,16 @@ impl SkillService {
|
||||
repo_branch = used_branch;
|
||||
|
||||
// 复制到 SSOT
|
||||
let source = Self::resolve_skill_source_dir(&temp_dir, &skill.directory).ok_or_else(|| {
|
||||
let missing = temp_dir.join(&source_rel).display().to_string();
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
anyhow!(format_skill_error(
|
||||
"SKILL_DIR_NOT_FOUND",
|
||||
&[("path", &missing)],
|
||||
Some("checkRepoUrl"),
|
||||
))
|
||||
})?;
|
||||
let source =
|
||||
Self::resolve_skill_source_dir(&temp_dir, &skill.directory).ok_or_else(|| {
|
||||
let missing = temp_dir.join(&source_rel).display().to_string();
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
anyhow!(format_skill_error(
|
||||
"SKILL_DIR_NOT_FOUND",
|
||||
&[("path", &missing)],
|
||||
Some("checkRepoUrl"),
|
||||
))
|
||||
})?;
|
||||
|
||||
let canonical_temp = temp_dir.canonicalize().unwrap_or_else(|_| temp_dir.clone());
|
||||
let canonical_source = source.canonicalize().map_err(|_| {
|
||||
@@ -3024,9 +3025,8 @@ mod tests {
|
||||
let nested = temp.path().join("skills").join("nested-skill");
|
||||
write_skill(&nested, "Nested Skill");
|
||||
|
||||
let resolved =
|
||||
SkillService::resolve_skill_source_dir(temp.path(), "skills/nested-skill")
|
||||
.expect("nested skill should resolve from its relative source path");
|
||||
let resolved = SkillService::resolve_skill_source_dir(temp.path(), "skills/nested-skill")
|
||||
.expect("nested skill should resolve from its relative source path");
|
||||
|
||||
assert_eq!(resolved, nested);
|
||||
}
|
||||
|
||||
@@ -35,10 +35,7 @@ pub fn scan_sessions() -> Vec<SessionMeta> {
|
||||
};
|
||||
|
||||
let project_root_file = entry.path().join(".project_root");
|
||||
let project_dir = match std::fs::read_to_string(project_root_file) {
|
||||
Ok(name) => Some(name),
|
||||
Err(_) => None,
|
||||
};
|
||||
let project_dir = std::fs::read_to_string(project_root_file).ok();
|
||||
|
||||
for file_entry in chat_files.flatten() {
|
||||
let path = file_entry.path();
|
||||
|
||||
@@ -61,6 +61,9 @@ export function useModelState({
|
||||
|
||||
const isUserEditingRef = useRef(false);
|
||||
const lastConfigRef = useRef(settingsConfig);
|
||||
const latestConfigRef = useRef(settingsConfig);
|
||||
|
||||
latestConfigRef.current = settingsConfig;
|
||||
|
||||
// 初始化读取:读新键;若缺失,按兼容优先级回退
|
||||
// Haiku: DEFAULT_HAIKU || SMALL_FAST || MODEL
|
||||
@@ -130,8 +133,8 @@ export function useModelState({
|
||||
if (field === "ANTHROPIC_DEFAULT_OPUS_MODEL") setDefaultOpusModel(value);
|
||||
|
||||
try {
|
||||
const currentConfig = settingsConfig
|
||||
? JSON.parse(settingsConfig)
|
||||
const currentConfig = latestConfigRef.current
|
||||
? JSON.parse(latestConfigRef.current)
|
||||
: { env: {} };
|
||||
if (!currentConfig.env) currentConfig.env = {};
|
||||
const env = currentConfig.env as Record<string, unknown>;
|
||||
@@ -146,12 +149,14 @@ export function useModelState({
|
||||
// 删除旧键
|
||||
delete env["ANTHROPIC_SMALL_FAST_MODEL"];
|
||||
|
||||
onConfigChange(JSON.stringify(currentConfig, null, 2));
|
||||
const updatedConfig = JSON.stringify(currentConfig, null, 2);
|
||||
latestConfigRef.current = updatedConfig;
|
||||
onConfigChange(updatedConfig);
|
||||
} catch (err) {
|
||||
console.error("Failed to update model config:", err);
|
||||
}
|
||||
},
|
||||
[settingsConfig, onConfigChange],
|
||||
[onConfigChange],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -13,6 +13,7 @@ function makeSkill(overrides: Partial<InstalledSkill> = {}): InstalledSkill {
|
||||
gemini: false,
|
||||
opencode: false,
|
||||
openclaw: false,
|
||||
hermes: false,
|
||||
},
|
||||
installedAt: 0,
|
||||
updatedAt: 0,
|
||||
|
||||
Reference in New Issue
Block a user