-
Notifications
You must be signed in to change notification settings - Fork 249
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
Adding activities in retrospect is very hard #630
base: master
Are you sure you want to change the base?
Adding activities in retrospect is very hard #630
Conversation
…ed date For activity in cmdline: `some activity` (without date and time) - checked incrementing and decrementing day - checked date picker - checked date picker set to one date and cmdline on another date (cmdline has higher priority) This fixes projecthamster#627 Adding activities in retrospect is very hard.
Adapted from projecthamster/hamster#630. This fixes some issues with coordination of the commandline and date widgets.
I just gave this PR a whirl. At first glance, it seems to work, but it seems to introduce a new problem: If you create a new activitity and add e.g. "-02:00" in the commandline to set the end time. Without this PR, the end date is set to tomorrow, but with this PR, the end date is set to today and saving is prevented. This problem does not occur when you enter the end time in the "end" input box, just in the commandline. So some part of the "past midnight" handling is broken by this. I also do not understand the fix in this commit completely yet, the commit message doesn't really help explain the fix here and should be improved before this is merged (but I can do that once I manage to figure out what it does exactly and why). It seems that he essence of the fix is to remove special "delta" handling from both the I also still wonder if, as I suggested in #590 (comment), it wouldn't be better to even remove |
src/hamster/edit_activity.py
Outdated
self.start_date.date = self.fact.start_time | ||
self.end_date.date = self.fact.end_time | ||
self.start_date.date = self.fact.date or self.date | ||
self.end_date.date = self.fact.date or self.date |
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.
@gsobczyk, Why is this change needed? It has a bug, since it uses self.fact.date
also for the start date, but I also wonder why this is needed at all. Especially the or self.data
part seems to set a default, but why not just let (especially) the end date unset when none is set yet?
This was unused.
The `extract_search` helper function was passed the text and parsed a Fact from that. However, all places calling this function already parsed that same text, so easier to just pass the parsed Fact rather than the text.
Inside CmdLineEntry, the text was previously parsed without specifying a default_day, causing the (start) date of that parsed fact to be the current date. This was mostly harmless, since these parsed facts are only used to generate completions (the actual fact to be saved is parsed by CustomFactController, which does apply the right date). However, in some cases, this caused suggestions to look slightly weird (such as when editing a fact with a start time before today and without end time, the "stop now" entry would show an explicit date, because the serialization *did* use default_day). By using the default_day also for parsing, the CmdLineEntry always has the right idea about the fact that it is creating, which removes these small weirdnesses.
This seems to be a small typo, see the comment I left inline (though I don't understand why this change is needed in the first place). I just pushed some extra commits to this PR. Three of them are fixups (separated for easier review) to the commit by @gsobczyk that:
I also added three new commits of my own, which are related cleanups and a small fix. I'm pondering to make some more changes, but I'm out of time now. In particular:
I think none of these changes really affect the PR as it is, though, so if people test and approve the PR as it is now, maybe we can merge this (after squashing the fixups and probably improving the commit message, didn't do that yet) and do the above changes in a new PR as well. |
This ensures that `self.date` remains correct, which indirectly makes sure the "dayline" at the top of the window is updated, and ensures that the cmdline also uses the right date for subsequent serialization and completions.
I added a commit to fix this by setting As for the other changes I suggested above, I think they are sensible, but I have the feeling that this entire code might need a more thorough redesign to become a bit less fragile. And I'd rather get these fixed merged (and released) ASAP, rather than letting that wait for a big redesign task. I also had another look at #627, and this PR fixes only "issue 5" described there (which is #590), the other issues are unfixed. However, I think the other issues are mostly small usability issues, not actually incorrect behaviour like #590. So, I have nothing more to add to this PR now, I think it's good to merge it as it is now. @gsobczyk, what do you think? Also, could you respond to my inline comment above? @Others, I'd welcome review and testing of these changes. |
I did test the code and indeed it fixes only issue 5 so the PR should be reworded to not close #627. I did not find any other serious side-effect so I believe it's OK to merge this but we should really have some non-regression tests covering the logic of such changes... the other usability issues are pretty annoying. |
Beware: @matthijskooijman and others want/seem to mix civil date and hamster day. The timeline choice is the hamster day. The start and end entries are civil dates. |
I have tested the PR, past midnight, and find that some things are still quirky. The Back arrow on the timeline moves the date back by two days and the Forward arrow is unresponsive. Setting the "New day starts at" to 00:00, things seem to behave better. My testing has not been very systematic, but I feel that the date handling is still too fragile. |
Indeed, that's a consequence of my previous comment. |
@gsobczyk, @matthijskooijman: My previous comment may have sounded negative, but your work on this critical issue is very much appreciated! Please keep at it! Personally I find the complexity of the code w.r.t. date and time handling too daunting to tackle myself. I would seek simplifications. Perhaps @matthijskooijman's idea of removing the date field from Fact would help. I think having three ways to adjust the date, i.e. cmdline, timeline arrows and date picker, are just too many. I would consider removing the arrows from the timeline for starters. They were very useful back when there was no date picker, but less so now. I would also go a step further and remove the "end date" date picker altogether. Normally the duration of activities would not exceed 24 hours and the end date can be determined by the start date and the start and end times. If the end time is greater than the start time the dates are the same, otherwise the end date is the day after the start date. This would eliminate the annoyance of the Save button being disabled for a reason the casual user doesn't understand. (Note that activities longer than 24 hours could still be entered on the cmdline by fully specifying start and end dates and times.) |
Ah, good point, I haven't looked properly at that, and didn't test past-midnight start times (only end times). It seems @GeraldJansen did and it is indeed broken. I'll have a look at this again later this week. Thanks for pointing this out and providing some extra links, let's see if I can make sense of them :-)
I had not taken it as negative, just as constructive feedback and testing. Thanks :-)
I'm not sure I agree here: If they all just work as expected, I think they each have a place. For example, I often use the date arrows for entering an activity yesterday or the day before. I could use the start date picker, but that's just a little less convenient. I'm also hesitant about removing long-standing features, since that's likely to make people unhappy (unless they are really broken or really unnecessary, of course, but I'm not convinced of that here).
I'm also not sure I like this idea. I agree that > 24h activities are rare, but the idea behind the expanded view we have now is that you can edit everything without using the cmdline, which IMHO makes it easier for people to figure out how the commandline works, or to just not use the commandline if they prefer to click instead of type where possible. I'd prefer not to break this by removing the (admittedly rarely used) end date picker. Of course, all the UI elements should be doing the right thing and make things easy, not hard for people, so there are still some things to fix here. But I think those are mostly the subject of #627, and I think I want to keep them out of scope for this PR for now. |
I had another look at this bit of code, and I think I now better understand the distinction between "civil date" (the actual date that a start of end time is in) and the "hamster day" (the effective day that a time belongs to, which is one day less than the civil date for past-midnight times) that @ederag has made. And indeed, the current version of this PR insufficiently respects this distinction. In particular, it should be noted that the dayline at the top shows the hamster day, while the date picker shows the civil date (so for a 2021-03-13 01:00 start time, the dayline will show 3-12, while the date picker will show 3-13). I guess this makes sense, with the date picker always showing the exact moment and the dayline showing the day the fact belongs to. However, my code in this PR does not make this distinction and when the date is changed (using the dayline or the date picker), the new date is treated as a civil date in both cases, which is wrong for the dayline and causes the behaviour that @GeraldJansen reported. I also think it would be good to update the code to make this distinction more clear, e.g. by using I also finally had a good look at @ederag's https://github.com/ederag/hamster/commits/fix-calendar-offset branch, and now I understand better what they are doing there. In fact, that branch already updates some uses of the hamsterday to use So, I'm going to try to make a new PR for this issue, based on @ederag's branch, adding more detailed commit messages, restructuring some of the commits and maybe doing a few things different (especially in the later commits). |
Good that you eventually reconsidered #597. You got it. But I explicitly ask you not to tamper with my commits. |
I guess #597 would be a better place for this discussion, so I've copied the above two comments there and I'll also reply there (I should probably have posted part of my previous comment there in the first place). |
PR #674 has been merged, which fixes this particular issue. However, I'll leave this PR open since it still contains some useful cleanups and refactorings, which should probably be extracted and serve as a basis for a more thorough cleanup of edit_activity later. |
Update edit_activity.py to components in the form be aware of selected date
For activity in cmdline:
some activity
(without date and time)This fixes #627 Adding activities in retrospect is very hard.