:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(posthog-ai): trim the first task message so its echo dedupes (#103080)
Alex Lider2a07917db66c
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.test.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.test.tsindex e89b1896e832..df1558cec7c0 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.test.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.test.ts@@ -322,6 +322,24 @@ describe('taskTrackerSceneLogic', () => {expect(router.values.location.pathname).toContain('/tasks/new-task')})+ // The backend strips `pending_user_message` and echoes the stripped text. An optimistic bubble that keeps+ // the trailing whitespace never matches that echo, so the first message rendered twice.+ it('sends and echoes the first message without surrounding whitespace', async () => {+ logic.mount()+ logic.actions.setNewTaskData({ description: ' do the thing \n' })+ logic.actions.submitNewTask()+ const streamKey = logic.values.activeCreation!.streamKey+ expect(runStreamLogic({ streamKey }).values.threadItems).toEqual([+ expect.objectContaining({ type: 'human_message', text: 'do the thing' }),+ ])++ await expectLogic(logic).toFinishAllListeners()++ expect(createBody).toMatchObject({ description: 'do the thing' })+ expect(runBody).toMatchObject({ pending_user_message: 'do the thing' })+ expect(logic.values.newTaskData.description).toBe('')+ })+// A warm sandbox is adopted inside `tasks/create`, which returns the activated Run as `latest_run`.// Issuing the usual run-create on top would strand that warm sandbox and cold-boot a second one —// exactly the ~16s the warm existed to avoid. The create must also carry the warm-reuse hints, sincediff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.tsindex ec53deb2a252..c0b828b3dc9f 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts@@ -642,10 +642,13 @@ export const taskTrackerSceneLogic = kea<taskTrackerSceneLogicType>([return}- const { description, permissionMode } = values.newTaskData+ // The backend strips `pending_user_message`, and the live echo carries that stripped text. The+ // optimistic bubble must match it exactly, or the echo renders as a second copy of the message.+ const description = values.newTaskData.description.trim()+ const { permissionMode } = values.newTaskDataconst repositoryConfig = values.effectiveRepositoryConfig- if (!description.trim()) {+ if (!description) {lemonToast.error('Description is required')actions.submitNewTaskFailure('Description is required')return@@ -834,7 +837,7 @@ export const taskTrackerSceneLogic = kea<taskTrackerSceneLogicType>([// Reset before signaling success: the success listener applies any seed held during this// submission, and resetting afterwards would wipe that seed's prefill.- if (creationIsActive || values.newTaskData.description === description) {+ if (creationIsActive || values.newTaskData.description.trim() === description) {actions.resetNewTaskData()}cache.submittingTask = null