Skip to content

Trim saved profiles to non-default filter values - #1239

Open
DannyM300 wants to merge 1 commit into
WatWowMap:mainfrom
DannyM300:fix/profile-filter-payload
Open

Trim saved profiles to non-default filter values#1239
DannyM300 wants to merge 1 commit into
WatWowMap:mainfrom
DannyM300:fix/profile-filter-payload

Conversation

@DannyM300

Copy link
Copy Markdown

Summary

Reduce saved profile payloads by storing only filter values that differ from the current server defaults.

This is independent of quest task filtering: ReactMap already merges a large dynamically generated filter tree into client state, so profiles can serialise thousands of default-valued entries. Additional dynamic filter categories only make that existing scaling issue easier to reach.

Problem

Profile creation and updating currently submit the complete persisted client state after available filters have been merged into it. Most generated filter entries are identical to the defaults supplied by the server, but are still repeated in every profile payload.

On a map with a large available filter set, the resulting backups.data insert became large enough to fail during testing.

Changes

  • Compare current filters recursively with the server-provided default filter tree.
  • Store only filter values that differ from those defaults.
  • Preserve unknown keys so profiles remain forwards/backwards compatible.
  • Keep non-filter profile settings unchanged.
  • Use the same compact payload for both profile creation and updating.
  • Display update errors using the same handling already used for create errors, including HTTP 413 responses.

Loading continues to use the existing default merge, so omitted default values are restored while explicit user selections remain intact. This avoids requiring a MySQL/MariaDB schema change.

Validation

  • Applied independently to current upstream main (8ce212ff).
  • git diff --check passes.
  • ESLint passes for Backups.jsx and the new backupData.js helper.
  • Manually tested profile creation, updating, switching and loading with changed filter selections.

This is being submitted separately from the Rocket identity fix and quest task filtering so it can be reviewed as an independent profile-storage improvement.

useStorage.getState() was saved verbatim, including every filter key at
its default value - the whole point of a profile backup is the handful
a user actually changed, not the full menu. The task filter feature
just added a large new set of possible keys on top of the existing
rocket/invasion/quest ones, making this far more likely to hit the
existing 413 "backup too large" handling than before.

createBackupData() diffs the current filters against the server's live
defaults (useMemory.filters) and keeps only what differs. Safe on load:
the backup write already clears localStorage and reloads the page, so
useMapData's existing deepMerge(serverDefaults, loadedState) fills back
in anything omitted because it matched the default at save time.

Also adds error feedback to the Update button, which previously failed
silently on the same 413 this was written to reduce.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Mygod
Mygod marked this pull request as ready for review August 10, 2026 18:40
@Mygod
Mygod requested a balanced review from Copilot August 10, 2026 18:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fcec3e743

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<Typography
variant="caption"
color="error"
sx={{ mt: 1, alignSelf: 'flex-start' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the unapproved update-error margin

When an update fails and the error caption is rendered, mt: 1 introduces new top-margin spacing without the user's explicit written permission. Remove this margin or obtain permission before changing the spacing.

AGENTS.md reference: AGENTS.md:L7-L7

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Compacts saved profiles by omitting filter values matching server defaults.

Changes:

  • Adds recursive filter comparison while preserving unknown keys.
  • Uses compact payloads for create and update operations.
  • Adds update error handling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/features/profile/Backups.jsx Applies compact payloads and displays update errors.
src/features/profile/backupData.js Implements recursive backup compaction.

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

Comment on lines +253 to +256
<Typography
variant="caption"
color="error"
sx={{ mt: 1, alignSelf: 'flex-start' }}

/** @param {unknown} err @param {(key: string) => string} t */
function getBackupErrorMessage(err, t) {
let message = t('backup_error_generic')
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