Skip to content

fix: resolve Chrome profile and T2I extra-image generation bugs - #219

Closed
C1ph3r404 wants to merge 1 commit into
ffroliva:developfrom
C1ph3r404:develop
Closed

C1ph3r404 wants to merge 1 commit into
ffroliva:developfrom
C1ph3r404:develop

Conversation

@C1ph3r404

Copy link
Copy Markdown
Contributor

Summary

  1. Fix Playwright chrome channel validation in browser_manager.py:

    • is_chrome_available() was returning True for system Chromium, causing Playwright to request channel="chrome" which expects real Google Chrome.
    • Replaced with a strict check against Playwright's actual expected Chrome paths so it falls back to bundled Chromium correctly.
  2. Fix image generation settings selector in ui_automation.py:

    • GEN_SETTINGS_BUTTON_SELECTORS lacked the aria-haspopup='menu' attribute and missed the crop_original icon.
    • Without it, the selector failed to find the panel after switching to image mode, leaving Flow's default generation count (2) active while the CLI only expected 1.
  3. Warn on silent extra image generation in client.py:

    • If Flow generates more images than requested (e.g. 2 instead of 1 due to the settings panel miss), _drive_image_generation silently discarded the extras.
    • A warning is now logged showing the extra media IDs, alerting users to the extra credit consumption while preserving the single-image API contract.

1. Fix Playwright chrome channel validation in `browser_manager.py`:
   - `is_chrome_available()` was returning True for system Chromium, causing Playwright to request `channel="chrome"` which expects real Google Chrome.
   - Replaced with a strict check against Playwright's actual expected Chrome paths so it falls back to bundled Chromium correctly.

2. Fix image generation settings selector in `ui_automation.py`:
   - `GEN_SETTINGS_BUTTON_SELECTORS` lacked the `aria-haspopup='menu'` attribute and missed the `crop_original` icon.
   - Without it, the selector failed to find the panel after switching to image mode, leaving Flow's default generation count (2) active while the CLI only expected 1.

3. Warn on silent extra image generation in `client.py`:
   - If Flow generates more images than requested (e.g. 2 instead of 1 due to the settings panel miss), `_drive_image_generation` silently discarded the extras.
   - A warning is now logged showing the extra media IDs, alerting users to the extra credit consumption while preserving the single-image API contract.
@C1ph3r404
C1ph3r404 requested a review from ffroliva as a code owner June 29, 2026 06:03
@github-actions github-actions Bot added external-contribution Pull request from a non-maintainer or fork needs-copilot-review Ask GitHub Copilot for advisory code review needs-maintainer-review Requires maintainer review before merge labels Jun 29, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the contribution. This PR has been marked as an external contribution and routed for maintainer review.

Before merge, please make sure:

  • The PR targets develop.
  • Commits use a real Git identity or GitHub noreply email.
  • External commits include a DCO sign-off: git commit -s.
  • The PR does not include secrets, cookies, account tokens, signed URLs, or private captured data.
  • Focused tests/docs are included for behavior changes.

GitHub Copilot code review may be requested as an advisory first pass, but maintainer approval is still required.

@ffroliva ffroliva left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for this @C1ph3r404 — both root causes are real and your fixes are correct. We ran a multi-dimensional council review and the three changes hold up:

  • channel_for_profile() gating on a Playwright-specific Chrome check correctly fixes the Chromium distribution 'chrome' is not found at /opt/google/chrome/chrome failure on Chromium-only hosts — is_chrome_available() was too permissive there.
  • Requiring button[aria-haspopup='menu'] on the gen-settings selector fixes the mis-click that skipped the count panel and let Flow bill its own default count.
  • The generate_image_extra_returned warning is a good observability add.

Council verdict: 🟡 YELLOW — correctness is sound; a few things to address before it can land:

  1. CHANGELOG — the [Unreleased] section is empty; add a ### Fixed block for the three bugfixes.
  2. DRY the selector — GEN_SETTINGS_BUTTON_SELECTORS is now byte-identical to MODE_SWITCH_TRIGGER_SELECTORS (same button). Alias it (GEN_SETTINGS_BUTTON_SELECTORS = MODE_SWITCH_TRIGGER_SELECTORS) so the two call sites stay a single source of truth.
  3. Narrow the Linux probe — _is_playwright_chrome_channel_available() should check only /opt/google/chrome/chrome on Linux. The extra /usr/bin/google-chrome / /usr/bin/google-chrome-stable entries would report the channel as available on hosts where Playwright's channel="chrome" still can't resolve it — re-triggering the very error this PR fixes.
  4. Tests — add unit coverage for (a) the generate_image_extra_returned warning firing when 2 images are returned, and (b) _is_playwright_chrome_channel_available() returning False on a Chromium-only host.

