channel-worker 2.5.19 → 2.5.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.5.19",
3
+ "version": "2.5.21",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {
@@ -283,7 +283,7 @@ async function run({ page, payload, log }) {
283
283
  } = payload || {};
284
284
  if (!video_url) throw new Error('No video_url provided');
285
285
 
286
- log('info', '[fb-pw] selectors version=2026.06.18c-proc-wait');
286
+ log('info', '[fb-pw] selectors version=2026.06.19b-thumb-diag');
287
287
 
288
288
  page.on('dialog', (d) => { d.accept().catch(() => {}); });
289
289
 
@@ -948,7 +948,6 @@ async function run({ page, payload, log }) {
948
948
  // iterations, throw with diagnostics.
949
949
  let published = false;
950
950
  let customThumbDone = false;
951
- let thumbWaitDone = false; // poll for the thumb-edit pill at most once
952
951
  let pubWaitDone = false; // guard: wait for a disabled "Đăng" at most once
953
952
  for (let step = 0; step < 7 && !published; step++) {
954
953
  await page.waitForTimeout(3000);
@@ -969,7 +968,9 @@ async function run({ page, payload, log }) {
969
968
  const dlgs = [];
970
969
  for (const d of allDlgs) {
971
970
  const txt = (d.innerText || '').slice(0, 400);
972
- if (/Tạo thước phim|Create reel|Create a reel/i.test(txt)) dlgs.push(d);
971
+ // Match ALL reel-composer steps: "Tạo thước phim" (video step),
972
+ // the caption/cover step, and "Cài đặt thước phim" (settings step).
973
+ if (/thước phim|create reel|create a reel|reel settings/i.test(txt)) dlgs.push(d);
973
974
  }
974
975
  if (dlgs.length === 0) return null;
975
976
  for (const dlg of dlgs) {
@@ -1001,17 +1002,18 @@ async function run({ page, payload, log }) {
1001
1002
  return null;
1002
1003
  }).catch(() => null);
1003
1004
  let editBtn = await findThumbBtn();
1004
- // The "Chỉnh sửa hình thu nhỏ" pill only appears AFTER FB finishes
1005
- // processing the uploaded video (frame extraction). For larger clips
1006
- // that lags past the 30s upload-wait, so a single check often misses it.
1007
- // Poll once (up to 75s) for it before giving up.
1008
- if (!editBtn && !thumbWaitDone) {
1009
- log('info', '[fb-pw] thumb-edit pill not visible yet waiting for video processing (up to 75s)…');
1010
- const tdl = Date.now() + 75_000;
1011
- while (!editBtn && Date.now() < tdl) { await page.waitForTimeout(4000); editBtn = await findThumbBtn(); }
1005
+ // The "Chỉnh sửa hình thu nhỏ" pill appears AFTER FB finishes processing
1006
+ // the video AND, on the Page-wall composer, only on a LATER step (the
1007
+ // cover/caption step AFTER clicking "Tiếp" from the video step) NOT on
1008
+ // the first video step. So poll briefly on THIS step; if it never shows,
1009
+ // fall through to click "Tiếp" and look again on the next step. Per-step
1010
+ // (not one-time) so the pill is caught on whichever step it renders.
1011
+ if (!editBtn) {
1012
+ log('info', '[fb-pw] thumb-edit pill not visible on this step polling up to 18s…');
1013
+ const tdl = Date.now() + 18_000;
1014
+ while (!editBtn && Date.now() < tdl) { await page.waitForTimeout(3000); editBtn = await findThumbBtn(); }
1012
1015
  if (editBtn) log('info', '[fb-pw] thumb-edit pill appeared after wait');
1013
1016
  }
1014
- thumbWaitDone = true;
1015
1017
 
1016
1018
  let thumbApplied = false;
1017
1019
  if (editBtn) {
@@ -1158,14 +1160,35 @@ async function run({ page, payload, log }) {
1158
1160
  }
1159
1161
  customThumbDone = thumbApplied;
1160
1162
  }
1161
- // The idea HAS a thumbnail it is REQUIRED. If the pill never showed
1162
- // (after the wait) or applying it failed, REFUSE to publish with FB's
1163
- // auto-thumb. Fail HERE at the caption step, BEFORE any "Tiếp"/publish
1164
- // so nothing ships and a retry can't double-post.
1163
+ // Pill not on THIS step (e.g. the video step before "Tiếp", or the
1164
+ // cover step hasn't rendered yet). Do NOT hard-fail here click "Tiếp"
1165
+ // to advance and retry the thumb flow on the next step. The pre-publish
1166
+ // check below (before clicking "Đăng") hard-fails if the thumb was never
1167
+ // applied across ANY step, so nothing ships with FB's auto-thumb and a
1168
+ // retry can't double-post.
1165
1169
  if (!customThumbDone) {
1166
- await dumpInventory(page, log, 'thumb-required-missing');
1167
- await dumpFailure(page, 'thumb-required-missing', log);
1168
- throw new Error('Custom thumbnail required but could not be applied (FB "Chỉnh sửa hình thu nhỏ" not available, or upload/save failed) — refusing to publish with FB auto-thumb');
1170
+ // DIAG: dump the reel-dialog buttons on this step so we can locate the
1171
+ // cover/thumbnail control when detection misses it (different UI variant).
1172
+ try {
1173
+ const diag = await page.evaluate(() => {
1174
+ const dlgs = [...document.querySelectorAll("[role='dialog']")]
1175
+ .filter(d => /thước phim|create reel|reel settings/i.test((d.innerText || '').slice(0, 400)));
1176
+ const out = [];
1177
+ for (const d of dlgs) {
1178
+ const hdr = (d.innerText || '').split('\n')[0].slice(0, 40);
1179
+ for (const el of d.querySelectorAll("[role='button'],button,[aria-label],img")) {
1180
+ const t = (el.innerText || '').trim().slice(0, 28);
1181
+ const al = (el.getAttribute('aria-label') || '').trim().slice(0, 40);
1182
+ const r = el.getBoundingClientRect();
1183
+ if (r.width < 10 || r.height < 10) continue;
1184
+ if (t || al) out.push(`[${hdr}] <${el.tagName.toLowerCase()}> t="${t}" al="${al}" ${Math.round(r.width)}x${Math.round(r.height)}`);
1185
+ }
1186
+ }
1187
+ return out.slice(0, 45);
1188
+ }).catch(() => []);
1189
+ log('info', `[fb-pw] thumb-diag step ${step + 1}: ${JSON.stringify(diag)}`);
1190
+ } catch { /* diag best-effort */ }
1191
+ log('info', '[fb-pw] thumb-edit pill not on this step yet — advancing via "Tiếp" to retry on the next step');
1169
1192
  }
1170
1193
  }
1171
1194