Skip to content

fix(address-book): base mutations on certified data - #8006

Open
yhabib wants to merge 1 commit into
mainfrom
fix/certified-address-book-mutations
Open

fix(address-book): base mutations on certified data#8006
yhabib wants to merge 1 commit into
mainfrom
fix/certified-address-book-mutations

Conversation

@yhabib

@yhabib yhabib commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

Address-book writes used local query data as their base. A later valid edit could save entries from an uncertified response.

Changes

  • Applied each address-book mutation to fresh certified backend data.
  • Changed add, edit, and remove flows to send explicit mutations.
  • Disabled mutation actions until certified data is available.
  • Added regression tests for certified mutations and disabled controls.

Tests

  • npm run check
  • npx tsc --noEmit -p tsconfig.spec.json
  • 37 focused address-book Vitest tests.

Todos

  • Accessibility (a11y) – native buttons expose the disabled state.
  • Changelog – no user-facing feature change.

@zeropath-ai

zeropath-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 23e8224.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► frontend/src/lib/modals/address-book/AddAddressModal.svelte
    + Adjust save flow to use mutation-based updates and require certification
► frontend/src/lib/services/address-book.services.ts
    + Add AddressBookMutation type, applyMutation function, and update saveAddressBook to handle mutations with certified backend data
► frontend/src/lib/modals/address-book/RemoveAddressModal.svelte
    + Update to use mutation-based removal; disable confirm when uncertified
► frontend/src/lib/modals/common/ConfirmationModal.svelte
    + Add disabledConfirm prop to disable confirmation when needed
► frontend/src/tests/lib/modals/address-book/AddAddressModal.spec.ts
    + Update tests to reflect mutation-based saveAddressBook calls and certification checks
► frontend/src/tests/lib/modals/address-book/RemoveAddressModal.spec.ts
    + New test file for remove mutation behavior and certification checks
► frontend/src/tests/lib/services/address-book.services.spec.ts
    + New tests for add, update, and remove mutations against certified backend data

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

There are confirmed correctness/UX edge cases in the new mutation logic (notably inconsistent name normalization for removals and post-save reload behavior that can leave the store uncertified/stale).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR hardens the address-book write path by ensuring mutations are always applied on top of freshly fetched certified backend data (rather than potentially stale/uncertified store/query data), and updates the UI flows/tests accordingly.

Changes:

  • Refactored saveAddressBook to accept explicit mutation objects (add/update/remove) and apply them to certified backend state before writing.
  • Disabled add/remove confirmation actions while the address book store is not certified.
  • Added/updated Vitest coverage for certified-mutation behavior and disabled controls.
File summaries
File Description
frontend/src/lib/services/address-book.services.ts Introduces mutation-based saving and applies writes atop certified backend data.
frontend/src/lib/modals/common/ConfirmationModal.svelte Adds disabledConfirm to disable the confirm button under external conditions.
frontend/src/lib/modals/address-book/RemoveAddressModal.svelte Switches remove flow to mutation-based save and disables confirm when uncertified.
frontend/src/lib/modals/address-book/AddAddressModal.svelte Switches add/edit flows to mutation-based save and disables save when uncertified.
frontend/src/tests/lib/services/address-book.services.spec.ts New unit tests verifying mutations are based on certified backend data.
frontend/src/tests/lib/modals/address-book/RemoveAddressModal.spec.ts New modal tests for mutation invocation and disabled confirm when uncertified.
frontend/src/tests/lib/modals/address-book/AddAddressModal.spec.ts Updates expectations for mutation payloads and adds disabled-save test for uncertified state.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +101 to +109
case "remove": {
const addresses = namedAddresses.filter(
({ name }) => name !== mutation.name
);
if (addresses.length === namedAddresses.length) {
throw new Error("The address book entry no longer exists.");
}
return addresses;
}
Comment on lines 130 to 131
await setAddressBook({ identity, namedAddresses });
await loadAddressBook();
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.

2 participants