Built-in agent: robust UI copy edits (logo/top-left, replace A with B) + prompt page-text map #6

Merged
leora merged 2 commits from fix/copy-edits into main 2026-10-08 20:50:31 +08:00
Owner

Fixes the live bug where 'replace agent market to new internet on the top left corner' did nothing useful (the built-in agent answered because the free quota is used up).

Root cause

  1. The built-in parser only understood logo|site name|brand to X, with no 'replace A with B', no 'top left/header' and no find-and-replace.
  2. Font names were matched as substrings, so "New Internet" matched the Inter font and the reply was "Done: Inter font". Same class of bug: "subtitle" matched the headline rule, so 'set the subtitle to X' changed both headline and subtitle.
  3. Unrecognised 'replace ... with ...' text containing words like "sell" fell through to the listing form or search.
  4. Model path: the prompt listed copy.logo but never said the logo is the top-left brand text, and didn't show the current page text, so a model couldn't match 'agent market' to the logo.

Fix

  • New market/copyedit.py, which runs before presets and style rules:
    • Handles replace/change/rename/swap/... A to/with/into/for B, 'LOC should say B', 'call the site B', 'use B as the LOC' and 'LOC: B'.
    • Understands locations (top left, header, logo, brand, site name, title, headline, subtitle/tagline, footer), quoted or unquoted text, and trailing 'on the top left corner'.
    • Generic find-and-replace: an exact whole-slot match first, then a unique substring match. Covers logo, headline, subtitle, footer, chip labels (emoji and action kept) and bullets, and uses the visitor's current text.
    • Case: B is kept as typed. All-lowercase input takes the replaced text's style.
    • When unsure (ambiguous, not found, typo), it says what it understood and offers the closest slot, with no set_theme and no listings.
  • Font names are word-bounded and need font context. The chip event: sell survives sanitising.
  • Prompt: added a slot map (copy.logo = TOP-LEFT brand text etc.), a replace rule and an example, plus PAGE_TEXT with the visitor's current copy.

Tests

  • New tests/test_copyedit.py 52/52. It covers the user's exact phrase plus 18 logo variants, headline/subtitle/footer/chip/bullet edits, ambiguity/typo/not-found replies, no hijacking of look/search/sell commands, the defaults staying in sync with App.tsx, and the prompt content.
  • llm_proxy_check 11/11: new mock-model check that the prompt lets a model map 'top left' to copy.logo.
  • browser_e2e 16/16 (exact phrase changes #logoText, then reset), e2e_http 24/24, theme_check 25/25, fake_model_browser 10/10, test_theme 19/19.
  • Staging ran on the mock model only.
Fixes the live bug where 'replace agent market to new internet on the top left corner' did nothing useful (the built-in agent answered because the free quota is used up). **Root cause** 1. The built-in parser only understood `logo|site name|brand to X`, with no 'replace A with B', no 'top left/header' and no find-and-replace. 2. Font names were matched as substrings, so "New **Inter**net" matched the Inter font and the reply was "Done: Inter font". Same class of bug: "sub**title**" matched the headline rule, so 'set the subtitle to X' changed both headline and subtitle. 3. Unrecognised 'replace ... with ...' text containing words like "sell" fell through to the listing form or search. 4. Model path: the prompt listed `copy.logo` but never said the logo is the top-left brand text, and didn't show the current page text, so a model couldn't match 'agent market' to the logo. **Fix** - New `market/copyedit.py`, which runs before presets and style rules: - Handles replace/change/rename/swap/... A to/with/into/for B, 'LOC should say B', 'call the site B', 'use B as the LOC' and 'LOC: B'. - Understands locations (top left, header, logo, brand, site name, title, headline, subtitle/tagline, footer), quoted or unquoted text, and trailing 'on the top left corner'. - Generic find-and-replace: an exact whole-slot match first, then a unique substring match. Covers logo, headline, subtitle, footer, chip labels (emoji and action kept) and bullets, and uses the visitor's current text. - Case: B is kept as typed. All-lowercase input takes the replaced text's style. - When unsure (ambiguous, not found, typo), it says what it understood and offers the closest slot, with no set_theme and no listings. - Font names are word-bounded and need font context. The chip `event: sell` survives sanitising. - Prompt: added a slot map (copy.logo = TOP-LEFT brand text etc.), a replace rule and an example, plus `PAGE_TEXT` with the visitor's current copy. **Tests** - New tests/test_copyedit.py 52/52. It covers the user's exact phrase plus 18 logo variants, headline/subtitle/footer/chip/bullet edits, ambiguity/typo/not-found replies, no hijacking of look/search/sell commands, the defaults staying in sync with App.tsx, and the prompt content. - llm_proxy_check 11/11: new mock-model check that the prompt lets a model map 'top left' to copy.logo. - browser_e2e 16/16 (exact phrase changes #logoText, then reset), e2e_http 24/24, theme_check 25/25, fake_model_browser 10/10, test_theme 19/19. - Staging ran on the mock model only.
leora added 2 commits 2026-10-08 20:50:28 +08:00
leora added 1 commit 2026-10-08 20:50:29 +08:00
leora merged commit aacd2b789e into main 2026-10-08 20:50:31 +08:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leora/agent-market#6
No description provided.