Skip to content

refactor(state): align inverse calc naming and collapse activeTab mutation (#692)#706

Open
grzanka wants to merge 1 commit into
masterfrom
claude/issue-692-oKDc9
Open

refactor(state): align inverse calc naming and collapse activeTab mutation (#692)#706
grzanka wants to merge 1 commit into
masterfrom
claude/issue-692-oKDc9

Conversation

@grzanka
Copy link
Copy Markdown
Contributor

@grzanka grzanka commented Jun 4, 2026

Closes #692.

Two low-risk consistency cleanups in src/lib/state/, no behaviour change.

A. Inverse -calc split convention

The multi-* families follow "data file + a single-effect *-calc.svelte.ts"
(multi-entity + multi-entity-calc, multi-program + multi-program-calc).
Inverse broke this by bundling two unrelated effects into one file.

  • Split inverse-calc.svelte.ts into:
    • inverse-range-calc.svelte.tssetupInverseRangeCalculation
    • inverse-stp-calc.svelte.tssetupInverseStpCalculation
  • Each file now holds exactly one $effect, mirroring the multi-* layout, with
    a doc comment pointing at its sibling.
  • Orchestrator imports updated; combined test renamed to
    inverse-calculation.test.ts (it exercises both effects), imports repointed,
    assertions unchanged.

B. Single activeTab mutation path

inverse-lookups.svelte.ts exposed both set activeTab(v) and
setActiveTab(tab). Removed the setter, keeping setActiveTab(tab) as the sole
mutation entry point and marking the interface field readonly. All call sites
(orchestrator, +page.svelte, tests) already used the method, so no call-site
changes were needed.

Acceptance criteria

  • Inverse calculation effects follow the documented multi-* convention
    (one effect per *-calc.svelte.ts file, with cross-reference comments).
  • activeTab has exactly one mutation entry point (setActiveTab); field
    is readonly in the interface.
  • pnpm check (0 errors) and pnpm lint (clean) pass; inverse-lookup
    tests unchanged in behaviour (42 tests pass).

Note: the unrelated guard-forbidden-files.test.ts failures seen locally are a
sandbox git commit-signing limitation, not caused by this change.

https://claude.ai/code/session_01RtN8sSC9RkYV2jM34xKZdz


Generated by Claude Code

…ation (#692)

Split the combined inverse-calc.svelte.ts into one-effect-per-file
inverse-range-calc.svelte.ts + inverse-stp-calc.svelte.ts so the inverse
family matches the multi-*-calc convention (data in inverse-lookups, one
calculation $effect per sibling file). Removed the redundant
`set activeTab(v)` setter, leaving setActiveTab(tab) as the single
mutation entry point and marking the interface field readonly.

No behaviour change; inverse-lookup tests unchanged.

https://claude.ai/code/session_01RtN8sSC9RkYV2jM34xKZdz
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR applies two code-health consistency refactors in the calculator “inverse” state layer under src/lib/state/, aligning it with the existing multi-*-calc convention and reducing redundant API surface on activeTab (no intended behavior change).

Changes:

  • Split inverse lookup calculation effects into one $effect per *-calc.svelte.ts module (inverse-range-calc and inverse-stp-calc) and update imports (orchestrator + unit tests).
  • Collapse InverseLookupState.activeTab mutation to a single public entry point (setActiveTab), making activeTab readonly in the interface.
  • Add/update AI session logging (changelog entry + session log + log index row).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib/state/inverse-range-calc.svelte.ts New dedicated module for the inverse CSDA-range calculation $effect.
src/lib/state/inverse-stp-calc.svelte.ts Leaves only the inverse stopping-power calculation $effect and documents the sibling module split.
src/lib/state/inverse-calc.svelte.ts Removed in favor of the one-effect-per-file split.
src/lib/state/inverse-lookups.svelte.ts Makes activeTab readonly in the interface and removes the redundant set activeTab(...) setter implementation.
src/lib/state/calculator-page-orchestrator.svelte.ts Repoints setup imports to the new inverse calc modules.
src/tests/unit/inverse-calculation.test.ts Updates imports to the split inverse calc modules; assertions remain the same.
CHANGELOG-AI.md Adds the required session entry linking to the detailed AI log.
docs/ai-logs/README.md Adds the new session log to the index table.
docs/ai-logs/2026-06-04-issue-692-state-naming.md Adds the detailed AI session narrative + task record for #692.

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.

State modules: align naming/API conventions (inverse-calc split, duplicate activeTab setter)

3 participants