Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(channel-reader): point the unresolved-sender notice at the tab that links the account
Jose Ramirez5b659bc8e8af
diff --git a/channel-reader/package-lock.json b/channel-reader/package-lock.jsonindex 656e07c41..cf2d84021 100644--- a/channel-reader/package-lock.json+++ b/channel-reader/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-channel-reader",- "version": "0.1.102",+ "version": "0.1.103","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-channel-reader",- "version": "0.1.102",+ "version": "0.1.103","license": "SEE LICENSE IN LICENSE","dependencies": {"@kubernetes/client-node": "^1.0.0",diff --git a/channel-reader/package.json b/channel-reader/package.jsonindex caefa522b..8aac34085 100644--- a/channel-reader/package.json+++ b/channel-reader/package.json@@ -1,6 +1,6 @@{"name": "clerum-channel-reader",- "version": "0.1.102",+ "version": "0.1.103","description": "Watches CommunicationChannel CRDs and fetches messages from Telegram, Email, and Slack","main": "dist/main.js","engines": {diff --git a/channel-reader/src/main.ts b/channel-reader/src/main.tsindex 681609315..1b034b3d8 100644--- a/channel-reader/src/main.ts+++ b/channel-reader/src/main.ts@@ -100,11 +100,41 @@ const PROVIDER_EVENT_DEDUPE_TTL_MS = 10 * 60 * 1000 // 10 minutes/** One "you are not linked" notice per Slack user per conversation per day. */const UNRESOLVED_NOTICE_TTL_MS = 24 * 60 * 60 * 1000 // 24 hoursconst UNRESOLVED_NOTICE_COPY =- "I can't accept messages from this Slack account. If you haven't linked it yet, " +- 'do that in your evenfire profile. If you think you should already have access, contact your admin.'+ "I can't accept messages from this Slack account. If you haven't linked it yet, open " ++ 'Settings > Social channels > Slack and choose Connect Slack. ' ++ 'If you think you should already have access, contact your admin.'const UNRESOLVED_NOTICE_COPY_TEAMS =- "I can't accept messages from this Teams account. If you haven't linked it yet, " +- 'do that in your evenfire profile. If you think you should already have access, contact your admin.'+ "I can't accept messages from this Teams account. If you haven't linked it yet, open " ++ 'Settings > Social channels > Teams and choose Connect Microsoft Teams. ' ++ 'If you think you should already have access, contact your admin.'++/**+ * Profile UI tab that owns the Connect button for a provider.+ *+ * The bare Profile UI root lands the user on their profile with no sign of+ * where to go next, and the control they need is four levels in: Settings >+ * Social channels > <provider> > Connect. These are real App Router segments+ * (profile-ui/app/settings/social/[network]), not query params, so they are+ * safe to link directly.+ *+ * The copy above still names the path in words. A deep link can be defeated by+ * a sign-in redirect that drops the user at the root, and someone reading this+ * from a phone needs to be able to find the screen without the link.+ */+const PROFILE_SOCIAL_CHANNEL_PATH: Partial<Record<ChannelType, string>> = {+ slack: '/settings/social/slack',+ teams: '/settings/social/teams',+}++/**+ * Profile UI link for the tab where `channelType` is linked. Falls back to the+ * configured base URL for a provider with no such tab, so a new channel type+ * degrades to today's behaviour rather than emitting a 404 path.+ */+export function profileSocialChannelUrl(baseUrl: string, channelType: ChannelType): string {+ const base = baseUrl.trim().replace(/\/+$/, '')+ return `${base}${PROFILE_SOCIAL_CHANNEL_PATH[channelType] ?? ''}`+}// Telegram deliberately gets no Profile UI link and no product name: unlike Teams// and Slack, anyone who discovers the bot handle can message it, so a reply must// not confirm what the bot belongs to.@@ -1642,7 +1672,9 @@ export class ChannelReader {const profileUrl = config.profileUiUrl?.trim()const baseCopy =msg.channelType === 'teams' ? UNRESOLVED_NOTICE_COPY_TEAMS : UNRESOLVED_NOTICE_COPY- content = profileUrl ? `${baseCopy} ${profileUrl}` : baseCopy+ content = profileUrl+ ? `${baseCopy} ${profileSocialChannelUrl(profileUrl, msg.channelType)}`+ : baseCopy}try {if (msg.channelType === 'teams') {diff --git a/channel-reader/test/unresolvedSenderNotice.test.ts b/channel-reader/test/unresolvedSenderNotice.test.tsindex 5afbd613d..3486638bd 100644--- a/channel-reader/test/unresolvedSenderNotice.test.ts+++ b/channel-reader/test/unresolvedSenderNotice.test.ts@@ -554,14 +554,54 @@ describe('unresolved notice link', () => {expect(sendEphemeral.mock.calls[0][2]).toContain('https://profile.example.com')})+ it('links straight to the Teams tab, not the Profile UI root', async () => {+ // The root drops the user on Profile with no indication of where to go, and+ // the path they need is four levels in (Settings > Social channels > Teams >+ // Connect). Deep-link to the tab that owns the Connect button.+ const { deliver, sendMessage } = buildReader({+ medium: 'teams',+ profileUiUrl: 'https://profile.example.com',+ })+ await deliver()+ expect(sendMessage.mock.calls[0][1]).toContain(+ 'https://profile.example.com/settings/social/teams'+ )+ })++ it('links straight to the Slack tab too', async () => {+ const { deliver, sendEphemeral } = buildReader({+ medium: 'slack',+ profileUiUrl: 'https://profile.example.com',+ })+ await deliver('C1', 'U1')+ expect(sendEphemeral.mock.calls[0][2]).toContain(+ 'https://profile.example.com/settings/social/slack'+ )+ })++ it('does not double the slash when the configured URL has a trailing one', async () => {+ const { deliver, sendMessage } = buildReader({+ medium: 'teams',+ profileUiUrl: 'https://profile.example.com/',+ })+ await deliver()+ expect(sendMessage.mock.calls[0][1]).toContain(+ 'https://profile.example.com/settings/social/teams'+ )+ expect(sendMessage.mock.calls[0][1]).not.toContain('.com//settings')+ })+it('sends the copy unchanged when no profile URL is configured', async () => {const { deliver, sendEphemeral } = buildReader({ profileUiUrl: undefined })await deliver('C1', 'U1')const text = sendEphemeral.mock.calls[0][2]expect(text).toBe(- "I can't accept messages from this Slack account. If you haven't linked it yet, " +- 'do that in your evenfire profile. If you think you should already have access, contact your admin.'+ "I can't accept messages from this Slack account. If you haven't linked it yet, open " ++ 'Settings > Social channels > Slack and choose Connect Slack. ' ++ 'If you think you should already have access, contact your admin.')expect(text).not.toContain('undefined')+ // No profile URL configured means no dangling path fragment either.+ expect(text).not.toContain('/settings/social')})})