Skip to content

promote: fix browser-post failures from captured failure DOM (reddit + dead-session detection) - #105

Merged
ralyodio merged 2 commits into
masterfrom
promote/browser-selectors
Jul 17, 2026
Merged

ralyodio merged 2 commits into
masterfrom
promote/browser-selectors

Conversation

@ralyodio

@ralyodio ralyodio commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Reads the real page HTML/URL captured on each failed sp_post (debug_html/url) and fixes against the actual DOM.

Root causes found:

  • reddit — logged in; real body editor is inside <shreddit-composer name="body">, but a HIDDEN duplicate data-lexical-editor in the flair-picker modal was matched by .first(). Fix: scope to the body composer + :visible. ✅
  • instagram — cookies DEAD (redirects to /accounts/emailsignup). ⚠️ re-export cookies.
  • threads — dead/blocked session (served a ~40-char shell). ⚠️ re-export cookies.
  • facebook — logged in ('(3) Facebook') but composer was past the 600KB capture truncation.

Code changes: reddit editor scoping; assertLoggedIn now waits for networkidle + flags empty shells so dead sessions report SESSION_EXPIRED (account flagged token_expired, UI prompts reconnect) instead of opaque timeouts; captureDom grabs <body> not the whole doc so FB's huge head stops truncating the composer; plus instagram file-input waits attached-not-visible and facebook drops the greedy [aria-label*=create].

tsc (app+worker) clean; live behavior only confirmable by re-running with valid sessions.

…gram)

Best-effort fixes for the browser-automation posting failures now surfacing
correctly after the #103 reconciliation fix. Each targets the exact element the
Playwright error resolved to:

- instagram: file input is display:none — wait for state:'attached', not
  'visible' (a hidden input never becomes visible → the reported timeout).
- reddit: scope the lexical body editor to :visible — a hidden editor template
  otherwise won .first() and never became visible.
- facebook: drop the `[aria-label*="create"]` fallback (it substring-matched
  "…why you created moshcoding" on a hidden element); match the composer by
  button text instead; scope the editor to :visible.
- threads: broaden the compose trigger (labels + "What's new?") and scope the
  editor to :visible.

CAVEAT: these are UNVERIFIED — browser automation of live social sites can't be
tested without the account's cookie session + a browser, and the sites change
their DOM frequently. The durable fix is connecting reddit/facebook/threads via
OAuth (the API adapters in lib/sp/post.ts already post reliably and return a
real URL); Instagram has no post API so it stays browser-only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

Pulled the real page HTML/URL from the failed sp_post rows (debug_html/url) and
fixed against the actual DOM instead of guessing:

- reddit: the real body editor is inside <shreddit-composer name="body">; Reddit
  ALSO renders a hidden duplicate data-lexical-editor in the flair-picker modal
  (<r-post-flair-edit-modal>, slot="editor") which .first() kept grabbing → the
  "resolved to hidden" timeout. Scope to the body composer + :visible.
- assertLoggedIn: wait for networkidle before judging (Instagram/Threads redirect
  to login CLIENT-SIDE after domcontentloaded, so the old immediate URL check
  missed dead sessions) and flag a near-empty shell as a login wall. Dead
  sessions now fail with SESSION_EXPIRED → account marked token_expired → the UI
  prompts a cookie reconnect instead of an opaque selector timeout.
- captureDom: capture <body> outerHTML, not the whole document — FB's multi-MB
  <head> was eating the 600k budget and truncating before the composer, making
  FB failures undiagnosable.

Diagnosis from the captured DOM (NOT code-fixable — user action):
- instagram cookies are DEAD (redirects to /accounts/emailsignup) → re-export.
- threads session dead/blocked (served a ~40-char shell) → re-export.
- facebook IS logged in ("(3) Facebook") but its composer was past the old
  truncation; the wider capture + #105 selector tweaks should surface next run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ralyodio ralyodio changed the title promote: repair browser-post selectors (reddit/facebook/threads/instagram) promote: fix browser-post failures from captured failure DOM (reddit + dead-session detection) Jul 17, 2026
@ralyodio
ralyodio merged commit cf26603 into master Jul 17, 2026
8 checks passed
ralyodio added a commit that referenced this pull request Jul 30, 2026
Pulled the real page HTML/URL from the failed sp_post rows (debug_html/url) and
fixed against the actual DOM instead of guessing:

- reddit: the real body editor is inside <shreddit-composer name="body">; Reddit
  ALSO renders a hidden duplicate data-lexical-editor in the flair-picker modal
  (<r-post-flair-edit-modal>, slot="editor") which .first() kept grabbing → the
  "resolved to hidden" timeout. Scope to the body composer + :visible.
- assertLoggedIn: wait for networkidle before judging (Instagram/Threads redirect
  to login CLIENT-SIDE after domcontentloaded, so the old immediate URL check
  missed dead sessions) and flag a near-empty shell as a login wall. Dead
  sessions now fail with SESSION_EXPIRED → account marked token_expired → the UI
  prompts a cookie reconnect instead of an opaque selector timeout.
- captureDom: capture <body> outerHTML, not the whole document — FB's multi-MB
  <head> was eating the 600k budget and truncating before the composer, making
  FB failures undiagnosable.

Diagnosis from the captured DOM (NOT code-fixable — user action):
- instagram cookies are DEAD (redirects to /accounts/emailsignup) → re-export.
- threads session dead/blocked (served a ~40-char shell) → re-export.
- facebook IS logged in ("(3) Facebook") but its composer was past the old
  truncation; the wider capture + #105 selector tweaks should surface next run.

Co-Authored-By: Claude Opus 4.8 <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