Skip to content

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

fix(pam-rdp): address PR review issues in replay player

bernie-ge20c04e5c09b
diff --git a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
index 0a4f84cb35..b08adfdd7e 100644
--- a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
+++ b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
@@ -90,7 +90,7 @@ const PageContent = () => {
const { data: account, isPending } = useGetPamAccountById(accountId);
- const { data: domain } = useGetPamDomainById(
+ const { data: domain, isPending: isDomainPending } = useGetPamDomainById(
(account?.domain?.domainType as PamDomainType) ?? PamDomainType.ActiveDirectory,
account?.domainId || undefined,
{ enabled: !!account?.domainId }
@@ -243,7 +243,13 @@ const PageContent = () => {
I={ProjectPermissionPamAccountActions.Access}
a={ProjectPermissionSub.PamAccounts}
>
- <Button variant="neutral" onClick={handleAccess}>
+ <Button
+ variant="neutral"
+ // Domain-account access uses `${fqdn}:${slug}` as the
+ // approval-layer identity. Block until the domain query lands.
+ isDisabled={isDomainAccount && (isDomainPending || !domain?.connectionDetails.domain)}
+ onClick={handleAccess}
+ >
<LogInIcon />
Access
</Button>
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx
index e9582db86b..dded3b0e02 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx
+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx
@@ -130,7 +130,7 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {
setAppliedMetadataEntries([]);
};
- const { data: domainData } = useGetPamDomainById(
+ const { data: domainData, isPending: isDomainPending } = useGetPamDomainById(
PamDomainType.ActiveDirectory,
resource.domainId || undefined,
{ enabled: !!resource.domainId }
@@ -553,6 +553,10 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {
<Button
variant="ghost"
size="xs"
+ // Domain-account access uses `${fqdn}:${slug}` as the
+ // approval-layer identity. Block until the domain
+ // query lands so the preflight matches the backend.
+ isDisabled={!!account.domainId && (isDomainPending || !domainData?.connectionDetails.domain)}
onClick={(e) => {
e.stopPropagation();
accessAccount(account);
diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/RdpReplayView/RdpReplayView.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/RdpReplayView/RdpReplayView.tsx
index 54d1ee8932..8170b71691 100644
--- a/frontend/src/pages/pam/PamSessionsByIDPage/components/RdpReplayView/RdpReplayView.tsx
+++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/RdpReplayView/RdpReplayView.tsx
@@ -50,6 +50,9 @@ export const RdpReplayView = ({ events, isStreaming = false, totalDurationMs }:
const [isBuffering, setIsBuffering] = useState(false);
const [lastSeenEventMs, setLastSeenEventMs] = useState(0);
const [error, setError] = useState<string | null>(null);
+ // Re-triggers the events / isStreaming effects once the async WASM init
+ // resolves; ref assignment alone wouldn't schedule a render.
+ const [playerReady, setPlayerReady] = useState(false);
// nonce remounts AnimatePresence on rapid toggles so the pulse restarts.
const [feedback, setFeedback] = useState<{
icon: "play" | "pause";
@@ -82,6 +85,17 @@ export const RdpReplayView = ({ events, isStreaming = false, totalDurationMs }:
const canvas = canvasRef.current;
if (!canvas) return undefined;
+ // RDP frames are deltas; bail before creating the player if the initial
+ // event range already includes a corrupt-chunk marker (the events effect
+ // below only checks events past lastParsedIndexRef).
+ for (let i = 0; i < events.length; i += 1) {
+ const ev = events[i];
+ if (isBrokenChunkMarker(ev)) {
+ setError(`Chunk ${ev.chunkIndex}: ${ev.message}`);
+ return undefined;
+ }
+ }
+
const initial = parseRange(events, 0, events.length);
lastParsedIndexRef.current = events.length;
if (initial.length > 0) setLastSeenEventMs(initial[initial.length - 1].elapsedMs);
@@ -101,6 +115,10 @@ export const RdpReplayView = ({ events, isStreaming = false, totalDurationMs }:
return;
}
playerRef.current = player;
+ // Trigger the events / isStreaming effects to handle any state that
+ // accumulated during the async init (events that arrived, isStreaming
+ // that flipped to false).
+ setPlayerReady(true);
})
.catch((e: unknown) => {
setError(e instanceof Error ? e.message : "Failed to initialize RDP replay player");
@@ -138,13 +156,13 @@ export const RdpReplayView = ({ events, isStreaming = false, totalDurationMs }:
player.appendEvents(more);
setLastSeenEventMs(more[more.length - 1].elapsedMs);
}
- }, [events]);
+ }, [events, playerReady]);
useEffect(() => {
if (!isStreaming && playerRef.current) {
playerRef.current.markStreamComplete();
}
- }, [isStreaming]);
+ }, [isStreaming, playerReady]);
useEffect(() => {
writeProgress(currentMsRef.current);