Skip to main content

kasl/libs/messages/
types.rs

1//! Message type definitions for the kasl application.
2//!
3//! Defines the central `Message` enum that represents all user-facing messages with type safety and compile-time verification.
4//!
5//! ## Features
6//!
7//! - **Type Safety**: All messages are strongly typed with appropriate parameters
8//! - **Centralization**: Single enum captures all application messaging needs  
9//! - **Extensibility**: Easy addition of new message types and categories
10//! - **Organization**: Logical grouping by functional categories
11//! - **Internationalization**: Structure supports future localization efforts
12//!
13//! ## Usage
14//!
15//! ```rust
16//! use kasl::libs::messages::types::Message;
17//! use kasl::{msg_info, msg_error, msg_success};
18//!
19//! msg_success!(Message::TaskCreated);
20//! msg_error!(Message::ConfigSaveError);
21//! msg_info!(Message::MonitorStarted {
22//!     pause_threshold: 60,
23//!     poll_interval: 500,
24//!     activity_threshold: 30,
25//! });
26//! ```
27
28/// Comprehensive message enumeration for all user-facing communication.
29///
30/// This enum represents every type of message that the kasl application can
31/// present to users. It provides a type-safe way to handle all application
32/// communication while ensuring consistent formatting and proper parameter
33/// handling across all components.
34///
35/// ## Message Categories
36///
37/// The enum is organized into logical categories that correspond to different
38/// areas of application functionality. Each category groups related messages
39/// to improve maintainability and make it easier to understand the scope
40/// of each functional area.
41///
42/// ## Parameter Conventions
43///
44/// - **String Parameters**: Used for names, descriptions, and user-provided text
45/// - **Numeric Parameters**: Used for counts, IDs, and measurements
46/// - **Status Parameters**: Used for system states and operation results
47/// - **Structured Parameters**: Named fields for complex message data
48///
49/// ## Adding New Messages
50///
51/// When adding new message variants:
52/// 1. Choose the appropriate category section
53/// 2. Use descriptive names that clearly indicate the message purpose
54/// 3. Include necessary parameters with appropriate types
55/// 4. Add corresponding text in the `Display` implementation
56/// 5. Document the message purpose and usage context
57///
58/// ## Backward Compatibility
59///
60/// The enum is designed to maintain backward compatibility:
61/// - New variants can be added without breaking existing code
62/// - Parameter changes should be additive when possible
63/// - Deprecated messages can be maintained for transition periods
64#[derive(Debug, Clone)]
65pub enum Message {
66    // === AUTOSTART MESSAGES ===
67    AutostartEnabled,
68    AutostartEnabledUser,
69    AutostartDisabled,
70    AutostartAlreadyDisabled,
71    AutostartEnableFailed(String),
72    AutostartDisableFailed(String),
73    AutostartStatus(String),
74    AutostartNotImplemented,
75    AutostartRequiresAdmin,
76    AutostartCheckingAlternative,
77
78    // === TASK MESSAGES ===
79    TaskCreated,
80    TaskUpdated,
81    TaskDeleted,
82    TaskNotFound,
83    TaskCreateFailed,
84    TaskUpdateFailed,
85    TaskDeleteFailed,
86    TasksDeletedCount(usize),
87    TasksNotFoundForDate(String),
88    TasksNotFoundSad,
89    TasksHeader,
90    TasksIncompleteHeader,
91    TasksGitlabHeader,
92    TasksJiraHeader,
93    /// Summary line before unified discovery MultiSelect
94    TasksDiscoverySummary {
95        incomplete: usize,
96        jira: usize,
97        gitlab: usize,
98    },
99    /// Non-selectable separator between incomplete and other items
100    TasksDiscoverySeparator,
101    TasksDiscoverySearchingIncomplete,
102    TasksDiscoveryFetchingExternal,
103    NoTaskIdsProvided,
104    TasksNotFoundForIds(Vec<i32>),
105    TasksToBeDeleted,
106    ConfirmDeleteTask,
107    ConfirmDeleteTasks(usize),
108    ConfirmDeleteAllTodayTasks(usize),
109    ConfirmDeleteAllTodayTasksFinal,
110    NoTasksForToday,
111    TaskNotFoundWithId(i32),
112    CurrentTaskState,
113    TaskEditPreview,
114    ConfirmTaskUpdate,
115    NoChangesDetected,
116    NoTasksSelected,
117    SelectTasksToEdit,
118    EditingTask(String),
119    TaskUpdatedWithName(String),
120    TaskSkippedNoChanges(String),
121    TaskEditingCompleted,
122    PromptTaskNameEdit,
123    PromptTaskCommentEdit,
124    PromptTaskCompletenessEdit,
125    TaskCompletenessRange,
126
127    // === WORKDAY MESSAGES ===
128    WorkdayEnded,
129    WorkdayNotFound,
130    WorkdayNotFoundForDate(String),
131    WorkdayCreateFailed,
132    WorkdayStarting(String),                    // date
133    WorkdayCouldNotFindAfterFinalizing(String), // date
134
135    // === CONFIGURATION MESSAGES ===
136    ConfigSaved,
137    ConfigDeleted,
138    ConfigLoaded,
139    ConfigFileNotFound,
140    ConfigParseError,
141    ConfigSaveError,
142    ConfigModuleGitLab,
143    ConfigModuleJira,
144    ConfigModuleSiServer,
145    ConfigModuleMonitor,
146    ConfigModuleServer,
147    ConfigModuleProductivity,
148    ConfigModuleTaskDiscovery,
149    ConfigModuleJiraInbox,
150    TaskDiscoveryIgnoreListHeader,
151    TaskDiscoveryIgnoreListEmpty,
152    TaskDiscoveryIgnoreNameAdded(String),
153    TaskDiscoveryIgnoreNameExists(String),
154    TaskDiscoveryIgnoreNamesAdded(usize),
155
156    // === REPORT MESSAGES ===
157    DailyReportSent(String),   // date
158    MonthlyReportSent(String), // date
159    MonthlyReportTriggered,
160    ReportSendFailed(String),        // status
161    MonthlyReportSendFailed(String), // status
162    ReportHeader(String),            // date
163    WorkingHoursForMonth(String),    // month/year
164
165    // === EXPORT MESSAGES ===
166    ExportingData(String, String), // data type, format
167    ExportCompleted(String),       // file path
168    ExportingAllData,
169    ExportFailed(String), // error
170
171    // === TEMPLATE MESSAGES ===
172    TemplateCreated(String),
173    TemplateUpdated(String),
174    TemplateDeleted(String),
175    TemplateNotFound(String),
176    TemplateAlreadyExists(String),
177    TemplateCreateFailed,
178    NoTemplatesFound,
179    TemplateListHeader,
180    SelectTemplateToEdit,
181    SelectTemplateToDelete,
182    ConfirmDeleteTemplate(String),
183    EditingTemplate(String),
184    NoTemplatesMatchingQuery(String),
185    TemplateSearchResults(String),
186    SelectTemplateAction,
187    PromptTemplateName,
188    PromptTemplateTaskName,
189    PromptTemplateComment,
190    PromptTemplateCompleteness,
191    CreatingTaskFromTemplate(String),
192    SelectTemplate,
193    CreateTemplateFirst,
194
195    // === TAG MESSAGES ===
196    TagCreated(String),
197    TagUpdated(String),
198    TagDeleted(String),
199    TagNotFound(String),
200    TagAlreadyExists(String),
201    NoTagsFound,
202    TagListHeader,
203    EditingTag(String),
204    SelectTagAction,
205    SelectTagToEdit,
206    SelectTagToDelete,
207    ConfirmDeleteTag(String),
208    ConfirmDeleteTagWithTasks(String, usize), // tag name, task count
209    PromptTagName,
210    PromptTagColor,
211    NoTasksWithTag(String),
212    TasksWithTag(String),
213    TagsAddedToTask(String),
214
215    // === SHORT INTERVALS MESSAGES ===
216    ShortIntervalsDetected(usize, String), // count, total duration
217    NoShortIntervalsFound(u64),            // min_minutes
218    ShortIntervalsToRemove(usize),         // count
219    RemovingPauses(usize),                 // count
220    ShortIntervalsCleared(usize),          // deleted count
221    NoRemovablePausesFound,
222    UpdatedReport,
223    PromptMinWorkInterval,
224
225    // === TIME ADJUSTMENT MESSAGES ===
226    SelectAdjustmentMode,
227    PromptAdjustmentMinutes,
228    PromptPauseStartTime,
229    ConfirmTimeAdjustment,
230    TimeAdjustmentApplied,
231    AdjustmentPreview,
232    InvalidAdjustmentTooMuchTime,
233    InvalidPauseOutsideWorkday,
234    WorkdayUpdateFailed,
235
236    // === PAUSE MESSAGES ===
237    PausesTitle(String),
238
239    // === MONITOR MESSAGES ===
240    MonitorStarted {
241        pause_threshold: u64,
242        poll_interval: u64,
243        activity_threshold: u64,
244    },
245    MonitorStopped,
246    MonitorStartFailed,
247    MonitorStopFailed,
248    MonitorExitedNormally,
249    MonitorShuttingDown,
250    MonitorError(String),
251    MonitorTaskPanicked(String),
252    PauseStarted,
253    PauseEnded,
254
255    // === WATCHER/DAEMON MESSAGES ===
256    WatcherStarted(u32), // PID
257    WatcherStopped(u32), // PID
258    WatcherStoppedSuccessfully,
259    WatcherNotRunning,
260    WatcherNotRunningPidNotFound,
261    WatcherStartingForeground,
262    WatcherStoppingExisting(String),     // PID
263    WatcherFailedToStopExisting(String), // error
264    WatcherFailedToStop(u32),            // PID
265    WatcherReceivedSigterm,
266    WatcherReceivedSigint,
267    WatcherReceivedCtrlC,
268    WatcherCtrlCListenFailed(String), // error
269    WatcherSignalHandlingNotSupported,
270    DaemonModeNotSupported,
271    FailedToGetCurrentExecutable,
272    FailedToCreateSigtermHandler,
273    FailedToCreateSigintHandler,
274
275    // === UPDATE MESSAGES ===
276    UpdateAvailable {
277        app_name: String,
278        latest: String,
279    },
280    UpdateCompleted {
281        app_name: String,
282        version: String,
283    },
284    NoUpdateRequired,
285    UpdateDownloadUrlNotSet,
286    WatcherStoppingForUpdate,
287    WatcherRestartingAfterUpdate,
288    WatcherStoppingForConfig,
289    WatcherRestartingAfterConfig,
290    WatcherRestarted,
291    WatcherRestartFailed {
292        error: String,
293    },
294    UpdateBinaryNotFoundInArchive,
295
296    // === AUTHENTICATION MESSAGES ===
297    WrongPassword(i32), // attempt count
298    InvalidCredentials,
299    SessionExpired,
300    AuthenticationFailed(String), // service name
301    JiraAuthenticateFailed,
302    LoginFailed,
303    CredentialsNotSet,
304
305    // === API MESSAGES ===
306    ApiConnectionFailed,
307    ApiAuthFailed,
308    ApiRequestFailed,
309    GitlabFetchFailed(String),  // error message
310    GitlabUserIdFailed(String), // error message
311    JiraFetchFailed(String),    // error message
312    SiServerConfigNotFound,
313    SiServerSessionFailed(String),          // error message
314    SiServerRestDatesFailed(String),        // error message
315    SiServerRestDatesParsingFailed(String), // error message
316
317    // === DATABASE MESSAGES ===
318    DbConnectionFailed,
319    DbQueryFailed,
320    DbMigrationFailed,
321    DatabaseOperationFailed {
322        operation: String,
323        error: String,
324    },
325    NoIdSet,
326
327    // === FILE SYSTEM MESSAGES ===
328    FileNotFound,
329    FileReadError,
330    FileWriteError,
331    InvalidPidFileContent,
332    DataStoragePathError,
333
334    // === SYSTEM/PATH MESSAGES ===
335    PathConfigured,
336    PathConfigWarning {
337        error: String,
338    },
339    PathQueryFailed(String), // status
340    PathSetFailed,
341    PathRegistryQueryError {
342        status: String,
343    },
344    PathRegistryUpdateError {
345        status: String,
346        stderr: String,
347    },
348    FailedToJoinPaths,
349    FailedToExecuteRegQuery,
350    FailedToParseRegOutput,
351    FailedToGetPathFromReg,
352    FailedToExecuteRegSet,
353    FailedToOpenProcess(u32),      // error code
354    FailedToTerminateProcess(u32), // error code
355    ProcessNotFound,
356    ProcessTerminationNotSupported,
357
358    // === PRODUCTIVITY MESSAGES ===
359    MonthlyProductivity(f64), // percentage
360    LowProductivityWarning {
361        current: f64,
362        threshold: f64,
363        needed_break_minutes: u64,
364    },
365    ProductivityTooLowToSend {
366        current: f64,
367        threshold: f64,
368        needed_break_minutes: u64,
369    },
370    BreakCreated {
371        start_time: String,
372        end_time: String,
373        duration_minutes: u64,
374    },
375    BreakCreateFailed(String),
376    BreakSuggestionCommand {
377        auto_minutes: u64,
378    },
379    BreakInteractivePrompt,
380    BreakDurationPrompt {
381        min_duration: u64,
382        max_duration: u64,
383    },
384    BreakPlacementOptions,
385    BreakOptionSelected(usize),
386    BreakConflictsWithPauses,
387    NoValidBreakPlacement,
388    ProductivityRecalculated(f64),
389
390    // === ENCRYPTION/SECRET MESSAGES ===
391    EncryptionKeyMustBeSet,
392    EncryptionIvMustBeSet,
393
394    // === PROMPTS ===
395    PromptTaskName,
396    TaskNameMergedFromPaste,
397    PromptTaskComment,
398    PromptTaskCompleteness,
399    PromptGitlabToken,
400    PromptGitlabUrl,
401    PromptJiraLogin,
402    PromptJiraUrl,
403    PromptJiraPassword,
404    PromptSiLogin,
405    PromptSiAuthUrl,
406    PromptSiApiUrl,
407    PromptSiPassword,
408    PromptMinPauseDuration,
409    PromptPauseThreshold,
410    PromptPollInterval,
411    PromptActivityThreshold,
412    PromptMinProductivityThreshold,
413    PromptWorkdayHours,
414    PromptMinWorkdayFraction,
415    PromptMinBreakDuration,
416    PromptMaxBreakDuration,
417    PromptServerApiUrl,
418    PromptServerAuthToken,
419    PromptConfirmDelete,
420    PromptSelectOptions,
421    PromptSelectModules,
422    PromptSelectTasks,
423    PromptSelectTasksToEdit,
424    PromptSelectTasksToImport,
425    PromptSelectTasksToIgnore,
426    PromptSelectIgnoreNamesToRemove,
427    PromptAddIgnoreName,
428
429    // === GENERAL MESSAGES ===
430    OperationCompleted,
431    OperationCancelled,
432    DataExported,
433    BackupCreated,
434    InvalidInput,
435    PermissionDenied,
436
437    // === ERROR LOGGING ===
438    ErrorSendingEvents(String),        // error message
439    ErrorSendingMonthlyReport(String), // error message
440    ErrorInRdevListener(String),       // error message
441    ErrorRequestingRestDates(String),  // error message
442
443    // === SPECIFIC UI MESSAGES ===
444    SelectingTask(String),           // task name
445    SelectedTaskFormat(String, i32), // task name, completeness
446
447    // === JIRA INBOX MESSAGES ===
448    JiraInboxRequiresJiraConfig,
449    JiraInboxEmpty,
450    JiraInboxListHeader,
451    JiraInboxSynced {
452        fetched: usize,
453        new_count: usize,
454        updated: usize,
455    },
456    JiraInboxNewIssues(usize),
457    JiraInboxNotFound(String),
458    JiraInboxPinned(String),
459    JiraInboxUnpinned(String),
460    JiraInboxDismissed(String),
461    JiraInboxOpened(String),
462    JiraInboxTaken(String),
463    JiraInboxOpenFailed(String),
464    PromptJiraInboxEnabled,
465    PromptJiraInboxPollInterval,
466    PromptJiraInboxNotify,
467    PromptJiraInboxSortFieldId,
468    PromptJiraInboxSortFieldLabel,
469    PromptJiraInboxExtraFieldId,
470    PromptJiraInboxExtraFieldLabel,
471
472    // === MIGRATION MESSAGES ===
473    MigrationsFound(usize),        // count
474    RunningMigration(u32, String), // version, name
475    MigrationCompleted(u32),       // version
476    MigrationFailed(u32, String),  // version, error
477    AllMigrationsCompleted,
478    DatabaseVersion(u32),
479    DatabaseUpToDate,
480    DatabaseNeedsUpdate,
481    MigrationHistory,
482    NothingToRollback,
483    RollingBack(u32, u32),  // from, to
484    RollbackCompleted(u32), // version
485}