Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai bbfcdda0c1 fix(agents): title a task from the prompt's text outside code fences
A prompt that opened with a pasted fenced block (a log, a code sample)
was titled from the first line inside the block until the generated
title arrived. A line outside the fences now wins; a prompt that is one
fenced block is still titled from inside it.
2026-11-24 19:56:51 +08:00
2 змінених файлів з 19 додано та 3 видалено

No files matched your search

+16 -3
Переглянути файл
@@ -4245,11 +4245,24 @@ fn file_uri(path: &Path) -> String {
out
}
/// The title of a task: the first line of the prompt that says something. A pasted Markdown
/// block opens with a code fence (```` ```text ````), which names no task.
/// The title of a task: the first line of the prompt that says something. Text inside a code
/// fence (```` ```text ````) is pasted material, so a line outside the fences wins; a prompt
/// that is all one pasted block still names its task from inside it.
fn title_of(prompt: &AgentPrompt) -> String {
let is_fence = |l: &str| l.starts_with("```") || l.starts_with("~~~");
let line = prompt.text.lines().map(str::trim).find(|l| !l.is_empty() && !is_fence(l));
let (mut outside, mut inside, mut fenced) = (None, None, false);
for l in prompt.text.lines().map(str::trim) {
if is_fence(l) {
fenced = !fenced;
} else if !l.is_empty() {
let slot = if fenced { &mut inside } else { &mut outside };
slot.get_or_insert(l);
if outside.is_some() {
break;
}
}
}
let line = outside.or(inside);
let line = match line {
Some(l) => l.to_owned(),
None => prompt.files.first().map(|f| file_name(&f.0)).unwrap_or_else(|| "Image".into()),
+3
Переглянути файл
@@ -1736,6 +1736,9 @@ fn prompts_become_acp_content_blocks() {
assert_eq!(title_of(&AgentPrompt { files: p.files.clone(), ..AgentPrompt::default() }), "my file.rs");
let pasted = AgentPrompt { text: "```text\n\n ## Fix the tab title\n```".into(), ..AgentPrompt::default() };
assert_eq!(title_of(&pasted), "## Fix the tab title");
let fenced_first =
AgentPrompt { text: "```txt\nlog line\n```\nWhy does this fail?".into(), ..AgentPrompt::default() };
assert_eq!(title_of(&fenced_first), "Why does this fail?");
assert!(clean(text(" ")).is_none());
}