Importazione sessioni: tornata la verifica upstream sul provider registrato (D tolta)
La tolleranza per le sessioni senza provider (parte di e39aae00) e i suoi due test sono funzioni
di aKode, non B: ripristinato il comportamento di Codex originale.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -304,7 +304,12 @@ fn persistence_metadata(
|
|||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})?;
|
})?;
|
||||||
if meta.cwd.as_os_str().is_empty() {
|
if meta.cwd.as_os_str().is_empty()
|
||||||
|
|| meta
|
||||||
|
.model_provider
|
||||||
|
.as_deref()
|
||||||
|
.is_none_or(|provider| provider.trim().is_empty())
|
||||||
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let memory_mode = match meta.memory_mode.as_deref() {
|
let memory_mode = match meta.memory_mode.as_deref() {
|
||||||
@@ -314,15 +319,7 @@ fn persistence_metadata(
|
|||||||
};
|
};
|
||||||
Some(ThreadPersistenceMetadata {
|
Some(ThreadPersistenceMetadata {
|
||||||
cwd: Some(meta.cwd.clone()),
|
cwd: Some(meta.cwd.clone()),
|
||||||
// aKode: a session started without a configured provider records no provider (or
|
model_provider: meta.model_provider.clone()?,
|
||||||
// ""). The thread store treats "" as "not set", so the append accepts it too instead
|
|
||||||
// of silently skipping the re-import.
|
|
||||||
model_provider: meta
|
|
||||||
.model_provider
|
|
||||||
.as_deref()
|
|
||||||
.map(str::trim)
|
|
||||||
.unwrap_or_default()
|
|
||||||
.to_string(),
|
|
||||||
memory_mode,
|
memory_mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,45 +140,3 @@ fn model_messages(items: &[RolloutItem]) -> Vec<(MessageRole, &str)> {
|
|||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn session_meta(thread_id: ThreadId, model_provider: Option<&str>) -> RolloutItem {
|
|
||||||
RolloutItem::SessionMeta(Box::new(akode_protocol::protocol::SessionMetaLine {
|
|
||||||
meta: akode_protocol::protocol::SessionMeta {
|
|
||||||
id: thread_id,
|
|
||||||
cwd: std::path::PathBuf::from("/work"),
|
|
||||||
model_provider: model_provider.map(str::to_string),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
git: None,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn sessions_recorded_without_a_provider_can_be_appended_to() {
|
|
||||||
let thread_id = ThreadId::new();
|
|
||||||
for recorded in [None, Some(""), Some(" ")] {
|
|
||||||
let mut items = vec![session_meta(thread_id, recorded)];
|
|
||||||
items.extend(rollout(&[(MessageRole::User, "hi")]));
|
|
||||||
let metadata = persistence_metadata(&items, thread_id)
|
|
||||||
.unwrap_or_else(|| panic!("provider {recorded:?} must not block the append"));
|
|
||||||
assert_eq!(metadata.model_provider, "");
|
|
||||||
assert_eq!(metadata.cwd, Some(std::path::PathBuf::from("/work")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn recorded_provider_is_kept_and_other_checks_still_apply() {
|
|
||||||
let thread_id = ThreadId::new();
|
|
||||||
let items = vec![session_meta(thread_id, Some("local"))];
|
|
||||||
assert_eq!(
|
|
||||||
persistence_metadata(&items, thread_id).map(|metadata| metadata.model_provider),
|
|
||||||
Some("local".to_string())
|
|
||||||
);
|
|
||||||
// A session for another thread or without a cwd is still refused.
|
|
||||||
assert!(persistence_metadata(&items, ThreadId::new()).is_none());
|
|
||||||
let mut no_cwd = session_meta(thread_id, Some("local"));
|
|
||||||
if let RolloutItem::SessionMeta(line) = &mut no_cwd {
|
|
||||||
line.meta.cwd = std::path::PathBuf::new();
|
|
||||||
}
|
|
||||||
assert!(persistence_metadata(&[no_cwd], thread_id).is_none());
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user