Skip to content

fix(xiaohongshu): prioritize visible title input over hidden scaffolding#1845

Open
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/xiaohongshu-publish-title-not-persisted
Open

fix(xiaohongshu): prioritize visible title input over hidden scaffolding#1845
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/xiaohongshu-publish-title-not-persisted

Conversation

@Benjamin-eecs
Copy link
Copy Markdown
Contributor

@Benjamin-eecs Benjamin-eecs commented Jun 3, 2026

Description

opencli xiaohongshu publish --title <text> saves the draft with an empty title even though the command reports status: ✅ 暂存成功 with the title echoed in detail. opencli xiaohongshu drafts shows the just-saved entry as (untitled), and the raw image-draft IndexedDB row has content.draftStore.title === "". Same symptom as #1840.

The cause is selector priority in TITLE_SELECTORS at clis/xiaohongshu/publish.js:34, not the typing mechanism. On the current creator-center DOM, document.querySelectorAll('input[class*="title"]') matches three visible inputs: two 4 px wide hidden scaffolding inputs (empty placeholder, register a Vue 3 IME composition handler set [onChange, onCompositionstart, onCompositionend, onInput] but never commit on save) plus the real user-facing title input (placeholder="填写标题会有更多赞哦", 499 px wide, simple [onChange, onInput, onFocus, onBlur] handler set, Vue 3 v-model). The previous order listed input[class*="title"] before the placeholder-based variants, so fillField typed into the first hidden 4 px input, its DOM .value updated, the verify phase read the same hidden input back and the command reported a false positive. The real Vue-bound input never received a keystroke, so the draft persisted with an empty title.

Move input[placeholder*="标题"] and input[placeholder*="title" i] ahead of the class-based variants in TITLE_SELECTORS. The placeholder-based selectors uniquely target the real user-facing title input across the variants currently shipped by xiaohongshu. The class-based selectors stay as fallbacks for any future variant that drops the Chinese placeholder. No typing path, locator helper, or save flow is touched.

Related issue: fixes #1840.

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

Screenshots / Output

Live verified on a logged-in creator.xiaohongshu.com session with opencli 1.8.2 + Browser Bridge v1.0.17 on macOS 26.5. The verification compares the draft content.draftStore.title written to the image-draft IndexedDB store before and after this patch:

publish.js variant drafts list title raw IDB draftStore.title
upstream/main (untitled) "" (BODY persisted correctly)
patched TITLE_REAL1780481801 "TITLE_REAL1780481801" (BODY persisted correctly)

DOM probe at fillField resolve time:

[
  { sel: 'input[class*="title"]', visible: true, rect_w: 4,   value: '', placeholder: '',                  vei_keys: [onChange, onCompositionstart, onCompositionend, onInput] },
  { sel: 'input[class*="title"]', visible: true, rect_w: 4,   value: '', placeholder: '',                  vei_keys: [onChange, onCompositionstart, onCompositionend, onInput] },
  { sel: 'input[placeholder*="标题"]', visible: true, rect_w: 500, value: '', placeholder: '填写标题会有更多赞哦', vei_keys: [onChange, onInput, onFocus, onBlur] }
]

The class-based selectors return the two 4 px hidden scaffolding inputs first; the placeholder-based selector returns the real visible input. All test drafts created during verification were deleted via opencli xiaohongshu draft-delete <id> --execute true after the run.

No code under test outside clis/xiaohongshu/publish.js was touched. cli-manifest.json is untouched (selectors are static array literals).

input[class*="title"] also matches two 4 px wide hidden inputs that have no v-model commit on save; placeholder-based selectors target the real user-facing title input so the draft saves with the typed title.

Fixes jackwener#1840
@Benjamin-eecs Benjamin-eecs force-pushed the fix/xiaohongshu-publish-title-not-persisted branch from 1c0133e to 403d225 Compare June 3, 2026 10:24
@Benjamin-eecs Benjamin-eecs marked this pull request as ready for review June 3, 2026 10:31
Copilot AI review requested due to automatic review settings June 3, 2026 10:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refines Xiaohongshu publish flow title-field detection to avoid targeting hidden/scaffolding inputs by adjusting selector priority and documenting the rationale.

Changes:

  • Reordered TITLE_SELECTORS to prefer placeholder-based <input> selectors before class-based ones.
  • Expanded inline documentation explaining UI variants and why placeholder selectors must take precedence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[xiaohongshu] publish: --title not persisted (draft saved with empty title)

2 participants