Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a48da724ee | ||
|
|
a84b375f5d | ||
|
|
52358c5bf9 | ||
|
|
c1e68c27c5 | ||
|
|
d4edff9059 | ||
|
|
0530b0d2f5 | ||
|
|
e2d4ac2431 | ||
|
|
24f5d63cfa | ||
|
|
2df406eed3 | ||
|
|
5efef66a58 | ||
|
|
9ebbd08b4b | ||
|
|
934ba9d8f9 | ||
|
|
144344d1c8 | ||
|
|
65ed0a0326 | ||
|
|
288a68b831 | ||
|
|
abfbac75ea | ||
|
|
2ec34b7968 | ||
|
|
e104d47dc1 |
+18
-1
@@ -144,8 +144,10 @@ public class TempFileCleanupService {
|
||||
int directoriesDeletedCount = 0;
|
||||
for (Path directory : registry.getTempDirectories()) {
|
||||
try {
|
||||
if (Files.exists(directory)) {
|
||||
if (Files.exists(directory)
|
||||
&& shouldDeleteRegisteredDirectory(directory, maxAgeMillis)) {
|
||||
GeneralUtils.deleteDirectory(directory);
|
||||
registry.unregisterDirectory(directory);
|
||||
directoriesDeletedCount++;
|
||||
log.debug("Cleaned up temporary directory: {}", directory);
|
||||
}
|
||||
@@ -275,6 +277,21 @@ public class TempFileCleanupService {
|
||||
return totalDeletedCount.get();
|
||||
}
|
||||
|
||||
private boolean shouldDeleteRegisteredDirectory(Path directory, long maxAgeMillis) {
|
||||
if (maxAgeMillis <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long lastModified = Files.getLastModifiedTime(directory).toMillis();
|
||||
return (currentTime - lastModified) > maxAgeMillis;
|
||||
} catch (IOException e) {
|
||||
log.debug("Could not check directory age, skipping cleanup: {}", directory, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the system temp directory path based on configuration or system property. */
|
||||
private Path getSystemTempPath() {
|
||||
String systemTempDir =
|
||||
|
||||
@@ -155,6 +155,7 @@ public class TempFileManager {
|
||||
if (directory != null && Files.isDirectory(directory)) {
|
||||
try {
|
||||
GeneralUtils.deleteDirectory(directory);
|
||||
registry.unregisterDirectory(directory);
|
||||
log.debug("Deleted temp directory: {}", directory.toString());
|
||||
} catch (IOException e) {
|
||||
log.warn("Failed to delete temp directory: {}", directory.toString(), e);
|
||||
|
||||
@@ -85,6 +85,18 @@ public class TempFileRegistry {
|
||||
return directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a temporary directory from the registry.
|
||||
*
|
||||
* @param directory The directory to unregister
|
||||
*/
|
||||
public void unregisterDirectory(Path directory) {
|
||||
if (directory != null) {
|
||||
tempDirectories.remove(directory);
|
||||
log.debug("Unregistered temp directory: {}", directory.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a third-party temporary file that requires special handling.
|
||||
*
|
||||
|
||||
+19
-1
@@ -176,11 +176,13 @@ class TempFileCleanupServiceMoreTest {
|
||||
class ScheduledCleanup {
|
||||
|
||||
@Test
|
||||
@DisplayName("deletes registered temp directories and reports counts")
|
||||
@DisplayName("deletes stale registered temp directories and reports counts")
|
||||
void deletesRegisteredDirectories() throws IOException {
|
||||
when(tempFileManager.cleanupOldTempFiles(anyLong())).thenReturn(2);
|
||||
Path regDir = Files.createDirectories(tempDir.resolve("registeredDir"));
|
||||
Files.createFile(regDir.resolve("inside.txt"));
|
||||
Files.setLastModifiedTime(
|
||||
regDir, FileTime.fromMillis(System.currentTimeMillis() - 2L * 60 * 60 * 1000));
|
||||
Set<Path> dirs = new HashSet<>();
|
||||
dirs.add(regDir);
|
||||
when(registry.getTempDirectories()).thenReturn(dirs);
|
||||
@@ -193,6 +195,22 @@ class TempFileCleanupServiceMoreTest {
|
||||
verify(tempFileManager).cleanupOldTempFiles(anyLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("keeps a fresh registered temp directory")
|
||||
void keepsFreshRegisteredDirectory() throws IOException {
|
||||
when(tempFileManager.cleanupOldTempFiles(anyLong())).thenReturn(0);
|
||||
Path regDir = Files.createDirectories(tempDir.resolve("freshRegisteredDir"));
|
||||
Files.createFile(regDir.resolve("inside.txt"));
|
||||
Set<Path> dirs = new HashSet<>();
|
||||
dirs.add(regDir);
|
||||
when(registry.getTempDirectories()).thenReturn(dirs);
|
||||
lenient().when(registry.contains(any(File.class))).thenReturn(false);
|
||||
|
||||
withIsolatedUserHome(cleanupService::scheduledCleanup);
|
||||
|
||||
assertThat(Files.exists(regDir)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("skips a registered directory that no longer exists")
|
||||
void skipsMissingRegisteredDirectory() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { usePan } from "@embedpdf/plugin-pan/react";
|
||||
import { useInteractionManagerCapability } from "@embedpdf/plugin-interaction-manager/react";
|
||||
import { useViewer } from "@app/contexts/ViewerContext";
|
||||
import { useActiveDocumentId } from "@app/components/viewer/useActiveDocumentId";
|
||||
import { useDocumentReady } from "@app/components/viewer/hooks/useDocumentReady";
|
||||
@@ -21,13 +22,18 @@ export function PanAPIBridge() {
|
||||
|
||||
function PanAPIBridgeInner({ documentId }: { documentId: string }) {
|
||||
const { provides: pan, isPanning } = usePan(documentId);
|
||||
const { provides: imCapability } = useInteractionManagerCapability();
|
||||
const { registerBridge, triggerImmediatePanUpdate } = useViewer();
|
||||
|
||||
// Keep pan ref updated to avoid re-running effect when object reference changes
|
||||
// Keep refs updated to avoid re-running effect when object references change
|
||||
const panRef = useRef(pan);
|
||||
useEffect(() => {
|
||||
panRef.current = pan;
|
||||
}, [pan]);
|
||||
const imRef = useRef(imCapability);
|
||||
useEffect(() => {
|
||||
imRef.current = imCapability;
|
||||
}, [imCapability]);
|
||||
|
||||
// Track previous isPanning value to detect changes
|
||||
const prevIsPanningRef = useRef<boolean>(isPanning);
|
||||
@@ -39,6 +45,17 @@ function PanAPIBridgeInner({ documentId }: { documentId: string }) {
|
||||
isPanning,
|
||||
};
|
||||
|
||||
// Pan off must always land in selection (pointerMode), not the default mode -
|
||||
// if pan ever became the default, disablePan/togglePan couldn't escape it (#5175).
|
||||
const goToPointerMode = () => {
|
||||
const im = imRef.current;
|
||||
if (im) {
|
||||
im.forDocument(documentId).activate("pointerMode");
|
||||
} else {
|
||||
currentPan.disablePan();
|
||||
}
|
||||
};
|
||||
|
||||
// Register this bridge with ViewerContext
|
||||
registerBridge("pan", {
|
||||
state: newState,
|
||||
@@ -47,22 +64,20 @@ function PanAPIBridgeInner({ documentId }: { documentId: string }) {
|
||||
currentPan.enablePan();
|
||||
},
|
||||
disable: () => {
|
||||
currentPan.disablePan();
|
||||
goToPointerMode();
|
||||
},
|
||||
toggle: () => {
|
||||
currentPan.togglePan();
|
||||
},
|
||||
makePanDefault: () => {
|
||||
// v2.5.0: makePanDefault may not exist, enable pan as fallback
|
||||
if (
|
||||
"makePanDefault" in currentPan &&
|
||||
typeof (currentPan as any).makePanDefault === "function"
|
||||
) {
|
||||
(currentPan as any).makePanDefault();
|
||||
if (isPanning) {
|
||||
goToPointerMode();
|
||||
} else {
|
||||
currentPan.enablePan();
|
||||
}
|
||||
},
|
||||
makePanDefault: () => {
|
||||
// Never make pan the default mode (that is what locks the viewer in
|
||||
// #5175). Just enable pan for the current interaction.
|
||||
currentPan.enablePan();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -75,7 +90,7 @@ function PanAPIBridgeInner({ documentId }: { documentId: string }) {
|
||||
return () => {
|
||||
registerBridge("pan", null);
|
||||
};
|
||||
}, [isPanning, registerBridge, triggerImmediatePanUpdate]);
|
||||
}, [isPanning, registerBridge, triggerImmediatePanUpdate, documentId]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -209,12 +209,10 @@ export function useViewerWorkbenchBarButtons(
|
||||
disabled:
|
||||
!isPanning && pendingCount > 0 && redactionActiveType !== null,
|
||||
onClick: () => {
|
||||
// Don't optimistically flip isPanning - it must reflect the real EmbedPDF
|
||||
// mode so the button can't show "off" while still stuck in pan (#5175).
|
||||
viewer.panActions.togglePan();
|
||||
setIsPanning((prev) => {
|
||||
const next = !prev;
|
||||
if (next && isRulerActive) setIsRulerActive?.(false);
|
||||
return next;
|
||||
});
|
||||
if (!isPanning && isRulerActive) setIsRulerActive?.(false);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import FileUploadRounded from "@mui/icons-material/FileUploadRounded";
|
||||
import { Button, Modal } from "@app/ui";
|
||||
import "@portal/views/AgentBuilder.css";
|
||||
|
||||
@@ -58,7 +59,7 @@ export function BootstrapDialog({ open, onClose }: BootstrapDialogProps) {
|
||||
onChange={(e) => setFileName(e.target.files?.[0]?.name ?? null)}
|
||||
/>
|
||||
<span className="portal-agents__dropzone-icon" aria-hidden>
|
||||
⇪
|
||||
<FileUploadRounded style={{ fontSize: "1.5rem" }} />
|
||||
</span>
|
||||
<span className="portal-agents__dropzone-text">
|
||||
{fileName ?? t("portal.agentBuilder.bootstrap.dropzoneText")}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import LockRounded from "@mui/icons-material/LockRounded";
|
||||
import { StatusBadge, Table, type TableColumn } from "@app/ui";
|
||||
import { type Extraction, type ReviewDocument } from "@portal/api/documents";
|
||||
import {
|
||||
@@ -55,7 +56,7 @@ export function DocumentExtractions({
|
||||
return (
|
||||
<div className="portal-documents__masked">
|
||||
<span className="portal-documents__masked-icon" aria-hidden>
|
||||
🔒
|
||||
<LockRounded style={{ fontSize: "1.5rem" }} />
|
||||
</span>
|
||||
<p className="portal-documents__masked-text">
|
||||
{t("portal.documents.extractions.masked")}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import ScheduleRounded from "@mui/icons-material/ScheduleRounded";
|
||||
import LockRounded from "@mui/icons-material/LockRounded";
|
||||
import { Banner, Button } from "@app/ui";
|
||||
import { formatCountdown } from "@portal/components/documents/format";
|
||||
|
||||
@@ -26,7 +28,7 @@ export function ElevationBanner({
|
||||
return (
|
||||
<Banner
|
||||
tone="success"
|
||||
icon={<span aria-hidden>⏱</span>}
|
||||
icon={<ScheduleRounded style={{ fontSize: "1.1rem" }} />}
|
||||
title={t("portal.documents.elevation.active.title", {
|
||||
time: formatCountdown(secondsLeft),
|
||||
})}
|
||||
@@ -42,7 +44,7 @@ export function ElevationBanner({
|
||||
return (
|
||||
<Banner
|
||||
tone="warning"
|
||||
icon={<span aria-hidden>🔒</span>}
|
||||
icon={<LockRounded style={{ fontSize: "1.1rem" }} />}
|
||||
title={t("portal.documents.elevation.gated.title")}
|
||||
description={
|
||||
fourEyes
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import LockRounded from "@mui/icons-material/LockRounded";
|
||||
import { Button, Chip, StatusBadge, Table, type TableColumn } from "@app/ui";
|
||||
import {
|
||||
classificationTone,
|
||||
@@ -75,7 +76,7 @@ export function ReviewQueueTable({
|
||||
title={t("portal.documents.table.sensitiveTitle")}
|
||||
aria-label={t("portal.documents.table.sensitiveLabel")}
|
||||
>
|
||||
🔒
|
||||
<LockRounded style={{ fontSize: "0.95rem" }} />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import AccountTreeRounded from "@mui/icons-material/AccountTreeRounded";
|
||||
import ChevronRightRoundedIcon from "@mui/icons-material/ChevronRightRounded";
|
||||
import {
|
||||
Chip,
|
||||
@@ -31,7 +32,7 @@ export function PipelinesTable({ pipelines, onRowClick }: PipelinesTableProps) {
|
||||
render: (p) => (
|
||||
<div className="portal-pipelines__name-cell">
|
||||
<span className="portal-pipelines__pipe-dot" aria-hidden>
|
||||
⛓
|
||||
<AccountTreeRounded style={{ fontSize: "1.2rem" }} />
|
||||
</span>
|
||||
<div className="portal-pipelines__name-text">
|
||||
<strong>{p.name}</strong>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import FileUploadRounded from "@mui/icons-material/FileUploadRounded";
|
||||
import { Button, EmptyState, Skeleton } from "@app/ui";
|
||||
import { useTier } from "@portal/contexts/TierContext";
|
||||
import { useAsync, useSectionFlags } from "@portal/hooks/useAsync";
|
||||
@@ -41,7 +42,7 @@ export function AgentBuilder() {
|
||||
</div>
|
||||
<Button
|
||||
onClick={() => setBootstrapOpen(true)}
|
||||
leftSection={<span aria-hidden>⇪</span>}
|
||||
leftSection={<FileUploadRounded style={{ fontSize: "1.2rem" }} />}
|
||||
>
|
||||
{t("portal.agentBuilder.bootstrapFromDocument")}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user