-
Notifications
You must be signed in to change notification settings - Fork 0
fix: ChatGPT 会话回合检测增加 fallback 选择器 #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
8b1a596
0437ca7
75971f6
a2f657f
4415502
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ | |
| chatgpt: { | ||
| turns: [ | ||
| "article[data-testid^='conversation-turn-']", | ||
| "[data-testid='conversation-turn']", | ||
| '[data-message-author-role]', | ||
| '[data-message-id]', | ||
| ], | ||
| turnRoleAttr: 'data-turn', | ||
|
|
@@ -556,10 +558,25 @@ function makePathEntry(turn) { | |
| } | ||
|
|
||
| function readChatGPTTurns() { | ||
| const turns = [...document.querySelectorAll('article[data-testid^="conversation-turn-"]')]; | ||
| let turns = [...document.querySelectorAll('article[data-testid^="conversation-turn-"]')]; | ||
|
|
||
| if (!turns.length) { | ||
| const fallbackSelectors = [ | ||
| "[data-testid='conversation-turn']", | ||
| '[data-message-author-role]', | ||
| 'main article', | ||
| ]; | ||
| const candidates = dedupeElements(fallbackSelectors.flatMap(sel => [...document.querySelectorAll(sel)])) | ||
| .filter(el => isReadableTurnCandidate(el, { minText: 2 })); | ||
| turns = candidates | ||
| .filter(el => !candidates.some(other => other !== el && other.contains(el))) | ||
| .sort((a, b) => rectTop(a) - rectTop(b)); | ||
| } | ||
|
|
||
| return turns.map((turn, idx) => { | ||
| const role = turn.getAttribute('data-turn') === 'user' ? 'user' : 'assistant'; | ||
| const msgDiv = turn.querySelector('[data-message-id]'); | ||
| const roleAttr = turn.getAttribute('data-turn') || turn.getAttribute('data-message-author-role') || ''; | ||
| const role = /^user$/i.test(roleAttr) ? 'user' : 'assistant'; | ||
|
Comment on lines
+577
to
+578
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Useful? React with 👍 / 👎. |
||
| const msgDiv = turn.matches('[data-message-id]') ? turn : turn.querySelector('[data-message-id]'); | ||
| const msgId = msgDiv?.getAttribute('data-message-id') || turn.getAttribute('data-turn-id') || null; | ||
| const nav = findChatGPTBranchNav(turn); | ||
| return { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The de-dup check returns as soon as any historical comment contains
pingText, so once one ping exists, all futuresynchronizeruns skipcreateComment. That makes the newly added synchronize trigger effectively inert for updated commits, because no fresh review request is posted after subsequent pushes.Useful? React with 👍 / 👎.