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