Guides

Component structure audit and split plan for large guide pages

Use this audit before splitting a large guide page. It states what was found in every file in pack app-campus.site.2, which files mix presentational markup, container state, business logic, and rendering, and the container and presentational split to ship for each file over the split threshold.

Scope and method

Every file listed in the pack was audited. A component in this slice is one guide page. This slice holds no JSX file. The JSX container and presentational pattern maps to HTML and script in this pack as follows.

Component definition for this slice
PartWhere it lives in this packWhat it owns
Presentational componentHTML markup, headings, tables, forms, and CSS classes in the guide fileLayout, labels, helper text, and empty states only. It owns no state and makes no data call.
Container componentInline script in the guide file, or an external script already referenced by the guide fileState, local storage reads and writes, event handling, filtering, aggregation, and rendering calls. It is the only part that reads or writes state.
Business logicFunctions inside the container script, such as token matching, week bucketing, eligibility checks, and count rulesPure rules with no direct document access, so the same rule can be tested without rendering.

Split threshold: a file is a split candidate when its markup plus inline script is over 300 lines and one script mixes state, business logic, and rendering. A short presentational stub with no script, or a page that already loads its logic from an external script, is not a split candidate.

Audit result in one view

Each row states a pattern found across the pack, the files that show it, and the verdict.

Pattern, files, and verdict
PatternFilesVerdict
Presentational stub, no inline scriptfirst-run-checklist, first-run, first-value, helpful-voting, mobile-workspace-layout, and other short stubs in the appendixKeep as one presentational component. No container to split.
Presentational plus external script alreadysave-answer-bundle, grounding-guardrailKeep the split. The external script is the container and the markup is presentational.
Presentational plus one inline script that mixes state, logic, and renderinghealth-readiness-checks, grounding-check, partial-answer-recovery, request-validation, search-indexing, share-answer, workspace-member-audit, and other single tool pages in the appendixSplit candidate when over the threshold. Move the script to one external container file with no markup change.
Presentational plus two or more inline scripts, or one large inline script that owns several state groupsindex, follow-a-question, my-library, weekly-quality-rate, role-first-run, get-started, for-instructors, verified-expert, test-answers, and other large interactive pages in the ranked list belowSplit candidate. Move each state group to its own container file and keep the markup as the presentational component.

Ranked split list, slowest and largest first

Rank is by growth risk first, then by how often the page runs. A page with uncapped state and repeated rendering ranks above a capped page that runs often.

Ranked files that mix state, logic, and rendering, with the split to ship
Rank and fileWhy it is mixedSplit to ship
Rank 1. public/guides/index.htmlTwo inline scripts. One owns search state, synonym logic, sorting, and card rendering. The other owns saved item state, storage, filtering, and list rendering. Both read and write the document while also owning the rules.Presentational: index.html markup and styles. Container 1: guides search container in public/guides-index.js with search state, token logic, and URL sync. Container 2: personal collection container in public/guides-personal-collection.js with saved item state and storage. Each container renders only its own list.
Rank 2. public/guides/my-library.htmlOne large inline script owns storage load and persist, draft recovery, search token logic, filtering, history, and full list rendering.Presentational: my-library.html markup. Container: my-library container in public/my-library.js that owns storage and events. Pure logic module in public/my-library-logic.js with token matching, filtering, and revisit rules and no document access.
Rank 3. public/guides/follow-a-question.htmlOne script owns eligibility logic and rendering. A second script owns follow state, storage, inbox and digest rendering, and CSV download.Presentational: follow-a-question.html markup. Container 1: eligibility container in public/follow-eligibility.js. Container 2: follow tool container in public/follow-tool.js. Pure eligibility rules stay in the container file as exported pure functions.
Rank 4. public/guides/weekly-quality-rate.htmlTwo large scripts own event recording, aggregation, pagination, search matching, and campaign attribution, each mixed with rendering.Presentational: weekly-quality-rate.html markup. Container 1: weekly quality container in public/weekly-quality.js. Container 2: campaign container in public/campaign-attribution.js. Aggregation and week bucket rules become pure functions in the weekly quality container file.
Rank 5. public/guides/role-first-run.htmlOne large script owns college and role state, outbox retry, draft recovery, hash restore, panel rendering, and sign in link rendering.Presentational: role-first-run.html markup. Container: role first run container in public/role-first-run.js. Pure state normalization and hash parsing become pure functions in that file.
Rank 6. public/guides/get-started.html and public/guides/for-instructors.htmlLong markup with a checklist script that owns progress state, storage, and step rendering in the same file.Presentational: guide markup. Container: one checklist container per page in public/get-started-checklist.js and public/for-instructors-checklist.js with progress state only.
Rank 7. public/guides/verified-expert.html, test-answers, search-indexing, and share-answerOne inline script per page owns form state, eligibility or search logic, and result rendering.Presentational: guide markup. Container: one container file per page that owns state and rendering, with the eligibility or search rule as a pure function in the same file.

Split specification that applies to every file above

Apply every row on every split. A file that cannot meet a row is changed in the same release that splits it.

Container and presentational rules
PartRule
Presentational componentMarkup, labels, helper text, empty states, and table structure only. It holds no state, reads no storage, and calls no data source. It exposes stable ids and classes for the container to bind.
Container componentOne external script file per state group, loaded with defer. It owns state, storage or fetch calls, event handlers, and rendering calls for its own list only. It does not own markup for another list.
Business logicPure functions with no document access for matching, filtering, aggregation, eligibility, and date rules. The container calls the pure function and renders the result. The same pure function is used in the page tool and, where the guide states it, in the signed in build.
State ownershipOne state group per container file. Search state, saved item state, follow state, and checklist state never share one object. A container reads its own storage key only and writes that key only.
Props and renderingThe container passes plain values, such as filtered rows and counts, to rendering code in the same file. Rendering code creates elements from those values and does not re-read storage or re-run a rule to build a row.
Bundle and cachingNo long lived caching is added to a file whose name does not change between versions. External container files load with defer, keep the same envelope and status rules as the inline script they replace, and add no new data call.

