Skip to content

fix(doubao): harden ask response parsing#933

Open
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Astro-Han:fix/doubao-main-replay
Open

fix(doubao): harden ask response parsing#933
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Astro-Han:fix/doubao-main-replay

Conversation

@Astro-Han
Copy link
Copy Markdown
Contributor

Description

Harden the Doubao ask flow so homepage and sidebar chrome are no longer misread as assistant output.

Related issue:

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Documentation (if adding/modifying an adapter)

  • Added doc page under docs/adapters/ (if new adapter)
  • Updated docs/adapters/index.md table (if new adapter)
  • Updated sidebar in docs/.vitepress/config.mts (if new adapter)
  • Updated README.md / README.zh-CN.md when command discoverability changed
  • Used positional args for the command's primary subject unless a named flag is clearly better
  • Normalized expected adapter failures to CliError subclasses instead of raw Error

Screenshots / Output

Relevant checks run in this worktree:

npm test
npm run test:adapter -- clis/doubao/
./node_modules/.bin/tsc --noEmit
npm run build

Built-in adapter execution check:

[
  {
    "Role": "User",
    "Text": "测试一下,只回复OK"
  },
  {
    "Role": "System",
    "Text": "No response within 15s. Doubao may still be generating."
  }
]

@hiSandog
Copy link
Copy Markdown
Contributor

Reviewed the diff against local clis/doubao/utils.ts. The changes address the root cause of #909 comprehensively:

Key improvements verified:

  1. Composer detection hardened: buildDoubaoComposerLocatorScript centralizes 13 selectors with visibility checks and proper element type validation (HTMLTextAreaElement | HTMLInputElement | HTMLElement), replacing the inline candidate loop that could miss edge cases.

  2. Response parsing fixed: The critical change in waitForDoubaoResponse removes the simple beforeSet dedup and replaces it with collectDoubaoTranscriptAdditions, which:

    • Normalizes sanitization before comparing against beforeLines
    • Filters landing-page UI noise (快速视频生成深入研究图像生成帮我写作音乐生成更多)
    • Filters sidebar chrome (AI创作云盘更多历史对话)
    • Handles prompt contamination in multiline transcripts
  3. Verification detection: detectDoubaoVerificationScript now throws CommandExecutionError early in both sendDoubaoMessage and getCandidate, preventing silent hangs on CAPTCHA/challenge pages.

One observation: The isLikelyTranscriptUiNoise function uses raw vs sanitized comparison but the third parameter promptText isn't used in the function body (seen in the diff). If this is intentional for future use, consider adding a comment; otherwise it might be dead code.

The test coverage (11 new test cases for collectDoubaoTranscriptAdditions) validates the main filtering scenarios well.

@Astro-Han
Copy link
Copy Markdown
Contributor Author

@hiSandog Thanks for the careful review.

One quick clarification: the current adapter lives in clis/doubao/utils.js, not utils.ts.

On the promptText note, that parameter is still used in isLikelyTranscriptUiNoise() to detect prompt-contaminated transcript lines:

const normalizedPrompt = normalizeWhitespace(promptText);
if (!normalizedPrompt || !normalizedRaw.startsWith(normalizedPrompt)) return false;

So that part is still intentional in the current branch.

Thanks again for the read-through.

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