Skip to content

fix(platform-scripture): Select-All excludes not-in-reference books#2463

Draft
lyonsil wants to merge 1 commit into
mainfrom
fix/manage-books-selectall-excludes-disabled
Draft

fix(platform-scripture): Select-All excludes not-in-reference books#2463
lyonsil wants to merge 1 commit into
mainfrom
fix/manage-books-selectall-excludes-disabled

Conversation

@lyonsil

@lyonsil lyonsil commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

Manage Books → Create → Based on template: "Select all" was selecting books that are not present in the reference project — the books the grid renders as disabled. This inflated the selection count and tripped the missing-model preflight prompt for books the orchestrator would only filter out at submit time anyway.

The set that Select-All, the header tri-state checkbox, the selection count, and the "{n} of {m} selected" announcement all derive from (selectableVisibleBooks) now excludes not-in-reference books. It shares a single predicate (isBookNotInCreateReference) with the grid's pill-disabling logic so the grid's "disabled" and the selection logic's "selectable" can no longer drift — the drift that caused this bug.

Root cause

selectableVisibleBooks included disabled (not-in-reference) books, and toggleAllVisible (Select-All) added all of them. The grid disabled those pills and an existing prune effect removed them on reference change, but Select-All re-added them. extensions/src/platform-scripture/src/manage-books-dialog/manage-books-dialog.component.tsx.

Fix

  • Extracted two pure helpers into manage-books-dialog.utils.ts (matching the existing deleteConfirmVariant / computeCompareState pure-helper pattern):
    • isBookNotInCreateReference(book, …) — single source of truth for "not creatable from the reference project".
    • computeSelectableVisibleBooks(…) — the genuinely-selectable set, excluding not-in-reference books.
  • Rewired selectableVisibleBooks and the grid's disabled condition to both use the shared predicate. The grid change is behavior-preserving (verified equivalent below).

Minimal diff: 3 files, changes confined to one dialog. No opportunistic refactors.

Reproduction & regression evidence (RED → GREEN)

Backend/logic defect — reproduced with a failing unit test, then fixed.

Before (RED):

× computeSelectableVisibleBooks > regression: Create-from-template excludes books not in the reference project (so Select-All cannot select disabled books)
  → expected [ 'GEN', 'EXO', 'LEV', 'NUM' ] to deeply equal [ 'GEN', 'EXO' ]
 Test Files  1 failed (1)
      Tests  1 failed | 32 passed (33)

After (GREEN):

✓ computeSelectableVisibleBooks > regression: Create-from-template excludes books not in the reference project (so Select-All cannot select disabled books)
 Test Files  1 passed (1)
      Tests  35 passed (35)

An independent reviewer ran the Revert Test: removing the fix's .filter(…) fails exactly the regression test and nothing else.

Self-review

Three adversarial reviews (architecture/correctness, scope/clarity, tests):

  • Correctness: the grid's disabled condition is provably equivalent to the original (verified by truth table including undefined reference state and empty present-set); no selectableVisibleBooks consumer regresses; the header tri-state now correctly reaches "all selected"; complements (does not conflict with) the existing prune effect; no null/undefined hazards.
  • Scope/clarity: tight scope, no dead code, helper extraction justified and pattern-conforming.
  • Tests: regression test meaningful, falsifiable (Revert Test confirmed), behavior-focused; added 2 extra coverage cases per review feedback.

A pre-existing, out-of-scope finding (the per-group toggleAllInGroup header does not filter disabled books — cosmetic, and after this fix it no longer affects the count or preflight) was recorded for follow-up rather than expanded into this PR.

Impact & confidence

  • User-visible: yes. Severity: medium (spurious preflight prompt + wrong selection count in Create-from-template). Frequency: occasional (Create-from-template when the reference project lacks some destination books). Confidence: ~0.95.

Provenance

Found by the automated quality-sweep run qs-2026-06-26 (cold-scan fallback; the Jira seed was unavailable this run, so the run degraded to backlog + cold scan). Scan dedup key: scan:platform-scripture:selectall-selects-disabled-books.

AI-assisted — generated by Claude Opus 4.8 via the quality-sweep harness.


This change is Reviewable

Found by the quality-sweep run (qs-2026-06-26).

In Manage Books > Create > Based on template, "Select all" added books not
present in the reference project (the ones the grid disables), inflating the
selection count and tripping the missing-model preflight for books the
orchestrator would only filter out at submit time anyway.

The set that Select-All, the header tri-state checkbox, the count, and the
"{n} of {m} selected" announcement all derive from (selectableVisibleBooks) now
excludes not-in-reference books, sharing one predicate (isBookNotInCreateReference)
with the grid's pill-disabling logic so the two notions of "selectable" can no
longer drift. The grid's disabled condition is rewired through the same predicate
(behavior-preserving) to keep a single source of truth.

Extracted computeSelectableVisibleBooks + isBookNotInCreateReference as pure,
unit-tested helpers, matching the file's existing pure-helper pattern
(deleteConfirmVariant / computeCompareState).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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