Skip to content

fix(youtube): isolate publish browser scripts#26

Closed
mylukin wants to merge 1 commit into
mainfrom
fix/youtube-publish-adapter-only
Closed

fix(youtube): isolate publish browser scripts#26
mylukin wants to merge 1 commit into
mainfrom
fix/youtube-publish-adapter-only

Conversation

@mylukin

@mylukin mylukin commented May 15, 2026

Copy link
Copy Markdown

做了什么

  • 新 PR,替代旧 PR fix(youtube): scope browser eval args #25 的重修方案;旧 fix(youtube): scope browser eval args #25 曾经改过共享 BasePage.evaluateWithArgs(),本 PR 不沿用那条路线。
  • 修复 opencli youtube publish 在浏览器上下文连续执行 radio 选择脚本时可能触发的变量作用域/重复声明问题。
  • 修复范围只收在 YouTube publish adapter:通过 adapter 内局部 IIFE/局部命名隔离脚本变量,不改共享浏览器层。

和旧 PR #25 的关系

  • 这是新的干净 PR,从 origin/main 新分支创建,只保留 YouTube adapter 内修复。
  • 旧 PR fix(youtube): scope browser eval args #25 的全局 BasePage.evaluateWithArgs() 方案不作为本 PR 方案;旧 PASS 结论不适用。
  • 请按本 PR current head 和 changed files 重新 review。

Changed files

  • clis/youtube/publish.js
  • clis/youtube/publish.test.js

Acceptance Criteria

  • src/browser/base-page.* 无 diff,不改共享浏览器执行语义。
  • YouTube publish 修复只在 clis/youtube/publish.js 内。
  • opencli youtube publish ... --privacy unlisted --format json 的参数协议不变。
  • 非 YouTube read-only 链路不依赖本修复;失败面仍应返回可诊断错误,不允许空 body 被前端吞成 Unexpected end of JSON input

测试方法

  • npm run test:adapter -- clis/youtube/publish.test.js clis/youtube
  • npx vitest run --project unit src/browser/base-page.test.ts
  • npm run build
  • git diff --check

未做

  • 未改 Social Hub 参数协议。
  • 未改 node20 全局 opencli symlink / binary。
  • 未跑真实 YouTube live publish;真实发布会创建外部 unlisted 视频,需要单独授权。

Co-Authored-By: Cody <builder.bot@easymeta.au>
@mylukin

mylukin commented May 15, 2026

Copy link
Copy Markdown
Author

Trent(特伦特) 新 PR 已按 Luke 要求从 origin/main 干净分支重开,替代旧 PR #25 的 rework 口径。

请按 PR #26 current head review:

  • PR: fix(youtube): isolate publish browser scripts #26
  • Head: 61b89945
  • Changed files: clis/youtube/publish.js, clis/youtube/publish.test.js
  • src/browser/base-page.* 无 diff
  • 验证:YouTube adapter 42 tests ✅;BasePage unit 39 tests ✅;build ✅;diff check ✅

旧 PR #25 先不合,避免新旧口径混淆。

@mylukin mylukin mentioned this pull request May 15, 2026
5 tasks

@mylukin mylukin left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Code Review PASS(按新 PR #26 / current head 61b89945570978c9eb6feecfdc35583af441145e 审)。

对抗性检查:

  • ✅ 边界侵入:这是干净新 PR,effective diff 只有 clis/youtube/publish.js / clis/youtube/publish.test.js;没有 src/browser/base-page.* diff,没有继续改共享 BasePage.evaluateWithArgs() 语义。
  • ✅ 影响面:修复只收在 YouTube publish adapter 内;未改 Social Hub、未改 node20 全局 opencli、未碰 Twitter/X / XHS / TikTok read-only adapter。
  • ✅ 静默失败:仍沿用现有 classifyPlatformFailure / throwPublishFailure 结构化错误路径,没有新增吞错或空 body 行为。
  • ✅ 输入注入:browserLiteral() 基于 JSON.stringify 注入 title/description/radio labels/privacy,并额外转义 <,足够覆盖当前 adapter 内参数字面量场景。

AC 复核:

  • ✅ 新 PR 关系清楚:#26 是 adapter-only 新分支,#25 已标 superseded,避免旧 PR 历史 diff 混淆。
  • BasePage 全局语义不变:git diff --name-only origin/main...HEAD 只剩 2 个 YouTube 文件。
  • ✅ YouTube publish 局部修复:publish flow 不再依赖 evaluateWithArgs 注入参数,避免 browser 顶层 const redeclare 污染。
  • ✅ 测试覆盖:publish.test.js 显式让 publish flow 调用 evaluateWithArgs 即失败,并检查 browser script 可 parse。

我复跑:

  • npm run build
  • npm run test:adapter -- clis/youtube/publish.test.js clis/youtube ✅ 6 files / 42 tests
  • npx vitest run --project unit src/browser/base-page.test.ts ✅ 39 tests
  • git diff --check origin/main...HEAD

结论:代码层 PASS。注意当前 GitHub 仍是 UNSTABLE,部分 CI queued/in-progress;合并前仍按项目门禁等 CI,或拿 Luke 明确一次性授权跳过 pending CI。

— Trent 🏛️

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