fix(coderd): truncate task prompt to 160 characters in notifications (#20147)

Truncates the task prompt used in notifications to a maximum of 160
characters. The length of 160 characters was chosen arbitrarily.
This commit is contained in:
Cian Johnston
2025-10-02 19:54:07 +01:00
committed by GitHub
parent 4d1003eace
commit ffcb7a1693
4 changed files with 123 additions and 13 deletions
+5
View File
@@ -484,6 +484,11 @@ func (api *API) enqueueAITaskStateNotification(
}
}
// As task prompt may be particularly long, truncate it to 160 characters for notifications.
if len(taskName) > 160 {
taskName = strutil.Truncate(taskName, 160, strutil.TruncateWithEllipsis, strutil.TruncateWithFullWords)
}
if _, err := api.NotificationsEnqueuer.EnqueueWithData(
// nolint:gocritic // Need notifier actor to enqueue notifications
dbauthz.AsNotifier(ctx),