chorus/bot/chorus_bot/cogs/thread_ingest.py
pyr0ball 73fb67b3bf fix: cog re-registration, thread NotFound, follow-up date, and error/empty states
I1: move cog registration + tree.sync into ChorusBot.setup_hook (called once
before gateway connect) instead of on_ready (fires on every reconnect),
preventing duplicate cogs/listeners/poll loops after a gateway RESUME.

I2 (email_ingest.py, addressed alongside I1 for IMAP stability): none here,
handled separately.

I3/I4: TriageList.vue now renders a follow_up_date column so it actually
surfaces back to Donna. App.vue adds a "Show completed" checkbox bound to
includeDone, matching what docs/smoke-test.md step 7 already describes.

I5: add frontend/tests/ItemModal.spec.js covering stagesForType() options
for donation/other/unset types and the type-change stage reset regression.

I6: App.vue wraps loadItems/openItem in try/catch with a calm (no-panic)
error message, and shows calm empty-state copy when there are zero items.

Also fixes thread_ingest.py: standalone threads not started from a message
raise discord.NotFound on fetch_message; now caught and returns early.
2026-07-13 15:01:32 -07:00

41 lines
1.4 KiB
Python

import discord
from discord.ext import commands
from chorus_bot.ping import parse_ping_embed
class ThreadIngestCog(commands.Cog):
"""Opening a thread on an #inbox ping is what creates the real triage row."""
def __init__(self, bot: commands.Bot, config, backend_client):
self.bot = bot
self.config = config
self.backend_client = backend_client
@commands.Cog.listener()
async def on_thread_create(self, thread: discord.Thread):
if thread.parent_id != self.config.inbox_channel_id:
return
try:
parent_message = await thread.parent.fetch_message(thread.id)
except discord.NotFound:
# Standalone thread not started from a message -- nothing to ingest.
return
if not parent_message.embeds:
return
parsed = parse_ping_embed(parent_message.embeds[0])
await self.backend_client.create_item(
modality=parsed["modality"],
raw_content=parsed["raw_content"],
captured_at=parsed["captured_at"],
discord_message_id=str(thread.id),
sender_id=parsed["sender_id"],
)
await thread.send(
"Logged in Chorus — open the app to fill in details and track this one."
)
async def setup(bot: commands.Bot, config, backend_client):
await bot.add_cog(ThreadIngestCog(bot, config, backend_client))