Skip to content

fix: 使用序号机制修复超级面板剪贴板识别问题#431

Merged
lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
Particaly:fix/super-panel-clipboard-detection
Apr 23, 2026
Merged

fix: 使用序号机制修复超级面板剪贴板识别问题#431
lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
Particaly:fix/super-panel-clipboard-detection

Conversation

@Particaly

Copy link
Copy Markdown
Collaborator

修复先选中 文件/文本 后触发超级面板,不进行操作,再选相同内容重新进入超级面板时未触发对应链路问题

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the clipboard monitoring logic in the SuperPanelManager to use a sequence-based tracking system instead of manual snapshots and comparisons. The ClipboardManager now maintains a sequence number for each copy event, and the SuperPanelManager uses this to reliably detect when a new copy operation has completed after simulating a keyboard shortcut. A potential race condition was identified in the getLastCopiedContent method where the calculation of the initial sequence could cause the system to miss a valid update if it occurs during the method execution.

}

const initialTimestamp = this.lastCopiedContent?.timestamp ?? 0
const initialSequence = Math.max(this.lastCopiedContent?.sequence ?? 0, minSequence ?? 0)

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.

high

此处使用 Math.max 可能会引入竞态条件(Race Condition)。如果在第 823 行的检查之后到第 827 行的赋值之前,剪贴板内容发生了更新(导致 sequence 增加),initialSequence 将会被设置为更新后的序号。这会导致随后的循环开始等待一个更晚的更新,从而错过刚刚发生的这次更新,最终可能导致超时。建议在提供 minSequence 时直接使用它作为基准,或者在未提供时使用当前序号。

Suggested change
const initialSequence = Math.max(this.lastCopiedContent?.sequence ?? 0, minSequence ?? 0)
const initialSequence = minSequence !== undefined ? minSequence : (this.lastCopiedContent?.sequence ?? 0)

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