ag_session/transcript_notice.rs
1use std::fmt;
2
3/// Canonical labels for bracketed workflow notices appended to a session
4/// transcript.
5///
6/// Session output rendering uses the same labels to recognize trailing
7/// workflow notices, so producing notices through this enum keeps new labels
8/// aligned with summary render ordering.
9#[derive(Clone, Copy, Debug, Eq, PartialEq)]
10pub enum TranscriptNotice {
11 /// Prompt `/apply` command status.
12 Apply,
13 /// Automatic published-branch push result.
14 BranchPush,
15 /// Automatic published-branch push failure.
16 BranchPushError,
17 /// Session auto-commit result.
18 Commit,
19 /// Agent-assisted auto-commit recovery attempt.
20 CommitAssist,
21 /// Session auto-commit failure.
22 CommitError,
23 /// Advisory for a commit that ran without a configured pre-commit hook.
24 CommitWarning,
25 /// Follow-on session creation failure.
26 ContinueError,
27 /// Generic prompt submission failure.
28 Error,
29 /// Session fork creation failure.
30 ForkError,
31 /// Follow-up task execution failure.
32 FollowUpTaskError,
33 /// Merge workflow progress.
34 Merge,
35 /// Merge workflow failure.
36 MergeError,
37 /// Main checkout changed during a provider turn.
38 MainCheckoutWarning,
39 /// Prompt image-paste failure.
40 PasteImageError,
41 /// Queued prompt failure.
42 QueueError,
43 /// Session sync workflow progress.
44 Rebase,
45 /// Agent-assisted session sync recovery attempt.
46 RebaseAssist,
47 /// Session sync workflow failure.
48 RebaseError,
49 /// Reply submission failure.
50 ReplyError,
51 /// Review-request creation result.
52 ReviewRequest,
53 /// Successful forge review-thread replies and resolution.
54 ReviewComments,
55 /// Partial or failed forge review-thread resolution.
56 ReviewCommentsWarning,
57 /// Review-request sync warning.
58 ReviewRequestSyncWarning,
59 /// Draft session start failure.
60 StartError,
61 /// Completed-turn metadata persistence failure.
62 TurnMetadataError,
63}
64
65impl TranscriptNotice {
66 /// Returns the bracketed transcript prefix for this notice kind.
67 pub const fn prefix(self) -> &'static str {
68 match self {
69 Self::Apply => "[Apply]",
70 Self::BranchPush => "[Branch Push]",
71 Self::BranchPushError => "[Branch Push Error]",
72 Self::Commit => "[Commit]",
73 Self::CommitAssist => "[Commit Assist]",
74 Self::CommitError => "[Commit Error]",
75 Self::CommitWarning => "[Commit Warning]",
76 Self::ContinueError => "[Continue Error]",
77 Self::Error => "[Error]",
78 Self::ForkError => "[Fork Error]",
79 Self::FollowUpTaskError => "[Follow-Up Task Error]",
80 Self::Merge => "[Merge]",
81 Self::MergeError => "[Merge Error]",
82 Self::MainCheckoutWarning => "[Main Checkout Warning]",
83 Self::PasteImageError => "[Paste Image Error]",
84 Self::QueueError => "[Queue Error]",
85 Self::Rebase => "[Sync]",
86 Self::RebaseAssist => "[Sync Assist]",
87 Self::RebaseError => "[Sync Error]",
88 Self::ReplyError => "[Reply Error]",
89 Self::ReviewRequest => "[Review Request]",
90 Self::ReviewComments => "[Review Comments]",
91 Self::ReviewCommentsWarning => "[Review Comments Warning]",
92 Self::ReviewRequestSyncWarning => "[Review Request Sync Warning]",
93 Self::StartError => "[Start Error]",
94 Self::TurnMetadataError => "[Turn Metadata Error]",
95 }
96 }
97
98 /// Formats one transcript notice as a newline-delimited paragraph.
99 pub fn format(self, detail: impl fmt::Display) -> String {
100 format!("\n{}\n", self.format_line(detail))
101 }
102
103 /// Formats one transcript notice as a single display line without
104 /// paragraph separators.
105 pub fn format_line(self, detail: impl fmt::Display) -> String {
106 format!("{} {}", self.prefix(), detail)
107 }
108}
109
110#[cfg(test)]
111#[path = "transcript_notice_test.rs"]
112mod tests;