Skip to content

[v1.4] ScriptEditor: 编辑冲突&脚本名称冲突#1223

Merged
CodFrm merged 3 commits intoscriptscat:release/v1.4from
cyfung1031:pr-script-name-conflict-002
Mar 17, 2026
Merged

[v1.4] ScriptEditor: 编辑冲突&脚本名称冲突#1223
CodFrm merged 3 commits intoscriptscat:release/v1.4from
cyfung1031:pr-script-name-conflict-002

Conversation

@cyfung1031
Copy link
Copy Markdown
Collaborator

@cyfung1031 cyfung1031 changed the title ScriptEditor: 脚本名称冲突 (合并至 develop/scripteditor-1) [v1.3] ScriptEditor: 脚本名称冲突 (合并至 develop/scripteditor-1) Feb 7, 2026
@cyfung1031 cyfung1031 force-pushed the pr-script-name-conflict-002 branch from b0d2926 to b563ab1 Compare February 8, 2026 03:39
@CodFrm CodFrm requested a review from Copilot February 12, 2026 08:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 在 ScriptEditor 的保存流程中新增“脚本名称 + namespace 冲突”检测:当新增脚本或修改脚本名称/命名空间时,如发现已有同名同命名空间脚本,则弹窗提醒用户是否仍要保存,以避免同页重复运行脚本的问题(#808)。

Changes:

  • 保存时检测同名同 namespace 脚本,冲突时弹出确认对话框,可选择继续保存或中止保存
  • 为该提示补充多语言文案(zh-CN/zh-TW/en-US/de-DE/ja-JP/ru-RU/vi-VN/ach-UG)

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/pages/options/routes/script/ScriptEditor.tsx 在保存逻辑中加入脚本名称冲突检测与确认弹窗
src/locales/zh-TW/translation.json 新增脚本名称冲突相关文案(繁中)
src/locales/zh-CN/translation.json 新增脚本名称冲突相关文案(简中)
src/locales/vi-VN/translation.json 新增脚本名称冲突相关文案(越南语)
src/locales/ru-RU/translation.json 新增脚本名称冲突相关文案(俄语)
src/locales/ja-JP/translation.json 新增脚本名称冲突相关文案(日语)
src/locales/en-US/translation.json 新增脚本名称冲突相关文案(英文)
src/locales/de-DE/translation.json 新增脚本名称冲突相关文案(德文)
src/locales/ach-UG/translation.json 新增脚本名称冲突相关文案(ach-UG)

setTimeout(e.focus.bind(e), 50);
if (modalResult === "no") {
Message.warning(t("save_abort_when_scriptname_conflict"));
return Promise.reject(new Error("This script name is already used by another script. Save aborted."));
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

这里在用户选择“不保存”时通过 Promise.reject(new Error(...)) 中止流程,会被外层 save().catch() 统一当作 invalid_script_code 处理并弹出错误提示;同时 run 菜单里 await save(...) 没有兜底 catch,取消保存会导致运行流程抛错/潜在未处理的 Promise rejection。建议为“用户主动取消保存”使用可识别的中止信号(如专用错误类型/错误码),并在 save() 的 catch 中对该类中止分支直接静默返回/仅保留 warning,不要走 invalid_script_code 提示;调用方(如 run)也应捕获并直接 return。

Suggested change
return Promise.reject(new Error("This script name is already used by another script. Save aborted."));
// 用户主动取消保存:中止当前保存流程,但不触发 Promise rejection
return;

Copilot uses AI. Check for mistakes.
@CodFrm
Copy link
Copy Markdown
Member

CodFrm commented Feb 12, 2026

有问题 这个脚本我有多个版本,如果就是想保留几个不同的版本,体验不是很好(等有用户提再优化也行),似乎 编辑冲突也有些问题

没太细看,我先看其它pr

1234.mp4

@cyfung1031
Copy link
Copy Markdown
Collaborator Author

有问题 这个脚本我有多个版本,如果就是想保留几个不同的版本,体验不是很好(等有用户提再优化也行),似乎 编辑冲突也有些问题

没太细看,我先看其它pr

1234.mp4

编辑冲突 我改了一下

a726ce0

Screenshot 2026-02-24 at 9 41 44

你有空测一下行不行

@cyfung1031 cyfung1031 marked this pull request as draft February 24, 2026 00:43
@cyfung1031 cyfung1031 force-pushed the pr-script-name-conflict-002 branch from 1f05905 to 04ed433 Compare February 24, 2026 01:14
@cyfung1031 cyfung1031 changed the title [v1.3] ScriptEditor: 脚本名称冲突 (合并至 develop/scripteditor-1) [v1.4] ScriptEditor: 编辑冲突&脚本名称冲突 (合并至 improve/scripteditor-2) Feb 24, 2026
@cyfung1031 cyfung1031 changed the base branch from develop/scripteditor-1 to improve/scripteditor-2 February 24, 2026 01:16
@cyfung1031 cyfung1031 linked an issue Feb 24, 2026 that may be closed by this pull request
@cyfung1031 cyfung1031 changed the base branch from improve/scripteditor-2 to release/v1.4 March 15, 2026 04:50
@cyfung1031 cyfung1031 force-pushed the pr-script-name-conflict-002 branch from 04ed433 to d6c1131 Compare March 15, 2026 04:54
@cyfung1031 cyfung1031 changed the title [v1.4] ScriptEditor: 编辑冲突&脚本名称冲突 (合并至 improve/scripteditor-2) [v1.4] ScriptEditor: 编辑冲突&脚本名称冲突 Mar 15, 2026
@cyfung1031 cyfung1031 marked this pull request as ready for review March 16, 2026 12:50
@cyfung1031
Copy link
Copy Markdown
Collaborator Author

有问题 这个脚本我有多个版本,如果就是想保留几个不同的版本,体验不是很好(等有用户提再优化也行),似乎 编辑冲突也有些问题
没太细看,我先看其它pr
1234.mp4

编辑冲突 我改了一下

a726ce0

Screenshot 2026-02-24 at 9 41 44 你有空测一下行不行

@CodFrm

@CodFrm
Copy link
Copy Markdown
Member

CodFrm commented Mar 17, 2026

Code review

Found 1 issue:

  1. 编辑冲突检测在连续保存时会误触发: 保存成功后,setEditors 只更新了 name 字段,没有更新 updatetime。导致下次保存时 existingScript.updatetime(编辑器打开时的旧值)与 oldScript.updatetime(从 DB 读取的新值)不一致,每次连续保存都会弹出编辑冲突对话框,即使没有外部修改。建议在 setEditors 中同时更新 updatetime

hotKeys: hotKeys.current,
isChanged: false,
};
insertEditor(newEditor);
setSelectSciptButtonAndTab(uuid);
} else {
Message.error("Script Not Found");
}
} else {
// 新建脚本
const e = await emptyScript(template || "", hotKeys.current, target || "blank");
insertEditor(e);
setSelectSciptButtonAndTab(e.script.uuid);
}
},
[scriptList, selectedScript]

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment on lines +314 to +316
script.namespace
) {
const searchResult = await scriptDAO.findByNameAndNamespace(script.name, script.namespace);
Comment on lines +323 to +324
title: t("scriptname_conflict"),
content: t("confirm_save_when_scriptname_conflict"),
Comment on lines +379 to +382
if (modalResult === "no") {
Message.warning(t("save_abort_when_edit_conflict"));
return Promise.reject(new Error("The script was edited in another instance. Save Aborted."));
}
@CodFrm
Copy link
Copy Markdown
Member

CodFrm commented Mar 17, 2026

看起来没问题了,只是有两个错误的弹窗,可以优化一下

用户在同名冲突或编辑冲突弹窗中点击取消属于主动取消,
统一使用 SAVE_CANCELED 标识并在 catch 链中跳过错误 toast。
@CodFrm CodFrm merged commit 283c8d4 into scriptscat:release/v1.4 Mar 17, 2026
2 of 3 checks passed
@cyfung1031 cyfung1031 deleted the pr-script-name-conflict-002 branch March 22, 2026 16:26
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.

[Feature] 提醒有相同名字的腳本 (安裝/更新/改代碼) [Editor] 多个分页编辑同一脚本时未检测到版本冲突

3 participants