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