Skip to content

refactor(ui): derive step status and ledger account in page - #213

Merged
jackchuma merged 1 commit into
mainfrom
toshi/cleanup-page.tsx-step-status-3b147721
Oct 27, 2026
Merged

jackchuma merged 1 commit into
mainfrom
toshi/cleanup-page.tsx-step-status-3b147721

Conversation

@jackchuma

@jackchuma jackchuma commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What changed? Why?

Two small cleanups in src/app/page.tsx, with no behavior change:

  • The step list repeated currentStep === X ? 'current' : (cond ? 'completed' : 'pending') as StepStatus five times, with an inline union cast on the first entry. A local stepStatus(step, completed) helper now builds every status, and the casts are gone. The confirmation step passes false, so it is still only current or pending.
  • userLedgerAccount was separate state that only mirrored selectedUser.ledgerId: it was set when a user was selected and reset to 0 when the selection was cleared, the same moments selectedUser changes. It is removed, and HardwareSigning gets selectedUser?.ledgerId ?? 0.

Interfaces removed: none. userLedgerAccount was local component state, read only by the HardwareSigning prop.

Notes to reviewers

  • The helper gives the current step precedence, then the completion condition, which is the same order as each old ternary for every (currentStep, condition) pair.
  • ConfigOption.ledgerId is a required number (src/components/UserSelection.tsx), and HardwareSigning renders only at the ledger step, after a user is selected. So the derived value matches the old one, including account 0. ?? 0 matches the old initial value.
  • The commits that added the removed pieces (8ea5dee, 990cccb) show no planned future use.

How has it been tested?

No new tests: jest runs only __tests__/**/*.test.ts in a node environment with no component harness, and this is a behavior-preserving refactor. Ran npm run build, npm run lint, npx prettier --check ., npx tsc --noEmit, and npm test (14 suites, 172 tests); all pass.

Why this cleanup

  • Production: +9 / -21 (net -12) in src/app/page.tsx. Tests: unchanged.
  • Interfaces removed: none (userLedgerAccount was local component state).
  • A reader no longer has to check that userLedgerAccount and selectedUser stay in sync, or work out why the five step entries use three different cast styles. The step list is now five one-line rows.
  • Keep gate judge: every remaining path behaves the same, the removed state only copied selectedUser.ledgerId, and the change removes redundant state plus five copies of one ternary, which the in-development cleanup rules call worth doing.

J-Engine-Session: toshi:ca2d90e5-8e3f-445d-9cb2-12325ea1e42d
@cb-heimdall

cb-heimdall commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Heimdall Review Status

Requirement Status More Info
Reviews ✅ 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@jackchuma
jackchuma marked this pull request as ready for review October 27, 2026 08:12
@jackchuma
jackchuma requested review from 0xth4nh and xenoliss October 27, 2026 08:13
@jackchuma
jackchuma merged commit 576d323 into main Oct 27, 2026
6 checks passed
@jackchuma
jackchuma deleted the toshi/cleanup-page.tsx-step-status-3b147721 branch October 27, 2026 15:23
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.

3 participants