Discord: fix /codex_resume identity resolution in brand-new threads#35
Open
huntharo wants to merge 1 commit intopwrdrvr:mainfrom
Open
Discord: fix /codex_resume identity resolution in brand-new threads#35huntharo wants to merge 1 commit intopwrdrvr:mainfrom
huntharo wants to merge 1 commit intopwrdrvr:mainfrom
Conversation
In brand-new Discord threads, the slash interaction can set ctx.from to the slash user identity (e.g. "slash:user-id") while the real channel target is in ctx.to. The previous ctx.from ?? ctx.to expression normalized a slash identity to undefined, causing toConversationTargetFromCommand() to return null and /cas_resume to fail on the first attempt. Fix: when ctx.from starts with "slash:", use ctx.to as the channel source instead. The existing behavior for established channels (ctx.from holds the channel identity) is unchanged. Adds a regression test covering the brand-new-thread scenario. Fixes pwrdrvr#30
mvanhorn
reviewed
Mar 22, 2026
mvanhorn
left a comment
There was a problem hiding this comment.
Summary
Traced through the fix and the regression test. The slash: prefix check correctly falls through to ctx.to for channel resolution, and the existing if (!conversationId) return null guard covers the case where ctx.to is also missing. Established-channel paths are untouched.
Recommendation
Looks good to merge.
Review assisted by Claude Code
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.
Summary
Fixes
/cas_resumefailing on the first attempt in brand-new Discord threads by correcting the identity resolution intoConversationTargetFromCommand().Why this matters
From #30: in a brand-new Discord thread, sending a first message before the agent has replied causes
/cas_resumeto show a generic "No active Codex sessions found" reply, with the picker only appearing ~40 seconds later via a retry.Root cause: the slash interaction placed the slash user identity (e.g.
slash:user-id) inctx.from, with the real channel target inctx.to. The expressionctx.from ?? ctx.toevaluated to"slash:user-id"(truthy string).normalizeDiscordConversationId()maps anyslash:prefix toundefined, sotoConversationTargetFromCommand()returnednull— and the command could not resolve a conversation target for the picker.Changes
src/controller.ts,toConversationTargetFromCommand()(line ~274): whenctx.fromstarts with"slash:", usectx.toas the channel source instead ofctx.from. Established-channel behavior is unchanged — whenctx.fromholds adiscord:channel:orchannel:identity, it continues to take precedence.Testing
Added a regression test in
src/controller.test.tswithctx.from = "slash:user-1"andctx.to = "discord:channel:chan-1"— asserts the thread picker is sent to the correct channel identity ("channel:chan-1"), not a null target.All 122 tests pass (
pnpm typecheck+pnpm test).Fixes #30
This contribution was developed with AI assistance (Claude Code).