refactor(db): PR 2 — rename channel_badge_counts to badge_counts#2914
Merged
iscekic merged 3 commits intofeat/kilo-chat-migration-pr1from Apr 30, 2026
Merged
refactor(db): PR 2 — rename channel_badge_counts to badge_counts#2914iscekic merged 3 commits intofeat/kilo-chat-migration-pr1from
iscekic merged 3 commits intofeat/kilo-chat-migration-pr1from
Conversation
Contributor
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (11 files)
Reviewed by gpt-5.5-2026-04-23 · 786,985 tokens |
The badge_counts.badge_bucket column is a free-form string. To prevent namespace collisions as more surfaces start emitting badge updates (per-instance today, per-conversation later), centralize bucket-key derivation in @kilocode/notifications and route NotificationChannelDO through it. Mirrors the presence-context builders in @kilocode/event-service. Safe to introduce now without a data migration because PR 2's migration already wipes badge_counts.
This was referenced Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2907 (PR 1). Part of the kilo-chat migration plan (plan).
Summary
channel_badge_counts→badge_countsand columnchannel_id→badge_bucket. The table becomes a generic per-user/per-bucket unread-count store;badge_bucketis whatever string the producer chooses (sandbox id today, conversation id later).services/notifications/src/dos/NotificationChannelDO.ts,apps/web/src/routers/user-router.ts(markChatReadinput renamedchannelId→badgeBucket;getUnreadCountsreturnsbadgeBucketinstead ofchannelId), andapps/web/src/routers/user-router.test.ts.0107_dapper_power_pack.sqlperforms the rename viaALTER TABLE … RENAMEwith PK/FK drop+re-add, thenDELETE FROM badge_countsto wipe pre-cutover Stream-keyed rows (acceptable per the plan — pre-cutover unread state has no semantic mapping forward).Notes
apps/mobile/src/components/kiloclaw/chat.tsx) are intentionally not updated — the plan ships the Stream-chat removal in PR 6 (Phase 14) and explicitly accepts these stale references in this PR.drizzle-kit pushwas skipped because the local Postgres isn't running; CI applies migrations against a real DB.Test plan
cd packages/db && pnpm typecheckcd services/notifications && pnpm typecheckcd apps/web && pnpm typecheckpnpm lintclean forapps/webandservices/notificationspnpm run format:changed(no diff)git grep -nE "channel_badge_counts|ChannelBadgeCount"returns zero hits outsidepackages/db/src/migrations/andapps/mobile/apps/webjest suite (incl.user-router.test.ts) passes against real DB