fix(chatgpt-review): remove duplicate SELECTORS.responseActions key breaking clipboard copy - #665
Merged
Conversation
…reaking clipboard copy SELECTORS defined `responseActions` twice: the properly-scoped, commented `['[role="group"][aria-label="Response actions" i]']` (added alongside copyLatestAssistantMarkdown), immediately shadowed a few lines later by a pre-existing, unrelated `['button[aria-label*="Good response"]', ...]` definition that was never removed. JS object literals silently let the second key win with no error and no lint warning (this repo has no ESLint config anywhere), so copyLatestAssistantMarkdown has been querying the wrong selector since the day it was introduced, always returning null, and every caller silently fell back to plain innerText() -- which strips Markdown heading syntax. This is the real root cause of the recurring "invalid_response: The delimited plan is not complete Markdown with a heading" failures in plan-author mode across this project's history, including 3 reproductions in a single live dry run today (issue #639). Confirmed live against a real open ChatGPT tab: the correct selector matched 3 groups with a real copy button in the last one; the shadowing selector's own text ("Good response"/ "Bad response") matched zero elements in ChatGPT's current UI -- doubly dead, wrong AND stale. Fix: delete the shadowing duplicate key. Added two regression tests: one asserting SELECTORS.responseActions holds the scoped group selector (not the stale button selector) directly, and one statically parsing the SELECTORS object literal's source text to assert no top-level key repeats -- independent of whatever runtime value the constant happens to hold, so it can't become vacuously self-consistent the way the existing mock-based tests are. 64/64 chatgpt-review unit tests pass (62 + 2 new).
This was referenced Aug 10, 2026
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.
Summary
Found live during the same
/ship 639dry-run smoke test as PR #664, afterthat fix's diagnostics made the real captured response text visible for the
first time.
SELECTORS(skills/chatgpt-review/scripts/lib/browser.mjs) definedresponseActionstwice: the properly-scoped, commented['[role="group"][aria-label="Response actions" i]'](added alongsidecopyLatestAssistantMarkdown), immediately shadowed a few lines later by apre-existing, unrelated
['button[aria-label*="Good response"]', ...]definition that was never removed when the new one was added. JS object
literals silently let the second key win with no error and no lint warning
(this repo has no ESLint config anywhere), so
copyLatestAssistantMarkdownhas been querying the wrong selector since the day it was introduced,
always returning
null, and every caller silently fell back to plain.innerText()— which strips Markdown heading syntax.This is the real root cause of the recurring
"invalid_response: The delimited plan is not complete Markdown with a heading"failures inplan-authormode across this project's history,including 3 reproductions in a single live dry run today. Confirmed live
against a real open ChatGPT tab (chrome-devtools MCP):
[role="group"]elements, the last onecontaining exactly 1 real copy button;
"Good response"/"Bad response")matched zero elements in ChatGPT's current UI — doubly dead, wrong
and stale.
Fix
Delete the shadowing duplicate key. Added two regression tests:
SELECTORS.responseActionsequals the scoped group selector directly(not the stale button selector) — independent of mechanics.
SELECTORSobject literal's source text assertingno top-level key repeats — can't become vacuously self-consistent the way
the existing mock-based tests (which read
SELECTORS.responseActions[0]to build their own mocks) are.
Test plan
node --test skills/chatgpt-review/tests/*.test.mjs— 64/64 pass (62 + 2 new)🤖 Generated with Claude Code
https://claude.ai/code/session_01LwFPT465eDJqYcRa8HGNLz