: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(desktop): stop imported chats reading as fresh activity (#105287)
Jake Ruth8aec0843702c
diff --git a/products/desktop/packages/core/src/sessions/sessionEvents.test.ts b/products/desktop/packages/core/src/sessions/sessionEvents.test.tsindex 4fcbf2431f47..816be3f02bee 100644--- a/products/desktop/packages/core/src/sessions/sessionEvents.test.ts+++ b/products/desktop/packages/core/src/sessions/sessionEvents.test.ts@@ -562,6 +562,7 @@ describe("convertStoredEntriesToEvents — imported user prompts", () => {const userChunkEntry = (text: string,meta?: Record<string, unknown>,+ contentMeta?: Record<string, unknown>,): StoredLogEntry =>({timestamp: "2026-06-22T00:00:00.000Z",@@ -571,7 +572,11 @@ describe("convertStoredEntriesToEvents — imported user prompts", () => {params: {update: {sessionUpdate: "user_message_chunk",- content: { type: "text", text },+ content: {+ type: "text",+ text,+ ...(contentMeta ? { _meta: contentMeta } : {}),+ },...(meta ? { _meta: meta } : {}),},},@@ -591,6 +596,18 @@ describe("convertStoredEntriesToEvents — imported user prompts", () => {});});+ it("keeps a hidden imported chunk out of the thread", () => {+ const events = convertStoredEntriesToEvents([+ userChunkEntry(+ "<system_reminder>Your initial mode is product_analytics.</system_reminder>",+ { importedUserPrompt: true },+ { ui: { hidden: true } },+ ),+ ]);+ const msg = events[0].message;+ expect("method" in msg && msg.method).toBe("session/update");+ });+it("leaves an unmarked user_message_chunk as a raw notification", () => {const events = convertStoredEntriesToEvents([userChunkEntry("internal user content"),diff --git a/products/desktop/packages/core/src/sessions/sessionEvents.ts b/products/desktop/packages/core/src/sessions/sessionEvents.tsindex 79bd40528a0e..77bad64fefed 100644--- a/products/desktop/packages/core/src/sessions/sessionEvents.ts+++ b/products/desktop/packages/core/src/sessions/sessionEvents.ts@@ -125,9 +125,12 @@ function promoteImportedUserPrompt(return null;}const content = update.content as- | { type?: string; text?: string }+ | { type?: string; text?: string; _meta?: { ui?: { hidden?: boolean } } }| undefined;if (content?.type !== "text" || !content.text) return null;+ // A hidden chunk is context the model reads and the person never typed: a compaction summary,+ // a mode note. Promoting it would put text nobody wrote at the top of their thread.+ if (content._meta?.ui?.hidden) return null;return createUserMessageEvent(content.text, ts);}diff --git a/products/desktop/packages/core/src/tasks/taskActivity.test.ts b/products/desktop/packages/core/src/tasks/taskActivity.test.tsindex 38bbcb51f2f5..353065f3ce43 100644--- a/products/desktop/packages/core/src/tasks/taskActivity.test.ts+++ b/products/desktop/packages/core/src/tasks/taskActivity.test.ts@@ -28,7 +28,7 @@ describe("taskActivityTimestamp", () => {);});- it("uses the latest task or run update in updated mode", () => {+ it("ignores the run's write time in updated mode", () => {const task = makeTask({updated_at: "2026-01-02T00:00:00Z",latest_run: {@@ -48,7 +48,32 @@ describe("taskActivityTimestamp", () => {});expect(taskActivityTimestamp(task, "updated")).toBe(- new Date("2026-01-04T00:00:00Z").getTime(),+ new Date("2026-01-02T00:00:00Z").getTime(),+ );+ });++ it("ignores a run's write time when the backend sent an activity stamp", () => {+ const task = makeTask({+ updated_at: "2026-09-23T13:41:11Z",+ last_activity_at: "2025-02-11T16:30:35Z",+ latest_run: {+ id: "run-1",+ task: "task-1",+ team: 1,+ branch: null,+ status: "completed",+ log_url: "",+ error_message: null,+ output: null,+ state: { imported_from: "conversation" },+ created_at: "2025-02-11T16:29:51Z",+ updated_at: "2026-09-23T13:41:11Z",+ completed_at: "2025-02-11T16:30:35Z",+ },+ });++ expect(taskActivityTimestamp(task, "updated")).toBe(+ new Date("2025-02-11T16:30:35Z").getTime(),);});diff --git a/products/desktop/packages/core/src/tasks/taskActivity.ts b/products/desktop/packages/core/src/tasks/taskActivity.tsindex 96077cec8731..e79e4363913d 100644--- a/products/desktop/packages/core/src/tasks/taskActivity.ts+++ b/products/desktop/packages/core/src/tasks/taskActivity.ts@@ -31,7 +31,7 @@ export function taskActivityAt(export function taskActivityTimestamp(task: Pick<TaskActivityInput,- "created_at" | "updated_at" | "last_activity_at" | "latest_run"+ "created_at" | "updated_at" | "last_activity_at">,sortMode: TaskActivitySortMode,): number {@@ -39,13 +39,10 @@ export function taskActivityTimestamp(return new Date(task.created_at).getTime();}- // The run's own timestamp still counts: it is the one activity signal a client talking to a- // backend without `last_activity_at` can see move during a run.- const runUpdatedAt = task.latest_run?.updated_at;- return Math.max(- runUpdatedAt ? new Date(runUpdatedAt).getTime() : 0,- new Date(taskActivityAt(task)).getTime(),- );+ // `last_activity_at` first, the field the web list orders by. A run's `updated_at` is not part+ // of this: it moves when that row is written, which for an imported transcript is the moment the+ // copy ran, not when the chat happened.+ return new Date(taskActivityAt(task)).getTime();}export function filterAndSortTasks<TaskType extends TaskActivityInput>(diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsxindex 6c53616cd2f6..3d7d6eb4f3c7 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx@@ -1013,7 +1013,10 @@ const FeedItem = memo(function FeedItem({</button>)}<span className="shrink-0 text-(--gray-9) text-xs">- · {formatRelativeTimeShort(task.updated_at)}+ ·{" "}+ {formatRelativeTimeShort(+ task.last_activity_at ?? task.updated_at,+ )}</span></div><div className="flex shrink-0 items-center gap-1">@@ -1410,7 +1413,7 @@ const FeedLogRow = memo(function FeedLogRow({/><span className="w-8 shrink-0 text-right text-muted-foreground text-xs tabular-nums transition-opacity group-hover:opacity-0">- {formatRelativeTimeShort(task.updated_at)}+ {formatRelativeTimeShort(task.last_activity_at ?? task.updated_at)}</span><span className="absolute right-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100"><TaskRowDropdownMenu menu={menu} />