AnRil f3367e09de chore+fix: repo hygiene, code-review fixes, audit cleanup
Three independent code reviews + a security audit produced ~200 findings.
This commit lands the high-impact subset. Tests pass (53), typecheck
clean, eslint clean (3 minor exhaustive-deps warnings left).

REPO HYGIENE
- Add .editorconfig, .prettierrc.json, .prettierignore.
- Add ESLint flat config (.eslintrc.cjs) — correctness-focused, no style
  rules (Prettier owns formatting).
- Add `format` / `format:check` / `lint` npm scripts.
- Add CHANGELOG.md (Keep a Changelog format, back-filled to 0.1.x).
- Reformat all source via Prettier so future diffs stay small.

DATA SAFETY (src/main/store.ts)
- Atomic write (tmp + rename) with retry on transient EBUSY/EPERM —
  was non-atomic writeFileSync, vulnerable to truncation on power loss.
- On corrupt JSON, rename to `app-state.json.corrupt-<ts>` instead of
  silently overwriting the user's exercises/history with defaults.
- Validate parsed shape before merging — reject arrays/scalars where
  objects expected; per-field array checks.
- Strip `id` from incoming patches in updateExercise/updateChallenge —
  a runtime caller (IPC) could otherwise smuggle id changes through.
- clearHistory now refuses an unbounded wipe (no beforeTs => no-op);
  callers must pass an explicit boundary.
- unref() the debounce timer so it doesn't keep the event loop alive.

SECURITY (src/main/*)
- gsi-server: hard 256 KB body cap (was unbounded — local OOM vector),
  reject any Origin/Sec-Fetch-Site header (blocks browser CSRF from
  visited pages), require application/json Content-Type, generic 400
  on parse error (no error string echo to client), closeAllConnections
  + async close on stop.
- dota2: validate auth.token from payload with timingSafeEqual against
  the per-install token — was unauthenticated, any local process could
  forge match-end events. Narrow object shape before spread-merge to
  avoid throws on hostile payloads like {player:"x"}. Reset latest /
  prevState after match_end so the next match starts clean.
- ipc: gate `dev:simulateMatchEnd` registration behind `!app.isPackaged`
  so it does not exist in shipped builds.
- preload: gate the matching `simulateMatchEnd` export behind
  `import.meta.env.MODE !== 'production'` so the bundler dead-code-
  eliminates it from the production preload bundle.
- windows: shell.openExternal allowlist (http/https/mailto only) — was
  forwarding any URL, including file:/javascript:/custom URI handlers
  (some Windows handlers have been RCE vectors). will-navigate blocks
  navigation to anywhere except file:// or the dev URL.

CORRECTNESS (src/main/* + src/shared/*)
- shared/types.ts isQuietAt: fix wrap-around + day-of-week filter.
  With from=22:00 to=07:00 days=[Mon..Fri], the window started THE
  PREVIOUS DAY when we're in the AM half — old code checked today's
  day-of-week and got the wrong answer Sat 02:00 and Mon 01:00. Now
  the filter is evaluated against the window's START day. Also reject
  malformed HH:MM strings instead of producing NaN.
- scheduler: call broadcastState() after firing exercises so the
  renderer's Dashboard/Exercises pages don't show stale nextFireAt
  until the next state-changing IPC. Guard powerMonitor listeners
  against double-registration on dev hot-reload.
- dota2: fix `launchOptionStatus = steamRunning ? 'queued' : 'queued'`
  tautology — both branches now correctly read 'queued'.
- steam-launch-options: replace `require('node:fs')` inside atomicWrite
  with the top-level import; retry on transient EBUSY/EPERM.

CORRECTNESS (src/renderer/*)
- lib/history.ts: replace `today.getTime() - i * MS_DAY` arithmetic
  with `setDate(date - i)` calendar arithmetic in dailyRepsRange and
  currentStreak — DST transitions shift epoch math by ±1h and cause
  dayKey() to emit duplicate or missing days at the boundary.
- lib/icon.tsx: restrict name lookup to ICON_CHOICES set — an arbitrary
  string from a corrupted state file could otherwise resolve to
  unrelated Lucide exports and crash the renderer.
- lib/format.ts: guard formatCountdown against NaN/Infinity.
- i18n/index.ts: replace regex-based interpolation with split/join so
  variable values containing regex metacharacters interpolate
  literally; warn in dev on missing keys; clamp pluralRu(-N) via abs.
- ReminderApp: keyboard shortcuts moved INTO ExerciseReminder so Enter
  respects the stepper's `adjusted` flag (was always passing planned
  reps). Stepper capped at 5× planned. Don't hijack Space when a
  button is focused. `key={exercise.id+nextFireAt}` forces a fresh
  component for back-to-back reminders so stepper state resets. Match
  summary view gets Esc-to-close. Functional setMode in onMarkDone
  avoids races against stale `mode.done`.
- UpdaterCard: guard against NaN/Infinity in download-progress events
  (electron-updater fires early events with undefined fields).
- Games: gate DevPanel behind `import.meta.env.DEV` in addition to the
  main-side IPC gate, and narrow the `simulateMatchEnd` access.
- Add aria-labels for the +/- stepper buttons (i18n keys added).

TESTS
- +2 quiet-hours tests covering wrap-around + day-filter combo and
  malformed HH:MM fallback. Total 53 passing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 23:04:49 +07:00
2026-05-16 13:43:29 +07:00
2026-05-16 13:43:29 +07:00
2026-05-16 13:43:29 +07:00

Laude — Exercise Reminder

Windows desktop приложение, которое напоминает делать упражнения во время работы за компьютером. Опционально подключается к Dota 2 и после каждого матча превращает статистику (смерти, убийства, ассисты) в количество повторений.

release tests platform

Что внутри

  • Гибкие напоминания — любое количество упражнений, интервал от минуты до часов, разные иконки.
  • История и стрики — heatmap-календарь активности, ежедневный счётчик, серия дней подряд.
  • Тихие часы — окно времени когда напоминания подавляются (например 22:00 → 08:00), с выбором дней недели.
  • Сделал частично — степпер /+ в окне напоминания: если ты сделал 5 из 10, в историю запишется честное число.
  • Игровая интеграция (Dota 2) — Game State Integration читает статистику матча, после Победа/Поражение показывает экран с «причитающимися» повторениями (например 10 смертей × 3 = 30 приседаний).
  • Apple-style интерфейс — Plus Jakarta Sans + Bricolage Grotesque, iOS-палитра, vibrancy sidebar, spring-анимации, светлая/тёмная/системная тема.
  • Два языка — русский и английский, переключение мгновенное.
  • Auto-update — приложение само скачивает новые версии из фиксированного update-channel (проверка каждый час, силент-ретрай при сетевых сбоях).

Скриншоты

TODO: вставить screenshots Dashboard / Reminder / Match summary (light + dark).

Установка

Скачай последний Exercise-Reminder-Setup-X.Y.Z.exe со страницы релизов и запусти. Установщик:

  • Создаёт ярлык на рабочем столе и в Пуске
  • Сохраняет настройки в %APPDATA%\Exercise Reminder\
  • При запуске поверх существующей инсталляции — обновляет, настройки сохраняются

Windows SmartScreen может предупредить «не доверено» — приложение не подписано code-signing сертификатом. Нажми ПодробнееВыполнить в любом случае.

Разработка

git clone https://xn--90adajar8af4h.xn--p1ai/git/AnRil/laude.git
cd laude
npm install
npm run dev

Полезные команды:

npm run typecheck       # tsc по main + renderer
npm run test            # vitest в watch-режиме
npm run test:run        # vitest один раз (для CI)
npm run build           # сборка без NSIS
npm run dist            # сборка + NSIS-инсталлятор → release/
npm run release -- -Bump patch    # bump версии + tag + push + upload в Gitea

Документ RELEASING.md описывает процесс выпуска новых версий.

Архитектура

  • Electron 33 — multi-process: main (Node/scheduler/GSI) + preload (contextBridge) + renderer (React)
  • Renderer — React 18, TypeScript 5, Vite 5, Tailwind 3, framer-motion, react-router, zustand
  • Persistence — единственный JSON-файл %APPDATA%\Exercise Reminder\app-state.json (debounced writes)
  • IPC — типизированные каналы через src/shared/ipc.ts, обёрнуто preload-ом
  • i18n — самописная микро-система: src/renderer/src/i18n/dict.ts (плоский словарь ~200 ключей × 2 языка) + хук useT()
  • Auto-updateelectron-updater с generic provider, манифест latest.yml лежит в Gitea release attachments
  • GSI Dota 2 — локальный HTTP-сервер слушает GameStateIntegration коллбэки от Steam, парсит match-end events

Тесты

src/shared/types.test.ts                (4)
src/shared/quiet-hours.test.ts          (5)
src/renderer/src/lib/format.test.ts     (8)
src/renderer/src/lib/history.test.ts   (13)
src/main/games/vdf.test.ts             (11)
src/renderer/src/i18n/i18n.test.ts     (10)
─────────────────────────────────────────
                                  51 ✓

Покрытие: чистые helpers (форматирование, история/стрики, тихие часы, парсер VDF для Steam-конфигов), i18n с плюрализацией для RU/EN, дефолты shared-типов.

Лицензия

Пока не указана. По умолчанию все права защищены. Если хочешь форк/использование — открой issue.

Stack

Description
Exercise reminder - Windows desktop app
Readme 1.7 MiB
2026-05-22 23:38:16 +07:00
Languages
TypeScript 93.5%
PowerShell 4.2%
CSS 1.5%
JavaScript 0.6%
HTML 0.2%