Skip to content

Let a conversation be deleted, and its thread with it - #197

Open
CristianPeralta wants to merge 1 commit into
CopilotKit:mainfrom
CristianPeralta:remove-a-conversation-and-forget-its-thread
Open

Let a conversation be deleted, and its thread with it#197
CristianPeralta wants to merge 1 commit into
CopilotKit:mainfrom
CristianPeralta:remove-a-conversation-and-forget-its-thread

Conversation

@CristianPeralta

Copy link
Copy Markdown

Closes #196.

What this changes

Adds DELETE /api/channels/:channelId. Deletes the channel row, which cascades its memberships, agent links, and Intelligence thread mapping (no migration needed, those FKs already cascade). Also asks Intelligence to permanently delete the thread.

Local delete commits first. A failed or unreachable thread delete is non-fatal: the channel is gone from the roster either way, with an audit row naming the thread and whether Intelligence actually forgot it.

Sidebar gets an options menu on each row, with a confirm dialog (new alert-dialog.tsx, wraps @base-ui/react/alert-dialog, already a dependency).

Where it runs

  • New state that outlives a request? None, this only deletes rows.
  • Second replica: the delete is one transaction; pg_notify fires inside it on commit, and every replica's own LISTEN connection fans it out to its own sockets.
  • Serialized: membership check and delete share a transaction. A second delete finds no membership, gets 404.
  • Fanned out to a browser: yes, deleted: true on the existing channel_activity topic.
  • New listener, port, schedule: none.

Boundary and audit

  • channel.deleted audit row on every delete, including a failed upstream thread delete.
  • agentId sent to Intelligence is derived server-side (channel:<id>), never accepted from the client.

Changelog

Added under Unreleased.

Proof

bun run format:check lint typecheck test all pass. Tested manually against a local stack: delete with confirm dialog, deleting the open channel redirects, two tabs stay in sync, audit row shows up.

Nothing removed a channel, so the roster only ever grew (CopilotKit#196). Adds
DELETE /api/channels/:channelId: the channel row, its memberships,
agent links, and thread mapping go through the FK cascades that
already existed for them, and the deployment asks Intelligence to
permanently delete the thread itself.

The local delete commits first. A rejected or unreachable upstream
thread delete is non-fatal and leaves the channel gone from the
roster either way, with an audit row (channel.deleted) naming the
thread and whether Intelligence actually forgot it - a channel gone
locally with an orphaned thread is a smaller, more honest failure
than one still sitting in the roster with its history silently
wiped.

Removal fans out over the existing channel_activity NOTIFY topic so
other open tabs see it live. The sidebar row gets an options menu
with a two-button confirm dialog (new alert-dialog.tsx, wrapping
@base-ui/react/alert-dialog).
@CristianPeralta

Copy link
Copy Markdown
Author

Menu, confirm dialog, and the resulting audit row:

Delete menu

Confirm dialog

Audit row

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.

Nothing removes a channel, so the roster only ever grows

1 participant