Record which coworker a person chose on /channel/new, not only in the home composer - #342
Open
kevin9327 wants to merge 1 commit into
Open
Record which coworker a person chose on /channel/new, not only in the home composer#342kevin9327 wants to merge 1 commit into
kevin9327 wants to merge 1 commit into
Conversation
… home composer The routing routes write a `channel.routed` row for both ways a message finds a coworker, and say why the named case is recorded at all: a trail with rows for routed conversations and none for chosen ones reads exactly like a row that failed to write. The home composer honours that, telling the server about an `@` choice before it starts the channel. `/channel/new` — where the sidebar's +, a coworker's card and its profile all lead — never did: the person picked a coworker in the To: field and the screen started the channel and told nobody, so every conversation begun from those three places has no row. One shared sequence now, `startWithChosen` in lib/channels/start.ts: record the choice, swallowing a failure to write it as the home composer already did, then start. Both screens call it through `useStartChannel().startChosen`, so they cannot drift again. Pure and tested; the routed branch of the home composer is unchanged.
kevin9327
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso and
tylerslaton
as code owners
September 2, 2026 22:14
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
What this changes
server/src/routing/routes.tsrecords achannel.routedrow for both ways a message finds a coworker, and says why the named case is recorded at all: "without that the trail answered 'why did this go to Risk Analyst' for routed conversations and said nothing at all for chosen ones, which reads exactly like a row that failed to write." The home composer honours that —routes/_authed/_app/index.tsxcallsrouteMessage(text, agentId)for an@choice beforestart./channel/newnever did. It is where the sidebar's + (app-sidebar.tsx), a coworker's card on the home screen, and a coworker's profile all lead; the person picks a coworker in the To: field and the screen callsstartalone.routeMessageis referenced fromindex.tsxand nowhere else, so every conversation begun from those three places has nochannel.routedrow: a trail with rows for some conversations and none for others, on the surface people use most.The fix is one shared sequence,
startWithChoseninlib/channels/start.ts: record the choice, swallowing a failure to write it (the person already decided and a missing row must not stop the conversation — the same stanceindex.tsxalready took), then start.useStartChannelexposes it asstartChosen, bound torouteMessage;/channel/newcalls it, andindex.tsx's@branch calls it too so the two screens cannot drift. The routed branch ofindex.tsxis unchanged.Not covered, and said out loud: a hidden coworker reached through a profile link is not on the roster
POST /api/routereads, so it answers 404 and the row is still not written; that is the server's call to make and is outside this change.#296 moves the recording into a routing service; it keeps
POST /api/routewithagentIdand touches nothing underapp/, so this composes with it either way.Where it runs
POST /api/route, intoaudit_events, as today.Boundary and audit
channel.routedrow now exists for a conversation that previously wrote none.Changelog
Unreleased.Proof
Before:
grep -rn routeMessage app/src—lib/channels/route.ts(the definition) androutes/_authed/_app/index.tsxonly;channel/new.tsxcallsstart(recipient.id, draft.text)with no record.After:
app/tests/start-chosen.test.tspins the sequence both screens now run — record before start, with the message and the coworker; a record that fails does not stop the conversation; the server's answer cannot change who was chosen; a channel that cannot be started still fails the send.bun run format:check,bun run lint, and the app typecheck pass. Hook glue is left untested, as elsewhere inapp/.