GshopfrontEssay14 January 20263-minute read

A desktop app is a website you can't refresh

Electron makes the first version easy. The interesting part is everything after you ship it.

On the web, most mistakes come with an escape hatch. Something gets into a strange state, the user refreshes, and the page starts again from a clean slate. A desktop app doesn't get that. It starts in the morning and runs all day, through sleep and wake, a dropped connection and a laptop lid closed mid-sentence. Whatever state it gets into, it stays in.

I learned this building a time tracker: an Electron app that recorded activity and took screenshots while people worked, and a backend that turned all of it into a work diary. The first version came together quickly. Electron hands you a browser window, React and TypeScript did the rest, and it all felt like familiar ground.

Then it had to survive real people's days.

The network is a suggestion

A web app can assume it's online, because it was online when it loaded. A desktop app can't assume anything. Connections drop for a few seconds or a few hours, and nobody stops working while they do.

So the tracker treated offline as the normal case. Everything it recorded went into a local SQLite database first, and the sync to the backend happened whenever it could. When the network came back, everything that had piled up went up in one go. A bad connection didn't mean a hole in the diary.

Pick a unit and stick to it

The decision that made everything else simpler was the ten-minute window. Activity, screenshots and time all belonged to one window. The app stored windows, synced windows, and the backend read windows.

That one choice pays off in more places than you'd expect. When a sync stops halfway, the question isn't which bytes got through, it's which windows the server has. And the work diary and the performance numbers come from the same windows, so they can't disagree with each other.

Nothing to refresh

A long-running process collects problems a web page never lives long enough to meet. Memory that creeps up over a day. Timers that lose track of time after the machine sleeps. A native module that behaves one way on your laptop and another way on everyone else's. None of it shows up in a quick test after launch. It shows up at four in the afternoon, on someone else's machine.

People are part of the system

Then there's the user who would rather look busy than be busy. Any tool that counts activity will meet someone who tries to fake it, and if the numbers can be gamed, they stop meaning anything. Part of building the tracker was deciding what real work looks like in the data, so a full diary meant a full day.

What I'd tell someone starting one

  • Write to disk first and sync second. Assume the network is down until it proves otherwise.
  • Choose the unit of your data early, and make storage, sync and reporting all speak it.
  • Expect the app to run for days. Test what happens after the machine wakes up, not just after it starts.
  • Assume someone will try to game it, and decide what the numbers should mean before they do.

Electron really does make the first version easy. Everything after that is the job.

Ring the bell

Got a question one of these didn't answer? Ask me directly.

Get in touch