fix(discord): preserve channel session keys via channel_id fallbacks#17622
fix(discord): preserve channel session keys via channel_id fallbacks#17622thewilloftheshadow merged 3 commits intomainfrom
Conversation
| it("falls back to message.rawData.channel_id", () => { | ||
| const channelId = resolveDiscordMessageChannelId({ | ||
| message: asMessage({ rawData: { channel_id: "456" } }), | ||
| }); | ||
| expect(channelId).toBe("456"); | ||
| }); |
There was a problem hiding this comment.
missing test case for message.channel_id fallback (the second fallback in the chain)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/discord/monitor/message-utils.test.ts
Line: 17:22
Comment:
missing test case for `message.channel_id` fallback (the second fallback in the chain)
How can I resolve this? If you propose a fix, please make it concise.|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
1 similar comment
|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
5056113 to
8d3fd4b
Compare
|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
…penclaw#17622) * fix(discord): preserve channel session keys via channel_id fallbacks * docs(changelog): add discord session continuity note * Tests: cover discord channel_id fallback --------- Co-authored-by: Shadow <[email protected]>
Summary
This is a focused first-pass fix for Discord session continuity issues reported in #16333 and #16979.
message.channelIdmessage.channel_idmessage.rawData.channel_idchannel_idmessageChannelIdthrough Discord preflight and processing so routing/session/history/reply paths no longer depend on a single runtime field shape.number/bigintIDs into stable string IDs for session keys.sessionKeyis reused when later looked up bysessionId, and PI embedded runner now emits session state transitions withsessionKeywhere available.Verification
bunx vitest run --config vitest.unit.config.ts src/discord/monitor/message-utils.test.ts src/discord/monitor/message-handler.process.test.ts src/logging/diagnostic.test.ts src/routing/resolve-route.test.tsbunx vitest run --config vitest.unit.config.ts src/discord/monitor/message-handler.inbound-contract.test.ts src/discord/monitor/monitor.test.tspnpm tsgopnpm checkRelated
Greptile Summary
This PR fixes Discord session continuity by implementing canonical channel ID resolution with multiple fallbacks (
message.channelId→message.channel_id→message.rawData.channel_id→ event payloadchannel_id). The changes thread thismessageChannelIdthrough preflight, processing, threading, and auto-thread creation paths to ensure consistent session keys regardless of runtime field shape variations.Key improvements:
resolveDiscordMessageChannelId()helper with numeric type coercion supportnormalizeId()in route resolution to handlenumber/biginttypes for stable session keyssessionKeywhen looked up bysessionIdsessionKeywhere availableThe implementation is solid with proper type handling and fallback chains. Test coverage is strong across the critical paths.
Confidence Score: 5/5
messageChannelIdthrough all paths is systematic and complete.Last reviewed commit: b8b2805