-
Notifications
You must be signed in to change notification settings - Fork 136
Fix: Start date remains unset unless explicitly selected by user #517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,9 @@ class DetailRouteController extends GetxController { | |||||||||
| var onEdit = false.obs; | ||||||||||
| var isReadOnly = false.obs; | ||||||||||
|
|
||||||||||
| // Track whether user explicitly selected a start date | ||||||||||
| bool startEdited = false; | ||||||||||
|
|
||||||||||
| @override | ||||||||||
| void onInit() { | ||||||||||
| super.onInit(); | ||||||||||
|
|
@@ -50,13 +53,19 @@ class DetailRouteController extends GetxController { | |||||||||
| } | ||||||||||
|
|
||||||||||
| if (name == 'start') { | ||||||||||
| debugPrint('Start Value Changed to $newValue'); | ||||||||||
| startEdited = true; // MARK AS USER-SELECTED | ||||||||||
|
||||||||||
| startEdited = true; // MARK AS USER-SELECTED | |
| startEdited = true; // Mark that user explicitly selected a start date |
Copilot
AI
Dec 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic has a potential issue: it checks if modify.original.start is not null and equals modify.original.entry, but it doesn't verify whether modify.draft.start is still the same value. If the user explicitly sets the start date to match the entry date (an unlikely but valid scenario), this code would incorrectly remove it.
Consider also checking that modify.draft.start equals modify.original.start to ensure you're only removing the backend-generated value, not a user's intentional selection.
| modify.original.start!.isAtSameMomentAs(modify.original.entry)) { | |
| modify.original.start!.isAtSameMomentAs(modify.original.entry) && | |
| modify.draft.start != null && | |
| modify.draft.start!.isAtSameMomentAs(modify.original.start!)) { |
Copilot
AI
Dec 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new behavior for handling start dates lacks test coverage. Given that tests exist for other task functions (e.g., test/taskfunctions/draft_test.dart), consider adding tests to verify:
- Start date remains null for new tasks with backend auto-generated start (start == entry)
- Start date is preserved when explicitly set by user
- Start date persists correctly after save and reopen
- The
startEditedflag behaves correctly across different scenarios
This will prevent regressions and document the expected behavior.
Copilot
AI
Dec 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new logic for handling the start date is complex and undocumented. Consider adding a comment explaining:
- What
backendAutoStartmeans (start date was auto-generated by backend when it equals entry date) - Why we hide it from the UI when not explicitly edited by the user
- The three scenarios being handled (user-edited, backend auto-generated, and meaningful existing start)
This will help future maintainers understand the intent behind this fix.
Copilot
AI
Dec 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The refactored conditional expression is missing proper formatting. While the logic is correct, it should be formatted more clearly for readability:
if (!value) {
tutorialCoachMark.show(context: context);
}The current single-line block without braces, while valid Dart, is inconsistent with the codebase style and less maintainable. If additional logic needs to be added later, it could lead to bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
startEditedflag is not reset when the controller is reused. If the user edits a task, saves it, and then opens another task detail view (or the same task again), the flag will still betruefrom the previous interaction. This could cause the start date logic to behave incorrectly.Consider resetting
startEdited = falsein theonInit()method or creating a new instance of the controller for each task.