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