Skip to content

fix: Add dedicated TPM license move option#1909

Merged
elibosley merged 6 commits intomainfrom
codex/tpm-move-license-option
Mar 14, 2026
Merged

fix: Add dedicated TPM license move option#1909
elibosley merged 6 commits intomainfrom
codex/tpm-move-license-option

Conversation

@elibosley
Copy link
Member

@elibosley elibosley commented Mar 14, 2026

Summary

  • add a dedicated Move License to TPM action on the registration page when a distinct TPM GUID is available
  • keep the existing Replace Key flow unchanged while adding a TPM-specific account callback payload
  • cover the new account payload and registration button behavior in store/component tests

Testing

  • pnpm test -- test/store/account.test.ts test/store/server.test.ts test/components/Registration.test.ts

Notes

  • unrelated local onboarding changes were intentionally left out of this PR

Summary by CodeRabbit

  • Bug Fixes

    • Onboarding modal now displays without being blocked by the login page.
  • New Features

    • Added a "Move License to TPM" action to initiate license relocation.
  • UI/UX

    • Replaced multi-step TPM transfer guidance with a single action button.
    • Removed mock unauthenticated user option from onboarding settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e0bfdf1f-2dbc-4d50-9af5-426ea0a24503

📥 Commits

Reviewing files that changed from the base of the PR and between 7003bd0 and 9c6bcc4.

📒 Files selected for processing (4)
  • web/__test__/components/Registration.test.ts
  • web/__test__/store/server.test.ts
  • web/src/components/Registration.standalone.vue
  • web/src/store/server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/store/server.ts

Walkthrough

The onboarding modal no longer treats the login page specially and unauthenticated mock support was removed. A "Move License to TPM" flow was added: UI button triggers a new replaceTpm action in the account store which uses server-side GUID-replacement logic exposed as serverReplacePayload.

Changes

Cohort / File(s) Summary
Onboarding Modal Simplification
web/src/components/Onboarding/OnboardingModal.vue, web/__test__/components/Onboarding/OnboardingModal.test.ts
Dropped login-page gating for the onboarding modal; removed the test that asserted non-rendering on the login route.
Onboarding Store Cleanup
web/src/components/Onboarding/store/onboardingStatus.ts
Removed mock unauthenticated storage/key, GraphQL error handling and public mock-auth API; canDisplayOnboardingModal now follows isVersionSupported only.
Onboarding Admin Panel
web/src/components/Onboarding/standalone/OnboardingAdminPanel.standalone.vue
Removed Mock Unauthenticated User UI and related handlers/state.
TPM License Move Feature (Account Store + Tests)
web/src/store/account.ts, web/__test__/store/account.test.ts
Added replaceTpm() action that sends an ACCOUNT_CALLBACK replace payload based on serverReplacePayload; tests added/updated to assert correct send payload and invocation.
Server Store GUID Replacement Logic (+ Tests)
web/src/store/server.ts, web/__test__/store/server.test.ts
Added hasDistinctTpmGuid, replaceFlashGuid, and public serverReplacePayload computed to choose TPM GUID over flash GUID when appropriate; tests cover GUID selection scenarios.
Registration UI Simplification
web/src/components/Registration.standalone.vue, web/__test__/components/Registration.test.ts
Replaced multi-step TPM transfer UI with a single BrandButton labeled "Move License to TPM" that calls accountStore.replaceTpm(); removed many TPM-transfer-specific computed properties and step content; tests updated for the new button and action.
Localization
web/src/locales/en.json
Removed detailed registration.tpmTransfer.* keys; added registration.moveLicenseToTpm = "Move License to TPM".

Sequence Diagram(s)

sequenceDiagram
    participant UI as Registration UI
    participant Account as Account Store
    participant ServerStore as Server Store (serverReplacePayload)
    participant Backend as send()/Backend

    UI->>Account: click "Move License to TPM"
    Account->>ServerStore: read serverReplacePayload
    ServerStore-->>Account: serverReplacePayload (with replaced guid)
    Account->>Backend: send ACCOUNT_CALLBACK {type: "replace", payload: serverReplacePayload}
    Backend-->>Account: ack
    Account-->>UI: update state / close UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 A button gleams, a GUID takes flight,
No login gate to block the light,
I hopped and pushed the TPM key,
Stores swapped GUIDs with glee,
Hooray — a license moved by me! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a dedicated TPM license move option, which aligns with the primary objective of introducing a new 'Move License to TPM' action on the registration page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/tpm-move-license-option
📝 Coding Plan
  • Generate coding plan for human review comments

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

@elibosley elibosley changed the title Add dedicated TPM license move option fix: Add dedicated TPM license move option Mar 14, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/__test__/store/server.test.ts (1)

671-696: Add tests for the remaining GUID-selection branches.

These tests cover TPM-available and TPM-equals-flash paths, but Line 211 also branches on guid.startsWith('03-') and missing tpmGuid. Add one case for each to guard regressions in TPM-boot and no-TPM states.

