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    UpdateLatestTagNotFound(String),
287    WatcherStoppingForUpdate,
288    WatcherRestartingAfterUpdate,
289    WatcherStoppingForConfig,
290    WatcherRestartingAfterConfig,
291    WatcherRestarted,
292    WatcherRestartFailed {
293        error: String,
294    },
295    UpdateBinaryNotFoundInArchive,
296
297    // === AUTHENTICATION MESSAGES ===
298    WrongPassword(i32), // attempt count
299    InvalidCredentials,
300    SessionExpired,
301    AuthenticationFailed(String), // service name
302    JiraAuthenticateFailed,
303    LoginFailed,
304    CredentialsNotSet,
305
306    // === API MESSAGES ===
307    ApiConnectionFailed,
308    ApiAuthFailed,
309    ApiRequestFailed,
310    GitlabFetchFailed(String),  // error message
311    GitlabUserIdFailed(String), // error message
312    JiraFetchFailed(String),    // error message
313    SiServerConfigNotFound,
314    SiServerSessionFailed(String),          // error message
315    SiServerRestDatesFailed(String),        // error message
316    SiServerRestDatesParsingFailed(String), // error message
317
318    // === DATABASE MESSAGES ===
319    DbConnectionFailed,
320    DbQueryFailed,
321    DbMigrationFailed,
322    DatabaseOperationFailed {
323        operation: String,
324        error: String,
325    },
326    NoIdSet,
327
328    // === FILE SYSTEM MESSAGES ===
329    FileNotFound,
330    FileReadError,
331    FileWriteError,
332    InvalidPidFileContent,
333    DataStoragePathError,
334
335    // === SYSTEM/PATH MESSAGES ===
336    PathConfigured,
337    PathConfigWarning {
338        error: String,
339    },
340    PathQueryFailed(String), // status
341    PathSetFailed,
342    PathRegistryQueryError {
343        status: String,
344    },
345    PathRegistryUpdateError {
346        status: String,
347        stderr: String,
348    },
349    FailedToJoinPaths,
350    FailedToExecuteRegQuery,
351    FailedToParseRegOutput,
352    FailedToGetPathFromReg,
353    FailedToExecuteRegSet,
354    FailedToOpenProcess(u32),      // error code
355    FailedToTerminateProcess(u32), // error code
356    ProcessNotFound,
357    ProcessTerminationNotSupported,
358
359    // === PRODUCTIVITY MESSAGES ===
360    MonthlyProductivity(f64), // percentage
361    LowProductivityWarning {
362        current: f64,
363        threshold: f64,
364    },
365    ProductivityTooLowToSend {
366        current: f64,
367        threshold: f64,
368    },
369    ManualPauseCreated {
370        start_time: String,
371        end_time: String,
372        duration_minutes: u64,
373    },
374    ManualPauseOverlaps {
375        start_time: String,
376        end_time: String,
377    },
378    ManualPauseRemoved(i32),
379    ManualPauseNotFound(i32),
380    ProductivityRecalculated(f64),
381
382    // === ENCRYPTION/SECRET MESSAGES ===
383    EncryptionKeyMustBeSet,
384    EncryptionIvMustBeSet,
385
386    // === PROMPTS ===
387    PromptTaskName,
388    TaskNameMergedFromPaste,
389    PromptTaskComment,
390    PromptTaskCompleteness,
391    PromptGitlabToken,
392    PromptGitlabUrl,
393    PromptJiraLogin,
394    PromptJiraUrl,
395    PromptJiraPassword,
396    PromptSiLogin,
397    PromptSiAuthUrl,
398    PromptSiApiUrl,
399    PromptSiPassword,
400    PromptMinPauseDuration,
401    PromptPauseThreshold,
402    PromptPollInterval,
403    PromptActivityThreshold,
404    PromptMinProductivityThreshold,
405    PromptWorkdayHours,
406    PromptMinWorkdayFraction,
407    PromptServerApiUrl,
408    PromptServerAuthToken,
409    PromptConfirmDelete,
410    PromptSelectOptions,
411    PromptSelectModules,
412    PromptSelectTasks,
413    PromptSelectTasksToEdit,
414    PromptSelectTasksToImport,
415    PromptSelectTasksToIgnore,
416    PromptSelectIgnoreNamesToRemove,
417    PromptAddIgnoreName,
418
419    // === GENERAL MESSAGES ===
420    OperationCompleted,
421    OperationCancelled,
422    DataExported,
423    BackupCreated,
424    InvalidInput,
425    PermissionDenied,
426
427    // === ERROR LOGGING ===
428    ErrorSendingEvents(String),        // error message
429    ErrorSendingMonthlyReport(String), // error message
430    ErrorInRdevListener(String),       // error message
431    ErrorRequestingRestDates(String),  // error message
432
433    // === SPECIFIC UI MESSAGES ===
434    SelectingTask(String),           // task name
435    SelectedTaskFormat(String, i32), // task name, completeness
436
437    // === JIRA INBOX MESSAGES ===
438    JiraInboxRequiresJiraConfig,
439    JiraInboxEmpty,
440    JiraInboxListHeader,
441    JiraInboxSynced {
442        fetched: usize,
443        new_count: usize,
444        changed: usize,
445        gone: usize,
446    },
447    JiraInboxNewIssues(usize),
448    JiraInboxNotFound(String),
449    JiraInboxPinned(String),
450    JiraInboxUnpinned(String),
451    JiraInboxDismissed(String),
452    JiraInboxOpened(String),
453    JiraInboxTaken(String),
454    JiraInboxOpenFailed(String),
455    PromptJiraInboxEnabled,
456    PromptJiraInboxPollInterval,
457    PromptJiraInboxNotify,
458    PromptJiraInboxSortFieldId,
459    PromptJiraInboxSortFieldLabel,
460    PromptJiraInboxExtraFieldId,
461    PromptJiraInboxExtraFieldLabel,
462
463    // === MIGRATION MESSAGES ===
464    MigrationsFound(usize),        // count
465    RunningMigration(u32, String), // version, name
466    MigrationCompleted(u32),       // version
467    MigrationFailed(u32, String),  // version, error
468    AllMigrationsCompleted,
469    DatabaseVersion(u32),
470    DatabaseUpToDate,
471    DatabaseNeedsUpdate,
472    MigrationHistory,
473    NothingToRollback,
474    RollingBack(u32, u32),  // from, to
475    RollbackCompleted(u32), // version
476}