Skip to content

fix(doubao): adapt to 2026-07 DOM refactor#2133

Open
RusianHu wants to merge 1 commit into
jackwener:mainfrom
RusianHu:fix/doubao-2026-07-dom-refactor
Open

fix(doubao): adapt to 2026-07 DOM refactor#2133
RusianHu wants to merge 1 commit into
jackwener:mainfrom
RusianHu:fix/doubao-2026-07-dom-refactor

Conversation

@RusianHu

Copy link
Copy Markdown

Problem

The doubao adapter is broken against Doubao's 2026-07 web refactor: ask, read, detail, and history all fail. The refactor removed data-testid attributes and renamed several CSS classes, so the adapter's selectors no longer match.

Symptoms on opencli v1.8.6:

  • doubao askCould not find Doubao input element (composer selector stale)
  • doubao readNo visible Doubao messages were found (message-list selector stale)
  • doubao historyNo conversation history found (sidebar selector stale)
  • doubao detailNo messages found. Verify the conversation ID. (detail script stale)

Root cause

  1. Composer: input is now a Semi Design <textarea class="semi-input-textarea"> with placeholder 发消息或按住空格说话...; data-testid="chat_input_input" was removed.
  2. Message list: container class is now list_items (previously matched via [class*="message-list-"] etc.).
  3. Sidebar: data-testid="flow_chat_sidebar" / chat_list_thread_item removed; sidebar now uses left-side-/w-sidebar-width classes, thread items are a[href*="/chat/"].
  4. Visibility check: the browser bridge operates on a 0x0/background tab where getBoundingClientRect().width === 0 for every element, so isVisible's width > 0 && height > 0 rejected everything — including the composer and message items that are nonetheless present and usable/readable.

Changes (clis/doubao/utils.js)

  • Composer selectors: prepend textarea.semi-input-textarea and textarea[placeholder*="发消息"].
  • isVisible (composer + getTurnsScript): relax width > 0. In a 0x0/background tab elements have zero width but are still present and readable; require height > 0 (composer) or drop the size check (message turns). display:none / visibility:hidden / hidden are still filtered.
  • getTurnsScript: add [class*="list_items"] to message-list selectors so messages are read via structured turns (clean) instead of falling back to the noisy transcript.
  • getTranscriptLinesScript: scope to the main chat area (sidebar's sibling) and strip header (title + disclaimer), input area (buttons), and follow-up suggestion chips, so the transcript fallback stays clean.
  • getConversationListScript (history): sidebar via [class*="left-side-"], [class*="w-sidebar-width"], thread items via a[href*="/chat/"].
  • getConversationDetail (detail): reuse getDoubaoVisibleTurns; the old data-testid-based detail script is fully stale.
  • prepareDoubaoComposerScript: include viewport/url/textarea details in the failure reason to aid future debugging.

Verification

End-to-end on opencli v1.8.6 against current doubao web (2026-07):

Command Result
doubao status ✅ Connected
doubao history ✅ lists 20 conversations
doubao detail <id> ✅ clean User/Assistant turns, no sidebar/follow-up noise
doubao read ✅ reads current conversation
doubao new ✅ creates new conversation
doubao ask "1加1等于几?请只回答数字" ✅ returns clean 2, no noise
  • Existing doubao unit tests: 32/32 pass (npx vitest run clis/doubao/)
  • npx tsc --noEmit: pass

Notes

  • The 0x0-viewport visibility issue is worth highlighting: it affects any adapter whose bridge tab is backgrounded/minimized. The relaxation here is scoped to doubao's composer + turns isVisible, so it should not affect other adapters.
  • Selector changes are additive (nothing removed) to preserve the 2026-05 fallback paths and existing unit-test fixtures.

Doubao's 2026-07 web refactor removed data-testid attributes and changed
several CSS class names, breaking the doubao adapter (ask/read/detail/
history all failed). Update selectors and relax the visibility check so
the adapter works against the current DOM.

- Composer: prepend `textarea.semi-input-textarea` and
  `textarea[placeholder*="发消息"]` (Semi Design textarea; data-testid removed)
- isVisible (composer + getTurnsScript): relax width>0. The browser bridge
  runs on a 0x0/background tab where elements have zero width but are still
  present and usable; require height>0 (composer) or drop the size check
  (message turns)
- getTurnsScript: add `[class*="list_items"]` to message-list selectors so
  messages are read via structured turns instead of the noisy transcript
- getTranscriptLinesScript: scope to the main chat area (sidebar's sibling)
  and strip header/input-area/follow-up chips so the transcript fallback
  stays clean
- getConversationListScript (history): sidebar via left-side-/w-sidebar-width,
  thread items via `a[href*="/chat/"]`
- getConversationDetail (detail): reuse getDoubaoVisibleTurns; the old
  data-testid-based detail script is fully stale
- prepareDoubaoComposerScript: include viewport/url/textarea details in the
  failure reason to aid future debugging

Verified end-to-end on opencli v1.8.6 against current doubao web:
status, history, detail, read, new, ask all pass; ask returns a clean
response with no sidebar/follow-up noise. Existing doubao unit tests
(32) and tsc --noEmit pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant