Skip to content

fix: harden agent conversion and localize fonts#14

Open
alexsssaalexsubay-afk wants to merge 2 commits into
nexu-io:mainfrom
alexsssaalexsubay-afk:fix/agent-reliability-local-fonts
Open

fix: harden agent conversion and localize fonts#14
alexsssaalexsubay-afk wants to merge 2 commits into
nexu-io:mainfrom
alexsssaalexsubay-afk:fix/agent-reliability-local-fonts

Conversation

@alexsssaalexsubay-afk
Copy link
Copy Markdown

@alexsssaalexsubay-afk alexsssaalexsubay-afk commented May 14, 2026

Summary

  • harden Codex invocation/parsing so successful newer Codex JSON output is not treated as an empty result
  • make agent subprocess proxying explicit via HTML_ANYTHING_AGENT_PROXY instead of a machine-specific default
  • add environment-based model/binary/custom-agent extension hooks
  • replace remote next/font/google usage with bundled local woff2 fonts to avoid Google Fonts network stalls
  • pass each template's shipped example.html into fresh conversion prompts as a visual fidelity reference
  • preserve successful conversion snapshots locally and expose them in a History tab so users can review and restore prior HTML results

Details

This keeps the existing curated agent/model picker, but lets users extend it without source edits:

  • HTML_ANYTHING_MODELS / HTML_ANYTHING_MODELS_<AGENT> append model options
  • HTML_ANYTHING_BINS_<AGENT> and HTML_ANYTHING_BIN_<AGENT> add or override binaries
  • HTML_ANYTHING_EXTRA_AGENTS registers wrapper CLIs that reuse an existing adapter such as codex
  • HTML_ANYTHING_AGENT_PROXY / HTML_ANYTHING_AGENT_PROXY_<AGENT> opt agent subprocesses into a proxy when needed

The proxy path is intentionally opt-in so this does not bake any local network setup into upstream defaults.

Fresh conversions now include the template folder's example HTML in the prompt with explicit instructions to reuse its visual system while replacing all sample content with the user's source. Successful runs are stored as bounded per-task result snapshots (latest 12) in the existing browser-local task store. The preview pane includes a History tab for result review, current-result indication, restore, and delete.

Validation

  • pnpm -s exec tsc --noEmit
  • pnpm build
  • git diff --check
  • smoke-tested /api/agents with env-added Codex model and a custom codex-nightly agent
  • smoke-tested /api/convert with Codex before and after the template-reference/history change: SSE emitted start, delta, meta, done; HTML markers present; no error events
  • verified / returns 200 and the rendered host HTML no longer references fonts.googleapis.com or fonts.gstatic.com

Not Tested

  • manual click-through of the new History tab in a real browser session

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Template example HTML now travels with each fresh conversion prompt so agents can reproduce the shipped visual system while replacing the sample content with the user's full source. Successful runs are snapshotted locally so prior outputs can be reviewed and restored from the service UI.

Constraint: users expect template-level fidelity and visible conversion history inside HTML Anything
Rejected: latest-output-only persistence | it overwrites useful generated artifacts and makes regressions hard to compare
Confidence: high
Scope-risk: moderate
Directive: keep result snapshots bounded to avoid unbounded localStorage growth
Tested: pnpm -s exec tsc --noEmit; pnpm build; git diff --check; local /api/convert smoke returned start/delta/meta/done with HTML and no errors
Not-tested: manual browser click-through of the history tab
Co-authored-by: OmX <omx@openai.com>
lefarcen pushed a commit that referenced this pull request May 15, 2026
* WIP feat(deploy): server-side Vercel pipeline + Settings Deploy panel

Backend + settings UI for one-click HTML deployment. PR #14-style
preview-pane button + result card + history dropdown still pending —
this commit is checkpoint material so the work survives session
boundaries.

Files in this commit:

- src/lib/deploy/config.ts          ~/.html-anything/<provider>.json
                                     token I/O with mask-on-read; chmod 600;
                                     DeployError class.
- src/lib/deploy/url-check.ts       waitForReachableDeploymentUrl + Vercel
                                     SSO-protected detection.
- src/lib/deploy/vercel.ts          POST /v13/deployments + readyState
                                     polling + URL candidates resolver.
- src/app/api/deploy/route.ts       POST /api/deploy { taskId, provider,
                                     html } → { url, status, ... }; wraps
                                     bare HTML fragments in a defensive
                                     <!DOCTYPE> envelope; 501 for non-Vercel
                                     providers (CF Pages stub).
- src/app/api/deploy/config/route.ts GET / PUT /api/deploy/config?provider=*
                                     for masked token CRUD.
- src/lib/store.ts                   v6 → v7 migration: Task.deployments[]
                                     ring (latest 5) + DeploymentRecord type
                                     + push/remove setters.
- src/lib/i18n.ts                    30+ deploy.* + settings.deploy.* keys
                                     (en + zh-CN).
- src/components/settings-modal.tsx  New "Deploy" section in Settings;
                                     Vercel token input with auto-mask
                                     read-back and Save / Clear; Cloudflare
                                     Pages "coming soon" placeholder.

