Skip to content

feat: track granular save sections#1452

Open
SameDesu123 wants to merge 15 commits into
kwaroran:mainfrom
SameDesu123:feat/save-section-detection
Open

feat: track granular save sections#1452
SameDesu123 wants to merge 15 commits into
kwaroran:mainfrom
SameDesu123:feat/save-section-detection

Conversation

@SameDesu123
Copy link
Copy Markdown
Contributor

@SameDesu123 SameDesu123 commented May 18, 2026

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?
  • If your PR uses models1, check the following:
    • Have you checked if it works normally in all models?
    • Have you checked if it works normally in all web, local, and node-hosted versions? If it doesn't, have you blocked it in those versions?
  • If your PR is highly AI generated2, check the following:
    • Have you understood what the code does?
    • Have you cleaned up any unnecessary or redundant code?
    • Is it not a huge change?

Summary

Adds save-section change tracking so the save loop can identify which major data areas changed before the existing database.bin encoder writes the compatible save blocks.

Related Issues

None

Changes

  • Added src/ts/storage/saveSections/sectionChangeDetection.ts with grouped section keys and helper utilities for tracking changed save sections.
  • Extended saveDb() change tracking for root settings, presets, characters, chats, modules, plugins, plugin storage, loadouts, and existing bot resource sections.
  • Preserved the existing save flags used by RisuSaveEncoder, so current database.bin save compatibility remains unchanged.
  • Added development-only console logging for detected save sections before a save is written.

Impact

This does not change the persisted save format. It records more granular change information while continuing to write through the existing save blocks. The development log should help verify which data area triggered a save without affecting production builds.

Additional Notes

Validated with pnpm check.

Footnotes

  1. Modifies the behavior of prompting, requesting, or handling responses from AI models.

  2. Over 80% of the code is AI generated.

@SameDesu123
Copy link
Copy Markdown
Contributor Author

Addressed the two review points in 18fb1e15.

  • Granular list-section tracking now keeps the corresponding legacy dirty flag set while RisuSaveEncoder remains the source of truth for database.bin writes. This covers presets/modules/plugins/loadouts/plugin storage and also keeps character/chat/root compatibility guards in place.
  • Preset/module/plugin/loadout granular tracking now uses per-section item signatures instead of ready sets, so an effect rerun no longer reports every existing item as changed. Initial observation only seeds signatures; later edits/additions/deletions report the actual affected item ids.

Validation: pnpm check passes with 0 errors and 0 warnings.

@SameDesu123 SameDesu123 marked this pull request as ready for review May 18, 2026 08:55
@SameDesu123 SameDesu123 marked this pull request as draft May 18, 2026 11:13
@SameDesu123
Copy link
Copy Markdown
Contributor Author

Addressed the latest follow-up in bec60eaf.

  • Granular-only section arrays are now cleared after cloning toSave, so dev save-section logs do not retain stale observational section ids. Legacy trackers (character / chat) keep their existing [first] reset behavior.
  • trackSaveListSection() now compares item order separately and records __order in the affected granular section when stable-id items are reordered.

Validation: pnpm check passes with 0 errors and 0 warnings.

@SameDesu123 SameDesu123 marked this pull request as ready for review May 19, 2026 05:27
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