Repository navigation
feat: 配置备份恢复 - #83
feat: 配置备份恢复#83clansty wants to merge 2 commits into
Conversation
- 将备份恢复入口移至顶栏最右并改为链接按钮,进入后显示返回 - 将弹窗改为下方区域的左右滑动切换内联视图(新增 ConfigEditor.module.sass,将 BackupRestoreModal 重构为 BackupRestoreView) - 统一差异列表与表头的 rem 网格列宽与内边距,修复「备份」表头与数据列未对齐问题 - 对调备份(红)与当前(绿)配色,移除栏目边框并改用 listItem 背景 - 将栏目启用状态变化直接展示在 section 标题行右侧,并清理各语言包中不再使用的 mod.backup.sectionEnabled
审阅者指南数据结构定义供端点和编辑器使用的备份响应结构。
API通过配置控制器及其生成的客户端 API 提供备份列表。
API 的使用方式让备份请求能够使用签名检查设置,并使配置编辑器辅助函数可供备份视图使用。
实现根据当前配置接口加载并解析备份文件,推导各分区和条目的覆盖值,并报告每个文件的解析错误。
提供可复用的声音通道选项,以及用于格式化备份差异中所显示配置值的易读格式。
规范化备份 DTO,并计算备份与当前配置之间的分区开关及条目值差异。
界面添加内嵌式备份浏览器和差异视图,包含恢复、撤销和值格式化交互。
添加顶部栏入口,并在配置编辑器与备份恢复视图之间加入动画过渡效果。
添加用于浏览备份和执行恢复操作的本地化标签及状态消息。
提示和命令与 Sourcery 交互
自定义使用体验访问你的控制面板,以便:
获取帮助Original review guide in EnglishReviewer's GuideData structuresDefine the backup response shape consumed by the endpoint and the editor.
APIExpose backup listing through the configuration controller and its generated client API.
Uses of the APIExpose the signature-check setting to backup requests and make the config editor helpers available to the backup view.
ImplementationLoad and parse backup files against the current config interface, deriving section and entry overrides while reporting per-file parse errors.
Provide reusable sound-channel options and human-readable formatting for config values displayed in backup diffs.
Normalize backup DTOs and compute section-switch and entry-value differences against the live config.
UIAdd the inline backup browser and diff view, including restore, undo, and value formatting interactions.
Add a top-bar entry and animated inline transition between the config editor and backup-restore view.
Add localized labels and status messages for backup browsing and restore actions.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嘿——我发现了 9 个问题
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="MaiChartManager/Controllers/Mod/ConfigurationController.cs" line_range="39" />
<code_context>
+ [HttpGet]
+ public async Task<IReadOnlyList<AquaMaiConfigBackupDto>> GetAquaMaiConfigBackups(bool skipSignatureCheck = false, CancellationToken ct = default)
+ {
+ return await modConfigService.GetAquaMaiConfigBackups(skipSignatureCheck, ct);
+ }
+
</code_context>
<issue_to_address>
**Historical settings exposed over LAN**
When the application is running in export mode with authentication disabled and backup files contain historical overrides, an unauthenticated LAN client can call this endpoint when export mode is enabled and `UseAuth` is false; the service returns parsed override values from every backup, exposing historical configuration that is no longer present in the current config.
Require authentication for this endpoint or otherwise prevent unauthenticated LAN clients from retrieving backup contents.
</issue_to_address>
### Comment 2
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="279" />
<code_context>
+ },
+ };
+ entryState.value = backupValue;
+ entryState.isDefault = backupValue === entryState.defaultValue;
+ };
+
</code_context>
<issue_to_address>
**Older save overwrites restored settings**
When a prior save is still running when a restore triggers another save, a debounced save for the previous editor state is still in flight when this assignment triggers a save of the restored state; the requests can complete out of order, and the older `SetAquaMaiConfig` request writes last, so the restored settings disappear.
Serialize config-save requests or reject stale saves using a monotonically increasing revision.
</issue_to_address>
### Comment 3
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="329-330" />
<code_context>
+ }
+ if (record.autoEnabledSection) {
+ const stillNeedsSection = Object.values(nextRecords).some(
+ (other) => other.kind === 'entry' && other.sectionPath === record.sectionPath && other.autoEnabledSection,
+ );
+ if (!stillNeedsSection) {
+ const sectionState = props.config.sectionStates[record.sectionPath];
</code_context>
<issue_to_address>
**Remaining restored entries are skipped**
When multiple entries in a disabled section are restored individually, then the entry that first enabled the section is undone, `undoRecord` counts only other entries with `autoEnabledSection`, so it disables the section even though other restored entries remain. `SetAquaMaiConfig` then skips those entries, and their restorations are not saved.
When undoing an auto-enabled entry, keep the section enabled while any restored entry in that section remains.
</issue_to_address>
### Comment 4
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="316" />
<code_context>
+ if (record.kind === 'section') {
+ const sectionState = props.config.sectionStates[record.sectionPath];
+ if (sectionState) {
+ sectionState.enabled = record.prevEnabled;
+ sectionState.isDefault = record.prevIsDefault;
+ }
</code_context>
<issue_to_address>
**Section undo leaves values unsaved**
When a section restore enables a disabled section, then the user undoes only the section switch while restored entries remain, `undoRecord` restores the section's previous disabled state but leaves the entry restores in place. `SetAquaMaiConfig` skips entries in disabled sections, so the UI shows values that are not written to the config.
When undoing a section switch, also undo dependent entry restores or keep the section enabled while they remain.
Also at `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:328-330`.
</issue_to_address>
### Comment 5
<location path="MaiChartManager/Front/src/views/ModManager/backupDiff.ts" line_range="93" />
<code_context>
+ currentState: EntryState,
+): ConfigValue => {
+ if (Object.prototype.hasOwnProperty.call(backup.entryOverrides, entryPath)) {
+ return backup.entryOverrides[entryPath] ?? currentState.defaultValue;
+ }
+ return currentState.defaultValue;
</code_context>
<issue_to_address>
**Explicit null restores as default**
When a backup contains a null override for an entry whose default is non-null, `getBackupEntryValue` uses `??` to replace the present null override with `currentState.defaultValue`, so the diff and restore use the default instead of the backed-up value.
Return the override whenever the entry path is present, including when its value is null.
Also at `MaiChartManager/Front/src/views/ModManager/backupDiff.ts:94`.
</issue_to_address>
### Comment 6
<location path="MaiChartManager/Front/src/views/ModManager/backupDiff.ts" line_range="45" />
<code_context>
+export const toNormalizedBackup = (dto: AquaMaiConfigBackupDto): NormalizedBackup => {
+ const entryOverrides: Record<string, ConfigValue> = {};
+ for (const [path, value] of Object.entries(dto.entryOverrides ?? {})) {
+ entryOverrides[path] = toConfigValue(value);
+ }
+ return {
</code_context>
<issue_to_address>
**Structured backup values become invalid**
When a backed-up configuration entry serializes to a JSON object rather than a scalar, `toConfigValue` converts object-valued JSON overrides to JavaScript’s default string, such as `[object Object]`. Restoring such an entry sends that string instead of the original value, so deserialization or saving fails for structured configuration values.
Preserve and support structured JSON values through backup comparison and restoration, or explicitly exclude unsupported value shapes from restore.
</issue_to_address>
### Comment 7
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="121" />
<code_context>
+ loading.value = true;
+ backups.value = [];
+ selectedFileName.value = null;
+ restoredRecords.value = {};
+ try {
+ const res = await api.GetAquaMaiConfigBackups({
</code_context>
<issue_to_address>
**Switching backups loses undo**
When the user restores one or more values and then selects a different backup, `watch(selectedFileName)` clears `restoredRecords` but leaves the restored values in the shared config; the config watcher still schedules those values for saving, while the view no longer has records to undo them, so switching backups permanently removes the restore actions for pending changes.
Preserve undo records across backup selection changes, or undo the staged changes before clearing their records.
</issue_to_address>
### Comment 8
<location path="MaiChartManager/Controllers/Mod/ModConfigService.cs" line_range="215" />
<code_context>
+
+ try
+ {
+ var toml = await File.ReadAllTextAsync(filePath, ct);
+ var config = configInterface.CreateConfig();
+ var view = configInterface.CreateConfigView(toml);
</code_context>
<issue_to_address>
**Valid backups appear malformed**
When the backup list reads a file while a config save is writing it, `GetAquaMaiConfigBackups` can read a partial TOML file and return a `ParseError` for a valid backup, so the UI shows it as failed until the list is reloaded.
Write backups atomically so the listing request reads only complete files.
</issue_to_address>
### Comment 9
<location path="MaiChartManager/Controllers/Mod/ModConfigService.cs" line_range="174" />
<code_context>
+ return [];
+ }
+
+ var files = Directory.GetFiles(ModPaths.AquaMaiConfigBackupDirPath, "*.toml");
+ if (files.Length == 0)
+ {
</code_context>
<issue_to_address>
**Large backup histories stall recovery**
When the backup directory contains many or large files, or the endpoint is called repeatedly, `GetAquaMaiConfigBackups` reads and parses every backup and returns all results on each request, making work and memory use grow with the uncapped history until the request slows or the service becomes unresponsive.
Limit backup history or paginate the listing so each request reads and returns a bounded set.
Also at `MaiChartManager/Controllers/Mod/ModConfigService.cs:206`.
</issue_to_address>Sourcery 评估
需要人工审查。 需要先处理 9 项发现;恢复备份会将其中的分区和条目值复制到当前配置中,之后可以将其保存到配置文件。如果这些值有误,即使回退此代码,它们仍会保留,但可以通过编辑配置或恢复其他备份来修复。
阻塞性问题:MaiChartManager/Controllers/Mod/ConfigurationController.cs:39、MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:279、MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:330、MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:316、MaiChartManager/Front/src/views/ModManager/backupDiff.ts:93,以及另外 4 项
Original comment in English
Hey - I've found 9 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="MaiChartManager/Controllers/Mod/ConfigurationController.cs" line_range="39" />
<code_context>
+ [HttpGet]
+ public async Task<IReadOnlyList<AquaMaiConfigBackupDto>> GetAquaMaiConfigBackups(bool skipSignatureCheck = false, CancellationToken ct = default)
+ {
+ return await modConfigService.GetAquaMaiConfigBackups(skipSignatureCheck, ct);
+ }
+
</code_context>
<issue_to_address>
**Historical settings exposed over LAN**
When the application is running in export mode with authentication disabled and backup files contain historical overrides, an unauthenticated LAN client can call this endpoint when export mode is enabled and `UseAuth` is false; the service returns parsed override values from every backup, exposing historical configuration that is no longer present in the current config.
Require authentication for this endpoint or otherwise prevent unauthenticated LAN clients from retrieving backup contents.
</issue_to_address>
### Comment 2
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="279" />
<code_context>
+ },
+ };
+ entryState.value = backupValue;
+ entryState.isDefault = backupValue === entryState.defaultValue;
+ };
+
</code_context>
<issue_to_address>
**Older save overwrites restored settings**
When a prior save is still running when a restore triggers another save, a debounced save for the previous editor state is still in flight when this assignment triggers a save of the restored state; the requests can complete out of order, and the older `SetAquaMaiConfig` request writes last, so the restored settings disappear.
Serialize config-save requests or reject stale saves using a monotonically increasing revision.
</issue_to_address>
### Comment 3
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="329-330" />
<code_context>
+ }
+ if (record.autoEnabledSection) {
+ const stillNeedsSection = Object.values(nextRecords).some(
+ (other) => other.kind === 'entry' && other.sectionPath === record.sectionPath && other.autoEnabledSection,
+ );
+ if (!stillNeedsSection) {
+ const sectionState = props.config.sectionStates[record.sectionPath];
</code_context>
<issue_to_address>
**Remaining restored entries are skipped**
When multiple entries in a disabled section are restored individually, then the entry that first enabled the section is undone, `undoRecord` counts only other entries with `autoEnabledSection`, so it disables the section even though other restored entries remain. `SetAquaMaiConfig` then skips those entries, and their restorations are not saved.
When undoing an auto-enabled entry, keep the section enabled while any restored entry in that section remains.
</issue_to_address>
### Comment 4
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="316" />
<code_context>
+ if (record.kind === 'section') {
+ const sectionState = props.config.sectionStates[record.sectionPath];
+ if (sectionState) {
+ sectionState.enabled = record.prevEnabled;
+ sectionState.isDefault = record.prevIsDefault;
+ }
</code_context>
<issue_to_address>
**Section undo leaves values unsaved**
When a section restore enables a disabled section, then the user undoes only the section switch while restored entries remain, `undoRecord` restores the section's previous disabled state but leaves the entry restores in place. `SetAquaMaiConfig` skips entries in disabled sections, so the UI shows values that are not written to the config.
When undoing a section switch, also undo dependent entry restores or keep the section enabled while they remain.
Also at `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:328-330`.
</issue_to_address>
### Comment 5
<location path="MaiChartManager/Front/src/views/ModManager/backupDiff.ts" line_range="93" />
<code_context>
+ currentState: EntryState,
+): ConfigValue => {
+ if (Object.prototype.hasOwnProperty.call(backup.entryOverrides, entryPath)) {
+ return backup.entryOverrides[entryPath] ?? currentState.defaultValue;
+ }
+ return currentState.defaultValue;
</code_context>
<issue_to_address>
**Explicit null restores as default**
When a backup contains a null override for an entry whose default is non-null, `getBackupEntryValue` uses `??` to replace the present null override with `currentState.defaultValue`, so the diff and restore use the default instead of the backed-up value.
Return the override whenever the entry path is present, including when its value is null.
Also at `MaiChartManager/Front/src/views/ModManager/backupDiff.ts:94`.
</issue_to_address>
### Comment 6
<location path="MaiChartManager/Front/src/views/ModManager/backupDiff.ts" line_range="45" />
<code_context>
+export const toNormalizedBackup = (dto: AquaMaiConfigBackupDto): NormalizedBackup => {
+ const entryOverrides: Record<string, ConfigValue> = {};
+ for (const [path, value] of Object.entries(dto.entryOverrides ?? {})) {
+ entryOverrides[path] = toConfigValue(value);
+ }
+ return {
</code_context>
<issue_to_address>
**Structured backup values become invalid**
When a backed-up configuration entry serializes to a JSON object rather than a scalar, `toConfigValue` converts object-valued JSON overrides to JavaScript’s default string, such as `[object Object]`. Restoring such an entry sends that string instead of the original value, so deserialization or saving fails for structured configuration values.
Preserve and support structured JSON values through backup comparison and restoration, or explicitly exclude unsupported value shapes from restore.
</issue_to_address>
### Comment 7
<location path="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx" line_range="121" />
<code_context>
+ loading.value = true;
+ backups.value = [];
+ selectedFileName.value = null;
+ restoredRecords.value = {};
+ try {
+ const res = await api.GetAquaMaiConfigBackups({
</code_context>
<issue_to_address>
**Switching backups loses undo**
When the user restores one or more values and then selects a different backup, `watch(selectedFileName)` clears `restoredRecords` but leaves the restored values in the shared config; the config watcher still schedules those values for saving, while the view no longer has records to undo them, so switching backups permanently removes the restore actions for pending changes.
Preserve undo records across backup selection changes, or undo the staged changes before clearing their records.
</issue_to_address>
### Comment 8
<location path="MaiChartManager/Controllers/Mod/ModConfigService.cs" line_range="215" />
<code_context>
+
+ try
+ {
+ var toml = await File.ReadAllTextAsync(filePath, ct);
+ var config = configInterface.CreateConfig();
+ var view = configInterface.CreateConfigView(toml);
</code_context>
<issue_to_address>
**Valid backups appear malformed**
When the backup list reads a file while a config save is writing it, `GetAquaMaiConfigBackups` can read a partial TOML file and return a `ParseError` for a valid backup, so the UI shows it as failed until the list is reloaded.
Write backups atomically so the listing request reads only complete files.
</issue_to_address>
### Comment 9
<location path="MaiChartManager/Controllers/Mod/ModConfigService.cs" line_range="174" />
<code_context>
+ return [];
+ }
+
+ var files = Directory.GetFiles(ModPaths.AquaMaiConfigBackupDirPath, "*.toml");
+ if (files.Length == 0)
+ {
</code_context>
<issue_to_address>
**Large backup histories stall recovery**
When the backup directory contains many or large files, or the endpoint is called repeatedly, `GetAquaMaiConfigBackups` reads and parses every backup and returns all results on each request, making work and memory use grow with the uncapped history until the request slows or the service becomes unresponsive.
Limit backup history or paginate the listing so each request reads and returns a bounded set.
Also at `MaiChartManager/Controllers/Mod/ModConfigService.cs:206`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 9 findings to address first, and restoring a backup copies its section and entry values into the live configuration, which can then be saved to the config file. If those values are wrong, they remain after reverting this code, but the configuration can be repaired by editing it or restoring another backup.
Blocking findings: MaiChartManager/Controllers/Mod/ConfigurationController.cs:39, MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:279, MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:330, MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:316, MaiChartManager/Front/src/views/ModManager/backupDiff.ts:93, and 4 more
| [HttpGet] | ||
| public async Task<IReadOnlyList<AquaMaiConfigBackupDto>> GetAquaMaiConfigBackups(bool skipSignatureCheck = false, CancellationToken ct = default) | ||
| { | ||
| return await modConfigService.GetAquaMaiConfigBackups(skipSignatureCheck, ct); |
There was a problem hiding this comment.
🟡 Medium · 通过局域网暴露历史设置
当应用在禁用身份验证的导出模式下运行,且备份文件包含历史覆盖值时,未经过身份验证的局域网客户端可以在启用导出模式且 UseAuth 为 false 时调用此端点;该服务会返回所有备份中解析出的覆盖值,从而暴露当前配置中已不存在的历史配置。
请对此端点要求身份验证,或以其他方式阻止未经过身份验证的局域网客户端获取备份内容。
面向 AI 智能体的提示
在 `MaiChartManager/Controllers/Mod/ConfigurationController.cs` 第 39 行:
**通过局域网暴露历史设置**
当应用在禁用身份验证的导出模式下运行,且备份文件包含历史覆盖值时,未经过身份验证的局域网客户端可以在启用导出模式且 `UseAuth` 为 false 时调用此端点;该服务会返回所有备份中解析出的覆盖值,从而暴露当前配置中已不存在的历史配置。
请对此端点要求身份验证,或以其他方式阻止未经过身份验证的局域网客户端获取备份内容。Original comment in English
🟡 Medium · Historical settings exposed over LAN
When the application is running in export mode with authentication disabled and backup files contain historical overrides, an unauthenticated LAN client can call this endpoint when export mode is enabled and UseAuth is false; the service returns parsed override values from every backup, exposing historical configuration that is no longer present in the current config.
Require authentication for this endpoint or otherwise prevent unauthenticated LAN clients from retrieving backup contents.
Prompt for AI agents
In `MaiChartManager/Controllers/Mod/ConfigurationController.cs` at line 39:
**Historical settings exposed over LAN**
When the application is running in export mode with authentication disabled and backup files contain historical overrides, an unauthenticated LAN client can call this endpoint when export mode is enabled and `UseAuth` is false; the service returns parsed override values from every backup, exposing historical configuration that is no longer present in the current config.
Require authentication for this endpoint or otherwise prevent unauthenticated LAN clients from retrieving backup contents.| }, | ||
| }; | ||
| entryState.value = backupValue; | ||
| entryState.isDefault = backupValue === entryState.defaultValue; |
There was a problem hiding this comment.
🟡 Medium · 较早的保存操作会覆盖已恢复的设置
当先前的保存操作仍在进行时,恢复操作又触发了另一次保存,此时针对先前编辑器状态的防抖保存仍在执行,而这次赋值会触发对恢复后状态的保存;这些请求可能乱序完成,较早的 SetAquaMaiConfig 请求最后写入,导致恢复的设置消失。
请串行处理配置保存请求,或使用单调递增的版本号拒绝过期的保存操作。
面向 AI 智能体的提示
在 `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` 第 279 行:
**较早的保存操作会覆盖已恢复的设置**
当先前的保存操作仍在进行时,恢复操作又触发了另一次保存,此时针对先前编辑器状态的防抖保存仍在执行,而这次赋值会触发对恢复后状态的保存;这些请求可能乱序完成,较早的 `SetAquaMaiConfig` 请求最后写入,导致恢复的设置消失。
请串行处理配置保存请求,或使用单调递增的版本号拒绝过期的保存操作。Original comment in English
🟡 Medium · Older save overwrites restored settings
When a prior save is still running when a restore triggers another save, a debounced save for the previous editor state is still in flight when this assignment triggers a save of the restored state; the requests can complete out of order, and the older SetAquaMaiConfig request writes last, so the restored settings disappear.
Serialize config-save requests or reject stale saves using a monotonically increasing revision.
Prompt for AI agents
In `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` at line 279:
**Older save overwrites restored settings**
When a prior save is still running when a restore triggers another save, a debounced save for the previous editor state is still in flight when this assignment triggers a save of the restored state; the requests can complete out of order, and the older `SetAquaMaiConfig` request writes last, so the restored settings disappear.
Serialize config-save requests or reject stale saves using a monotonically increasing revision.| (other) => other.kind === 'entry' && other.sectionPath === record.sectionPath && other.autoEnabledSection, | ||
| ); |
There was a problem hiding this comment.
🟠 High · 其余已恢复条目会被跳过
当逐个恢复已禁用分区中的多个条目,然后撤销最先启用该分区的条目时,undoRecord 只统计其他具有 autoEnabledSection 的条目,因此即使该分区中仍有其他已恢复条目,也会将分区禁用。随后 SetAquaMaiConfig 会跳过这些条目,导致它们的恢复结果无法保存。
撤销自动启用分区的条目时,只要该分区中仍有已恢复条目,就应保持分区启用。
面向 AI 智能体的提示
在 `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` 第 329-330 行:
**其余已恢复条目会被跳过**
当逐个恢复已禁用分区中的多个条目,然后撤销最先启用该分区的条目时,`undoRecord` 只统计其他具有 `autoEnabledSection` 的条目,因此即使该分区中仍有其他已恢复条目,也会将分区禁用。随后 `SetAquaMaiConfig` 会跳过这些条目,导致它们的恢复结果无法保存。
撤销自动启用分区的条目时,只要该分区中仍有已恢复条目,就应保持分区启用。Original comment in English
🟠 High · Remaining restored entries are skipped
When multiple entries in a disabled section are restored individually, then the entry that first enabled the section is undone, undoRecord counts only other entries with autoEnabledSection, so it disables the section even though other restored entries remain. SetAquaMaiConfig then skips those entries, and their restorations are not saved.
When undoing an auto-enabled entry, keep the section enabled while any restored entry in that section remains.
Prompt for AI agents
In `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` at lines 329-330:
**Remaining restored entries are skipped**
When multiple entries in a disabled section are restored individually, then the entry that first enabled the section is undone, `undoRecord` counts only other entries with `autoEnabledSection`, so it disables the section even though other restored entries remain. `SetAquaMaiConfig` then skips those entries, and their restorations are not saved.
When undoing an auto-enabled entry, keep the section enabled while any restored entry in that section remains.| if (record.kind === 'section') { | ||
| const sectionState = props.config.sectionStates[record.sectionPath]; | ||
| if (sectionState) { | ||
| sectionState.enabled = record.prevEnabled; |
There was a problem hiding this comment.
🟡 Medium · 撤销分区操作会导致值未保存
当恢复某个分区并启用原本已禁用的分区后,如果用户只撤销分区开关,而已恢复的条目仍保留,undoRecord 会将分区恢复为之前的禁用状态,但不会撤销条目恢复操作。SetAquaMaiConfig 会跳过已禁用分区中的条目,因此界面显示的值不会写入配置。
撤销分区开关时,也应撤销依赖于该操作的条目恢复,或在这些条目仍保留时保持分区启用。
另见 MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:328-330。
面向 AI 智能体的提示
在 `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` 第 316 行:
**撤销分区操作会导致值未保存**
当恢复某个分区并启用原本已禁用的分区后,如果用户只撤销分区开关,而已恢复的条目仍保留,`undoRecord` 会将分区恢复为之前的禁用状态,但不会撤销条目恢复操作。`SetAquaMaiConfig` 会跳过已禁用分区中的条目,因此界面显示的值不会写入配置。
撤销分区开关时,也应撤销依赖于该操作的条目恢复,或在这些条目仍保留时保持分区启用。
另见 `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:328-330`。Original comment in English
🟡 Medium · Section undo leaves values unsaved
When a section restore enables a disabled section, then the user undoes only the section switch while restored entries remain, undoRecord restores the section's previous disabled state but leaves the entry restores in place. SetAquaMaiConfig skips entries in disabled sections, so the UI shows values that are not written to the config.
When undoing a section switch, also undo dependent entry restores or keep the section enabled while they remain.
Also at MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:328-330.
Prompt for AI agents
In `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` at line 316:
**Section undo leaves values unsaved**
When a section restore enables a disabled section, then the user undoes only the section switch while restored entries remain, `undoRecord` restores the section's previous disabled state but leaves the entry restores in place. `SetAquaMaiConfig` skips entries in disabled sections, so the UI shows values that are not written to the config.
When undoing a section switch, also undo dependent entry restores or keep the section enabled while they remain.
Also at `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:328-330`.| currentState: EntryState, | ||
| ): ConfigValue => { | ||
| if (Object.prototype.hasOwnProperty.call(backup.entryOverrides, entryPath)) { | ||
| return backup.entryOverrides[entryPath] ?? currentState.defaultValue; |
There was a problem hiding this comment.
🟡 Medium · 显式 null 会被恢复为默认值
当备份中某个条目的覆盖值为 null,而该条目的默认值非 null 时,getBackupEntryValue 使用 ?? 将这个实际存在的 null 覆盖值替换为 currentState.defaultValue,因此差异比较和恢复操作使用的是默认值,而不是备份中的值。
只要条目路径存在,就应返回覆盖值,包括其值为 null 的情况。
另见 MaiChartManager/Front/src/views/ModManager/backupDiff.ts:94。
面向 AI 智能体的提示
在 `MaiChartManager/Front/src/views/ModManager/backupDiff.ts` 第 93 行:
**显式 null 会被恢复为默认值**
当备份中某个条目的覆盖值为 null,而该条目的默认值非 null 时,`getBackupEntryValue` 使用 `??` 将这个实际存在的 null 覆盖值替换为 `currentState.defaultValue`,因此差异比较和恢复操作使用的是默认值,而不是备份中的值。
只要条目路径存在,就应返回覆盖值,包括其值为 null 的情况。
另见 `MaiChartManager/Front/src/views/ModManager/backupDiff.ts:94`。Original comment in English
🟡 Medium · Explicit null restores as default
When a backup contains a null override for an entry whose default is non-null, getBackupEntryValue uses ?? to replace the present null override with currentState.defaultValue, so the diff and restore use the default instead of the backed-up value.
Return the override whenever the entry path is present, including when its value is null.
Also at MaiChartManager/Front/src/views/ModManager/backupDiff.ts:94.
Prompt for AI agents
In `MaiChartManager/Front/src/views/ModManager/backupDiff.ts` at line 93:
**Explicit null restores as default**
When a backup contains a null override for an entry whose default is non-null, `getBackupEntryValue` uses `??` to replace the present null override with `currentState.defaultValue`, so the diff and restore use the default instead of the backed-up value.
Return the override whenever the entry path is present, including when its value is null.
Also at `MaiChartManager/Front/src/views/ModManager/backupDiff.ts:94`.| export const toNormalizedBackup = (dto: AquaMaiConfigBackupDto): NormalizedBackup => { | ||
| const entryOverrides: Record<string, ConfigValue> = {}; | ||
| for (const [path, value] of Object.entries(dto.entryOverrides ?? {})) { | ||
| entryOverrides[path] = toConfigValue(value); |
There was a problem hiding this comment.
🟠 High · 结构化备份值会变得无效
当备份的配置条目序列化为 JSON 对象而非标量时,toConfigValue 会将对象类型的 JSON 覆盖值转换为 JavaScript 的默认字符串,例如 [object Object]。恢复此类条目时会发送该字符串,而不是原始值,因此结构化配置值会在反序列化或保存时失败。
请在备份比较和恢复过程中保留并支持结构化 JSON 值,或明确排除不受支持的值形态,避免恢复这些值。
面向 AI 智能体的提示
在 `MaiChartManager/Front/src/views/ModManager/backupDiff.ts` 第 45 行:
**结构化备份值会变得无效**
当备份的配置条目序列化为 JSON 对象而非标量时,`toConfigValue` 会将对象类型的 JSON 覆盖值转换为 JavaScript 的默认字符串,例如 `[object Object]`。恢复此类条目时会发送该字符串,而不是原始值,因此结构化配置值会在反序列化或保存时失败。
请在备份比较和恢复过程中保留并支持结构化 JSON 值,或明确排除不受支持的值形态,避免恢复这些值。Original comment in English
🟠 High · Structured backup values become invalid
When a backed-up configuration entry serializes to a JSON object rather than a scalar, toConfigValue converts object-valued JSON overrides to JavaScript’s default string, such as [object Object]. Restoring such an entry sends that string instead of the original value, so deserialization or saving fails for structured configuration values.
Preserve and support structured JSON values through backup comparison and restoration, or explicitly exclude unsupported value shapes from restore.
Prompt for AI agents
In `MaiChartManager/Front/src/views/ModManager/backupDiff.ts` at line 45:
**Structured backup values become invalid**
When a backed-up configuration entry serializes to a JSON object rather than a scalar, `toConfigValue` converts object-valued JSON overrides to JavaScript’s default string, such as `[object Object]`. Restoring such an entry sends that string instead of the original value, so deserialization or saving fails for structured configuration values.
Preserve and support structured JSON values through backup comparison and restoration, or explicitly exclude unsupported value shapes from restore.| }); | ||
|
|
||
| watch(selectedFileName, () => { | ||
| restoredRecords.value = {}; |
There was a problem hiding this comment.
🟡 Medium · 切换备份会丢失撤销记录
当用户恢复一个或多个值后又选择其他备份时,watch(selectedFileName) 会清空 restoredRecords,但共享配置中的已恢复值仍然保留;配置监听器仍会安排保存这些值,而界面已没有可用于撤销它们的记录,因此切换备份会永久丢失对待处理更改的撤销操作。
请在切换备份时保留撤销记录,或在清除记录之前撤销暂存的更改。
面向 AI 智能体的提示
在 `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` 第 121 行:
**切换备份会丢失撤销记录**
当用户恢复一个或多个值后又选择其他备份时,`watch(selectedFileName)` 会清空 `restoredRecords`,但共享配置中的已恢复值仍然保留;配置监听器仍会安排保存这些值,而界面已没有可用于撤销它们的记录,因此切换备份会永久丢失对待处理更改的撤销操作。
请在切换备份时保留撤销记录,或在清除记录之前撤销暂存的更改。Original comment in English
🟡 Medium · Switching backups loses undo
When the user restores one or more values and then selects a different backup, watch(selectedFileName) clears restoredRecords but leaves the restored values in the shared config; the config watcher still schedules those values for saving, while the view no longer has records to undo them, so switching backups permanently removes the restore actions for pending changes.
Preserve undo records across backup selection changes, or undo the staged changes before clearing their records.
Prompt for AI agents
In `MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx` at line 121:
**Switching backups loses undo**
When the user restores one or more values and then selects a different backup, `watch(selectedFileName)` clears `restoredRecords` but leaves the restored values in the shared config; the config watcher still schedules those values for saving, while the view no longer has records to undo them, so switching backups permanently removes the restore actions for pending changes.
Preserve undo records across backup selection changes, or undo the staged changes before clearing their records.|
|
||
| try | ||
| { | ||
| var toml = await File.ReadAllTextAsync(filePath, ct); |
There was a problem hiding this comment.
🟡 Medium · 有效备份会被误判为格式错误
当备份列表在配置保存正在写入文件时读取该文件,GetAquaMaiConfigBackups 可能会读到不完整的 TOML 文件,并对有效备份返回 ParseError,导致界面将其显示为失败状态,直到重新加载列表。
请以原子方式写入备份,确保列表请求只读取完整文件。
面向 AI 智能体的提示
在 `MaiChartManager/Controllers/Mod/ModConfigService.cs` 第 215 行:
**有效备份会被误判为格式错误**
当备份列表在配置保存正在写入文件时读取该文件,`GetAquaMaiConfigBackups` 可能会读到不完整的 TOML 文件,并对有效备份返回 `ParseError`,导致界面将其显示为失败状态,直到重新加载列表。
请以原子方式写入备份,确保列表请求只读取完整文件。Original comment in English
🟡 Medium · Valid backups appear malformed
When the backup list reads a file while a config save is writing it, GetAquaMaiConfigBackups can read a partial TOML file and return a ParseError for a valid backup, so the UI shows it as failed until the list is reloaded.
Write backups atomically so the listing request reads only complete files.
Prompt for AI agents
In `MaiChartManager/Controllers/Mod/ModConfigService.cs` at line 215:
**Valid backups appear malformed**
When the backup list reads a file while a config save is writing it, `GetAquaMaiConfigBackups` can read a partial TOML file and return a `ParseError` for a valid backup, so the UI shows it as failed until the list is reloaded.
Write backups atomically so the listing request reads only complete files.| return []; | ||
| } | ||
|
|
||
| var files = Directory.GetFiles(ModPaths.AquaMaiConfigBackupDirPath, "*.toml"); |
There was a problem hiding this comment.
🟡 Medium · 大量备份历史会拖慢恢复
当备份目录中存在许多或很大的文件,或者端点被反复调用时,GetAquaMaiConfigBackups 会在每次请求时读取并解析所有备份,然后返回全部结果;由于历史记录没有上限,工作量和内存用量会不断增长,最终导致请求变慢或服务无响应。
请限制备份历史记录的数量,或对列表进行分页,使每个请求读取并返回有界数量的结果。
另见 MaiChartManager/Controllers/Mod/ModConfigService.cs:206。
面向 AI 智能体的提示
在 `MaiChartManager/Controllers/Mod/ModConfigService.cs` 第 174 行:
**大量备份历史会拖慢恢复**
当备份目录中存在许多或很大的文件,或者端点被反复调用时,`GetAquaMaiConfigBackups` 会在每次请求时读取并解析所有备份,然后返回全部结果;由于历史记录没有上限,工作量和内存用量会不断增长,最终导致请求变慢或服务无响应。
请限制备份历史记录的数量,或对列表进行分页,使每个请求读取并返回有界数量的结果。
另见 `MaiChartManager/Controllers/Mod/ModConfigService.cs:206`。Original comment in English
🟡 Medium · Large backup histories stall recovery
When the backup directory contains many or large files, or the endpoint is called repeatedly, GetAquaMaiConfigBackups reads and parses every backup and returns all results on each request, making work and memory use grow with the uncapped history until the request slows or the service becomes unresponsive.
Limit backup history or paginate the listing so each request reads and returns a bounded set.
Also at MaiChartManager/Controllers/Mod/ModConfigService.cs:206.
Prompt for AI agents
In `MaiChartManager/Controllers/Mod/ModConfigService.cs` at line 174:
**Large backup histories stall recovery**
When the backup directory contains many or large files, or the endpoint is called repeatedly, `GetAquaMaiConfigBackups` reads and parses every backup and returns all results on each request, making work and memory use grow with the uncapped history until the request slows or the service becomes unresponsive.
Limit backup history or paginate the listing so each request reads and returns a bounded set.
Also at `MaiChartManager/Controllers/Mod/ModConfigService.cs:206`.There was a problem hiding this comment.
10 issues found across 14 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx">
<violation number="1" location="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:87">
P2: 切换备份时这里会清空撤销记录,却保留共享配置中的已恢复值,用户因此失去撤销这些待保存更改的入口;请在清除记录前回滚暂存更改,或保留对应记录。</violation>
<violation number="2" location="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:255">
P2: 同一栏目下先后恢复两个条目后,撤销先恢复的那个会把栏目重新禁用,而另一个条目仍显示为已恢复,保存时该修改会被跳过。自动启用栏目的归属需要转交给同栏目仍存活的恢复记录,可在 `restoreEntry` 中让后续记录继承该归属。</violation>
<violation number="3" location="MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx:278">
P2: 此赋值会触发恢复后的配置保存,但先前的 `SetAquaMaiConfig` 请求仍可能在途并最后写入;请串行化保存或拒绝过期请求,避免恢复结果被覆盖。</violation>
</file>
<file name="MaiChartManager/Front/src/locales/zh-TW.yaml">
<violation number="1" location="MaiChartManager/Front/src/locales/zh-TW.yaml:416">
P3: 此按钮会恢复整个配置分区及其多个配置项,但繁体中文写成了“欄位”(字段),会误导用户操作范围。请改为“還原此分區”或其他表示区段的用语。</violation>
</file>
<file name="MaiChartManager/Front/src/views/ModManager/backupDiff.ts">
<violation number="1" location="MaiChartManager/Front/src/views/ModManager/backupDiff.ts:45">
P1: 备份中的对象型覆盖值会经 `toConfigValue` 转成字符串,恢复时发送的将不是原始 JSON 值;请在备份规范化、比较和恢复过程中保留结构化值,或明确阻止恢复不支持的值。</violation>
<violation number="2" location="MaiChartManager/Front/src/views/ModManager/backupDiff.ts:93">
P2: `getBackupEntryValue` 会把合法的 null 备份值错误地回退为默认值,导致该配置项显示差异错误且无法恢复为 null。键已确认存在时应直接返回覆盖值。</violation>
</file>
<file name="MaiChartManager/Front/src/views/ModManager/ConfigEditor.tsx">
<violation number="1" location="MaiChartManager/Front/src/views/ModManager/ConfigEditor.tsx:182">
P3: 备份恢复入口使用仅绑定 `onClick` 的 `<span>`,键盘用户无法访问该功能。请改用原生 `<button>`,或补充按钮语义、焦点和 Enter/Space 键处理。</violation>
</file>
<file name="MaiChartManager/Controllers/Mod/ConfigurationController.cs">
<violation number="1" location="MaiChartManager/Controllers/Mod/ConfigurationController.cs:39">
P1: 该端点会直接返回所有备份中的历史覆盖值;请在 `UseAuth` 关闭时限制未认证访问,避免局域网客户端读取当前配置中已不存在的设置。</violation>
</file>
<file name="MaiChartManager/Controllers/Mod/ModConfigService.cs">
<violation number="1" location="MaiChartManager/Controllers/Mod/ModConfigService.cs:197">
P2: 此列表会逐个读取并解析目录中的所有备份,历史规模会直接放大每次请求的 I/O、内存和响应体;请限制每次处理的数量或实现分页。</violation>
<violation number="2" location="MaiChartManager/Controllers/Mod/ModConfigService.cs:215">
P2: 列表读取可能与配置保存对同一备份文件的写入重叠,从而读到不完整 TOML 并暂时返回 `ParseError`;请原子写入备份或同步读写。</violation>
</file>
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Re-trigger cubic
| [HttpGet] | ||
| public async Task<IReadOnlyList<AquaMaiConfigBackupDto>> GetAquaMaiConfigBackups(bool skipSignatureCheck = false, CancellationToken ct = default) | ||
| { | ||
| return await modConfigService.GetAquaMaiConfigBackups(skipSignatureCheck, ct); |
There was a problem hiding this comment.
P1: 该端点会直接返回所有备份中的历史覆盖值;请在 UseAuth 关闭时限制未认证访问,避免局域网客户端读取当前配置中已不存在的设置。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Controllers/Mod/ConfigurationController.cs, line 39:
<comment>该端点会直接返回所有备份中的历史覆盖值;请在 `UseAuth` 关闭时限制未认证访问,避免局域网客户端读取当前配置中已不存在的设置。</comment>
<file context>
@@ -29,11 +29,16 @@ public ConfigurationController(StaticSettings settings, ILogger<ConfigurationCon
+ [HttpGet]
+ public async Task<IReadOnlyList<AquaMaiConfigBackupDto>> GetAquaMaiConfigBackups(bool skipSignatureCheck = false, CancellationToken ct = default)
+ {
+ return await modConfigService.GetAquaMaiConfigBackups(skipSignatureCheck, ct);
+ }
+
</file context>
| export const toNormalizedBackup = (dto: AquaMaiConfigBackupDto): NormalizedBackup => { | ||
| const entryOverrides: Record<string, ConfigValue> = {}; | ||
| for (const [path, value] of Object.entries(dto.entryOverrides ?? {})) { | ||
| entryOverrides[path] = toConfigValue(value); |
There was a problem hiding this comment.
P1: 备份中的对象型覆盖值会经 toConfigValue 转成字符串,恢复时发送的将不是原始 JSON 值;请在备份规范化、比较和恢复过程中保留结构化值,或明确阻止恢复不支持的值。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Front/src/views/ModManager/backupDiff.ts, line 45:
<comment>备份中的对象型覆盖值会经 `toConfigValue` 转成字符串,恢复时发送的将不是原始 JSON 值;请在备份规范化、比较和恢复过程中保留结构化值,或明确阻止恢复不支持的值。</comment>
<file context>
@@ -0,0 +1,160 @@
+export const toNormalizedBackup = (dto: AquaMaiConfigBackupDto): NormalizedBackup => {
+ const entryOverrides: Record<string, ConfigValue> = {};
+ for (const [path, value] of Object.entries(dto.entryOverrides ?? {})) {
+ entryOverrides[path] = toConfigValue(value);
+ }
+ return {
</file context>
|
|
||
| const prevSectionEnabled = sectionState.enabled; | ||
| const prevSectionIsDefault = sectionState.isDefault; | ||
| let autoEnabledSection = false; |
There was a problem hiding this comment.
P2: 同一栏目下先后恢复两个条目后,撤销先恢复的那个会把栏目重新禁用,而另一个条目仍显示为已恢复,保存时该修改会被跳过。自动启用栏目的归属需要转交给同栏目仍存活的恢复记录,可在 restoreEntry 中让后续记录继承该归属。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx, line 255:
<comment>同一栏目下先后恢复两个条目后,撤销先恢复的那个会把栏目重新禁用,而另一个条目仍显示为已恢复,保存时该修改会被跳过。自动启用栏目的归属需要转交给同栏目仍存活的恢复记录,可在 `restoreEntry` 中让后续记录继承该归属。</comment>
<file context>
@@ -0,0 +1,616 @@
+
+ const prevSectionEnabled = sectionState.enabled;
+ const prevSectionIsDefault = sectionState.isDefault;
+ let autoEnabledSection = false;
+ // 禁用栏目下的条目在保存时会被后端跳过,因此恢复其中条目时需一并启用栏目
+ if (!section.attribute.alwaysEnabled && !sectionState.enabled && backupEnabled) {
</file context>
| currentState: EntryState, | ||
| ): ConfigValue => { | ||
| if (Object.prototype.hasOwnProperty.call(backup.entryOverrides, entryPath)) { | ||
| return backup.entryOverrides[entryPath] ?? currentState.defaultValue; |
There was a problem hiding this comment.
P2: getBackupEntryValue 会把合法的 null 备份值错误地回退为默认值,导致该配置项显示差异错误且无法恢复为 null。键已确认存在时应直接返回覆盖值。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Front/src/views/ModManager/backupDiff.ts, line 93:
<comment>`getBackupEntryValue` 会把合法的 null 备份值错误地回退为默认值,导致该配置项显示差异错误且无法恢复为 null。键已确认存在时应直接返回覆盖值。</comment>
<file context>
@@ -0,0 +1,160 @@
+ currentState: EntryState,
+): ConfigValue => {
+ if (Object.prototype.hasOwnProperty.call(backup.entryOverrides, entryPath)) {
+ return backup.entryOverrides[entryPath] ?? currentState.defaultValue;
+ }
+ return currentState.defaultValue;
</file context>
| loading.value = true; | ||
| backups.value = []; | ||
| selectedFileName.value = null; | ||
| restoredRecords.value = {}; |
There was a problem hiding this comment.
P2: 切换备份时这里会清空撤销记录,却保留共享配置中的已恢复值,用户因此失去撤销这些待保存更改的入口;请在清除记录前回滚暂存更改,或保留对应记录。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx, line 87:
<comment>切换备份时这里会清空撤销记录,却保留共享配置中的已恢复值,用户因此失去撤销这些待保存更改的入口;请在清除记录前回滚暂存更改,或保留对应记录。</comment>
<file context>
@@ -0,0 +1,616 @@
+ loading.value = true;
+ backups.value = [];
+ selectedFileName.value = null;
+ restoredRecords.value = {};
+ try {
+ const res = await api.GetAquaMaiConfigBackups({
</file context>
| prevSectionIsDefault, | ||
| }, | ||
| }; | ||
| entryState.value = backupValue; |
There was a problem hiding this comment.
P2: 此赋值会触发恢复后的配置保存,但先前的 SetAquaMaiConfig 请求仍可能在途并最后写入;请串行化保存或拒绝过期请求,避免恢复结果被覆盖。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Front/src/views/ModManager/BackupRestoreView.tsx, line 278:
<comment>此赋值会触发恢复后的配置保存,但先前的 `SetAquaMaiConfig` 请求仍可能在途并最后写入;请串行化保存或拒绝过期请求,避免恢复结果被覆盖。</comment>
<file context>
@@ -0,0 +1,616 @@
+ prevSectionIsDefault,
+ },
+ };
+ entryState.value = backupValue;
+ entryState.isDefault = backupValue === entryState.defaultValue;
+ };
</file context>
| }) | ||
| .OrderByDescending(x => x.timestamp) | ||
| .ThenByDescending(x => x.fileName, StringComparer.OrdinalIgnoreCase) | ||
| .ToArray(); |
There was a problem hiding this comment.
P2: 此列表会逐个读取并解析目录中的所有备份,历史规模会直接放大每次请求的 I/O、内存和响应体;请限制每次处理的数量或实现分页。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Controllers/Mod/ModConfigService.cs, line 197:
<comment>此列表会逐个读取并解析目录中的所有备份,历史规模会直接放大每次请求的 I/O、内存和响应体;请限制每次处理的数量或实现分页。</comment>
<file context>
@@ -146,4 +163,102 @@ public async Task<IConfig> GetCurrentAquaMaiConfig(bool forceDefault = false, bo
+ })
+ .OrderByDescending(x => x.timestamp)
+ .ThenByDescending(x => x.fileName, StringComparer.OrdinalIgnoreCase)
+ .ToArray();
+
+ var configInterface = await LoadConfigInterface(skipSignatureCheck, ct);
</file context>
| .ToArray(); | |
| .Take(100).ToArray(); |
|
|
||
| try | ||
| { | ||
| var toml = await File.ReadAllTextAsync(filePath, ct); |
There was a problem hiding this comment.
P2: 列表读取可能与配置保存对同一备份文件的写入重叠,从而读到不完整 TOML 并暂时返回 ParseError;请原子写入备份或同步读写。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Controllers/Mod/ModConfigService.cs, line 215:
<comment>列表读取可能与配置保存对同一备份文件的写入重叠,从而读到不完整 TOML 并暂时返回 `ParseError`;请原子写入备份或同步读写。</comment>
<file context>
@@ -146,4 +163,102 @@ public async Task<IConfig> GetCurrentAquaMaiConfig(bool forceDefault = false, bo
+
+ try
+ {
+ var toml = await File.ReadAllTextAsync(filePath, ct);
+ var config = configInterface.CreateConfig();
+ var view = configInterface.CreateConfigView(toml);
</file context>
| backupValue: 備份 | ||
| currentValue: 目前 | ||
| restore: 還原 | ||
| restoreSection: 還原此欄位 |
There was a problem hiding this comment.
P3: 此按钮会恢复整个配置分区及其多个配置项,但繁体中文写成了“欄位”(字段),会误导用户操作范围。请改为“還原此分區”或其他表示区段的用语。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Front/src/locales/zh-TW.yaml, line 416:
<comment>此按钮会恢复整个配置分区及其多个配置项,但繁体中文写成了“欄位”(字段),会误导用户操作范围。请改为“還原此分區”或其他表示区段的用语。</comment>
<file context>
@@ -402,6 +402,23 @@ mod:
+ backupValue: 備份
+ currentValue: 目前
+ restore: 還原
+ restoreSection: 還原此欄位
+ restoreAll: 全部還原
+ restored: 已還原
</file context>
| </div> | ||
| )} | ||
| {editorConfig.value && !isBothModsPresent.value && ( | ||
| <span |
There was a problem hiding this comment.
P3: 备份恢复入口使用仅绑定 onClick 的 <span>,键盘用户无法访问该功能。请改用原生 <button>,或补充按钮语义、焦点和 Enter/Space 键处理。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At MaiChartManager/Front/src/views/ModManager/ConfigEditor.tsx, line 182:
<comment>备份恢复入口使用仅绑定 `onClick` 的 `<span>`,键盘用户无法访问该功能。请改用原生 `<button>`,或补充按钮语义、焦点和 Enter/Space 键处理。</comment>
<file context>
@@ -169,6 +178,19 @@ export default defineComponent({
</div>
)}
+ {editorConfig.value && !isBothModsPresent.value && (
+ <span
+ class={[theme.value.lc, 'fl cursor-pointer ml-auto mr-1 shrink-0 select-none inline-flex items-center gap-1 z-0']}
+ onClick={() => { showBackupRestore.value = !showBackupRestore.value; }}
</file context>
Sourcery 摘要
为模组配置编辑器添加 AquaMai 配置历史比较和恢复控件。
新功能:
改进:
杂项:
Original summary in English
Summary by Sourcery
Add historical AquaMai configuration comparison and restore controls to the mod configuration editor.
New Features:
Enhancements:
Chores: