refactor(channel-db): drop dead sourceId column and move UI to Global Settings#3091
Conversation
|
Claude finished @Yeraze's task —— View job Code Review Complete ✅Reviewing PR #3091 - refactor to drop unused sourceId column from channel_database and move UI to Global Settings. Review Checklist:
Review SummaryThis is a well-executed refactor that properly removes dead code and aligns UI with runtime behavior. The implementation is thorough and follows the codebase's multi-database patterns correctly. ✅ StrengthsMigration Quality
Code Consistency
UI Relocation Logic
Test Coverage
🔍 Key Architectural InsightsGlobal Channel Database is Correct Design
Proper Implementation Details
🟡 Minor ObservationsDocumentation Gaps
Security & Performance
✅ ConclusionThis refactor correctly removes technical debt by eliminating the unused Recommendation: Approve - This is a clean, well-tested refactor that improves code clarity and removes dead weight. --- | Branch: |
… Settings The channel_database.sourceId column added by migration 021 was never wired up. Repository reads ignored it, HTTP routes never passed it on create, and channelDecryptionService pooled every enabled row into a single global cache consumed by every source. After PR 3089, MQTT also decrypts against that same global cache, making the per-source illusion even more misleading. Migration 063 drops the column across SQLite/PostgreSQL/MySQL (idempotent). Schema, types, repository, and tests are stripped of the field. Unified channels/messages routes drop the `vc.sourceId === source.id` filter so virtual channels are surfaced under every source (their actual semantics). The ChannelDatabaseSection UI moves from the per-source Meshtastic Device Configuration menu to the Global Settings menu, matching runtime behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nc call PR 3089's bootstrapMqttChannelDatabase passed sourceId as a second argument to channel_database.createAsync. With the channel database now global, the parameter is gone and the auto-seeded LongFast row is owned by no source. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
23fea93 to
ddefe90
Compare
|
Claude finished @Yeraze's task —— View job Code Review Complete ✅Reviewing PR #3091 - refactor to drop unused sourceId column from channel_database and move UI to Global Settings. Review Checklist:
Review SummaryThis is a well-executed refactor that properly removes dead code and aligns UI with runtime behavior. The implementation is thorough and follows the codebase's multi-database patterns correctly. ✅ StrengthsMigration Quality
Code Consistency
UI Relocation Logic
Test Coverage
🔍 Key Architectural InsightsGlobal Channel Database is Correct Design
Proper Implementation Details
🟡 Minor ObservationsDocumentation Gaps
Security & Performance
✅ ConclusionThis refactor correctly removes technical debt by eliminating the unused Recommendation: Approve - This is a clean, well-tested refactor that improves code clarity and removes dead weight. --- | Branch: |
…up pass server.ts boots a routine that backfills NULL sourceId rows on every data table. Migration 063 removed sourceId from channel_database, so the runtime UPDATE now produces a noisy 'no such column' warning on every boot. The caught-error branch swallows the failure but it's cruft — channel_database is global and doesn't belong in the per-source backfill list. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job Code Review Complete ✅Reviewing PR #3091 - refactor to drop unused sourceId column from channel_database and move UI to Global Settings. Review Checklist:
Review SummaryThis is a well-executed refactor that properly removes dead code and aligns UI with runtime behavior. The implementation is thorough and follows the codebase's multi-database patterns correctly. ✅ StrengthsMigration Quality
Code Consistency
UI Relocation Logic
Test Coverage
🔍 Key Architectural InsightsGlobal Channel Database is Correct Design
Proper Implementation Details
🟡 Minor ObservationsDocumentation Gaps
Security & Performance
✅ ConclusionThis refactor correctly removes technical debt by eliminating the unused Recommendation: Approve - This is a clean, well-tested refactor that improves code clarity and removes dead weight. --- | Branch: |
… save The editor used to detect a 1-byte PSK (e.g. AQ== → 0x01 → "default key") and replace it with the expanded 16-byte LongFast key before sending the update. To the user this looked like the system was silently rewriting their key. The MQTT bootstrap already stores AQ== as-is, and channelDecryptionService.refreshChannelCache calls expandShorthandPsk at cache build time, so the round-trip works end-to-end without UI expansion. Validation kept: 0 / 16 / 32 byte lengths accepted, byte 0 still rejected as "no crypto". The local expandShorthandPsk / uint8ArrayToBase64 helpers and the MESHTASTIC_DEFAULT_KEY constant are dead now and removed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job Code Review Complete ✅Reviewing PR #3091 - refactor to drop unused sourceId column from channel_database and move UI to Global Settings. Review Checklist:
Review SummaryThis is a well-executed refactor that properly removes dead code and aligns UI with runtime behavior. The implementation is thorough and follows the codebase's multi-database patterns correctly. ✅ StrengthsMigration Quality
Code Consistency
UI Relocation Logic
Test Coverage
🔍 Key Architectural InsightsGlobal Channel Database is Correct Design
Proper Implementation Details
🟡 Minor ObservationsDocumentation Gaps
Security & Performance
✅ ConclusionThis refactor correctly removes technical debt by eliminating the unused Recommendation: Approve - This is a clean, well-tested refactor that improves code clarity and removes dead weight. --- | Branch: |
Patch release covering the MQTT-ingest rework (#3089) and follow-on UX fixes (#3093 channel display-name, #3091 Channel Database move to Global) plus the usual dependency bumps and minor fixes. Version bumps across all five canonical files: package.json, package-lock.json (regenerated), helm/meshmonitor/Chart.yaml, desktop/package.json, desktop/src-tauri/tauri.conf.json. CHANGELOG: organized under [4.6.2] with the user-visible MQTT/channel items called out as the headline changes. CLAUDE.md: - Migration count 62+ → 63+ (latest: 063_drop_source_id_from_channel_database) - "Every row carries a sourceId" rule gains an exception note for channel_database — it's intentionally global (decryption service tries every enabled row regardless of source) and migration 063 dropped the dead sourceId column. Blog post + news.json: "MeshMonitor v4.6.2 — MQTT in the Unified views & cleaner channel names" — three things users will notice immediately (slot-0 channel renamed from "Primary" to the modem-preset label, Channel Database moved to Global Settings, MQTT sources now participate in Unified Messages and Unified Telemetry) plus action items after upgrade. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
The
channel_database.sourceIdcolumn added by migration 021 was never wired up:ChannelDatabaseRepositoryreads (getAllAsync,getEnabledAsync,getByIdAsync) never filtered bysourceId.channelDatabaseRoutes.ts,v1/channelDatabase.ts) never passedsourceIdtocreateAsync, so every API-created row landed withsourceId = NULL.channelDecryptionServiceis a singleton with one flat cache populated fromgetEnabledAsync()— the union of every enabled row.Permissions (
channel_database_permissions) are already keyed only on(userId × channelDatabaseId)with no source dimension, so dropping the column is consistent with the existing permission model.What's in here
Migration 063 (
063_drop_source_id_from_channel_database.ts)Drops the column across SQLite (
ALTER TABLE DROP COLUMN), PostgreSQL (DROP COLUMN IF EXISTS), and MySQL (information_schema guard + drop). Idempotent.Schema / repository / types
src/db/schema/channelDatabase.ts: dropsourceIdfrom all three dialect tables.src/db/repositories/channelDatabase.ts: dropsourceIdarg oncreateAsyncand the field onmapToDbChannelDatabase.src/db/types.ts: dropsourceIdfromDbChannelDatabase.src/db/repositories/channelDatabase.test.ts: dropsourceIdfrom the SQLite/PG/MySQL test schemas.Unified routes
src/server/routes/unifiedRoutes.ts: drop thevc.sourceId === source.idfilters in both/channelsand/messages. Virtual channels are global — every readable channel-db entry is surfaced under every source the user can read. Comments updated. The matching test was rewritten to assert the new global semantics.MQTT bootstrap (post-rebase reconcile with #3089)
src/server/mqttIngestion.ts:bootstrapMqttChannelDatabaseno longer passessourceIdtocreateAsync. The auto-seeded LongFast row is unowned, matching the global model.Frontend — UI relocation
src/components/ConfigurationTab.tsx: drop theChannelDatabaseSectionimport, theconfig-channel-databasemenu entry, and its render block. The now-unuseduseAuthimport was removed too.src/components/SettingsTab.tsx: importChannelDatabaseSection, add'settings-channel-database'toGLOBAL_SECTIONS, register an admin-gated menu entry between System Backup and Database Maintenance, and mount the section. The device-specificrebroadcastModeprop is dropped; the component already handlesundefinedby hiding the rebroadcast warning block — appropriate for a global context.Registry / tests
src/db/migrations.ts: register migration 063 with the standard idempotent pattern.src/db/migrations.test.ts: bump count 62 → 63 and update the "last migration" assertion.Migration numbering
Latest migration on
mainpost-#3089 is 62. PR #3089 did not add any migrations, so 063 is the next free number.Test plan
npx tsc --noEmit— 0 errorsnpx vitest run— 5090/5090 passing (5066 baseline + 24 added by feat(mqtt): full source-scoped ingest with channel decryption and unified-view fixes #3089)no-explicit-anywarnings)/channelspicker shows virtual channels under every source🤖 Generated with Claude Code