How the split changes the page, in order

```mermaid
flowchart LR
 A[Presentational markup] --> B[Container script]
 B --> C[State and storage]
 B --> D[Pure logic]
 D --> E[Filtered rows and counts]
 E --> B
 B --> F[Render list only]
```

Worked example: index guide

Before: one HTML file holds markup, search logic, saved item logic, and rendering. After: one presentational file and two container files.

Before and after for the index guide
PartBeforeAfter
PresentationalGuide cards, filter controls, saved panel, and empty states in index.htmlSame markup, ids, and classes in index.html, with no inline script
Container 1Inline search script mixed with card renderingpublic/guides-index.js owns search state, token logic, URL sync, and card rendering only
Container 2Inline saved item script mixed with list renderingpublic/guides-personal-collection.js owns saved item state, storage, filter state, and list rendering only
  • Search and saved item state never share one object. Clearing search restores guide cards and does not change saved items.
  • Each container renders only its own list. A search render does not rebuild the saved list, and a saved item render does not rebuild guide cards.
  • Token matching, synonym, and one letter off rules stay in the search container file as pure functions, with the same match rules as before.

Steps to ship the split, in order

Ship one file at a time through the normal build. Each step keeps every existing test passing before the next step starts.

  1. Step 1: Confirm the file and record its state groups

    Measure the file in the shipped build. List each storage key, each form or list id, and each pure rule in its script. A file under the threshold or with no script stops here.

  2. Step 2: Move one state group to a new container file

    Create one external script file for one state group. Move its state, storage calls, handlers, pure functions, and rendering calls word for word. Replace the inline script block with a script tag with defer that points to the new file.

  3. Step 3: Keep the presentational file unchanged except for script tags

    Keep every id, class, label, helper text, and empty state in the markup. Do not rename a field or change a storage key in the same change.

  4. Step 4: Repeat for the next state group

    Move the next state group to its own container file in the same way. Do not merge two state groups into one new file.

  5. Step 5: Test the page as before

    Run each check below on phone and desktop. If a check fails, fix it before the next file.

Checks before you ship a split

Run each check on a phone and on a desktop with keyboard and screen reader before you publish.

  • The page shows the same headings, counts, empty states, and source links as before, with focus visible and controls at least 44 pixels high
  • Each container file owns one state group only, reads and writes one storage key only, and renders one list only
  • Pure logic functions run with no document access and return the same result as the inline rule they replace
  • Clearing search, clearing filters, and clearing saved items each restore the full list for that state group only and keep focus on the filter control
  • No new data call, no new permission, no new role, and no change to tenancy is added by the split
  • The build passes and every existing test passes before the next file is split

Next guide

Keep empty states consistent wherever a list can be empty.

Appendix: every file audited

Each file below was checked for presentational markup, container state, and business logic mix. Files not in the ranked list either stay under the threshold, hold no script, or already load logic from an external script.

  • public/guides/first-empty-state.html
  • public/guides/first-login-no-workspace.html
  • public/guides/first-run-checklist.html
  • public/guides/first-run.html
  • public/guides/first-value.html
  • public/guides/follow-a-question.html
  • public/guides/follow-and-digest.html
  • public/guides/for-instructors.html
  • public/guides/form-field-standard.html
  • public/guides/generation-settings.html
  • public/guides/get-started.html
  • public/guides/grounding-check.html
  • public/guides/grounding-guardrail.html
  • public/guides/hand-off-to-office.html
  • public/guides/health-readiness-checks.html
  • public/guides/helpful-voting.html
  • public/guides/index.html
  • public/guides/invited-first-answer.html
  • public/guides/merge-duplicate-questions.html
  • public/guides/metric-dictionary.html
  • public/guides/mobile-workspace-layout.html
  • public/guides/my-library.html
  • public/guides/notification-audit.html
  • public/guides/notification-consolidation.html
  • public/guides/notification-preferences-model.html
  • public/guides/owner-dashboard-metrics.html
  • public/guides/pagination-and-filtering.html
  • public/guides/partial-answer-recovery.html
  • public/guides/payload-performance.html
  • public/guides/performance-audit.html
  • public/guides/publish-widget.html
  • public/guides/query-performance.html
  • public/guides/read-reports.html
  • public/guides/reminder-lifecycle.html
  • public/guides/request-access.html
  • public/guides/request-source-review.html
  • public/guides/request-validation.html
  • public/guides/requested-capabilities.html
  • public/guides/role-features.html
  • public/guides/role-first-run.html
  • public/guides/role-home-view.html
  • public/guides/safe-defaults-deny-by-default.html
  • public/guides/save-answer-bundle.html
  • public/guides/search-indexing.html
  • public/guides/search-scope.html
  • public/guides/set-notification-preferences.html
  • public/guides/set-retention-and-access.html
  • public/guides/share-answer.html
  • public/guides/shared-answer-collections.html
  • public/guides/sign-in-session-recovery.html
  • public/guides/spanish-help.html
  • public/guides/stale-question-reminders.html
  • public/guides/student-workflows.html
  • public/guides/study-sets.html
  • public/guides/test-answers.html
  • public/guides/unified-form-layout.html
  • public/guides/verified-answer.html
  • public/guides/verified-expert.html
  • public/guides/weekly-quality-rate.html
  • public/guides/work-unanswered.html
  • public/guides/workspace-member-audit.html
  • public/guides/workspace-shared-answers.html