Two notes for context:

  • This PR is behind develop (it predates the merged #225/#224), so it currently shows mergeable: unknown and needs a rebase.
  • It is not the fix for #222 — that turned out to be a --password-store=basic login/generation asymmetry, resolved separately in #225. This PR fixes a distinct Chromium-only channel bug + the T2I over-generation bug.

We've co-landed your work in #226 (rebased on current develop, with the four items above applied) and live-verified the T2I path on a real-Chrome host — the gen-settings panel is now found, count locks to 1, and no extra image is generated. You're credited as co-author on that commit. We took this route because the fix needs verification on a host with Google Chrome proper, which a Chromium-only environment can't do. Closing this in favor of #226 once it merges — but huge thanks for the diagnosis and the fix. 🙏

ffroliva added a commit that referenced this pull request Jun 29, 2026
fix(browser,image): co-land #219 — Chromium-only channel gate + T2I extra-image guard
@ffroliva

Copy link
Copy Markdown
Owner

Co-landed as #226 (now merged into develop) — rebased on current develop, all four council must-fixes applied, and live-verified on a real-Chrome host (gen-settings panel found, count locks to 1, no extra image generated). You're credited as co-author on the landing commit. Thank you again for the diagnosis and the fix, @C1ph3r404 — closing this in favor of #226. 🙏

@ffroliva ffroliva closed this Jun 29, 2026
C1ph3r404 added a commit to C1ph3r404/gflow-cli that referenced this pull request Jun 30, 2026
…ge guard (ffroliva#219)

Co-lands PR ffroliva#219 (Chrome profile + T2I extra-image bugs) with the council's
required must-fixes folded in.

Changes:
- browser_manager: add `_is_playwright_chrome_channel_available()` probing only
  the exact Google-Chrome paths Playwright hardcodes; `channel_for_profile()`
  gates `channel="chrome"` on it instead of `is_chrome_available()` (which also
  accepts Chromium). Fixes the misleading "Chromium distribution 'chrome' is not
  found at /opt/google/chrome/chrome" on Chromium-only hosts. Linux probe is
  limited to `/opt/google/chrome/chrome` only (must-fix ffroliva#3 — the over-broad
  `/usr/bin/google-chrome*` paths would re-trigger the very error fixed here).
- ui_automation: `GEN_SETTINGS_BUTTON_SELECTORS` aliased to
  `MODE_SWITCH_TRIGGER_SELECTORS` (must-fix #2 — single source of truth); both
  require `button[aria-haspopup='menu']`, preventing a mis-click that skipped
  the count panel and left Flow's default count (≈2) billing extra generations.
- client: `generate_image()` logs `client.generate_image_extra_returned` when
  the transport returns more images than the requested count=1.
- CHANGELOG: add [Unreleased] ### Fixed block (must-fix #1).
- tests: extra-image warning fires on 2 images (+ negative case);
  `_is_playwright_chrome_channel_available()` Chromium-only → False (must-fix ffroliva#4).

Co-Authored-By: C1ph3r404 <C1ph3r404@users.noreply.github.com>
@ffroliva ffroliva mentioned this pull request Jul 1, 2026
15990166686ll-crypto pushed a commit to 15990166686ll-crypto/gflow-cli that referenced this pull request Aug 24, 2026
…ge guard (ffroliva#219)

Co-lands PR ffroliva#219 (Chrome profile + T2I extra-image bugs) with the council's
required must-fixes folded in.

Changes:
- browser_manager: add `_is_playwright_chrome_channel_available()` probing only
  the exact Google-Chrome paths Playwright hardcodes; `channel_for_profile()`
  gates `channel="chrome"` on it instead of `is_chrome_available()` (which also
  accepts Chromium). Fixes the misleading "Chromium distribution 'chrome' is not
  found at /opt/google/chrome/chrome" on Chromium-only hosts. Linux probe is
  limited to `/opt/google/chrome/chrome` only (must-fix ffroliva#3 — the over-broad
  `/usr/bin/google-chrome*` paths would re-trigger the very error fixed here).
- ui_automation: `GEN_SETTINGS_BUTTON_SELECTORS` aliased to
  `MODE_SWITCH_TRIGGER_SELECTORS` (must-fix ffroliva#2 — single source of truth); both
  require `button[aria-haspopup='menu']`, preventing a mis-click that skipped
  the count panel and left Flow's default count (≈2) billing extra generations.
- client: `generate_image()` logs `client.generate_image_extra_returned` when
  the transport returns more images than the requested count=1.
- CHANGELOG: add [Unreleased] ### Fixed block (must-fix ffroliva#1).
- tests: extra-image warning fires on 2 images (+ negative case);
  `_is_playwright_chrome_channel_available()` Chromium-only → False (must-fix ffroliva#4).

Co-Authored-By: C1ph3r404 <C1ph3r404@users.noreply.github.com>
15990166686ll-crypto pushed a commit to 15990166686ll-crypto/gflow-cli that referenced this pull request Aug 24, 2026
fix(browser,image): co-land ffroliva#219 — Chromium-only channel gate + T2I extra-image guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution Pull request from a non-maintainer or fork needs-copilot-review Ask GitHub Copilot for advisory code review needs-maintainer-review Requires maintainer review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants