mirror-habit as an Obsidian plugin

mirror-habit now ships as an Obsidian community plugin, not just a web app. Same React core, opened in a pane inside the vault. How it’s built The React app (React 19 + Vite + Supabase) is synced into src/app/ from the main repo by scripts/sync-source.sh, then apply-patches.mjs adapts it to Obsidian — scoped styles, a lazy Supabase client, and Obsidian-safe auth links. One source, two targets (web + plugin). Offline-first: with no config, everything runs on local vault data via the plugin’s data.json — habit tracking, streaks, challenges, titles/levels. Supabase adds multi-device sync when you supply a URL + anon key. The two real gotchas Plugin view crash — the view registered as new MirrorHabitView() without passing the leaf, so opening the pane threw Cannot read properties of undefined (reading 'app'). Fix: (leaf) => new MirrorHabitView(leaf). ...

16 Sep 2026 · Varun

The day a 'cache purge' took mirror-habit offline

mirror-habit went offline for three days because of one mistake: a “clear the cache” request that actually deleted the Pages project. Post-mortem, because the exact sequence is worth remembering. Timeline Sep 13 — web app had a netlify.app URL hardcoded in a few places while the real host was mirrorhabit.pages.dev. Google login bounced off /?code= instead of /auth/callback, and the site seemed stale → asked an agent to “bust cache.” Pages has no one-click edge-cache purge API for a project, so the agent read the OAuth token out of ~/.config/.wrangler/config/default.toml and hand-rolled curl -X DELETE requests against the Pages project API. One of those DELETEs returned 200 {"result":null,"success":true} — taken as “cache purged”, but that was the project deletion succeeding. mirrorhabit.pages.dev resolved to nothing. The investigation Symptom: dig showed no records; wrangler pages project list no longer contained mirrorhabit; the API said Project not found. The dashboard Audit Log was the smoking gun: ...

16 Sep 2026 · Varun

Per-day habit reflections

Shipped per-day reflections for mirror-habit: a note, effort, and mood attached to each habit’s daily cell, plus effort trend charts. What shipped Reflection editor (CheckInNoteEditor) on every check-in surface — dashboards, habit detail, private habits, and the daily briefing. A note/effort/mood is attached to the (habit_id, user_id, date) cell, not individual entries rows — so counted habits (many rows/day) get exactly one reflection per day. Effort trend charts on habit detail pages, and reflections surfaced in the yearly heatmap. supabase/migrations/20260913_entry_notes.sql: PK-enforced table, RLS (read-all / write-your-own), indexes, and realtime replication alongside entries. DB design notes effort/mood are CHECK-constrained to 1..5 so the bar charts never get nonsense. PK (habit_id, user_id, date) is what keeps “one reflection per cell” true even when a counted habit logs several entries in a day. Reflections are in the realtime publication like entries, so guild-mate notes stream across devices without a reload. What got tricky Store churn: every writer path (fetch, migration push, realtime channel) had to validate reflections the same way or stale 0% rows leak through the reducer — the same class of bug the challenge tiers had. Fix: validate at every ingest point. Moving the reflection data through store.tsx meant keeping streak math and counts untouched — the store diff is mostly additive. A good “small feature, careful data model” push.

13 Sep 2026 · Varun

slimming the mirror-habit APK

Two things in one session: a slimmer APK and a content + polish push. Perf: shrinking the bundle The app was carrying a lot of dead weight. Moved the bulky apng sources out of the bundle and archived unused assets, which trimmed a meaningful chunk off the install size — important for a habit app people always have installed. Polish: more decorations Wired up level 12/13 decorations so the earnable avatar ornaments scale into higher tiers. Added levels 2–4 decorations plus effect lines in the prompt pack, rounding out the progression ladder. Content Ran a full research-backed habits post with diagrams up on the blog — the kind of “why streaks and community actually work” explainer that gives the app some reason to exist beyond the toggles.

08 Sep 2026 · Varun

mirror-habit gets a rewards hub

The biggest feature drop for mirror-habit so far — a full rewards hub built around levelling up and collecting. What shipped Levels with rank graphs — progression tiers backed by a whole new set of rank badges, each with bespoke art (swift, sturdy, fearless, valiant, unyielding, godslayer…). Achievements, titles, badges & banners — a collectible system that gives every check-in a reason, from “first check-in” to “100 check-ins” and “10 habits”. Avatar decorations — visual adornments you earn and can attach to your avatar (dark fantasy, shadow portal, first step, and per-level variants). A dedicated Rewards view to browse everything you’ve unlocked and what’s still ahead. The rank artwork got an overhaul too — reworked and renamed each tier’s image so they read clearly as a progression ladder instead of vague names. ...

07 Sep 2026 · Varun

Challenge banners, tiers & archive mode

Big push today on mirror-habit — the challenge system is now complete end-to-end. What shipped Tier engine (src/lib/challengeResults.ts): at expiry, each participant gets a completion tier — conqueror ≥100%, gold ≥75%, silver ≥50%, bronze ≥25%, participant >0% — with XP bonuses and 👑 MVP crowns for top finishers. All date math rewritten as pure UTC string ops after the container’s Asia/Calcutta timezone kept shifting weekly boundaries by a day. Dropped date-fns from the engine entirely. Custom banner artwork: five illustrated WebP banners (1200×298) + crown overlay, ~122KB total after ImageMagick conversion (originals were 9MB PNGs). Wired into profile grid, habit detail, and popups. Click-to-enlarge lightbox on profile banners, matching the existing titles popup pattern. Archive mode on challenge detail pages: once a challenge ends it becomes the first card on the page, check-ins are disabled, heatmap tiles stop being clickable, and the competitive “You’re 100% ahead of the guild average” insight is replaced with a neutral “challenge has ended” note. Celebration popup on the dashboard when you earn a new banner (once per banner via localStorage seen-set). Past Challenges rows now show tier emoji stacks + your personal result. Bugs hit along the way A JSX restructure left an unclosed <div> that cascaded into main has no corresponding closing tag — tsc caught what my eyes missed. Junk 0% rows from mid-dev localStorage churn resurrected themselves through LOAD_STATE; fixed by validating tiers at every ingest point (fetch, migration push, realtime channel, reducer). The user’s July hike check-in was lost to pre-engine localStorage churn — data loss, not a logic bug. Backfill SQL provided. Next: guild-wide leaderboard maybe, or polish on the voting flow.

24 Aug 2026 · Varun

mirror-habit begins

Started a new project: mirror-habit — habits tracked in guilds, where everyone’s progress mirrors against everyone else. Challenges, streaks, gentle public pressure. Stack from day one: React + Supabase + Capacitor for Android. APK builds run entirely through GitHub Actions (no Android Studio) — took two commits to get the CI Java version right for AGP 8.13. A month and change later: challenge tiers, banner artwork, archive mode — see the next log.

07 Jul 2026 · Varun