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): clear Pi permission footer state (#78907)

Jonathan Mielooa5d0af2a3dff
diff --git a/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx b/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx
index ca45d57db84a..f4bc3a93c5db 100644
--- a/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx
+++ b/products/desktop/packages/ui/src/features/pi-sessions/PiSessionView.tsx
@@ -701,6 +701,7 @@ export function PiSessionView({
taskId={taskId}
repoPath={repoPath}
promptRecallRef={promptRecallRef}
+ hasPendingPermission={Boolean(mcpPermission)}
/>
</Box>
<Box
diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThread.tsx b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThread.tsx
index 84826ecfccce..877d062fc4bf 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThread.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThread.tsx
@@ -1143,6 +1143,7 @@ interface SharedChatThreadProps {
task?: Task;
taskId?: string;
footerState?: Omit<BuildResult, "items">;
+ hasPendingPermission?: boolean;
}
export interface ChatThreadProps extends SharedChatThreadProps {
@@ -1216,6 +1217,7 @@ function ChatThreadRenderer({
task,
taskId,
footerState,
+ hasPendingPermission,
promptRecallRef,
}: ChatThreadRendererProps) {
const diffWorkerFactory = useService<DiffWorkerFactory>(DIFF_WORKER_FACTORY);
@@ -1342,6 +1344,7 @@ function ChatThreadRenderer({
task={task}
taskId={taskId}
footerState={footerState}
+ hasPendingPermission={hasPendingPermission}
/>
</>
);
diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.test.ts b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.test.ts
new file mode 100644
index 000000000000..6bea92c14c63
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from "vitest";
+import { resolvePendingPermissionVisibility } from "./pendingPermissionVisibility";
+
+describe("resolvePendingPermissionVisibility", () => {
+ it.each([
+ [undefined, 0, false],
+ [undefined, 1, true],
+ [true, 0, true],
+ [false, 1, false],
+ ])(
+ "uses override %s with %i stored permissions",
+ (override, storedCount, expected) => {
+ expect(resolvePendingPermissionVisibility(override, storedCount)).toBe(
+ expected,
+ );
+ },
+ );
+});
diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx
index 009798ad8d98..25c4c1ca89e6 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx
@@ -9,6 +9,7 @@ import {
useSessionForTask,
} from "@posthog/ui/features/sessions/sessionStore";
import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";
+import { resolvePendingPermissionVisibility } from "./pendingPermissionVisibility";
interface ChatThreadFooterProps {
events: AcpMessage[];
@@ -17,6 +18,7 @@ interface ChatThreadFooterProps {
task?: Task;
taskId?: string;
footerState?: Omit<BuildResult, "items">;
+ hasPendingPermission?: boolean;
}
/**
@@ -35,6 +37,7 @@ export function ChatThreadFooter({
task,
taskId,
footerState,
+ hasPendingPermission,
}: ChatThreadFooterProps) {
const showDebugLogs = useSettingsStore((s) => s.debugLogsCloudRuns);
const eventFooterState = useConversationItems(events, isPromptPending, {
@@ -48,6 +51,10 @@ export function ChatThreadFooter({
footerState?.completedToolCallCount ??
eventFooterState.completedToolCallCount;
const pendingPermissions = usePendingPermissionsForTask(taskId ?? "");
+ const pendingPermissionVisible = resolvePendingPermissionVisibility(
+ hasPendingPermission,
+ pendingPermissions.size,
+ );
const queuedCount = useQueuedMessagesForTask(taskId).length;
const session = useSessionForTask(taskId);
const pausedDurationMs = session?.pausedDurationMs ?? 0;
@@ -65,7 +72,7 @@ export function ChatThreadFooter({
}
lastStopReason={lastTurnInfo?.stopReason}
queuedCount={queuedCount}
- hasPendingPermission={pendingPermissions.size > 0}
+ hasPendingPermission={pendingPermissionVisible}
pausedDurationMs={pausedDurationMs}
isCompacting={isCompacting}
completedToolCallCount={completedToolCallCount}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/pendingPermissionVisibility.ts b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/pendingPermissionVisibility.ts
new file mode 100644
index 000000000000..b612455ffb70
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/pendingPermissionVisibility.ts
@@ -0,0 +1,6 @@
+export function resolvePendingPermissionVisibility(
+ override: boolean | undefined,
+ storedCount: number,
+): boolean {
+ return override ?? storedCount > 0;
+}