Skip to content

feat: chat auto-archive owner digest notifications#24643

Merged
johnstcn merged 13 commits into
mainfrom
cj/chat-archive-notifications
Apr 28, 2026
Merged

feat: chat auto-archive owner digest notifications#24643
johnstcn merged 13 commits into
mainfrom
cj/chat-archive-notifications

Conversation

@johnstcn

@johnstcn johnstcn commented Apr 22, 2026

Copy link
Copy Markdown
Member

Depends on #24642

Adds per-owner digest notifications onto the chat auto-archive subsystem.

Each tick's archived rows are grouped by owner, the top 25 titles per owner are rendered into a new Chats Auto-Archived notification template, and any remainder surfaces as and N more. Each digest is per-tick, so users with large amounts of purgeable data may get multiple notifications in sequence (one per user per tick).

The template body branches on retention_days: when retention is disabled (retention_days=0), users are told archived chats are kept indefinitely rather than falsely claiming imminent deletion.

Changes

  • migration 000XXX_chat_auto_archive_notification_template adds new notification template
  • dbpurge: threads notifications.Enqueuer through New; and enqueues notification message.
  • cli/server.go: passes options.NotificationsEnqueuer into dbpurge.New.
  • coderd/notifications/events.go: new TemplateChatAutoArchiveDigest UUID.
  • coderd/inboxnotifications.go: inbox registration.
  • Docs: adds a Notifications section to chat-auto-archive.md.

🤖

@github-actions

Copy link
Copy Markdown

Docs preview

📖 View docs preview

@johnstcn johnstcn force-pushed the cj/chat-archive-core branch 2 times, most recently from 4583b50 to 641ee3a Compare April 23, 2026 08:16
@johnstcn johnstcn force-pushed the cj/chat-archive-notifications branch from 5ef1213 to d18e271 Compare April 23, 2026 08:29
@johnstcn johnstcn changed the title feat(coderd): chat auto-archive owner digest notifications feat: chat auto-archive owner digest notifications Apr 23, 2026
@johnstcn johnstcn force-pushed the cj/chat-archive-core branch 7 times, most recently from 81ffa45 to e1e03ba Compare April 23, 2026 17:41
@johnstcn johnstcn force-pushed the cj/chat-archive-notifications branch 4 times, most recently from 2110a30 to d18e271 Compare April 23, 2026 19:04
@johnstcn johnstcn force-pushed the cj/chat-archive-core branch from d0cc93d to ddbfe37 Compare April 23, 2026 19:52
@johnstcn johnstcn force-pushed the cj/chat-archive-notifications branch 3 times, most recently from 52454f0 to 967880f Compare April 24, 2026 10:06
johnstcn added a commit that referenced this pull request Apr 24, 2026
Adds a background job in `dbpurge` that periodically archives chats
inactive beyond a configurable threshold. Each archived root chat gets a
background audit entry tagged `chat_auto_archive`. Disabled by default.

* New `AutoArchiveInactiveChats` SQL query with LATERAL last-activity
subquery and partial index on archive candidates
* `site_configs`-backed `auto_archive_days` setting with admin-only PUT,
any-authenticated-user GET
* Cascade archive via `root_chat_id`; pinned chats and active threads
exempt
* Root-only audit dispatch on detached context, matching manual archive
(`patchChat`) behavior
* 11 subtests covering disabled no-op, boundary, deleted messages, child
activity, pinned exemption, multi-owner, idempotency, and batch
pagination

PR #24643 adds per-owner digest notifications.
PR #24704 adds the requisite UI controls.

> 🤖
Base automatically changed from cj/chat-archive-core to main April 24, 2026 13:18
@johnstcn johnstcn force-pushed the cj/chat-archive-notifications branch 2 times, most recently from d6e9113 to 65bac27 Compare April 24, 2026 15:08
Layers per-owner digest notifications onto the chat auto-archive
subsystem introduced in #24642.

Each tick's archived rows are grouped by owner, the top 25 titles
per owner are rendered into a new 'Chats Auto-Archived' notification
template, and any remainder surfaces as 'and N more'. Duplicate
same-day digests collapse via the notifier's existing dedupe hash.

The template body branches on retention_days: when retention is
disabled (retention_days=0), users are told archived chats are kept
indefinitely rather than falsely claiming imminent deletion.

Adds one test subtest for the digest overflow cap, plus digest
assertions to the existing archive subtests from #24642. Two
notification test fixtures (standard and retention-zero) lock the
two template branches into goldens.

Depends on #24642. Migration 000476 adds the notification template
row; 000475 (in the core PR) already created the candidate index.
@johnstcn johnstcn force-pushed the cj/chat-archive-notifications branch from 65bac27 to 05d96ca Compare April 24, 2026 15:16
@johnstcn johnstcn marked this pull request as ready for review April 27, 2026 10:15
@johnstcn

Copy link
Copy Markdown
Member Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-engineered feature. The dual-context shutdown design, the deterministic blockingEnqueuer test, the self-review commit that filled three categories of gaps before requesting review, and the thorough golden-file coverage across all template branches are all quality work.

Severity count: 1 P2 (body), 8 P3, 4 Nit, 1 Note.

The P2 is a stale claim in the PR description: it says dedupe collapses same-day digests, but the code comments and BatchSizePagination test confirm the opposite. Four reviewers independently flagged the template grammar bug (singular "chat was" when overflow reveals multiple chats). The most actionable P3s are the missing config-field test assertions and the CTA linking to the active-chats view instead of archived.

P2 [DEREM-4]: PR description stale dedupe claim. The description says "Duplicate same-day digests collapse via the notifier's existing dedupe hash." The code comments at dbpurge.go:384 say the opposite: "notification_messages dedupe will not collapse these, because each tick's payload carries a different title list." The BatchSizePagination test explicitly asserts two separate digests for the same owner across ticks. The initial commit carried this claim; the self-review commit corrected the code comments but left the description untouched. Please update the PR description to match the corrected understanding. (Mafu-san)

Ging-Go found no Go idiom issues. Pariston's differential diagnosis confirmed the problem-solution alignment: framing #1 (missing notification) is the right one, and the stateless per-tick model is a reasonable first implementation.

"A user who clicks 'View chats' expecting to see their archived conversations sees their active ones instead and has to find the archived filter." (Luffy)

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/database/migrations/000480_chat_auto_archive_notification_template.up.sql Outdated
Comment thread coderd/database/dbpurge/dbpurge_test.go
Comment thread coderd/database/dbpurge/dbpurge.go Outdated
Comment thread coderd/database/dbpurge/dbpurge.go
Comment thread coderd/database/dbpurge/dbpurge.go
Comment thread coderd/database/dbpurge/dbpurge_test.go
Comment thread coderd/database/dbpurge/dbpurge.go Outdated
Comment thread docs/ai-coder/agents/platform-controls/chat-auto-archive.md Outdated
Comment thread coderd/database/dbpurge/dbpurge.go
@johnstcn

Copy link
Copy Markdown
Member Author

P2 [DEREM-4]: PR description stale dedupe claim. The description says "Duplicate same-day digests collapse via the notifier's existing dedupe hash." The code comments at dbpurge.go:384 say the opposite: "notification_messages dedupe will not collapse these, because each tick's payload carries a different title list." The BatchSizePagination test explicitly asserts two separate digests for the same owner across ticks. The initial commit carried this claim; the self-review commit corrected the code comments but left the description untouched. Please update the PR description to match the corrected understanding. (Mafu-san)

PR description updated.

@johnstcn

Copy link
Copy Markdown
Member Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 15 R1 findings addressed. The DEREM-7 fix (both chat config reads skip together on error) is stronger than what was suggested. The DEREM-2 fix chose a pragmatically different approach: since singular-with-overflow is unreachable under the current cap, the golden was updated to a realistic shape rather than patching a dead template branch. DEREM-11's sorted owner iteration now uses slice.Ascending matching the repo idiom.

R2 findings: 2 P3, 3 Nit. The two P3s are a garbled comment and a missing golden test for the singular template branch. The three Nits are cleanup from fix commits.

Meruem verified the structural correctness of the two-context split, concurrency safety of buildDigestData, and the sorted owner iteration. No interleaving issues found.

"This test suite is a little treasure chest." (Bisky)

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/database/dbpurge/dbpurge.go Outdated
Comment thread coderd/notifications/notifications_test.go
Comment thread site/src/testHelpers/entities.ts
Comment thread coderd/database/dbpurge/dbpurge_test.go
Comment thread coderd/database/dbpurge/dbpurge_test.go Outdated
Comment thread coderd/database/dbpurge/dbpurge.go Outdated
Comment thread coderd/database/dbpurge/dbpurge.go
Comment thread coderd/database/dbpurge/dbpurge.go Outdated
@johnstcn johnstcn merged commit 70d6efa into main Apr 28, 2026
31 checks passed
@johnstcn johnstcn deleted the cj/chat-archive-notifications branch April 28, 2026 07:56
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants