Skip to content
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

replace advanceToTime with some Fritter timers #71

Open
11 tasks
Tracked by #51
glyph opened this issue Oct 23, 2024 · 0 comments
Open
11 tasks
Tracked by #51

replace advanceToTime with some Fritter timers #71

glyph opened this issue Oct 23, 2024 · 0 comments

Comments

@glyph
Copy link
Owner

glyph commented Oct 23, 2024

The current model for how the activity loop is driven, where a periodic timer calls advanceToTime, is extremely brittle, error-prone, and complex to modify.

For example:

  • just look at the mess that is earlyEvaluationSpecialCase
  • the 3-level deep match/if/else logic is complex
  • invalid/impossible states like "rolling off the end of a streak but the streak is empty somehow" exist in the control flow that need to be accounted for

Plus, I obviously want to be using Fritter here to have a nice reified model of time

However, this migration presents significant challenges. Inverting this logic so that it is expressed in terms of changes to timers would naively mean we need to be statefully keeping track of timers for start/end of every interval in our inventory, which is not ideal either.

What are the events that can affect the time of the next state change? All of these depend on the active interval type.

User takes an action:

  • With an active Pomodoro interval, if it is evaluated, that starts the next Duration from the StreakRules.
    • In principle, you could end a Break early too, and maybe we should add the ability to do that.
  • Same deal with abandoning the intention associated with an active pomodoro (oops this one's not even implemented yet at all!)
  • In an Idle interval, rules for recurring session start change, which should set a timer for the start of the next automatic session, to start StartPrompts.
  • In a StartPrompt, the session's duration is changed. (It's not valid to move the start time of a session that has already started.)
  • When a grace period is ended by a Pomodoro starting, the next event moves to the end of the Pomdoro.

Time Passes:

  • When a Pomodoro expires, we start the next Break
  • When a break expires, we start the next StartPrompt
  • When a grace period expires, the current streak ends, and we go to the next grace period.
  • In a StartPrompt, it expires, which should schedule the next StartPrompt.
  • When an Idle interval expires, we start the session that ends it

This sounds like it might be a job for https://github.com/glyph/automat/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant