feat(backend,frontend): lot utilisateur #310 #311 #312 #313 — horodatage conversation, stop agent robuste, préférence terminal par défaut, paramètres projet (QA verte)
- #310: horodatage de tous les messages et événements de conversation visibles — composant partagé EntryTimestamp, timestamps propagés dans le transcript chat, les annonces inter-agent et le viewer de conversation, normalisation côté domain/adapters (conversation_log, paginate). - #311: stop d'agent robuste pour PTY non monté, sessions headless et CLI custom — lifecycle/orchestrator durcis, ponts chat app-tauri/web-server alignés, arrêt fiable sans session orpheline. - #312: préférence globale d'interface terminal par défaut — nouveau store settings (domain/application/infrastructure + tests), DTO et commandes backend, adapter frontend userSettings, panneau TerminalSettings dans les paramètres globaux. - #313: Paramètres du projet — contexte de projet éditable et couleur de thème par projet (ProjectSettingsPanel + projectTheme), teinte des onglets projet, persistance via DTO projet. QA verte (GO QA sur feature/batch-310-311-312-313-chat-stop-prefs-theme) — vérifications Git: git diff --cached --check OK; staging borné à crates/ et frontend/ (74 fichiers, +2105/-531), commit unique de lot conforme à la convention des lots (précédents batch-151/158/159, batch-210/211/212) car les fichiers partagés (dto.rs, commands.rs, CustomAgentChatView) entrelacent les 4 tickets. fichiers .ideai/* (agents/test.md, chat-drafts.json, system-permissions.json, tickets/counter.json, tickets/index.json, tickets/308-313/), attachments/ et scripts/ hors périmètre et préservés en worktree ; aucun push. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -48,17 +48,22 @@ fn sid() -> SessionId {
|
||||
}
|
||||
|
||||
fn delta(s: &str) -> ReplyChunk {
|
||||
ReplyChunk::TextDelta { text: s.to_owned() }
|
||||
ReplyChunk::TextDelta {
|
||||
at_ms: None,
|
||||
text: s.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
fn final_chunk(s: &str) -> ReplyChunk {
|
||||
ReplyChunk::Final {
|
||||
at_ms: None,
|
||||
content: s.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
fn error_chunk(s: &str) -> ReplyChunk {
|
||||
ReplyChunk::Error {
|
||||
at_ms: None,
|
||||
message: s.to_owned(),
|
||||
}
|
||||
}
|
||||
@ -70,6 +75,7 @@ fn progress_chunk(
|
||||
) -> ReplyChunk {
|
||||
ReplyChunk::Progress {
|
||||
progress: ReplyProgressDto {
|
||||
occurred_at_ms: None,
|
||||
progress_id: None,
|
||||
source: ReplyProgressSourceDto::ProviderNative,
|
||||
kind,
|
||||
@ -91,6 +97,7 @@ fn progress_chunk_with_id(
|
||||
) -> ReplyChunk {
|
||||
ReplyChunk::Progress {
|
||||
progress: ReplyProgressDto {
|
||||
occurred_at_ms: None,
|
||||
progress_id: Some(progress_id.to_owned()),
|
||||
source: ReplyProgressSourceDto::ProviderNative,
|
||||
kind,
|
||||
@ -107,6 +114,7 @@ fn progress_chunk_with_id(
|
||||
fn chunk_bytes(chunk: &ReplyChunk) -> usize {
|
||||
match chunk {
|
||||
ReplyChunk::UserPrompt {
|
||||
at_ms: _,
|
||||
text,
|
||||
attachments,
|
||||
attachment_refs,
|
||||
@ -123,13 +131,13 @@ fn chunk_bytes(chunk: &ReplyChunk) -> usize {
|
||||
})
|
||||
.sum::<usize>()
|
||||
}
|
||||
ReplyChunk::TextDelta { text } => text.len(),
|
||||
ReplyChunk::ToolActivity { label } => label.len(),
|
||||
ReplyChunk::TextDelta { text, .. } => text.len(),
|
||||
ReplyChunk::ToolActivity { label, .. } => label.len(),
|
||||
ReplyChunk::Progress { progress } => {
|
||||
progress.label.len() + progress.text.as_ref().map_or(0, String::len)
|
||||
}
|
||||
ReplyChunk::Final { content } => content.len(),
|
||||
ReplyChunk::Error { message } => message.len(),
|
||||
ReplyChunk::Final { content, .. } => content.len(),
|
||||
ReplyChunk::Error { message, .. } => message.len(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,11 +145,32 @@ fn chunk_bytes(chunk: &ReplyChunk) -> usize {
|
||||
// chunk_from_event — exhaustive mapping (zone 6)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn accepted_reply_events_keep_the_backend_timestamp() {
|
||||
let chunk = app_tauri_lib::chat::chunk_from_event_at(
|
||||
ReplyEvent::Final {
|
||||
content: "done".to_owned(),
|
||||
},
|
||||
Some(42_424),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
chunk,
|
||||
ReplyChunk::Final {
|
||||
at_ms: Some(42_424),
|
||||
content: "done".to_owned()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chunk_from_event_maps_text_delta() {
|
||||
assert_eq!(
|
||||
chunk_from_event(ReplyEvent::TextDelta { text: "hi".into() }),
|
||||
Some(ReplyChunk::TextDelta { text: "hi".into() })
|
||||
Some(ReplyChunk::TextDelta {
|
||||
at_ms: None,
|
||||
text: "hi".into()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@ -202,6 +231,7 @@ fn chunk_from_event_maps_final() {
|
||||
content: "done".into()
|
||||
}),
|
||||
Some(ReplyChunk::Final {
|
||||
at_ms: None,
|
||||
content: "done".into()
|
||||
})
|
||||
);
|
||||
@ -236,7 +266,10 @@ fn pump_turn(bridge: &ChatBridge, session: &SessionId, gen: u64, events: Vec<Rep
|
||||
for event in events {
|
||||
// Mirror the real pump: heartbeats map to no chunk and are skipped.
|
||||
if let Some(chunk) = chunk_from_event(event) {
|
||||
if matches!(chunk, ReplyChunk::Final { .. } | ReplyChunk::Error { .. }) {
|
||||
if matches!(
|
||||
chunk,
|
||||
ReplyChunk::Final { at_ms: None, .. } | ReplyChunk::Error { at_ms: None, .. }
|
||||
) {
|
||||
terminal_visible = true;
|
||||
}
|
||||
let _ = bridge.send_output(session, chunk);
|
||||
@ -277,10 +310,13 @@ fn pump_delivers_deltas_then_exactly_one_final_in_order() {
|
||||
// Exactly one Final, and it is last (deterministic terminal chunk).
|
||||
let finals = got
|
||||
.iter()
|
||||
.filter(|c| matches!(c, ReplyChunk::Final { .. }))
|
||||
.filter(|c| matches!(c, ReplyChunk::Final { at_ms: None, .. }))
|
||||
.count();
|
||||
assert_eq!(finals, 1, "exactly one Final per turn");
|
||||
assert!(matches!(got.last(), Some(ReplyChunk::Final { .. })));
|
||||
assert!(matches!(
|
||||
got.last(),
|
||||
Some(ReplyChunk::Final { at_ms: None, .. })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -490,6 +526,7 @@ fn scrollback_accumulates_every_routed_chunk_in_order() {
|
||||
.map(|chunk| match chunk {
|
||||
ReplyChunk::Progress { progress } => {
|
||||
ReplyChunk::ToolActivity {
|
||||
at_ms: None,
|
||||
label: progress.label,
|
||||
}
|
||||
}
|
||||
@ -499,6 +536,7 @@ fn scrollback_accumulates_every_routed_chunk_in_order() {
|
||||
vec![
|
||||
delta("x"),
|
||||
ReplyChunk::ToolActivity {
|
||||
at_ms: None,
|
||||
label: "runs".into()
|
||||
},
|
||||
final_chunk("x"),
|
||||
@ -756,15 +794,15 @@ fn scrollback_drops_oldest_whole_chunks_when_byte_cap_is_exceeded() {
|
||||
assert_eq!(scrollback.len(), 4);
|
||||
assert!(matches!(
|
||||
scrollback.first(),
|
||||
Some(ReplyChunk::TextDelta { text }) if text.starts_with("02:")
|
||||
Some(ReplyChunk::TextDelta { text, .. }) if text.starts_with("02:")
|
||||
));
|
||||
assert!(matches!(
|
||||
scrollback.last(),
|
||||
Some(ReplyChunk::TextDelta { text }) if text.starts_with("05:")
|
||||
Some(ReplyChunk::TextDelta { text, .. }) if text.starts_with("05:")
|
||||
));
|
||||
assert!(scrollback.iter().all(|chunk| matches!(
|
||||
chunk,
|
||||
ReplyChunk::TextDelta { text } if text.len() == chunk_size
|
||||
ReplyChunk::TextDelta { text, .. } if text.len() == chunk_size
|
||||
)));
|
||||
}
|
||||
|
||||
@ -781,6 +819,7 @@ fn truncated_scrollback_replays_valid_unmodified_chunks_in_order() {
|
||||
bridge.send_output(
|
||||
&session,
|
||||
ReplyChunk::ToolActivity {
|
||||
at_ms: None,
|
||||
label: "tool".into(),
|
||||
},
|
||||
);
|
||||
@ -793,6 +832,7 @@ fn truncated_scrollback_replays_valid_unmodified_chunks_in_order() {
|
||||
&scrollback[(MAX_CHAT_SCROLLBACK_CHUNKS - 2)..],
|
||||
&[
|
||||
ReplyChunk::ToolActivity {
|
||||
at_ms: None,
|
||||
label: "tool".into()
|
||||
},
|
||||
final_chunk("done")
|
||||
|
||||
Reference in New Issue
Block a user