Status: tsc clean. Backend smoke-tested via curl
(`POST /api/deploy/config?provider=vercel`,
 `POST /api/deploy` with bad token → DeployError 400).
End-to-end with a real Vercel token: not yet.

TODO before merging: preview-pane Publish button + DeployResultCard +
past-deployments dropdown; real-token e2e verification; CF Pages
deployer (deferred to a follow-up because of blake3-wasm dependency).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(deploy): preview-pane Publish button + result card + history ring

Wires the existing /api/deploy backend into a user-visible action. Sits
on the preview-pane toolbar next to Refresh / Present, only appears
once a Convert has produced HTML (`status === "done" && html`).

Three things in one popover-anchor block:

1. Primary "📤 Publish" pill — disabled with an i18n tooltip when no
   HTML is ready. Coral pulse + "Deploying…" label while in flight.

2. Result card — rendered immediately under the button after a
   successful deploy. Shows the live URL with Copy / Open. Three
   colored status badges:
   - green   = "Live at"        (status: ready)
   - coral   = "SSO-protected"  (status: protected — Vercel Hobby
                                  default; we surface a paragraph
                                  pointing the user at Deployment
                                  Protection settings)
   - amber   = "Waiting for CDN" (status: link-delayed)

3. History dropdown — bounded ring (latest 5 per task; v6→v7 store
   migration backfills `deployments: []`). Each row shows the URL,
   provider, timestamp, short html-fingerprint hash so the user can
   tell which version of the page each historical URL points to.
   Hover reveals Copy / Forget actions per row.

`useDeploy()` (`src/lib/use-deploy.ts`) wraps fetch + status state +
auto-persists successful deployments via `pushDeploymentFor`. The
html-hash is FNV-1a → 12 hex chars, just a fingerprint, not crypto.

Verification (macOS arm64):
- Settings → Deploy section renders with Vercel token input + Cloudflare
  Pages "Coming soon" placeholder, in both en and zh-CN.
- Deploy button hidden on idle tasks; visible after Convert completes.
- POST /api/deploy/config?provider=vercel GET/PUT with masked-token
  read-back works.
- POST /api/deploy without a configured token returns the i18n-friendly
  DeployError ("Vercel token is not configured. Open Settings → Deploy
  to add one.") — confirmed via curl.
- Real-token end-to-end deploy: not yet exercised. Maintainers with a
  Vercel API token can validate by saving it in Settings and clicking
  Publish on any completed task.

CF Pages still surfaced as "Coming soon" — the wasm-blake3 dependency
required for the asset-upload step is intentionally deferred to its own
follow-up PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: joey <joey@joeydeMacBook-Air-2.local>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lefarcen lefarcen requested a review from nettee May 15, 2026 13:13
@lefarcen lefarcen added size/XL PR size: 700-1499 changed lines risk/medium Medium risk change type/bugfix Bug fix labels May 15, 2026
@lefarcen
Copy link
Copy Markdown

Heads-up: PR #27 is also open against src/lib/agents/argv.ts and focuses narrowly on the newer Codex agent_message / turn.completed JSON shape from #23. Your PR includes a broader agent/local-font/history set, so it may be worth comparing scope with @tackcrypto1031 before review goes too far in parallel. The maintainer team will decide which path lands.

@nettee
Copy link
Copy Markdown

nettee commented May 15, 2026

@alexsssaalexsubay-afk I'm holding off on generating review comments for #14 because this pull request has merge conflicts right now.

Please resolve the conflicts with main and push the updated branch. Once that's done, request or wait for the review to run again and I'll take another look.

🔁 Powered by Looper · runner=reviewer · agent=opencode · model=openai/gpt-5.4 · An autonomous AI dev team for your GitHub repos.

@PerishCode
Copy link
Copy Markdown
Contributor

Thanks for the PR. I am not going to patch this branch directly because the scope is broad and several parts now overlap with changes already on current main.

What changed upstream:

  • The repo now uses the next/ + e2e/ workspace shape.
  • Remote next/font/google usage has already been removed on main, so the font-stall part of this PR is partly covered.
  • Tests should now live in next/ Vitest or e2e/ui/ Playwright, not root scripts.

Suggested next step:

  • Split this into smaller PRs with one behavior boundary each, for example:
    • agent env/model/bin extension hooks
    • Codex invocation/parser hardening
    • template example HTML in conversion prompts
    • result snapshot/history UI
  • Rebase each slice onto current main using next/src/... paths.
  • Add focused tests for each slice before review. The history UI in particular needs browser coverage under e2e/ui/ because the current PR body says it was not manually clicked through.

Recommended validation for each smaller PR:

  • pnpm install --frozen-lockfile
  • pnpm exec tsx scripts/guard.ts
  • pnpm -F @html-anything/next typecheck
  • pnpm -F @html-anything/next test
  • pnpm -F @html-anything/next build
  • pnpm -F @html-anything/e2e test when UI behavior changes

This should make the useful pieces much easier to review without accidentally changing unrelated agent or persistence behavior during the rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/medium Medium risk change size/XL PR size: 700-1499 changed lines type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants