fix(ui): F8-06 calculator polish — input steps, lock idiom, tech floor, speed-lock fix #61

Merged
developer merged 4 commits from feature/issue-49-calculator-polish into development 2026-05-26 17:23:27 +00:00
Owner

Closes #49

F8-06 (subtask of #43). Four related calculator nits:

  • п.9 — smart input steps. Drive / weapons / shields / cargo inputs use a JS-driven step on ArrowUp / ArrowDown: 0 jumps straight to 1 (skipping the invalid (0, 1) range), otherwise ±0.1; ArrowDown collapses 1 → 0. Native spinner is hidden on these inputs so it cannot reintroduce invalid 0.01 intermediates. Armament keeps its native step 1.
  • п.10 — unified lock idiom + reserved space. Tech and planet MAT cells now follow the same idiom as the goal-seek locks below the design area: open padlock 🔓 over the inherited value → click to open an input with a closed padlock 🔒. The padlock slot is always reserved, so the column width is stable as the lock state toggles.
  • п.11 — tech floor at current player tech. Design-area tech overrides and modernization target tech are floored at the player's current tech on this turn; lower values are flagged with a red border + tooltip.
  • п.12 — speed-lock at the ceiling regression. pkg/calc/solve.go DriveForSpeed now treats restMass == 0 as a valid ceiling-only case (every positive drive achieves it), so locking the displayed speed of a D=1, W=A=S=C=0 ship is no longer a phantom "infeasible".

Test plan

  • go test ./pkg/calc/... ./ui/core/calc/... — green (new TestDriveForSpeedZeroRest).
  • pnpm exec vitest run — 769 unit tests pass (3 wasm-binary tests skipped locally; they boot the TinyGo build in CI).
  • pnpm run check — clean.
  • pnpm exec vite build — succeeds.
  • CI: go-unit, ui-test (vitest + Playwright), integration.

🤖 Generated with Claude Code

Closes #49 F8-06 (subtask of #43). Four related calculator nits: - **п.9 — smart input steps.** Drive / weapons / shields / cargo inputs use a JS-driven step on ArrowUp / ArrowDown: 0 jumps straight to 1 (skipping the invalid (0, 1) range), otherwise ±0.1; ArrowDown collapses 1 → 0. Native spinner is hidden on these inputs so it cannot reintroduce invalid 0.01 intermediates. Armament keeps its native step 1. - **п.10 — unified lock idiom + reserved space.** Tech and planet MAT cells now follow the same idiom as the goal-seek locks below the design area: open padlock 🔓 over the inherited value → click to open an input with a closed padlock 🔒. The padlock slot is always reserved, so the column width is stable as the lock state toggles. - **п.11 — tech floor at current player tech.** Design-area tech overrides and modernization target tech are floored at the player's current tech on this turn; lower values are flagged with a red border + tooltip. - **п.12 — speed-lock at the ceiling regression.** `pkg/calc/solve.go` `DriveForSpeed` now treats `restMass == 0` as a valid ceiling-only case (every positive drive achieves it), so locking the displayed speed of a D=1, W=A=S=C=0 ship is no longer a phantom "infeasible". ## Test plan - [x] `go test ./pkg/calc/... ./ui/core/calc/...` — green (new `TestDriveForSpeedZeroRest`). - [x] `pnpm exec vitest run` — 769 unit tests pass (3 wasm-binary tests skipped locally; they boot the TinyGo build in CI). - [x] `pnpm run check` — clean. - [x] `pnpm exec vite build` — succeeds. - [ ] CI: go-unit, ui-test (vitest + Playwright), integration. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
developer added 1 commit 2026-05-26 12:31:08 +00:00
fix(ui): calculator polish — smart input steps, unified tech/MAT lock idiom, tech floor, speed-lock ceiling fix
Tests · Go / test (push) Successful in 2m31s
Tests · UI / test (push) Waiting to run
Tests · Integration / integration (pull_request) Successful in 1m41s
Tests · Go / test (pull_request) Successful in 3m14s
Tests · UI / test (pull_request) Successful in 2m32s
e9b904332e
- pkg/calc: DriveForSpeed treats restMass==0 as a valid ceiling-only
  case (every positive drive solves it), so locking the displayed
  speed of a D=1, W=A=S=C=0 ship is no longer a phantom "infeasible".
- ship-design-area: drive/weapons/shields/cargo inputs use a JS-driven
  smart step on ArrowUp/ArrowDown (0↔1 jump, otherwise ±0.1) and hide
  the native spinner so it cannot produce invalid (0, 1) values;
  armament keeps its native step 1.
- Tech and planet MAT cells follow the same lock idiom as goal-seek
  locks: open padlock (🔓) over the inherited value → click to open
  an input with a closed padlock (🔒). The padlock slot is always
  reserved, so the column width is stable.
- Tech overrides (design area and modernization target) are floored
  at the player's current tech on this turn — a lower value is
  flagged as invalid.
developer requested review from owner 2026-05-26 12:31:13 +00:00
developer added 1 commit 2026-05-26 16:03:00 +00:00
fix(ui): F8-06 calculator polish — unified spinner UX, lock-infeasible on (0, 1), dropdown reset-changes
Tests · UI / test (push) Has been cancelled
Tests · Integration / integration (pull_request) Successful in 1m45s
Tests · Go / test (pull_request) Successful in 2m3s
Tests · UI / test (pull_request) Successful in 2m28s
cbf7f65916
Owner review on PR #61:

- п.9 (option B). Hide the native spinner on EVERY numeric input in
  the calculator (DWSC blocks, armament, tech, planet MAT, custom
  load, lock value, modernization target tech) and drive every step
  through ArrowUp / ArrowDown. The column widths stay stable and the
  inputs read consistently across the whole row. The ship blocks
  keep the smart (0 ↔ 1) jump on ArrowUp/ArrowDown; armament steps
  ±1 with a JS handler instead of relying on the native spinner.
  Other inputs step by their natural grain (±0.001 for tech / lock,
  ±0.01 for MAT / load).
- п.10. Tech-level labels (`tech-val`) and the planet MAT label
  (`mat-val`) now read through the same `Ceil3` formatter as the
  derived results, so plain-text numeric values share the report's
  3-decimal tabular formatting. The design-area component receives
  `formatNumber` as a prop; the resolved (goal-seek) cell uses the
  same formatter, so the read-only computed value matches the rest
  of the row.
- п.12. `computeCalculator` now validates the back-solved block
  against the same DWSC rule the live validator enforces (`0` or
  `≥ 1`). When the solver lands in the `(0, 1)` gap (e.g. attack
  0.5 / weaponsTech 1.5 → weapons 0.333…) the lock is flagged
  infeasible — the lock input flips red and the claimed block is
  NOT back-solved into the invalid range, so the design preview
  keeps reading the user's own typed values instead of silently
  showing a sub-1 block.
- new. Selecting an existing ship class from the name datalist now
  loads it immediately. `change` fires only on blur in Firefox,
  which is why the previous behaviour looked delayed; switching the
  load to `oninput` with an `InputEvent.inputType` check makes the
  load synchronous everywhere (datalist replacement carries
  `"insertReplacementText"` in Chromium / WebKit, `undefined` in
  Firefox; keyboard typing always carries a typing `inputType`).
  Before loading we compare the live blocks to the previously
  loaded class (or to the empty defaults) and, if they differ, ask
  through a `window.confirm`. On decline we revert the name field
  and leave the design untouched.

Tests: calculator-tab and calc-model gain six cases (armament
step, tech/MAT formatter labels, lock infeasible on (0, 1) for
both attack→weapons and emptyMass→cargo, lock-value Arrow step,
dropdown immediate load + confirm-blocks-load + confirm-allows-load),
all 779 vitest tests green. docs/calculator-ux.md follows the new
behaviour.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
developer added 1 commit 2026-05-26 16:43:38 +00:00
fix(ui): F8-06 calculator polish — always 3-decimal display, mono font, input cap
Tests · UI / test (push) Has been cancelled
Tests · Integration / integration (pull_request) Successful in 1m48s
Tests · Go / test (pull_request) Successful in 2m3s
Tests · UI / test (pull_request) Successful in 2m28s
cc4727a32e
Owner feedback round 2 on PR #61:

- Pad every read-only calculator value to three decimals: tech labels,
  derived results (mass, speed, attack, defence, bombing, cargo
  capacity), planet MAT, planet build-rate, modernization cost, and
  the full-cargo capacity label all read as "1.000" instead of "1",
  matching the goal-seek back-solved input and the report. Drops
  thousands grouping so the same `fmt()` string also embeds cleanly
  in the read-only `<input type="number">` cell.
- Switch label and input styling onto the existing `--font-mono`
  token (right-aligned, tabular-nums) so columns line up vertically
  across rows like a financial table.
- Refuse a fourth decimal as the user types in every calculator
  number input (DWSC blocks, tech, MAT, custom load, lock value,
  modernization target tech): the `oninput` truncates the input text
  past three decimal digits and explicitly writes the truncated
  value back through `bind:value`, so Svelte's later reactive flush
  cannot undo the cap.
- Doc + tests follow the rule (five new vitest cases covering the
  3-decimal label format, the input cap on each input class, and
  the integer-padding rule for derived results).
developer added 1 commit 2026-05-26 17:11:03 +00:00
fix(ui): F8-06 calculator polish — drop delete-class button, reserve lock slot
Tests · UI / test (push) Has been cancelled
Tests · Integration / integration (pull_request) Successful in 1m48s
Tests · Go / test (pull_request) Successful in 2m1s
Tests · UI / test (pull_request) Successful in 2m34s
b01a60e42b
- Remove the `delete <ship_class_name>` button (and `deleteClass`,
  `canDelete`, `.delete` CSS, `game.calculator.action.delete` i18n key)
  from the calculator. Delete-class lives in the ship-classes table —
  the broader rework will land under #53.
- Bombing and cargo-capacity rows now reserve a hidden lock-slot
  placeholder so their value column lines up vertically with the
  mass/speed/attack/defence rows (which carry a lock button).
owner approved these changes 2026-05-26 17:20:53 +00:00
developer merged commit b03993fcb1 into development 2026-05-26 17:23:27 +00:00
developer deleted branch feature/issue-49-calculator-polish 2026-05-26 17:23:27 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: developer/galaxy-game#61