Skip to content

Step 2: real Playwright integration for fetch-page-title#3

Merged
rockfordlhotka merged 1 commit intomainfrom
step-2-playwright
Apr 21, 2026
Merged

Step 2: real Playwright integration for fetch-page-title#3
rockfordlhotka merged 1 commit intomainfrom
step-2-playwright

Conversation

@rockfordlhotka
Copy link
Copy Markdown
Member

Summary

Replaces the HttpClient + regex implementation of fetch-page-title with a real Chromium navigation through Foragent.Browser. Milestone 2 from the project spec (§9.1).

  • Foragent.Browser becomes a real library: IBrowserSession + IBrowserSessionFactory (public contracts) backed by PlaywrightBrowserHost (IHostedService owning one shared Chromium per process) and PlaywrightBrowserSessionFactory (fresh IBrowserContext per session, spec §3.5). AddForagentBrowser() extension wires the lot.
  • ForagentTaskHandler no longer takes HttpClient; it pulls an IBrowserSession from the factory and disposes it after use. Public A2A contract unchanged.
  • Unit tests in Foragent.Agent.Tests use a StubBrowserSessionFactory — no Chromium. Integration tests in Foragent.Browser.Tests exercise the real factory against an in-process Kestrel host serving canned pages (plain title, missing title, HTML entities, JS-rendered title, redirects, 404, session isolation). Chromium is installed on demand into ~/.cache/ms-playwright.
  • InternalsVisibleTo("Foragent.Browser.Tests") on Foragent.Browser so integration tests drive the real factory/session without promoting implementation types to public.
  • Dockerfile uses mcr.microsoft.com/dotnet/aspnet:10.0 (the Playwright v1.50.0-noble image ships only .NET 8) and installs Chromium + OS deps at image-build time via dotnet exec --runtimeconfig Foragent.Agent.runtimeconfig.json Microsoft.Playwright.dll install chromium --with-deps. Dropped the /app named volume that was masking the fresh image contents.
  • docs/framework-feedback.md appended with step-2 observations.

Test plan

  • dotnet build --configuration Release — clean, 0 warnings
  • dotnet test — 15/15 pass (7 unit tests + 7 Playwright integration tests + 1 placeholder)
  • docker compose build foragent succeeds
  • Foragent container starts, logs Launching Playwright Chromium + Chromium launched (version 133.x)
  • POST http://localhost:5210/ with fetch-page-title against https://example.com returns Example Domain end-to-end (HTTP → auth → bus → handler → Playwright navigation → reply back through bus → HTTP response)

Known limitations (carried to later milestones)

  • Still requires the incoming message text to be a bare URL (spec §5.3 LLM-assisted intent translation is future work).
  • EchoChatClient still present — Foragent v2 still doesn't do LLM reasoning.
  • Playwright NuGet version and Dockerfile base-image tag must stay in sync manually. Flagged as framework feedback.

🤖 Generated with Claude Code

Replaces the HttpClient + regex implementation with a Playwright Chromium
navigation through Foragent.Browser. Milestone 2 from the project spec (§9.1).

- Foragent.Browser becomes a real library: IBrowserSession + IBrowserSessionFactory
  (public contracts) backed by PlaywrightBrowserHost (IHostedService owning
  one shared Chromium per process) and PlaywrightBrowserSessionFactory (fresh
  IBrowserContext per session per spec §3.5). AddForagentBrowser() extension
  wires the lot.
- ForagentTaskHandler no longer takes HttpClient; it pulls an IBrowserSession
  from the factory, disposes it after use. Handler contract to A2A is unchanged.
- Unit tests in Foragent.Agent.Tests use a StubBrowserSessionFactory — no
  Chromium spin-up. Integration tests in Foragent.Browser.Tests exercise the
  real PlaywrightBrowserSessionFactory against an in-process Kestrel host
  serving canned pages (plain title, missing title, HTML entities, JS-rendered
  title, redirects, 404, session isolation). Tests install Chromium on demand.
- InternalsVisibleTo("Foragent.Browser.Tests") on Foragent.Browser so tests
  drive the real factory/session without promoting those types to public.
- Dockerfile switches to aspnet:10.0 base (Playwright's own v1.50.0-noble
  image ships only .NET 8) and installs Chromium + system deps at image-build
  time via `dotnet exec --runtimeconfig ... Microsoft.Playwright.dll install
  chromium --with-deps`. Dropped the /app named volume that was masking the
  new image contents.
- framework-feedback.md appended with step-2 observations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rockfordlhotka rockfordlhotka merged commit 96fb594 into main Apr 21, 2026
1 check passed
@rockfordlhotka rockfordlhotka deleted the step-2-playwright branch April 21, 2026 18:31
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