Skip to main content

kasl/libs/messages/
display.rs

1//! Display implementation for kasl application messages.
2//!
3//! Provides the core `Display` trait implementation for the `Message` enum, enabling automatic conversion of structured message data into human-readable text.
4//!
5//! ## Usage
6//!
7//! ```rust
8//! use kasl::libs::messages::types::Message;
9//!
10//! let message = Message::TaskCreated;
11//! println!("{}", message);
12//!
13//! let parameterized = Message::MonitorStarted {
14//!     pause_threshold: 60,
15//!     poll_interval: 500,
16//!     activity_threshold: 30,
17//! };
18//! println!("{}", parameterized);
19//! ```
20
21use super::types::Message;
22use std::fmt::{Display, Formatter, Result};
23
24impl Display for Message {
25    /// Converts a `Message` enum variant into human-readable text.
26    ///
27    /// # Examples
28    ///
29    /// ```rust
30    /// use kasl::libs::messages::Message;
31    ///
32    /// // Automatic formatting through Display trait
33    /// let message = Message::TaskCreated;
34    /// println!("{}", message); // "Task created successfully"
35    ///
36    /// // With parameters
37    /// let date_message = Message::WorkdayStarting("2025-01-15".to_string());
38    /// println!("{}", date_message); // "Starting workday for 2025-01-15"
39    /// ```
40    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
41        let text = match self {
42            // === AUTOSTART MESSAGES ===
43            Message::AutostartEnabled => "Autostart has been enabled. Kasl will start automatically on system boot.".to_string(),
44            Message::AutostartEnabledUser => "Autostart has been enabled for current user. Kasl will start when you log in.".to_string(),
45            Message::AutostartDisabled => "Autostart has been disabled.".to_string(),
46            Message::AutostartAlreadyDisabled => "Autostart was already disabled.".to_string(),
47            Message::AutostartEnableFailed(error) => format!("Failed to enable autostart: {}", error),
48            Message::AutostartDisableFailed(error) => format!("Failed to disable autostart: {}", error),
49            Message::AutostartStatus(status) => format!("Autostart is currently: {}", status),
50            Message::AutostartRequiresAdmin => "Administrator privileges required for system-level autostart. Trying user-level alternative...".to_string(),
51            Message::AutostartCheckingAlternative => "Checking alternative autostart method...".to_string(),
52
53            // === TASK MESSAGES ===
54            Message::TaskCreated => "Task created successfully".to_string(),
55            Message::TaskUpdated => "Task updated successfully".to_string(),
56            Message::TaskNotFound => "Task not found".to_string(),
57            Message::TaskUpdateFailed => "Failed to update task".to_string(),
58            Message::TasksDeletedCount(count) => format!("Deleted {} task(s) successfully.", count),
59            Message::TasksNotFoundForDate(date) => format!("Tasks not found for {}, report not sent.", date),
60            Message::TasksNotFoundSad => "No tasks found.".to_string(),
61            Message::TasksHeader => "Tasks:".to_string(),
62            Message::TasksDiscoverySummary { incomplete, jira, gitlab } => {
63                let mut parts = Vec::new();
64                if *incomplete > 0 {
65                    parts.push(format!("{} incomplete", incomplete));
66                }
67                if *jira > 0 {
68                    parts.push(format!("{} jira", jira));
69                }
70                if *gitlab > 0 {
71                    parts.push(format!("{} gitlab", gitlab));
72                }
73                format!("Found: {}", parts.join(", "))
74            }
75            Message::TasksDiscoverySeparator => "──────── other ────────".to_string(),
76            Message::TasksDiscoverySearchingIncomplete => "Looking for incomplete tasks...".to_string(),
77            Message::TasksDiscoveryFetchingExternal => "Fetching GitLab commits and Jira issues...".to_string(),
78            Message::NoTaskIdsProvided => "No task IDs provided for deletion.".to_string(),
79            Message::TasksNotFoundForIds(ids) => format!("No tasks found with IDs: {:?}", ids),
80            Message::TasksToBeDeleted => "The following tasks will be deleted:".to_string(),
81            Message::ConfirmDeleteTask => "Are you sure you want to delete this task?".to_string(),
82            Message::ConfirmDeleteTasks(count) => format!("Are you sure you want to delete {} tasks?", count),
83            Message::ConfirmDeleteAllTodayTasks(count) => format!("Are you sure you want to delete ALL {} tasks for today?", count),
84            Message::ConfirmDeleteAllTodayTasksFinal => "This action cannot be undone. Are you REALLY sure?".to_string(),
85            Message::NoTasksForToday => "No tasks found for today.".to_string(),
86            Message::TaskNotFoundWithId(id) => format!("Task with ID {} not found.", id),
87            Message::CurrentTaskState => "Current task:".to_string(),
88            Message::TaskEditPreview => "Task after changes:".to_string(),
89            Message::ConfirmTaskUpdate => "Save changes?".to_string(),
90            Message::NoChangesDetected => "No changes detected.".to_string(),
91            Message::NoTasksSelected => "No tasks selected for editing.".to_string(),
92            Message::SelectTasksToEdit => "Select tasks to edit (space to select, enter to confirm)".to_string(),
93            Message::EditingTask(name) => format!("Editing task: {}", name),
94            Message::TaskUpdatedWithName(name) => format!("Task '{}' updated successfully.", name),
95            Message::TaskSkippedNoChanges(name) => format!("Task '{}' - no changes, skipped.", name),
96            Message::TaskEditingCompleted => "Task editing completed.".to_string(),
97            Message::PromptTaskNameEdit => "Task name".to_string(),
98            Message::PromptTaskCommentEdit => "Comment (optional)".to_string(),
99            Message::PromptTaskCompletenessEdit => "Completeness (0-100)".to_string(),
100            Message::TaskCompletenessRange => "Completeness must be between 0 and 100".to_string(),
101
102            // === WORKDAY MESSAGES ===
103            Message::WorkdayEnded => "Workday ended for today.".to_string(),
104            Message::WorkdayNotFoundForDate(date) => format!("No workday record found for {}", date),
105            Message::WorkdayCreateFailed => "Failed to create workday".to_string(),
106            Message::WorkdayStarting(date) => format!("Starting workday for {}", date),
107            Message::WorkdayCouldNotFindAfterFinalizing(date) => {
108                format!("Could not find workday for {} after finalizing.", date)
109            }
110
111            // === CONFIGURATION MESSAGES ===
112            Message::ConfigSaved => "Configuration saved successfully".to_string(),
113            Message::ConfigDeleted => "Configuration deleted successfully".to_string(),
114            Message::ConfigParseError => "Failed to parse configuration".to_string(),
115            Message::ConfigSaveError => "Failed to save configuration".to_string(),
116            Message::ConfigModuleGitLab => "GitLab settings".to_string(),
117            Message::ConfigModuleJira => "Jira settings".to_string(),
118            Message::ConfigModuleSiServer => "SiServer settings".to_string(),
119            Message::ConfigModuleMonitor => "Monitor settings".to_string(),
120            Message::ConfigModuleServer => "Server settings".to_string(),
121            Message::ConfigModuleProductivity => "Productivity settings".to_string(),
122            Message::ConfigModuleTaskDiscovery => "Task discovery settings".to_string(),
123            Message::ConfigModuleJiraInbox => "Jira inbox settings".to_string(),
124            Message::TaskDiscoveryIgnoreListHeader => "Current ignore list:".to_string(),
125            Message::TaskDiscoveryIgnoreListEmpty => "Ignore list is empty.".to_string(),
126            Message::TaskDiscoveryIgnoreNameAdded(name) => format!("Added '{}' to ignore list.", name),
127            Message::TaskDiscoveryIgnoreNameExists(name) => format!("'{}' is already in the ignore list.", name),
128            Message::TaskDiscoveryIgnoreNamesAdded(count) => {
129                format!("Added {} name(s) to the discovery ignore list.", count)
130            }
131
132            // === REPORT MESSAGES ===
133            Message::DailyReportSent(date) => {
134                format!(
135                    "Your report dated {} has been successfully submitted\nWait for a message to your email address",
136                    date
137                )
138            }
139            Message::MonthlyReportSent(date) => {
140                format!(
141                    "Your monthly report dated {} has been successfully submitted\nWait for a message to your email address",
142                    date
143                )
144            }
145            Message::MonthlyReportTriggered => "It's the last working day of the month. Submitting the monthly report as well...".to_string(),
146            Message::ReportSendFailed(status) => format!("Failed to send report. Status: {}", status),
147            Message::MonthlyReportSendFailed(status) => format!("Failed to send monthly report. Status: {}", status),
148            Message::ReportHeader(date) => format!("Report for {}", date),
149            Message::WorkingHoursForMonth(month_year) => format!("Working hours for {}", month_year),
150
151            // === EXPORT MESSAGES ===
152            Message::ExportingData(data, format) => format!("Exporting {} in {} format...", data, format),
153            Message::ExportCompleted(path) => format!("Export completed successfully: {}", path),
154            Message::ExportingAllData => "Exporting all data...".to_string(),
155
156            // === TEMPLATE MESSAGES ===
157            Message::TemplateCreated(name) => format!("Template '{}' created successfully.", name),
158            Message::TemplateUpdated(name) => format!("Template '{}' updated successfully.", name),
159            Message::TemplateDeleted(name) => format!("Template '{}' deleted successfully.", name),
160            Message::TemplateNotFound(name) => format!("Template '{}' not found.", name),
161            Message::TemplateAlreadyExists(name) => format!("Template '{}' already exists.", name),
162            Message::TemplateCreateFailed => "Failed to create template.".to_string(),
163            Message::NoTemplatesFound => "No templates found.".to_string(),
164            Message::TemplateListHeader => "Task Templates:".to_string(),
165            Message::SelectTemplateToEdit => "Select template to edit".to_string(),
166            Message::SelectTemplateToDelete => "Select template to delete".to_string(),
167            Message::ConfirmDeleteTemplate(name) => format!("Delete template '{}'?", name),
168            Message::EditingTemplate(name) => format!("Editing template: {}", name),
169            Message::NoTemplatesMatchingQuery(query) => format!("No templates matching '{}'", query),
170            Message::TemplateSearchResults(query) => format!("Templates matching '{}':", query),
171            Message::SelectTemplateAction => "What would you like to do?".to_string(),
172            Message::PromptTemplateName => "Template name (unique identifier)".to_string(),
173            Message::PromptTemplateTaskName => "Task name".to_string(),
174            Message::PromptTemplateComment => "Comment (optional)".to_string(),
175            Message::PromptTemplateCompleteness => "Default completeness (0-100)".to_string(),
176            Message::CreatingTaskFromTemplate(name) => format!("Creating task from template '{}'", name),
177            Message::SelectTemplate => "Select a template".to_string(),
178            Message::CreateTemplateFirst => "Create templates with 'kasl template add'".to_string(),
179
180            // === TAG MESSAGES ===
181            Message::TagCreated(name) => format!("Tag '{}' created successfully.", name),
182            Message::TagUpdated(name) => format!("Tag '{}' updated successfully.", name),
183            Message::TagDeleted(name) => format!("Tag '{}' deleted successfully.", name),
184            Message::TagNotFound(name) => format!("Tag '{}' not found.", name),
185            Message::TagAlreadyExists(name) => format!("Tag '{}' already exists.", name),
186            Message::NoTagsFound => "No tags found.".to_string(),
187            Message::TagListHeader => "Tags:".to_string(),
188            Message::EditingTag(name) => format!("Editing tag: {}", name),
189            Message::SelectTagAction => "What would you like to do?".to_string(),
190            Message::SelectTagToEdit => "Select tag to edit".to_string(),
191            Message::SelectTagToDelete => "Select tag to delete".to_string(),
192            Message::ConfirmDeleteTag(name) => format!("Delete tag '{}'?", name),
193            Message::ConfirmDeleteTagWithTasks(name, count) => format!("Tag '{}' is used by {} task(s). Delete anyway?", name, count),
194            Message::PromptTagName => "Tag name".to_string(),
195            Message::PromptTagColor => "Tag color (e.g., blue, green, red)".to_string(),
196            Message::NoTasksWithTag(tag) => format!("No tasks found with tag '{}'.", tag),
197            Message::TasksWithTag(tag) => format!("Tasks with tag '{}':", tag),
198            Message::TagsAddedToTask(tags) => format!("Tags added: {}", tags),
199
200            // === SHORT INTERVALS MESSAGES ===
201            Message::ShortIntervalsDetected(count, duration) => format!("Found {} short work intervals (total: {})", count, duration),
202            Message::PromptMinWorkInterval => "Minimum work interval (minutes)".to_string(),
203
204            // === TIME ADJUSTMENT MESSAGES ===
205            Message::WorkdayUpdateFailed => "Failed to update workday.".to_string(),
206
207            // === PAUSE MESSAGES ===
208            Message::PausesTitle(date) => format!("Pauses for {}", date),
209
210            // === MONITOR MESSAGES ===
211            Message::MonitorStarted {
212                pause_threshold,
213                poll_interval,
214                activity_threshold,
215            } => {
216                format!(
217                    "Monitor is running with pause threshold {}s, poll interval {}ms, activity threshold {}s",
218                    pause_threshold, poll_interval, activity_threshold
219                )
220            }
221            Message::MonitorExitedNormally => "Monitor exited normally".to_string(),
222            Message::MonitorShuttingDown => "Shutting down monitor...".to_string(),
223            Message::MonitorError(error) => format!("Monitor error: {}", error),
224            Message::MonitorTaskPanicked(error) => format!("Monitor task panicked: {}", error),
225            Message::PauseStarted => "Pause Start".to_string(),
226            Message::PauseEnded => "Pause End".to_string(),
227
228            // === WATCHER/DAEMON MESSAGES ===
229            Message::WatcherStarted(pid) => format!("Watcher started in the background (PID: {}).", pid),
230            Message::WatcherStopped(pid) => format!("Watcher process (PID: {}) stopped successfully.", pid),
231            Message::WatcherNotRunning => "Watcher is not running.".to_string(),
232            Message::WatcherNotRunningPidNotFound => "Watcher does not appear to be running (PID file not found).".to_string(),
233            Message::WatcherStartingForeground => "Starting watcher in foreground... Press Ctrl+C to exit.".to_string(),
234            Message::WatcherStoppingExisting(pid) => format!("Stopping existing watcher (PID: {})...", pid),
235            Message::WatcherFailedToStopExisting(error) => format!("Warning: Failed to stop existing daemon: {}", error),
236            Message::WatcherReceivedSigterm => "Received SIGTERM, shutting down gracefully...".to_string(),
237            Message::WatcherReceivedSigint => "Received SIGINT, shutting down gracefully...".to_string(),
238            Message::WatcherReceivedCtrlC => "Received Ctrl+C, shutting down gracefully...".to_string(),
239            Message::WatcherCtrlCListenFailed(error) => format!("Failed to listen for Ctrl+C: {}", error),
240            Message::WatcherSignalHandlingNotSupported => "Warning: Signal handling not supported on this platform".to_string(),
241            Message::DaemonModeNotSupported => "Daemon mode is not supported on this platform.".to_string(),
242            Message::FailedToGetCurrentExecutable => "Failed to get the path of the current executable".to_string(),
243            Message::FailedToCreateSigtermHandler => "Failed to create SIGTERM handler".to_string(),
244            Message::FailedToCreateSigintHandler => "Failed to create SIGINT handler".to_string(),
245
246            // === UPDATE MESSAGES ===
247            Message::UpdateAvailable { app_name, latest } => {
248                format!(
249                    "A new version of {} is available: v{}\nUpgrade now by running: {} self-update",
250                    app_name, latest, app_name
251                )
252            }
253            Message::UpdateCompleted { app_name, version } => {
254                format!("The {} application has been successfully updated to version {}!", app_name, version)
255            }
256            Message::NoUpdateRequired => "No update required. You are using the latest version!".to_string(),
257            Message::UpdateDownloadUrlNotSet => "Download URL not set".to_string(),
258            Message::UpdateLatestTagNotFound(url) => format!("Could not resolve the latest release tag from {}", url),
259            Message::WatcherStoppingForUpdate => "Stopping watcher for update...".to_string(),
260            Message::WatcherRestartingAfterUpdate => "Restarting watcher after update...".to_string(),
261            Message::WatcherStoppingForConfig => "Stopping watcher to apply new configuration...".to_string(),
262            Message::WatcherRestartingAfterConfig => "Restarting watcher with updated configuration...".to_string(),
263            Message::WatcherRestarted => "Watcher successfully restarted with new configuration".to_string(),
264            Message::WatcherRestartFailed { error } => format!("Warning: Failed to restart watcher: {}", error),
265            Message::UpdateBinaryNotFoundInArchive => "Binary not found in the release archive.".to_string(),
266
267            // === AUTHENTICATION MESSAGES ===
268            Message::WrongPassword(count) => format!("You entered the wrong password {} times!", count),
269
270            // === API MESSAGES ===
271            Message::GitlabFetchFailed(error) => format!("[kasl] Failed to get GitLab events: {}", error),
272            Message::GitlabUserIdFailed(error) => format!("[kasl] Failed to get GitLab user ID: {}", error),
273            Message::JiraFetchFailed(error) => format!("[kasl] Failed to get Jira issues: {}", error),
274            Message::SiServerConfigNotFound => "SiServer configuration not found in config file.".to_string(),
275            Message::SiServerSessionFailed(error) => format!("[kasl] Failed to get SiServer session for rest dates: {}", error),
276            Message::SiServerRestDatesFailed(error) => format!("[kasl] Failed to request rest dates: {}", error),
277            Message::SiServerRestDatesParsingFailed(error) => format!("[kasl] Failed to parse rest dates response: {}", error),
278
279            // === KASL-SERVER MESSAGES ===
280            Message::KaslServerReached { url, version } => format!("{} is kasl-server {}", url, version),
281            Message::KaslServerConnected { user_name, agent_name } => {
282                format!("Connected as {} (agent '{}')", user_name, agent_name)
283            }
284            Message::KaslServerConfigured(url) => format!("Configured server: {}", url),
285            Message::KaslServerDatabaseUnhealthy(state) => {
286                format!(
287                    "The server answered, but reports its database as '{}' - uploads will fail until that clears.",
288                    state
289                )
290            }
291            Message::KaslServerUnreachable(error) => format!("Cannot reach the server: {}", error),
292            Message::KaslServerTokenRejected(error) => format!("The stored token no longer works: {}", error),
293            Message::KaslServerUrlNeedsScheme(url) => {
294                format!(
295                    "'{}' has no scheme - write http:// or https:// so it is clear whether the token crosses the network in the clear.",
296                    url
297                )
298            }
299            Message::KaslServerTokenEmpty => "No token entered; nothing was changed.".to_string(),
300            Message::KaslServerTokenMissing => "A server is configured but no token is stored - run `kasl server connect` again.".to_string(),
301            Message::KaslServerTokenNotRemoved(error) => {
302                format!("The address was forgotten, but the stored token could not be removed: {}", error)
303            }
304            Message::KaslServerNotConnected => "This machine is not connected to a kasl-server.".to_string(),
305            Message::KaslServerDisconnected => "Disconnected; the stored token has been removed.".to_string(),
306
307            // === DATABASE MESSAGES ===
308            Message::DatabaseOperationFailed { operation, error } => {
309                format!("Database operation '{}' failed (continuing monitoring): {}", operation, error)
310            }
311            Message::NoIdSet => "No ID set".to_string(),
312
313            // === FILE SYSTEM MESSAGES ===
314            Message::FileNotFound => "File not found".to_string(),
315            Message::InvalidPidFileContent => "Invalid PID file content".to_string(),
316
317            // === SYSTEM/PATH MESSAGES ===
318            Message::PathConfigured => "PATH successfully configured for system-wide access".to_string(),
319            Message::PathConfigWarning { error } => format!(
320                "Warning: Could not configure PATH automatically. {}\nYou may need to run as administrator or manually add kasl to your PATH.",
321                error
322            ),
323            Message::PathRegistryQueryError { status } => format!("Registry query failed (exit code: {})", status),
324            Message::PathRegistryUpdateError { status, stderr } => {
325                if stderr.trim().is_empty() {
326                    format!("Registry update failed (exit code: {})", status)
327                } else {
328                    format!("Registry update failed (exit code: {}): {}", status, stderr.trim())
329                }
330            }
331            Message::FailedToJoinPaths => "Failed to join paths".to_string(),
332            Message::FailedToExecuteRegQuery => "Failed to execute reg query".to_string(),
333            Message::FailedToParseRegOutput => "Failed to parse reg query output".to_string(),
334            Message::FailedToGetPathFromReg => "Failed to get PATH value from reg query".to_string(),
335            Message::FailedToExecuteRegSet => "Failed to execute reg set".to_string(),
336            Message::FailedToOpenProcess(code) => format!("Failed to open process: error code {}", code),
337            Message::FailedToTerminateProcess(code) => format!("Failed to terminate process: error code {}", code),
338            Message::ProcessTerminationNotSupported => "Process termination not supported on this platform".to_string(),
339
340            // === PRODUCTIVITY MESSAGES ===
341            Message::MonthlyProductivity(percentage) => format!("Monthly work productivity: {:.1}%", percentage),
342            Message::LowProductivityWarning { current, threshold } => {
343                format!(
344                    "🔴 LOW PRODUCTIVITY: {:.1}% (minimum: {:.1}%)\n   If an absence is missing from the day, record it: kasl pauses add --start HH:MM --minutes N",
345                    current, threshold
346                )
347            }
348            Message::ProductivityTooLowToSend { current, threshold } => {
349                format!(
350                    "Cannot send report: productivity {:.1}% is below minimum {:.1}%\nIf an absence is missing from the day, record it: kasl pauses add --start HH:MM --minutes N",
351                    current, threshold
352                )
353            }
354            Message::ManualPauseCreated {
355                start_time,
356                end_time,
357                duration_minutes,
358            } => {
359                format!("Pause recorded: {} - {} ({} minutes)", start_time, end_time, duration_minutes)
360            }
361            Message::ManualPauseOverlaps { start_time, end_time } => {
362                format!("Overlaps an existing pause ({} - {})", start_time, end_time)
363            }
364            Message::ManualPauseRemoved(id) => format!("Pause {} removed", id),
365            Message::ManualPauseNotFound(id) => format!("no pause with id '{}' - see `kasl pauses list`", id),
366
367            // === ENCRYPTION/SECRET MESSAGES ===
368
369            // === PROMPTS ===
370            Message::PromptTaskName => "Enter task name (multi-line paste OK)".to_string(),
371            Message::TaskNameMergedFromPaste => "Merged pasted lines into the task name.".to_string(),
372            Message::PromptTaskComment => "Enter comment".to_string(),
373            Message::PromptTaskCompleteness => "Enter completeness".to_string(),
374            Message::PromptMinPauseDuration => "Enter minimum pause duration (minutes)".to_string(),
375            Message::PromptPauseThreshold => "Enter pause threshold (seconds)".to_string(),
376            Message::PromptPollInterval => "Enter poll interval (milliseconds)".to_string(),
377            Message::PromptActivityThreshold => "Enter activity threshold (seconds)".to_string(),
378            Message::PromptMinProductivityThreshold => "Enter minimum productivity threshold (%)".to_string(),
379            Message::PromptWorkdayHours => "Enter expected workday duration (hours)".to_string(),
380            Message::PromptMinWorkdayFraction => "Enter minimum workday fraction before suggesting breaks (0.0-1.0)".to_string(),
381            Message::PromptServerApiUrl => "Enter server API URL".to_string(),
382            Message::PromptServerAuthToken => "Enter server auth token".to_string(),
383            Message::PromptKaslServerUrl => "kasl-server URL".to_string(),
384            Message::PromptKaslServerToken => "Agent token (issued by your administrator)".to_string(),
385            Message::PromptSelectModules => "Select nodes to configure".to_string(),
386            Message::PromptSelectTasksToImport => "Select tasks to import".to_string(),
387            Message::PromptSelectTasksToIgnore => "Select tasks to ignore (optional)".to_string(),
388            Message::PromptSelectIgnoreNamesToRemove => "Select ignore names to remove (optional)".to_string(),
389            Message::PromptAddIgnoreName => "Add ignore name (empty to finish)".to_string(),
390
391            // === GENERAL MESSAGES ===
392            Message::OperationCompleted => "Operation completed successfully".to_string(),
393            Message::OperationCancelled => "Operation cancelled".to_string(),
394            Message::InvalidInput => "Invalid input provided".to_string(),
395            Message::PermissionDenied => "Permission denied".to_string(),
396            Message::DeprecatedCommand(old, new) => {
397                format!("`kasl {}` is now `kasl {}`. The old name still works but will be removed in 2.0.", old, new)
398            }
399
400            // === ERROR LOGGING ===
401            Message::ErrorSendingEvents(error) => format!("[kasl] Error sending events: {}", error),
402            Message::ErrorSendingMonthlyReport(error) => format!("[kasl] Error sending monthly report: {}", error),
403            Message::ErrorInRdevListener(error) => format!("Error in rdev listener: {:?}", error),
404            Message::ErrorRequestingRestDates(error) => format!("Error requesting rest dates: {}", error),
405
406            // === SPECIFIC UI MESSAGES ===
407            Message::SelectingTask(name) => format!("Selected task: {}", name),
408
409            // === JIRA INBOX MESSAGES ===
410            Message::JiraInboxRequiresJiraConfig => "Jira inbox requires Jira to be configured. Run `kasl setup` and select Jira.".to_string(),
411            Message::JiraInboxEmpty => "Jira inbox is empty.".to_string(),
412            Message::JiraInboxListHeader => "Jira inbox:".to_string(),
413            Message::JiraInboxSynced {
414                fetched,
415                new_count,
416                changed,
417                gone,
418            } => {
419                format!("Jira inbox synced: {} fetched, {} new, {} changed, {} gone.", fetched, new_count, changed, gone)
420            }
421            Message::JiraInboxNewIssues(count) => format!("Jira inbox: {} new issue(s).", count),
422            Message::JiraInboxNotFound(key) => format!("Issue '{}' not found in inbox.", key),
423            Message::JiraInboxPinned(key) => format!("Pinned {}.", key),
424            Message::JiraInboxUnpinned(key) => format!("Unpinned {}.", key),
425            Message::JiraInboxDismissed(key) => format!("Dismissed {}.", key),
426            Message::JiraInboxOpened(key) => format!("Opened {} in browser.", key),
427            Message::JiraInboxTaken(key) => format!("Imported {} into tasks.", key),
428            Message::JiraInboxAlreadyTaken(key, name) => format!("{} is already taken as '{}'.", key, name),
429            Message::JiraInboxSummary { total, fresh, taken } => {
430                // Only the parts that carry information: "3 in the inbox" says
431                // enough when none are new and none are taken.
432                let mut parts = Vec::new();
433                if *fresh > 0 {
434                    parts.push(format!("{} new", fresh));
435                }
436                if *taken > 0 {
437                    parts.push(format!("{} taken", taken));
438                }
439                let detail = if parts.is_empty() {
440                    String::new()
441                } else {
442                    format!(" ({})", parts.join(", "))
443                };
444                format!("{} in the inbox{}", total, detail)
445            }
446            Message::JiraInboxOpenFailed(err) => format!("Failed to open browser: {}", err),
447            Message::PromptJiraInboxEnabled => "Enable Jira inbox polling?".to_string(),
448            Message::PromptJiraInboxPollInterval => "Jira inbox poll interval (seconds)".to_string(),
449            Message::PromptJiraInboxNotify => "Show toast notifications for new issues?".to_string(),
450            Message::PromptJiraInboxSortFieldId => "Sort field id for ranking (e.g. customfield_12345 for Scoring; empty to skip)".to_string(),
451            Message::PromptJiraInboxSortFieldLabel => "Label for sort field (default Scoring)".to_string(),
452            Message::PromptJiraInboxExtraFieldId => "Additional custom field id to fetch (empty to finish)".to_string(),
453            Message::PromptJiraInboxExtraFieldLabel => "Label for this custom field".to_string(),
454
455            // === MIGRATION MESSAGES ===
456            Message::MigrationsFound(count) => format!("Found {} pending database migrations", count),
457            Message::RunningMigration(version, name) => format!("Running migration v{}: {}", version, name),
458            Message::MigrationCompleted(version) => format!("✓ Migration v{} completed", version),
459            Message::MigrationFailed(version, error) => format!("✗ Migration v{} failed: {}", version, error),
460            Message::AllMigrationsCompleted => "All database migrations completed successfully".to_string(),
461            Message::DatabaseVersion(version) => format!("Current database version: {}", version),
462            Message::DatabaseUpToDate => "Database schema is up to date".to_string(),
463            Message::DatabaseNeedsUpdate => "Database schema needs to be updated".to_string(),
464            Message::MigrationHistory => "Migration history:".to_string(),
465            Message::NothingToRollback => "Nothing to rollback".to_string(),
466            Message::RollingBack(from, to) => format!("Rolling back from v{} to v{}", from, to),
467            Message::RollbackCompleted(version) => format!("Rollback to v{} completed", version),
468        };
469
470        write!(f, "{}", text)
471    }
472}