Skip to content

feat(masters): add --add-sitelink/--remove-sitelink to masters update - #800

Closed
axisrow wants to merge 2 commits into
mainfrom
ao/direct-cli-84/masters-648-sitelinks
Closed

feat(masters): add --add-sitelink/--remove-sitelink to masters update#800
axisrow wants to merge 2 commits into
mainfrom
ao/direct-cli-84/masters-648-sitelinks

Conversation

@axisrow

@axisrow axisrow commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

Implements быстрые ссылки (sitelinks) support in direct masters update — part of issue #648's Этап C (structural sections: sitelinks, audience, Metrika counters/goals). This is a browser-driven feature (Мастер кампаний has no API), following the same add/remove-by-position pattern already established for --add-audience-tag/--remove-audience-tag (#681), adapted for sitelinks' 3-field card structure (Title/Href/Description) instead of a plain text tag.

  • --add-sitelink "Title|Href|Description" — pipe-delimited, adds a new card via the "Добавить" button.
  • --remove-sitelink POSITION — removes a card by its 0-based on-page position.
  • _read_sitelinks/_add_sitelink/_remove_sitelink in direct_cli/browser/masters.py, wired into update_master (snapshot-before + high-to-low removal, mirroring the audience-tags convention) and _verify_saved (multiset check on (Title, Href)Description is not bulk-readable, see below).

⚠️ NOT LIVE-VERIFIED

Testid structure was confirmed via two live read-only recon passes against campaign 713277109 (Playwright + mcp claude-in-chrome, no mutations saved) — but the actual add/remove/save behavior has not been exercised end to end against a real Yandex session. Specifically open questions:

  1. How the inline SitelinkRow.* edit form closes/commits — no dedicated "Готово"/save testid appeared in recon. The code presses Escape then clicks the section container as a best-effort dismiss, relying on update_master's own re-read (_verify_saved) as the real proof of success rather than trusting the close action itself.
  2. contenteditable vs plain <textarea> for SitelinkRow.name/href/description.textarea — conservatively assumed contenteditable (same class as headline/text slots), reusing _clear_text_field + .type(). If it turns out to be a plain textarea, this degrades to a harmless no-op equivalent, not a functional bug.
  3. Whether "Добавить" opens a new card with the SitelinkRow.* triple immediately available — assumed by analogy with every other "click Добавить, fill, commit" flow in this module (target actions, audience tags), never itself clicked in recon.
  4. The real maximum sitelink count_SITELINKS_SLOT_COUNT = 5 comes from UI copy ("добавить до 5 штук"), not from actually adding a 5th sitelink past the 4 the recon campaign already had.

None of this is claimed as working in the docstrings/CLI help — see the module comment above _SITELINKS_EDITOR_TESTID in direct_cli/browser/masters.py for the full recon writeup. A live mutation-verification pass is planned as a follow-up (browser session currently queued for other in-flight work) before this is considered safe to rely on in production.

Test plan

  • pytest tests/test_masters.py -k "sitelink or Sitelink" — 28 passed
  • Full offline suite pytest -n auto — 3405 passed, 23 skipped, no regressions
  • black/flake8 clean on all changed files
  • Live verification (add, remove, save-persists) — pending, tracked as a follow-up before this is relied upon

Relates to #648 (no dedicated sub-issue for this specific section).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FF5MKQjSX89UpwHfFG3uBe

axisrow and others added 2 commits August 7, 2026 00:03
…e` (#648)

Implements the "Быстрые ссылки" (sitelinks) section for Мастер кампаний,
following the point-position pattern already used for audience tags:

- Browser layer (direct_cli/browser/masters.py): _read_sitelinks,
  _add_sitelink, _remove_sitelink, plus testid constants and a
  Counter-based multiset verification in _verify_saved mirroring the
  audience-tags check.
- CLI layer (direct_cli/commands/masters.py): --add-sitelink
  "Title|Href|Description" and --remove-sitelink <position> on
  `masters update`, with _parse_add_sitelink_options/
  _parse_remove_sitelink_options helpers.
- Tests (tests/test_masters.py): unit coverage for the readers/mutators,
  verification, CLI parsers, and CLI wiring.

Based on two live, read-only recon passes (2026-08-06, campaign
713277109) that confirmed the section/card/row testids but NOT how the
inline edit form closes/commits, whether its fields are plain textareas
or contenteditable divs, or the real max sitelink count -- all documented
inline as NOT LIVE-VERIFIED, with the contenteditable path assumed
conservatively (reusing _clear_text_field).

Closes #648 (Этап C sitelinks slice).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FF5MKQjSX89UpwHfFG3uBe
@axisrow

axisrow commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Закрываю и переоткрою для форсирования нового CI-прогона — GitHub Actions застрял в queued больше 1.5 часа с рассинхроном Checks/Actions API, новые пуши (пустые коммиты) не триггерят новый pull_request synchronize event.

@axisrow

axisrow commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Закрываю окончательно и пересоздаю как новый PR — CI застрял без единого нового workflow run уже несколько часов, включая после push и close/reopen. Новый PR должен получить чистый webhook-цикл.

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