Skip to content

Fix missing schedule/deadline/norm params in backfill paths#56

Merged
sohamM97 merged 5 commits intomainfrom
feature/reserved-scheduled-slot
Mar 27, 2026
Merged

Fix missing schedule/deadline/norm params in backfill paths#56
sohamM97 merged 5 commits intomainfrom
feature/reserved-scheduled-slot

Conversation

@sohamM97
Copy link
Copy Markdown
Owner

Summary

  • Bug fix: 5 of 7 pickWeightedN call sites in todays_five_screen.dart were missing scheduleBoostedIds, deadlineDaysMap, and normData params, silently dropping the 2.5x schedule boost, up to 8x deadline boost, and normalization during:
    • Restore backfill (saved tasks that are no longer leaves)
    • refreshSnapshots backfill (tasks that become non-leaf mid-session)
    • _replaceIfNoLongerLeaf (single task replacement after adding a child)
    • Pinned-descendant replacement in both restore and refresh paths
  • All 5 paths now use _fetchSelectionContext() to pass full params
  • Added CLAUDE.md guideline to prevent recurrence
  • 3 widget tests covering restore backfill, refreshSnapshots backfill, and pinned-descendant replacement

Test plan

  • flutter analyze passes
  • All existing tests pass
  • 3 new widget tests for fixed backfill paths
  • Manual tests: restore, tab-switch, non-leaf replacement, swap

🤖 Generated with Claude Code

Soham Marik and others added 3 commits March 26, 2026 14:32
… paths

Bug fix: 5 of 7 pickWeightedN call sites in todays_five_screen.dart were
missing scheduleBoostedIds, deadlineDaysMap, and normData params, silently
dropping the 2.5x schedule boost and up to 8x deadline boost during
restore/backfill/replacement operations. Only _generateNewSet and _swapTask
passed them correctly.

Fix: replace standalone getAllLeafTasks() calls with _fetchSelectionContext()
in _loadTodaysTasksInner, refreshSnapshots, and _replaceIfNoLongerLeaf,
then pass full params to all pickWeightedN calls.

Also adds CLAUDE.md guideline requiring all pickWeightedN calls to use
_fetchSelectionContext() params.

Tests not yet run — WIP commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tests verifying that pickWeightedN backfill paths now receive full
selection context (scheduleBoostedIds, deadlineDaysMap, normData):
- restore backfill in _loadTodaysTasksInner
- refreshSnapshots backfill after task becomes non-leaf
- pinned-descendant replacement on restore

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3da38a1b7d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/screens/todays_five_screen.dart Outdated
if (!mounted) return;
final provider = context.read<TaskProvider>();
final allLeaves = await provider.getAllLeafTasks();
final ctx = await _fetchSelectionContext();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Lazy-load selection context during snapshot refresh

refreshSnapshots() is called on routine Today-tab returns, but this change now eagerly calls _fetchSelectionContext() before any replacement/backfill is detected. That forces extra DB queries (including getNormalizationData, which runs recursive ancestry/count work) even when every task is still a valid leaf and no weighted pick is needed, so normal navigation can incur avoidable latency as task counts grow. Fetch this context only inside the branches that actually call pickWeightedN.

Useful? React with 👍 / 👎.

Soham Marik and others added 2 commits March 27, 2026 13:23
- Add widget test for _replaceIfNoLongerLeaf path (uncomplete flow) to
  cover the third backfill fix missing from PR review feedback
- Fix "no dialog shown for task without deadline" test hanging: bump
  pumpAndLoad/pumpAsync rounds to 40 because _fetchSelectionContext now
  does 5 DB queries instead of 1, needing more FakeAsync pump cycles

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…DB queries

Previously, _fetchSelectionContext() was called eagerly at the start of
refreshSnapshots(), running 5 DB queries (including recursive norm data)
on every Today-tab return even when all tasks were still valid leaves and
no weighted pick was needed. Now fetch it lazily only inside the branches
that actually call pickWeightedN (pinned-descendant replacement and backfill).

Also adds a test verifying refreshSnapshots completes correctly when all
tasks remain valid leaves (the common case on routine tab returns).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sohamM97 sohamM97 merged commit 205515e into main Mar 27, 2026
2 checks passed
@sohamM97 sohamM97 deleted the feature/reserved-scheduled-slot branch March 27, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant