refactor(state): align inverse calc naming and collapse activeTab mutation (#692)#706
Open
grzanka wants to merge 1 commit into
Open
refactor(state): align inverse calc naming and collapse activeTab mutation (#692)#706grzanka wants to merge 1 commit into
grzanka wants to merge 1 commit into
Conversation
…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
Contributor
There was a problem hiding this comment.
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
$effectper*-calc.svelte.tsmodule (inverse-range-calcandinverse-stp-calc) and update imports (orchestrator + unit tests). - Collapse
InverseLookupState.activeTabmutation to a single public entry point (setActiveTab), makingactiveTabreadonlyin 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #692.
Two low-risk consistency cleanups in
src/lib/state/, no behaviour change.A. Inverse
-calcsplit conventionThe 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.
inverse-calc.svelte.tsinto:inverse-range-calc.svelte.ts—setupInverseRangeCalculationinverse-stp-calc.svelte.ts—setupInverseStpCalculation$effect, mirroring the multi-* layout, witha doc comment pointing at its sibling.
inverse-calculation.test.ts(it exercises both effects), imports repointed,assertions unchanged.
B. Single
activeTabmutation pathinverse-lookups.svelte.tsexposed bothset activeTab(v)andsetActiveTab(tab). Removed the setter, keepingsetActiveTab(tab)as the solemutation entry point and marking the interface field
readonly. All call sites(orchestrator,
+page.svelte, tests) already used the method, so no call-sitechanges were needed.
Acceptance criteria
(one effect per
*-calc.svelte.tsfile, with cross-reference comments).activeTabhas exactly one mutation entry point (setActiveTab); fieldis
readonlyin the interface.pnpm check(0 errors) andpnpm lint(clean) pass; inverse-lookuptests unchanged in behaviour (42 tests pass).
Note: the unrelated
guard-forbidden-files.test.tsfailures seen locally are asandbox git commit-signing limitation, not caused by this change.
https://claude.ai/code/session_01RtN8sSC9RkYV2jM34xKZdz
Generated by Claude Code