fix: 结果区更新时保留「复制」按钮 - #6
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Assigning textContent on result containers removed all child nodes, including the per-box copy button, after the first tool output. Co-authored-by: Muki182 <Muki182@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
Multiple tools write output with
element.textContent = ...on the shared.result-boxcontainer that also holds the per-box 复制 button. In the DOM, assigningtextContenton a parent replaces all descendants with a single text node, so the copy control disappeared after the first successful operation (JSON 格式化、Base64、时间戳、Hash、UUID 等). Users lost one-click copy for the rest of the session unless they reloaded the page.Root cause
textContenton the parentresult-boxclears child nodes, including the<button class="copy-btn">.Fix
<span class="result-text">in each affected panel.setResultBoxText(boxId, text)to update only that span.copyResultat.result-textwhen present.Validation
<script>withnew Function(...)under Node to confirm syntax.No automated test harness exists in this static single-file repo.