Skip to content

Исправить удаление выполненных позиций списка покупок - #857

Open
dankarization wants to merge 6 commits into
AlexxIT:masterfrom
dankarization:fix/shopping-list-remove-chunks
Open

dankarization wants to merge 6 commits into
AlexxIT:masterfrom
dankarization:fix/shopping-list-remove-chunks

Conversation

@dankarization

Copy link
Copy Markdown

Проблема

Синхронизация списка покупок (media_content_type=shopping_list, media_content_id=update) отправляет Алисе одну команду «Удали» сразу с несколькими индексами. Сейчас это до 5 индексов за раз.

Если отметить выполненными больше 4–5 позиций и запустить обновление, колонка отвечает «не найдено» и ничего не удаляет. Список после повторного опроса не меняется, цикл снова видит те же индексы и отправляет ту же команду. Повтор не заканчивается.

Пачка из 5 индексов не удаляет ничего, потому что Алиса отклоняет такое удаление и отвечает «не найдено». Следующий запрос списка возвращает те же позиции, условие цикла остаётся истинным, и та же команда уходит снова.

Ранее это обсуждалось в #405.

Что изменено

  • Живой путь update режет удаление до отправки, а не после ошибки. Первая команда содержит не больше 3 индексов: это ниже наблюдённого сбоя на пачке больше 4–5.
  • Если чанк отклонён и список не изменился, та же команда не повторяется. Синхронизация при этом не останавливается: пробуется меньший чанк, вплоть до одной позиции.
  • Одиночно отклонённая позиция пропускается и не зацикливает колонку. Завершённые флаги остальных позиций, которые Алиса ещё может снять, не сбрасываются.
  • Позиции needs_action к удалению не выбираются.
  • Тот же отказ на пути todo больше не обрывает всю синхронизацию: чанк тоже уменьшается до одной позиции.

Как проверено

  • Автотесты tests/test_shopping_sync.py: 13 ok.
  • Живой Home Assistant 2026.10.2 и Yandex.Station 3.22.3, скрипт обновления списка покупок (shopping_list / update).
  • До: 26 completed и 42 needs_action.
  • Ушли 9 команд, все не больше 3 индексов (последняя из 2), без «не найдено» и без повтора той же команды.
  • После: completed 0, needs_action 42, ни одна незавершённая позиция не пропала.

Chunk completed removals before sending and stop when the same delete
leaves the list unchanged, so a "not found" reply cannot loop. Keep HA
completed flags for items Alice did not actually remove.
Start below the observed 4-5 item failure, and if Alice rejects a chunk
without changing the list, try a smaller chunk instead of ending the sync.
A single rejected item is skipped so the rest can still be removed.
@AlexxIT AlexxIT added the ai label Nov 17, 2026
@AlexxIT

AlexxIT commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Идея понятна, но такой нейрослоп я точно не прийму.

@AlexxIT AlexxIT self-assigned this Nov 17, 2026
@AlexxIT AlexxIT added the doubt label Nov 17, 2026
@dankarization

Copy link
Copy Markdown
Author

Займусь очисткой.

Abort on unreadable or incomplete list snapshots instead of reusing stale indexes. Fall back only after a confirmed refusal and a fresh unchanged list; report partial removals while preserving completed flags. Remove the successful-iteration cap and unrelated selector and ID changes. Replace standalone module stubs with scoped pytest regressions.
Exercise the status-only SUCCESS response observed on the live local protocol. It must abort both sync paths without stale-index deletes or saving an unreadable list.
Station sendText now acknowledges without vinsResponse, so the local card
path cannot see Alice's list. Notes RPC is a different empty store.
Reuse the existing cookie session to ask the assistant for the numbered
text, keep Glagol for add/delete, and still abort if that text is missing.
Glagol indexes follow the speaker. A cloud/assistant snapshot can be a
different order or account, so using it to build "Удали N" can remove an
active item. Abort again when the station returns no card, and cover the
reordered-list case. Leave any new transport out of this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants