Skip to content

: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.

fix(desktop): viewing a task clears its unread activity (#78708)

Shy Alterc66757956ac7
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx
index 71601f0a6d93..bf149c36554a 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskDetail.tsx
@@ -14,6 +14,7 @@ import { logger } from "../../../shell/logger";
import { useArchiveTask } from "../../archive/useArchiveTask";
import { ChannelBreadcrumb } from "../../canvas/components/ChannelBreadcrumb";
import { CopyThreadLinkButton } from "../../canvas/components/CopyThreadLinkButton";
+import { useMarkTaskActivityRead } from "../../canvas/hooks/useMarkTaskActivityRead";
import {
LazyCloudReviewPage as CloudReviewPage,
LazyReviewPage as ReviewPage,
@@ -129,6 +130,19 @@ export function TaskDetail({
};
}, [enableScope, disableScope]);
+ // Mounting TaskDetail means the task was actually rendered in front of the
+ // user — that, not any API fetch of the task, is what clears the unread
+ // activity flag ("the agent is waiting for your reply"). Now-based rather
+ // than row-versioned since everything up to mount has been seen; a waiting
+ // flag landing after mount re-flags unread. Marking client-side rather than
+ // in the retrieve endpoint: a task fetch (list refresh, poll, prefetch)
+ // isn't a view.
+
+ const { mutate: markTasksRead } = useMarkTaskActivityRead();
+ useEffect(() => {
+ markTasksRead([{ task_id: taskId, seen_before: new Date().toISOString() }]);
+ }, [markTasksRead, taskId]);
+
useHotkeys("mod+p", () => openFilePicker(), {
enableOnContentEditable: true,
enableOnFormTags: true,