Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(pam): address Claude bot review comments — correctness and UX

bernie-g1cbc4243e84b
diff --git a/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts b/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
index c213fcb71e..683cc09b2d 100644
--- a/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
+++ b/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
@@ -28,8 +28,8 @@ export const pamSessionExpirationServiceFactory = ({
const { sessionId } = job.data;
try {
logger.info({ sessionId }, `${QueueName.PamSessionExpiration}: expiring session [sessionId=${sessionId}]`);
- const session = await pamSessionDAL.findById(sessionId);
const updated = await pamSessionDAL.expireSessionById(sessionId);
+ const session = updated > 0 ? await pamSessionDAL.findById(sessionId) : null;
if (updated > 0) {
logger.info(
{ sessionId },
diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsx
index 11753a8baf..c53607a9f2 100644
--- a/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsx
+++ b/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsx
@@ -39,6 +39,12 @@ const Page = () => {
const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["terminateSession"] as const);
const [scrollToLogIndex, setScrollToLogIndex] = useState<number | undefined>();
+ const handleWarningClick = (logIndex: number) => {
+ // Reset to undefined first so clicking the same warning twice triggers a new scroll
+ setScrollToLogIndex(undefined);
+ requestAnimationFrame(() => setScrollToLogIndex(logIndex));
+ };
+
const isActive =
session?.status === PamSessionStatus.Active || session?.status === PamSessionStatus.Starting;
const isGatewaySession = !!session?.gatewayIdentityId;
@@ -99,7 +105,7 @@ const Page = () => {
<PamSessionDetailsSection session={session} />
</div>
<div className="flex min-w-0 flex-1 flex-col gap-4">
- <PamSessionAiInsightsSection session={session} onWarningClick={setScrollToLogIndex} />
+ <PamSessionAiInsightsSection session={session} onWarningClick={handleWarningClick} />
<PamSessionLogsSection session={session} scrollToLogIndex={scrollToLogIndex} />
</div>
</div>
diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx
index 5fcf55a09d..91abe219e5 100644
--- a/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx
+++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx
@@ -3,6 +3,7 @@ import { faChevronRight, faMagnifyingGlass } from "@fortawesome/free-solid-svg-i
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { twMerge } from "tailwind-merge";
+import { createNotification } from "@app/components/notifications";
import { Input } from "@app/components/v2";
import { HighlightText } from "@app/components/v2/HighlightText";
import { TPamCommandLog } from "@app/hooks/api/pam";
@@ -23,7 +24,13 @@ export const CommandLogView = ({ logs, scrollToLogIndex }: Props) => {
if (scrollToLogIndex == null) return;
if (scrollToLogIndex === handledScrollIndexRef.current) return;
const target = logs[scrollToLogIndex - 1];
- if (!target) return;
+ if (!target) {
+ createNotification({
+ type: "info",
+ text: "Log entry not yet loaded. Load more logs to jump to this entry."
+ });
+ return;
+ }
handledScrollIndexRef.current = scrollToLogIndex;
setSearch("");
setExpandedLogTimestamps(new Set([target.timestamp]));
diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx
index b9e2975f58..bba9532a28 100644
--- a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx
+++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx
@@ -20,11 +20,8 @@ export const PamSessionAiInsightsSection = ({ session, onWarningClick }: Props)
const isEnded =
session.status === PamSessionStatus.Ended || session.status === PamSessionStatus.Terminated;
- // Only show if:
- // 1. Session is ended AND has an aiInsightsStatus, OR
- // 2. Session has completed insights
- if (!isEnded && !aiInsightsStatus) return null;
- if (isEnded && !aiInsightsStatus) return null;
+ // Only show for ended sessions that have an aiInsightsStatus
+ if (!isEnded || !aiInsightsStatus) return null;
return (
<div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">