Skip to content

Commit dab65c0

Browse files
Remove the "Answered in" duration footer from Slack assistant replies (#25237)
Removes the "Answered in {x}s" footer the Slack assistant appended to every answer. ## What changed - `build-slack-assistant-answer-blocks.ts`: dropped the "Answered in {x}s" context block, so rich replies are now the markdown body plus the feedback buttons. - Plain-text replies (the fallback for answers too long for a markdown block): the worker posts `responseText` directly. `build-slack-assistant-answer-text.ts`, which only existed to append the footer, is deleted along with its test. - `format-slack-assistant-duration.ts` deleted (no remaining users); the worker no longer tracks `startedAt`/`durationMilliseconds`. - Tests updated to the new block layout. `strip-slack-assistant-answer-footer.ts` is deliberately kept: it strips the footer from the bot's own earlier messages when replaying thread history into the agent context, and still-live threads contain footered messages posted by previous versions. Its comment now explains that. ## Validation - `yarn typecheck` clean - `yarn lint` 0 warnings / 0 errors - `yarn test:unit` 193 tests pass (2 fewer than before: the deleted footer tests) --- _Generated by [Claude Code](https://claude.ai/code/session_01UYyiPFprpyCDwhb1J3mCkU)_ <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/25237?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
1 parent 9ab6988 commit dab65c0

8 files changed

Lines changed: 4 additions & 94 deletions

packages/twenty-apps/public/slack/src/__tests__/slack-assistant-worker.integration-test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,6 @@ describe('Slack assistant worker', () => {
218218

219219
expect(postedAnswer?.blocks).toEqual([
220220
{ type: 'markdown', text: 'Acme has 3 open deals.' },
221-
{
222-
type: 'context',
223-
elements: [
224-
{ type: 'mrkdwn', text: expect.stringMatching(/^Answered in \d+s$/) },
225-
],
226-
},
227221
// The feedback buttons carry the request record id, which is how a click
228222
// finds the answer it rates.
229223
expect.objectContaining({

packages/twenty-apps/public/slack/src/logic-functions/slack-assistant-worker.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { updateSlackAssistantRequest } from 'src/logic-functions/data/update-sla
1717
import { slackPostMessageHandler } from 'src/logic-functions/handlers/slack-post-message-handler';
1818
import { type SlackAssistantRequestRecord } from 'src/logic-functions/types/slack-assistant-request-record.type';
1919
import { buildSlackAssistantAnswerBlocks } from 'src/logic-functions/utils/build-slack-assistant-answer-blocks';
20-
import { buildSlackAssistantAnswerText } from 'src/logic-functions/utils/build-slack-assistant-answer-text';
2120
import { buildSlackAssistantMessages } from 'src/logic-functions/utils/build-slack-assistant-messages';
2221
import { buildSlackAssistantRequestName } from 'src/logic-functions/utils/build-slack-assistant-request-name';
2322
import { extractAgentResponseText } from 'src/logic-functions/utils/extract-agent-response-text';
@@ -39,7 +38,6 @@ type SlackAssistantRequestCreatedEvent = DatabaseEventPayload<
3938
export const slackAssistantWorkerHandler = async (
4039
event: SlackAssistantRequestCreatedEvent,
4140
): Promise<object> => {
42-
const startedAt = Date.now();
4341
const record = event.properties.after;
4442

4543
if (record.status !== SLACK_ASSISTANT_REQUEST_STATUS.PENDING) {
@@ -152,14 +150,9 @@ export const slackAssistantWorkerHandler = async (
152150
});
153151
}
154152

155-
const durationMilliseconds = Date.now() - startedAt;
156-
157153
const deliveryResult = await slackPostMessageHandler({
158154
slackChannelId,
159-
messageText: buildSlackAssistantAnswerText({
160-
responseText,
161-
durationMilliseconds,
162-
}),
155+
messageText: responseText,
163156
parentMessageTimestamp,
164157
messageFormat: 'markdown',
165158
unfurlLinks: false,
@@ -169,7 +162,6 @@ export const slackAssistantWorkerHandler = async (
169162
? undefined
170163
: buildSlackAssistantAnswerBlocks({
171164
responseText,
172-
durationMilliseconds,
173165
requestId: record.id,
174166
}),
175167
});

packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/build-slack-assistant-answer-blocks.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@ import { buildSlackAssistantAnswerBlocks } from 'src/logic-functions/utils/build
55
const REQUEST_ID = '3f77d0b1-30a1-4c3d-9d02-2f2a9f6f9d10';
66

77
describe('buildSlackAssistantAnswerBlocks', () => {
8-
it('should render the answer as a markdown block followed by a duration footer and feedback buttons', () => {
8+
it('should render the answer as a markdown block followed by feedback buttons', () => {
99
expect(
1010
buildSlackAssistantAnswerBlocks({
1111
responseText: 'All done.',
12-
durationMilliseconds: 3000,
1312
requestId: REQUEST_ID,
1413
}),
1514
).toEqual([
1615
{ type: 'markdown', text: 'All done.' },
17-
{
18-
type: 'context',
19-
elements: [{ type: 'mrkdwn', text: 'Answered in 3s' }],
20-
},
2116
{
2217
type: 'context_actions',
2318
block_id: REQUEST_ID,
@@ -49,7 +44,6 @@ describe('buildSlackAssistantAnswerBlocks', () => {
4944

5045
const [markdownBlock] = buildSlackAssistantAnswerBlocks({
5146
responseText,
52-
durationMilliseconds: 1000,
5347
requestId: REQUEST_ID,
5448
});
5549

packages/twenty-apps/public/slack/src/logic-functions/utils/__tests__/build-slack-assistant-answer-text.test.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/twenty-apps/public/slack/src/logic-functions/utils/build-slack-assistant-answer-blocks.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,15 @@ import { type KnownBlock } from '@slack/web-api';
22

33
import { SLACK_ASSISTANT_FEEDBACK_ACTION_ID } from 'src/logic-functions/constants/slack-assistant-feedback-action-id';
44
import { SLACK_ASSISTANT_FEEDBACK_BUTTON_VALUE } from 'src/logic-functions/constants/slack-assistant-feedback-button-value';
5-
import { formatSlackAssistantDuration } from 'src/logic-functions/utils/format-slack-assistant-duration';
65

76
export const buildSlackAssistantAnswerBlocks = ({
87
responseText,
9-
durationMilliseconds,
108
requestId,
119
}: {
1210
responseText: string;
13-
durationMilliseconds: number;
1411
requestId: string;
1512
}): KnownBlock[] => [
1613
{ type: 'markdown', text: responseText },
17-
{
18-
type: 'context',
19-
elements: [
20-
{
21-
type: 'mrkdwn',
22-
text: `Answered in ${formatSlackAssistantDuration(durationMilliseconds)}`,
23-
},
24-
],
25-
},
2614
{
2715
type: 'context_actions',
2816
block_id: requestId,

packages/twenty-apps/public/slack/src/logic-functions/utils/build-slack-assistant-answer-text.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/twenty-apps/public/slack/src/logic-functions/utils/format-slack-assistant-duration.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/twenty-apps/public/slack/src/logic-functions/utils/strip-slack-assistant-answer-footer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// mirrors the footer appended by buildSlackAssistantAnswerText
1+
// older versions of the bot appended this footer to every answer; still-live
2+
// threads carry those messages, so replayed history keeps needing the strip
23
const ANSWER_FOOTER_PATTERN = /\n\n_Answered in [^\n_]+_$/;
34

45
export const stripSlackAssistantAnswerFooter = (text: string): string =>

0 commit comments

Comments
 (0)