fix(app): channel sync keeps a new channel's empty fields out on retry, orders saves, drops stale lookups

- A rate-limited edit of a newly registered channel is retried with the
  same "never clear Discord with an empty field" rule (it was retried as
  an existing channel and cleared the topic).
- Channel edits go one at a time, and Discord's form of the name is
  written back only while the settings still hold the name that was sent,
  so a slow answer to an earlier save never overwrites a later one.
- The chat channel screen drops a Discord name/topic lookup that answers
  after the ID was changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 19:49:47 +09:00
parent 0d9c6ec984
commit d4bd4acfe9
3 changed files with 80 additions and 22 deletions

View File

@@ -215,12 +215,14 @@ start it first, so nothing answers before the brain can, and stop it last.
keeps its Discord name and topic in step with its `name` and `description`:
- Registering a channel fills empty name and description with the channel's Discord name and topic
(`discord_channel_info`).
(`discord_channel_info`); an answer that arrives after the ID was changed is dropped.
- `settings_apply` with `chatChannels` first refuses a description over Discord's topic limit
(1,024 characters) of a syncing channel, saving nothing. After saving, each syncing channel that
is new, or whose name or description changed, is compared with Discord and edited where they
differ (a new channel never clears a Discord name or topic with an empty field). Discord's form of
the name (spaces become `-`) is written back to the settings so the screen shows it. The results
differ (a new channel never clears a Discord name or topic with an empty field, also when its edit
is retried later). Edits go one at a time, so a later save waits for an earlier one and Discord
ends with the later. Discord's form of the name (spaces become `-`) is written back to the
settings so the screen shows it, only while the settings still hold the name that was sent. The results
come back in `sync` (`applied` with the name, `pending` with the wait, `failed` with the reason)
and stay readable with `channel_sync_status`.
- Discord allows about two name or topic edits per channel in ten minutes. A refused edit is
@@ -327,8 +329,9 @@ UTF-8 read on to the end; the window data folder (data folder, or a scratch fold
the TTS speed reaching the worker's arguments; chat channel names and topics (only new or edited
syncing channels sent, the topic limit refused before saving, Discord's form of the name written
back, a missing permission failing with the reason and the text kept, a rate-limited edit pending
and retried once with the latest text, a new channel never clearing Discord, unchanged ones not
edited; through `settings_apply` too); a background start that is starting at once, so a stop right after it cancels it
and retried once with the latest text, a new channel never clearing Discord (also on its retry), a
slow first save never overwriting a later one, unchanged ones not edited; through `settings_apply`
too); a background start that is starting at once, so a stop right after it cancels it
and a second start is refused, also through the admin commands; a failed stop reported as failed; the brain's
config loaded without writing to the home folder, `tests/test_config_db_path.py`); the dashboard from made-up events (captions replaced and cleared, latency stages
and medians, an answer matched to its asker's final, missed requests without text); the admin