Clear the reading panel when its last message leaves
"Mark as Spam" moved the message but left it on screen. Two causes, both fixed generally rather than for this one action. `move_job` published message.changed without a thread_id, so the WS handler invalidated the message list but never the thread the user was reading — the panel had no reason to refetch. It now names the thread. And a thread whose last visible message has gone should not linger. MailLayout closes the panel when the open thread comes back empty, whoever emptied it — core action or plugin. `move_to_special` now also publishes the move immediately rather than waiting for the IMAP job, since a plugin acting on the user's behalf has no client-side handle to update optimistically the way the core endpoint's caller does. That exposed an ordering bug: the optimistic event reaches the passive-learning hook, which would re-teach the lesson /learn had just taught. /learn now records `learned` before moving, so the hook's dedup stands down — and records it with an upsert, because provider-filed spam has no verdict row of ours to update. One real mistake on the way: the event first reported the destination folder as the source, which would have made every move look like a no-op to anything reading the pair. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018SqJYt7jD7oUEkoY68sBZo
This commit is contained in:
@@ -130,6 +130,10 @@ async def move_job(
|
||||
# transition, not the destination. "Now in Spam" and "moved out of Spam"
|
||||
# are different facts, and only the pair distinguishes them.
|
||||
src_special, dst_special = src.special_use, dst.special_use
|
||||
# The open reading panel is keyed by thread: without this the UI
|
||||
# invalidates the message list but never refetches the thread the user is
|
||||
# looking at, so a moved message stays on screen.
|
||||
thread_id = message.thread_id
|
||||
|
||||
provider = build_provider(account)
|
||||
try:
|
||||
@@ -152,6 +156,7 @@ async def move_job(
|
||||
{
|
||||
"user_id": str(user_id),
|
||||
"message_id": str(mid),
|
||||
"thread_id": str(thread_id) if thread_id else None,
|
||||
"mailbox_id": str(dst_id),
|
||||
"previous_mailbox_id": src_mailbox_id,
|
||||
"special_use": dst_special,
|
||||
|
||||
Reference in New Issue
Block a user