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    },
364    ProductivityTooLowToSend {
365        current: f64,
366        threshold: f64,
367    },
368    ManualPauseCreated {
369        start_time: String,
370        end_time: String,
371        duration_minutes: u64,
372    },
373    ManualPauseOverlaps {
374        start_time: String,
375        end_time: String,
376    },
377    ManualPauseRemoved(i32),
378    ManualPauseNotFound(i32),
379    ProductivityRecalculated(f64),
380
381    // === ENCRYPTION/SECRET MESSAGES ===
382    EncryptionKeyMustBeSet,
383    EncryptionIvMustBeSet,
384
385    // === PROMPTS ===
386    PromptTaskName,
387    TaskNameMergedFromPaste,
388    PromptTaskComment,
389    PromptTaskCompleteness,
390    PromptGitlabToken,
391    PromptGitlabUrl,
392    PromptJiraLogin,
393    PromptJiraUrl,
394    PromptJiraPassword,
395    PromptSiLogin,
396    PromptSiAuthUrl,
397    PromptSiApiUrl,
398    PromptSiPassword,
399    PromptMinPauseDuration,
400    PromptPauseThreshold,
401    PromptPollInterval,
402    PromptActivityThreshold,
403    PromptMinProductivityThreshold,
404    PromptWorkdayHours,
405    PromptMinWorkdayFraction,
406    PromptServerApiUrl,
407    PromptServerAuthToken,
408    PromptConfirmDelete,
409    PromptSelectOptions,
410    PromptSelectModules,
411    PromptSelectTasks,
412    PromptSelectTasksToEdit,
413    PromptSelectTasksToImport,
414    PromptSelectTasksToIgnore,
415    PromptSelectIgnoreNamesToRemove,
416    PromptAddIgnoreName,
417
418    // === GENERAL MESSAGES ===
419    OperationCompleted,
420    OperationCancelled,
421    DataExported,
422    BackupCreated,
423    InvalidInput,
424    PermissionDenied,
425
426    // === ERROR LOGGING ===
427    ErrorSendingEvents(String),        // error message
428    ErrorSendingMonthlyReport(String), // error message
429    ErrorInRdevListener(String),       // error message
430    ErrorRequestingRestDates(String),  // error message
431
432    // === SPECIFIC UI MESSAGES ===
433    SelectingTask(String),           // task name
434    SelectedTaskFormat(String, i32), // task name, completeness
435
436    // === JIRA INBOX MESSAGES ===
437    JiraInboxRequiresJiraConfig,
438    JiraInboxEmpty,
439    JiraInboxListHeader,
440    JiraInboxSynced {
441        fetched: usize,
442        new_count: usize,
443        updated: usize,
444    },
445    JiraInboxNewIssues(usize),
446    JiraInboxNotFound(String),
447    JiraInboxPinned(String),
448    JiraInboxUnpinned(String),
449    JiraInboxDismissed(String),
450    JiraInboxOpened(String),
451    JiraInboxTaken(String),
452    JiraInboxOpenFailed(String),
453    PromptJiraInboxEnabled,
454    PromptJiraInboxPollInterval,
455    PromptJiraInboxNotify,
456    PromptJiraInboxSortFieldId,
457    PromptJiraInboxSortFieldLabel,
458    PromptJiraInboxExtraFieldId,
459    PromptJiraInboxExtraFieldLabel,
460
461    // === MIGRATION MESSAGES ===
462    MigrationsFound(usize),        // count
463    RunningMigration(u32, String), // version, name
464    MigrationCompleted(u32),       // version
465    MigrationFailed(u32, String),  // version, error
466    AllMigrationsCompleted,
467    DatabaseVersion(u32),
468    DatabaseUpToDate,
469    DatabaseNeedsUpdate,
470    MigrationHistory,
471    NothingToRollback,
472    RollingBack(u32, u32),  // from, to
473    RollbackCompleted(u32), // version
474}