Repository navigation
feat(habits): add good and bad habit types - #304
Merged
Merged
Conversation
ahmet-cetinkaya
force-pushed
the
feat/habit-types-good-bad
branch
from
September 5, 2026 15:00
f5c3588 to
b46f6d4
Compare
The Zed debug session failed to link the Linux desktop build on NixOS:
clang++: error: linker command failed with exit code 1
ld: cannot find -lgstapp-1.0
Two independent causes:
1. flake.nix passed only `-Wl,-rpath-link` to CMake. ld uses that solely to
resolve indirect dependencies, never as a library *search* path, so plugins
linking with bare `-l` flags (audioplayers_linux -> -lgstapp-1.0, -lglib-2.0)
could not be resolved. The generated link line contained no `-L` at all.
Add `-L` for every Nix build input.
2. The Dart extension never entered the dev shell. It ignores `customTool`
entirely and resolves the binary via `worktree.which("fvm")` *before* the
debug config's `env` map is applied, so neither the existing wrapper script
nor a project-local PATH override could redirect it
(zed-extensions/dart, src/dart.rs).
Drop the dead `customTool` entry and keep `useFvm: true`, which the extension
does honour — without it the adapter looks for a bare `flutter` and reports
"flutter not found in PATH", since Flutter is pinned via FVM here.
The remaining piece is host-side and cannot live in the repo, because it must
sit on the PATH Zed itself sees: a `~/.local/bin/fvm` shim that re-enters
`nix develop` for flake projects and delegates straight through elsewhere.
Verified from a clean build/linux with `env -i` and only ~/.local/bin on PATH.
ahmet-cetinkaya
force-pushed
the
feat/habit-types-good-bad
branch
from
September 5, 2026 15:01
b46f6d4 to
d5c6876
Compare
…axis labels - Fix x-axis month/percent labels duplication by adding missing fl_chart interval configuration - Fix bad-habit trend data scoped to current month with day-level keys; now uses real trailing-12-month trend - Add comprehensive test coverage for habit statistics view and query logic
A rebase artifact left both SUM(...) and TOTAL(...) projections aliased as total_duration, causing SQLite to compute the same aggregate twice per group. The ORDER BY clause now uses SUM to match the projection, ensuring the sort key is consistent with the selected value. Adds integration test covering sorting by actual time, which previously had no coverage.
_presenter was a getter, so every one of the up-to-42 month-grid cells constructed a new HabitDayPresenter and re-indexed all habit records. It is now built once per grid build and passed into the day builders, with late keeping it unbuilt on the good-habit path that never reads it.
WidgetHabitData.fromJson used Enum.values.byName, which handled an absent field but threw ArgumentError on a present-but-unrecognised value; since the persisted widget blob survives app upgrades and downgrades, a name written by a newer version broke the widget permanently with no way to self-heal. It now reuses the domain's total HabitType.fromJson and a name-map lookup for HabitDayState, matching how every neighbouring field degrades. Adds a regression test.
updateType mutated the habit and notified listeners before awaiting the save, so a failed save left the UI showing the new type with hasGoal, targetFrequency, periodDays, and dailyTarget blanked while the database still held the old values; editing any other field would then persist that corrupted state. saveHabitImmediately now accepts an onError hook and updateType restores the previous values plus the goal field's visibility. Adds a regression test.
The handler caught only BusinessException, so infrastructure failures (DB lock, disk full) in this fire-and-forget notification callback propagated with nothing logged. This left the user with a dismissed notification, no recorded habit, and no diagnostic trail. A general catch now logs the error with its stack trace and rethrows, preserving the existing propagation behavior that notification_handlers_test.dart asserts.
The repository decoded the column with HabitType.values[...], which threw an uncaught RangeError on any value outside 0..1 — reachable from a row written by a newer build or from corrupted data — and silently tied the stored meaning to enum declaration order, so reordering variants would reinterpret every existing row. HabitType now declares an explicit id per variant with a fromId function that defaults unknown ids to good, matching the existing fromJson policy. Tests cover the out-of-range row, the id mapping, and a guard asserting each id still equals its ordinal, since the Drift intEnum column persists the index.
The raw filter SQL passed HabitType.bad.index while the repository now decodes the column through HabitType.fromId, splitting one persistence contract across two sources. The four query variables now use HabitType.bad.id so reads and writes agree on a single identity. Values are unchanged, so behavior is identical today.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class good and bad habit types. Good habits retain their existing completion-based behavior; bad habits track successful avoidance.
Changes by area
Behavior specification
notDonerecord means the habit was performed that day.completehistory is preserved when converting types, but is ignored while a habit is in bad mode.QA evidence
Artifacts are available under
.omo/evidence/.dart analyze: cleanrps lint: 0rps test:locale: 0rps test:migrate: 0 (673 tests)Defects found and fixed during development
'$TaskErrorIds.x'to'${TaskErrorIds.x}'; applied the same correction to the task handler for contract consistency.Risks / notes
LIMIT/OFFSET—was intentionally left untouched as out of scope.