Suggested test additions
+  it('should create serverReplacePayload with flash guid when booted from TPM guid', () => {
+    const store = getStore();
+
+    store.setServer({
+      flashGuid: '058F-6387-0000-0000F1F1E1C6',
+      guid: '03-V35H8S0L1QHK1SBG1XHXJNH7',
+      state: 'PRO' as ServerState,
+      tpmGuid: '03-V35H8S0L1QHK1SBG1XHXJNH7',
+    });
+
+    expect(store.serverReplacePayload.guid).toBe('058F-6387-0000-0000F1F1E1C6');
+  });
+
+  it('should create serverReplacePayload with flash guid when TPM guid is missing', () => {
+    const store = getStore();
+
+    store.setServer({
+      flashGuid: '058F-6387-0000-0000F1F1E1C6',
+      guid: '058F-6387-0000-0000F1F1E1C6',
+      state: 'PRO' as ServerState,
+      tpmGuid: undefined,
+    });
+
+    expect(store.serverReplacePayload.guid).toBe('058F-6387-0000-0000F1F1E1C6');
+  });

Based on learnings: Applies to /test/store//*.ts : Test Pinia store getter dependencies are properly mocked.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/__test__/store/server.test.ts` around lines 671 - 696, Add two unit tests
to cover the remaining GUID-selection branches in the store: (1) a case where
the server.guid startsWith('03-') and tpmGuid is undefined — call getStore(),
then store.setServer({ guid: '03-XXXX...', flashGuid: '058F-...', state: 'PRO'
as ServerState }) and assert store.serverReplacePayload.guid matches the
server.guid (the '03-' GUID) to cover the TPM-boot branch; (2) a case where
tpmGuid is missing (undefined) and guid does not start with '03-' — call
getStore(), then store.setServer({ guid: '058F-...', flashGuid: '058F-...',
state: 'PRO' as ServerState }) and assert store.serverReplacePayload.guid equals
the flashGuid to cover the no-TPM branch; reuse the existing pattern around
getStore(), store.setServer(...) and assertions for serverReplacePayload.guid.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/store/server.ts`:
- Around line 137-145: The computed replaceFlashGuid currently falls back to
flashGuid.value which can be missing/stale; change its logic to use guid.value
as the default and only substitute tpmGuid.value when bootDeviceType.value ===
'flash' && hasDistinctTpmGuid.value, i.e. return tpmGuid.value in that
distinct-TPM case otherwise return guid.value || undefined; update any related
usage in serverReplacePayload and the showTpmTransferInfo logic in
Registration.standalone.vue to use the same fallback (guid over flashGuid) and
only swap to tpmGuid for the distinct TPM path to avoid overwriting a valid
current guid with undefined.

---

Nitpick comments:
In `@web/__test__/store/server.test.ts`:
- Around line 671-696: Add two unit tests to cover the remaining GUID-selection
branches in the store: (1) a case where the server.guid startsWith('03-') and
tpmGuid is undefined — call getStore(), then store.setServer({ guid:
'03-XXXX...', flashGuid: '058F-...', state: 'PRO' as ServerState }) and assert
store.serverReplacePayload.guid matches the server.guid (the '03-' GUID) to
cover the TPM-boot branch; (2) a case where tpmGuid is missing (undefined) and
guid does not start with '03-' — call getStore(), then store.setServer({ guid:
'058F-...', flashGuid: '058F-...', state: 'PRO' as ServerState }) and assert
store.serverReplacePayload.guid equals the flashGuid to cover the no-TPM branch;
reuse the existing pattern around getStore(), store.setServer(...) and
assertions for serverReplacePayload.guid.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 11d971e9-4947-4426-94c1-a05033f9bcd0

📥 Commits

Reviewing files that changed from the base of the PR and between 2f3f34b and 7003bd0.

📒 Files selected for processing (11)
  • web/__test__/components/Onboarding/OnboardingModal.test.ts
  • web/__test__/components/Registration.test.ts
  • web/__test__/store/account.test.ts
  • web/__test__/store/server.test.ts
  • web/src/components/Onboarding/OnboardingModal.vue
  • web/src/components/Onboarding/standalone/OnboardingAdminPanel.standalone.vue
  • web/src/components/Onboarding/store/onboardingStatus.ts
  • web/src/components/Registration.standalone.vue
  • web/src/locales/en.json
  • web/src/store/account.ts
  • web/src/store/server.ts
💤 Files with no reviewable changes (2)
  • web/src/components/Onboarding/standalone/OnboardingAdminPanel.standalone.vue
  • web/test/components/Onboarding/OnboardingModal.test.ts

@github-actions
Copy link
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1909/dynamix.unraid.net.plg

@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 78.72340% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.94%. Comparing base (2f3f34b) to head (9c6bcc4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
web/src/store/server.ts 50.00% 9 Missing ⚠️
...rc/components/Onboarding/store/onboardingStatus.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1909      +/-   ##
==========================================
- Coverage   50.97%   50.94%   -0.03%     
==========================================
  Files        1023     1023              
  Lines       70701    70542     -159     
  Branches     7703     7681      -22     
==========================================
- Hits        36038    35941      -97     
+ Misses      34539    34477      -62     
  Partials      124      124              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@elibosley elibosley merged commit 36c56f7 into main Mar 14, 2026
13 checks passed
@elibosley elibosley deleted the codex/tpm-move-license-option branch March 14, 2026 17:03
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