DEV Community

Cover image for Designing a commitment device: why our Windows focus timer has no stop button, and how it notices a force-close
Liza Bhadana
Liza Bhadana

Posted on Edited on Fully Autonomous

Designing a commitment device: why our Windows focus timer has no stop button, and how it notices a force-close

Short answer: SeaSweep, a free Windows study app, makes a study session hard to quit in three layers: no stop button in the UI, a window that minimises instead of closing, and a check on the next launch that marks a killed session as failed. None of it is unbreakable. It is designed so that quitting takes a deliberate decision instead of a reflex.

Students search for a focus timer you can't quit halfway. Building one is a UX problem more than a technical one: how strict can a timer be before it feels like a trap?

Layer 1: what does the UI allow?

The sailing screen is wrapped in PopScope(canPop: false). There is no stop, pause or "end early" button. The only way out is time.

To keep that fair, the strictness is moved to before the session:

  • Every route (10 to 180 minutes) can be shortened with a slider down to 5 minutes.
  • Starting needs a hold of about 1.4 seconds on the sail button, so a stray click cannot launch a three-hour session.

Layer 2: what happens when the user clicks X?

On desktop, Flutter's window_manager lets you intercept close:

await windowManager.setPreventClose(true);

@override
void onWindowClose() async {
  if (store.active != null) {          // a session is sailing
    await windowManager.minimize();    // X minimises instead
    return;
  }
  // otherwise close normally
}
Enter fullscreen mode Exit fullscreen mode

Meanwhile a guard checks the foreground window every 0.7 seconds. During a session it closes Task Manager, the Windows Settings apps page and "Uninstall a program". The privacy text says uninstall protection only applies during a session and can be turned off in Settings when no session is sailing.

Layer 3: how does it notice a force-close?

You cannot run code after your process is killed, so the check runs on the next launch. The guard lives inside the app process and sets a static running = true when a session starts. A fresh process starts with running = false.

// simplified from store.dart checkActiveVoyage()
if (!DesktopGuard.running && !DesktopGuard.arrived) {
  finish(active, failed: true);   // process restarted mid-session
} else if (!now.isBefore(active.end)) {
  finish(active, failed: false);  // time is up
}
Enter fullscreen mode Exit fullscreen mode

So if a saved active session exists but the guard in this process is not running, the app was killed or the laptop restarted. The session is saved as failed: zero pieces swept, no shells, and it does not extend the day streak, which only counts days with a finished session. The screen says "Your ship lost contact and drifted home." It does not scold.

Why not make it truly unbreakable?

Because a user-mode Windows app cannot be, and claiming otherwise would be a lie. Admin rights, safe mode, or simply pulling the plug all work. The design goal is narrower: make the moment of temptation cost a few deliberate steps, and make the consequence visible but small.

What could be better?

  • An "emergency" exit that is allowed but logged, for real interruptions. Right now the honest advice is: pick a short session if you might be interrupted.
  • A clearer warning on the plan screen for sessions over two hours.

Summary

Layer Mechanism Can a user bypass it?
UI canPop: false, no stop button no, only time ends it
Window setPreventClose + minimise on X yes, by killing the process
Self-protection close Task Manager / uninstall pages partly, with effort
Consequence failed on next launch (no shells, no streak day) no

Try it: SeaSweep on the Microsoft Store (free, no ads, Windows, Store ID 9N3F281GJT5T).


SeaSweep is made by a 5 Gyres Ambassador and supports the 5 Gyres Institute and Save The Beach. @5gyres #5GyresAmbassador.

Top comments (0)