Skip to main content

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