Skip to content

perf/refactor: SW network-only for APIs + extract estimator form primitives - #6

Merged
Steel-tech merged 2 commits into
mainfrom
feat/phase-3-perf
Jun 18, 2026
Merged

perf/refactor: SW network-only for APIs + extract estimator form primitives#6
Steel-tech merged 2 commits into
mainfrom
feat/phase-3-perf

Conversation

@Steel-tech

@Steel-tech Steel-tech commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Continues Phase 3 (Depth & Polish) of the roadmap (docs/plans/2026-06-17-001).

Changes

  • U13 — service worker fix. The fetch handler cached every GET /api response and served it stale on failure, contradicting its own "no offline fallback" comment (the U13 "doesn't cache stale API responses" requirement). API is now network-only; cache version bumped to v2 so clients purge any v1 runtime cache. The AI endpoints are POST so were never cached, but this closes the latent footgun for any GET API.
  • U12 — estimator file split. Extracted the pure presentational primitives (Section/Field/TextInput/NumberInput/CheckRow) from estimator-form.tsx into a co-located form-primitives.tsx. The form drops 502 → 344 lines, now focused on state/logic. Behavior-preserving.

Verification

  • 71 tests green · tsc --noEmit clean · lint 0 errors (22 pre-existing warnings) · production build compiles successfully (covers the split + the RSC/client boundary).

Finding surfaced (recommended next, NOT in this PR)

content/state-registry.ts (2860 lines) is imported directly by 17 "use client" components, so the full registry ships in the client bundle. Fixing it properly (server-side data loading or per-state dynamic import) is a deliberate, higher-risk refactor across all 17 — it warrants its own focused PR with before/after bundle measurement, not a blind autonomous change. Flagging it as the highest-value remaining perf item.

Still remaining in Phase 3

  • Larger component splits (onboarding-chat 611L, wizard page 591L, pages) — no clean primitive boundary; need care.
  • Registry client-bundle fix + CI bundle/Lighthouse budget (belong together, see finding above).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Reorganized estimator form UI components into a separate module.
  • Chores

    • Updated service worker cache version (v1 to v2) and modified API request handling to use network-only strategy.

Steel-tech and others added 2 commits June 18, 2026 00:52
The fetch handler cached every GET /api response and served it stale on
failure — contradicting its own 'no offline fallback' comment and risking
stale AI/regulatory responses. API is now network-only (no cache write, no
stale fallback); offline fails and the app surfaces the error. Bumped the
cache version to v2 so clients purge any v1 runtime cache holding old API
responses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Section/Field/TextInput/NumberInput/CheckRow were pure presentational
primitives inline in estimator-form.tsx (502 lines). Moved to
form-primitives.tsx; estimator-form is now 344 lines and focused on state
and logic. Behavior-preserving.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Extracts five presentational React components (Section, Field, TextInput, NumberInput, CheckRow) from estimator-form.tsx into a new form-primitives.tsx file, replacing the local definitions with an import. Separately, the service worker cache version is bumped to ironforge-v2 and the /api/* fetch strategy is changed from network-first-with-cache-fallback to strict network-only.

Changes

Estimator Form Primitives Extraction

Layer / File(s) Summary
New form-primitives.tsx components
components/estimator/form-primitives.tsx
Introduces five exported presentational components: Section (accent-bordered container), Field (label with optional suffix/hint), TextInput (controlled text input), NumberInput (controlled numeric input with NaN→0 fallback and focus-select), and CheckRow (styled checkbox row with conditional checkmark SVG).
Import update in estimator-form.tsx
components/estimator/estimator-form.tsx
Adds import of all five primitives from ./form-primitives and removes their now-redundant local definitions, leaving EstimatorForm logic and handlers unchanged.

Service Worker API Cache Strategy

Layer / File(s) Summary
Network-only API handling and version bump
public/sw.js
Cache version constant changed from ironforge-v1 to ironforge-v2; the /api/* fetch branch is replaced with a direct fetch(request) call, removing all runtime caching and cache-fallback behavior for API requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through the code with glee,
Pulled the form bits out so they're free!
Five little components in their own file,
The service worker changed its style.
No more caching API calls — network-only from now,
Clean and tidy, that's the way of the hare, meow! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes both main changes: the service worker API caching fix and the estimator form primitives extraction, matching the PR's core objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/phase-3-perf

Comment @coderabbitai help to get the list of available commands and usage tips.

@Steel-tech
Steel-tech merged commit 46b5828 into main Jun 18, 2026
1 of 2 checks passed
@Steel-tech
Steel-tech deleted the feat/phase-3-perf branch June 18, 2026 06:55
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