Skip to content

fix: apply header rules in order and open settings on the options page - #157

Merged
Kirrrusha merged 4 commits into
mainfrom
fix/update-request-with-tab-windows
Nov 2, 2026
Merged

Kirrrusha merged 4 commits into
mainfrom
fix/update-request-with-tab-windows

Conversation

@Kirrrusha

@Kirrrusha Kirrrusha commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Исправляет Windows-специфичную гонку, когда при переключении вкладок и редактировании заголовков могли применяться устаревшие значения (старый снапшот из storage), перезаписывая актуальную конфигурацию.

Changes

  • Атомарное обновление DNR-правил: применяем declarativeNetRequest.updateDynamicRules({ removeRuleIds, addRules }) одним вызовом, чтобы избежать гонки remove→add.
  • Сериализация применения в background: добавлена очередь (single-flight), которая склеивает параллельные триггеры и гарантирует "latest wins".
  • Строгая версия конфигурации: сохраняем headersConfigMetaV1 (seq, монотонный updatedAt) и в background пропускаем устаревшие снапшоты, даже если события приходят не по порядку.
  • Убрано лишнее применение на смене вкладки: DNR-правила глобальные, поэтому пересборка на tabs.onActivated только увеличивала вероятность гонок.
  • Убран legacy reload-путь: удалены updateOverrideHeaders/runtime reload message; обновления теперь идут через storage.onChanged.

Why this works

На Windows из-за другой латентности и планирования событий чаще происходили перекрывающиеся триггеры применения правил. Версионирование + очередь не позволяют применить старую конфигурацию "после" новой.

Test plan

  • pnpm test:unit
  • Ручная проверка (Windows):
    • Менять значения заголовков в popup и быстро переключать вкладки (несколько раз).
    • Проверить, что запросы уходят с последними значениями заголовков.
    • В логах background убедиться, что устаревшие снапшоты пропускаются (Apply skipped (stale meta)), а применения идут последовательно.

Notes

  • seq — best-effort при конкурентных записях; updatedAt принудительно монотонный и используется как tie-breaker.

Summary

Ветка пересобрана поверх актуального main. Конфликты со скриншотами и UI после миграции на @cloud-ru/ds разрешены, история схлопнута в четыре коммита. Временное отключение e2e в workflow не перенесено.

Исправляет гонку, когда при переключении вкладок и редактировании заголовков применялся устаревший снапшот из storage и перезаписывал актуальную конфигурацию.

Последний коммит — страница настроек из cursor/settings-log-download-a9c1, вместе с эталонами скриншотов из CI. Chrome и Firefox регистрируют options_ui с options.html и open_in_tab. Шестерёнка рядом с иконкой GitHub вызывает browser.runtime.openOptionsPage(). В настройках: тема, скачивание логов расширения и профиля, версия Cloudhood.

Commits

  1. fix: version header config and apply DNR rules in order — монотонная headersConfigMetaV1, очередь в background, повтор временных ошибок DNR и запасной путь через session rules.
  2. fix: reconcile DNR rules when the service worker restarts — применение правил на старте worker, чтобы выключенные заголовки не оставались активными после его перезапуска.
  3. fix: keep disabled headers off when dynamic rules stick — ранняя очистка stale dynamic rules, counteracting session rules с priority 2, сериализация обновлений и предупреждение в popup, если Chrome не применил правило.
  4. feat: open extension settings on the browser options page — настройки и скачивание логов из cursor/settings-log-download-a9c1, плюс эталоны скриншотов страницы настроек из CI. Для скриншота с несколькими URL-фильтрами допуск 400 пикселей. Сброс курсора применения, если meta удалили из storage. Зависший вызов badge API в Firefox больше не блокирует следующие обновления заголовков.

Test plan

  • pnpm test:unit — 132 теста
  • На том же дереве в PR feat: open extension settings on the browser options page #183 уже проходили lint, typecheck и функциональные e2e Chrome/Firefox
  • Скриншоты настроек заменены на фактические кадры из CI и лежат в коммите настроек
Open in Web Open in Cursor 

@Kirrrusha
Kirrrusha requested a review from AndreyTheWeb as a code owner August 5, 2026 12:58
github-actions Bot pushed a commit that referenced this pull request Aug 5, 2026
github-actions Bot pushed a commit that referenced this pull request Aug 5, 2026
@Kirrrusha
Kirrrusha force-pushed the fix/update-request-with-tab-windows branch from 9882193 to 8751d6c Compare August 5, 2026 13:26
github-actions Bot pushed a commit that referenced this pull request Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

PR tester build for 5f71a53 has been published:

Artifact folder: https://github.com/cloud-ru-tech/cloudhood/tree/artifacts/pull-requests/157

Commit: 5f71a536d98340ef920e794b2ae8c2130d1554de

Comment thread src/entities/dnr-health/model.ts Resolved
github-actions Bot pushed a commit that referenced this pull request Aug 6, 2026
@cursor
cursor Bot force-pushed the fix/update-request-with-tab-windows branch from a208d36 to 4560a49 Compare September 9, 2026 06:52
github-actions Bot pushed a commit that referenced this pull request Sep 9, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 9, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 9, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 9, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 9, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 9, 2026
Kirill Lebedenko and others added 3 commits November 2, 2026 18:14
Store a monotonic headers config meta and run background applies through a single-flight queue so an older storage snapshot cannot overwrite a newer one. Retry transient declarativeNetRequest failures and fall back to session rules when dynamic updates fail.

Co-authored-by: Kirill Lebedenko <kirilllebedenko@gmail.com>
Apply stored headers on service worker startup so disabled headers are not left active after Chrome kills the worker. Restart tests drive the same apply path through a storage fingerprint change.

Co-authored-by: Kirill Lebedenko <kirilllebedenko@gmail.com>
Clear stale dynamic rules as soon as the worker boots, give counteracting session rules priority over stuck dynamic rules, and serialize rule updates. Show a warning in the popup when Chrome reports that a header was not applied.

Co-authored-by: Kirill Lebedenko <kirilllebedenko@gmail.com>
@cursor
cursor Bot force-pushed the fix/update-request-with-tab-windows branch from eaa0432 to e44707e Compare November 2, 2026 18:15
@cursor cursor Bot changed the title Fix/update request with tab windows fix: apply header rules in order and open settings on the options page Nov 2, 2026
@cursor
cursor Bot force-pushed the fix/update-request-with-tab-windows branch from a7abb5b to 6340cf5 Compare November 2, 2026 18:28
github-actions Bot pushed a commit that referenced this pull request Nov 2, 2026
@cursor
cursor Bot force-pushed the fix/update-request-with-tab-windows branch from ba489da to 8f0fe32 Compare November 2, 2026 18:47
github-actions Bot pushed a commit that referenced this pull request Nov 2, 2026
@cursor
cursor Bot force-pushed the fix/update-request-with-tab-windows branch from 8f0fe32 to 5f71a53 Compare November 2, 2026 19:17
github-actions Bot pushed a commit that referenced this pull request Nov 2, 2026
@Kirrrusha
Kirrrusha merged commit f9b91fa into main Nov 2, 2026
16 checks passed
@Kirrrusha
Kirrrusha deleted the fix/update-request-with-tab-windows branch November 2, 2026 19:43
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.

2 participants