Skip to content

feat(bot): drive episode upload dialog via dialog-engine#29

Merged
k0te1ch merged 6 commits into
mainfrom
feat/dialog-engine
Jun 6, 2026
Merged

feat(bot): drive episode upload dialog via dialog-engine#29
k0te1ch merged 6 commits into
mainfrom
feat/dialog-engine

Conversation

@k0te1ch

@k0te1ch k0te1ch commented Jun 5, 2026

Copy link
Copy Markdown
Owner

What

Migrates the episode upload conversation from the hand-rolled aiogram
UploadFile StatesGroup to the dialog-engine
library.

The three-step flow is unchanged for the user — pick episode type → send the
MP3 → send the metadata template — but step order, validation and answer
storage now live in the library instead of being spread across handler code.
The handlers keep doing all the Telegram-side work (download, tagging, upload).

How

  • forms/upload_file.py now defines a dialog-engine schema (the three steps,
    the episode-type choice, the file/text validators) instead of a StatesGroup.
  • utils/dialog.py is a thin adapter that stores the DialogSession as
    serialised data inside FSMContext, so an in-progress upload still survives a
    restart (same as the old FSM state did, Redis-backed in prod).
  • filters/dialog_filters.py adds OnStep(...) / InDialog() filters that
    route messages by the session's current step, replacing StateFilter.
  • Handlers read collected answers from the session and advance it through the
    engine; the per-step side effects are untouched.

type_episode was only read inside podcast_handler itself (the FTP/WordPress/
Boosty handlers get it from the sidecar metadata), so moving where it's stored
is safe.

Dependency

dialog-engine is pulled from GitHub for now; it'll switch to a PyPI version
constraint once it's published. Lockfile updated accordingly.

Tests

  • Rewrote the five podcast_handler tests against the session model.
  • Added tests for the schema (tests/unit/forms), the FSM adapter
    (tests/unit/utils/dialog) and the routing filters (tests/unit/filters).
  • Full suite: 160 passed; ruff lint + format clean.

Holding for a prod smoke test before merge.

k0te1ch added 6 commits June 5, 2026 16:53
Replace the aiogram UploadFile StatesGroup with the dialog-engine library.
The three-step flow (episode type, MP3, metadata template) is now described
as an engine schema; step order, validation and answer storage live in the
library, while the handlers keep doing the Telegram-side work.

Progress is stored as a serialised DialogSession in FSMContext, so a running
upload still survives restarts. Routing moves from StateFilter to OnStep /
InDialog filters backed by the session. dialog-engine is pulled from GitHub
until it ships on PyPI.
Poetry's bundled dulwich client cannot install the dialog-engine git
dependency ("No module named dulwich.worktree"). Switch the bot env install
to the system git binary in CI and the Docker build, and add git to the
Docker base image.
Recent Poetry uses dulwich's new WorkTree API (module dulwich.worktree,
dulwich>=0.24) for git dependencies; an older dulwich on the runner/base
image breaks installing dialog-engine. Pin it when installing Poetry in CI
and the Docker build. Replaces the earlier system-git-client attempt, which
did not take effect.
The dev group pulls poetry-plugin-up, which drags in an old poetry and
dulwich<0.22. With virtualenvs.create false that dulwich overwrites Poetry's
own client during install and breaks fetching the dialog-engine git
dependency ("No module named dulwich.worktree"). Move pytest-cov to the
testing group and install only that group in CI. Reverts the earlier
dulwich/system-git-client workarounds; the Docker build only installs the
main group, so it was never affected.
--with adds optional groups but non-optional groups (dev) still install by
default, so the dev group's poetry-plugin-up kept dragging in dulwich<0.22
and breaking the dialog-engine git install. --only restricts the install to
exactly main + testing.
The main protection ruleset requires a status check named 'test', but the
single-value matrix made the job report as 'test (3.12)', leaving the
requirement permanently unmet. Drop the matrix so the context matches.
@k0te1ch k0te1ch merged commit d1d11cf into main Jun 6, 2026
5 checks passed
@k0te1ch k0te1ch deleted the feat/dialog-engine branch June 6, 2026 03:58
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