Skip to content

Scope the usage pin to its usageOpened block - #3156

Draft
HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/3-settings-usage-block
Draft

HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/3-settings-usage-block

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3155

Owner: Dev-3
Written-by: Dev-3
Bot: FlyBot Dev-3
Tier: T1 (test-only)
Claim-Id: 55513261fb7d4d74840006f046a3cf52
Branch: dev/3-settings-usage-block

What changed

every settings page has a rendered branch pinned usage with a whole-file search, const PAGE_PINS = { usage: /h\((UsagePage),/ }. Moving h(UsagePage, …) out of the usageOpened ? h('div', { key: 'usage' …) block, while keeping it in the file, left the case green — and the Usage panel would then paint before it is opened (#3155). #3154 merged the pre-fix tree; this branch carries the fix that did not reach main.

The case now pins every page key to the form that actually paints it:

  • a ternary page needs shown === '<key>' … ? h(<Component> on one line, and <Component> must be defined (function/const/let) or imported in settings.js;
  • usage is pinned inside its own block: the slice runs from usageOpened ? h('div', { key: 'usage' to that block's : null) and must contain h(UsagePage,. It is a bounded window — not a whole-file search, and not a [\s\S]*? scan into the rest of the file — so moving the call out of the block is red too;
  • the reverse check stays: a shown === '<key>' literal naming a key outside SETTINGS_PAGES is red.

Case count is unchanged (5); the file goes 138 → 151 lines against current main. Test content only, no production file, no changelog fragment.

Verification at the tip

Tip SHA: 12452d438c22ec76609a13ae02b927355d95ba0b (tree 358147247f65a71d2669344a9d39c1b34a140984, base ed935b304f71f1da386a73c31bb1f0e070573691 = parent, 2 files +18/−4 each)

Ran, from core/ on Node v22.23.2: node --test test/settings-page-keys.test.js

(e) unmodified tree: # tests 5 / # pass 5 / # fail 0, twice, same shape.

Four mutations, source only (the test file untouched), each run twice with the same shape (4 pass / 1 fail):

mutation (source only) failing case names
(a) h(UsagePage, { roster, actions, focusId: usageFocus }) → null 4 every settings page has a rendered branch usage
(b) move that call out of the usageOpened ? h('div', { key: 'usage' …) block, still in the file 4 same usage
(c) shown === 'about' ? h(AboutPage, { … }) : null → shown === 'about' ? null : null 4 same about
(d) a branch key mistyped: shown === 'feedback' → shown === 'feedbacks' 4 same feedback (page side)
(d′) a branch naming a key outside the list: shown === 'ghost' ? h(FeedbackPage, …) added 4 same ghost (branch side)

Verbatim from (a), both runs identical:

not ok 4 - every settings page has a rendered branch
  ---
  failureType: 'testCodeFailure'
  error: |-
    settings pages with no rendered branch:
    usage
    + actual - expected

    + [
    +   'usage'
    + ]
    - []

  code: 'ERR_ASSERTION'

Verbatim from (b), both runs identical — the call is still in the file, only outside the panel block:

not ok 4 - every settings page has a rendered branch
  ---
  failureType: 'testCodeFailure'
  error: |-
    settings pages with no rendered branch:
    usage
    + actual - expected

    + [
    +   'usage'
    + ]
    - []

  code: 'ERR_ASSERTION'

(c) prints about in the same shape; (d) prints feedback; (d′) prints:

not ok 4 - every settings page has a rendered branch
  error: |-
    rendered branches that name no settings page:
    ghost
    + actual - expected

    + [
    +   'ghost'
    + ]
    - []

Reverting each mutation restores settings.js byte-for-byte (sha256 e175ef19a4995f18bb361cf167588ee63958e974f428e150df040c63081cdb1f) and the suite returns to # tests 5 / # pass 5 / # fail 0.

Mirror: node scripts/ds-bot-patches.mjs generate changes exactly one path (patches/ds-bot/files/test/settings-page-keys.test.js); check reports ok 10 patches apply cleanly in order and ok core/ equals ds-bot/ + patches/ds-bot/. Both copies are byte-identical, sha256 a732cf528203cca1859b806f4511045f771754d7171c49555a29f91f90a6ab15.

Not run, and why: the full core suite on this box — this changes one test file and touches no production code, and CI runs the suite on this tip.

Follow-up

#3154 merged as ed935b304f71f1da386a73c31bb1f0e070573691 on the pre-fix tree, and that merge closed #3153; main still carries the whole-file PAGE_PINS pin. This pull request lands the block-scoped pin, so the usage case goes red when the call is moved out of its panel block.

Checkpoint

{
  "pr": 3156,
  "claim": "Dev-3",
  "issue": 3155,
  "summary": "Scopes the usage pin to its own block: every settings page key must draw a component, and usage must contain h(UsagePage, between usageOpened ? h('div', { key: 'usage' and that block's : null). Moved out of the block the call still sits in the file and the case is red, so a whole-file search cannot pass it. Test content only, with the ds-bot mirror regenerated to the same sha256.",
  "files": ["core/test/settings-page-keys.test.js", "patches/ds-bot/files/test/settings-page-keys.test.js"],
  "checks": { "ran": "node --test test/settings-page-keys.test.js (green twice); mutations a/b/c/d1/d2 twice each (red, 4 pass / 1 fail); ds-bot-patches generate + check", "result": "green", "at": "12452d438c22ec76609a13ae02b927355d95ba0b" },
  "next": "none — ready for review; the FlyBot Test advisory on this sha is the remaining gate"
}

The whole-file usage pin still passed with h(UsagePage, …) moved out of the usageOpened block, so the panel rendered before it was opened. Read the block from usageOpened ? h('div', { key: 'usage' to its : null) and require the call inside that window.
@Birfy
Birfy marked this pull request as ready for review November 18, 2026 01:59
@HugoXK
HugoXK marked this pull request as draft November 18, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant