rustyclaw_core/threads/
events.rs1use super::{ThreadId, ThreadInfo, ThreadStatus};
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub enum ThreadEvent {
9 Created {
11 thread: ThreadInfo,
12 parent_id: Option<ThreadId>,
13 },
14
15 StatusChanged {
17 thread_id: ThreadId,
18 old_status: ThreadStatus,
19 new_status: ThreadStatus,
20 },
21
22 DescriptionChanged {
24 thread_id: ThreadId,
25 description: String,
26 },
27
28 Foregrounded {
30 thread_id: ThreadId,
31 previous_foreground: Option<ThreadId>,
32 },
33
34 Completed {
36 thread_id: ThreadId,
37 summary: Option<String>,
38 result: Option<String>,
39 },
40
41 Failed {
43 thread_id: ThreadId,
44 error: String,
45 },
46
47 Removed {
49 thread_id: ThreadId,
50 },
51
52 MessageAdded {
54 thread_id: ThreadId,
55 message_count: usize,
56 },
57}
58
59impl ThreadEvent {
60 pub fn thread_id(&self) -> ThreadId {
62 match self {
63 Self::Created { thread, .. } => thread.id,
64 Self::StatusChanged { thread_id, .. } => *thread_id,
65 Self::DescriptionChanged { thread_id, .. } => *thread_id,
66 Self::Foregrounded { thread_id, .. } => *thread_id,
67 Self::Completed { thread_id, .. } => *thread_id,
68 Self::Failed { thread_id, .. } => *thread_id,
69 Self::Removed { thread_id } => *thread_id,
70 Self::MessageAdded { thread_id, .. } => *thread_id,
71 }
72 }
73
74 pub fn triggers_sidebar_update(&self) -> bool {
76 !matches!(self, Self::MessageAdded { .. })
78 }
79}