Compare commits

...
Author SHA1 Message Date
Frooodle 9a8c67086e Merge branch 'main' into default-single-placement-for-add-tools 2026-07-13 09:34:50 +01:00
Anthony StirlingandGitHub a84b375f5d Portal Pipelines: SVG pipeline icon (#7002)
# Description of Changes

Replaces the chain glyph in the pipelines table with a proper pipeline
icon.

Part of a portal (processor) UI-consistency pass, split into small
focused PRs.

## Before / after

<!-- paste before / after screenshots here -->

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [x] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have run `task check` to verify linters, typechecks, and tests
pass
- [x] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing)
for more details.
2026-07-12 23:56:07 +00:00
Anthony StirlingandGitHub 52358c5bf9 Portal Agent Builder: SVG upload icon (#7001)
# Description of Changes

Replaces the upload glyph in the agent bootstrap dialog with a proper
SVG icon.

Part of a portal (processor) UI-consistency pass, split into small
focused PRs.

## Before / after

<!-- paste before / after screenshots here -->

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [x] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have run `task check` to verify linters, typechecks, and tests
pass
- [x] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing)
for more details.
2026-07-12 23:55:54 +00:00
Anthony StirlingandGitHub c1e68c27c5 Portal Documents: SVG lock and timer icons (#7000)
# Description of Changes

Replaces the emoji lock and timer icons in the document queue and
extraction views with stroke SVG icons.

Part of a portal (processor) UI-consistency pass, split into small
focused PRs.

## Before / after

<!-- paste before / after screenshots here -->

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [x] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have run `task check` to verify linters, typechecks, and tests
pass
- [x] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing)
for more details.
2026-07-12 23:55:43 +00:00
LudyandGitHub d4edff9059 fix(temp-files): prevent cleanup of active registered directories (#7006) 2026-07-12 22:33:09 +01:00
Frooodle bc87093588 format specs 2026-07-10 11:50:16 +01:00
Frooodle a8bd5e61f3 fix e2e dirname 2026-07-10 11:40:29 +01:00
Frooodle f981986681 merge main 2026-07-10 10:46:43 +01:00
Frooodle 982991689e merge main 2026-07-06 18:50:40 +01:00
Frooodle baa00ba186 merge main 2026-07-02 09:41:31 +01:00
Frooodle 0456434040 merge main 2026-07-01 08:47:07 +01:00
Frooodle 285a96c342 merge main 2026-06-30 08:30:06 +01:00
Frooodle 08c326d745 merge main 2026-06-29 11:21:13 +01:00
Frooodle 4100e63afe merge main 2026-06-27 08:23:12 +01:00
Frooodle 6a27923af1 merge main 2026-06-25 14:01:14 +01:00
Frooodle 8549176f4a merge main 2026-06-25 09:52:37 +01:00
Frooodle 1f511635cf merge main 2026-06-24 10:41:13 +01:00
Frooodle 058e7bd509 merge main 2026-06-23 15:12:11 +01:00
Anthony Stirling 1ed61c7d9d Merge remote-tracking branch 'origin/main' into default-single-placement-for-add-tools
# Conflicts:
#	frontend/editor/public/locales/en-GB/translation.toml
2026-06-08 15:42:36 +01:00
Anthony Stirling 3f5717b5ad Add Playwright spec covering single vs multiple placement behaviour 2026-05-28 12:04:44 +01:00
Anthony Stirling 3b9113b9a6 Fix place-multiple toggle and reset placement state on tool exit 2026-05-28 11:42:41 +01:00
Anthony Stirling 6dc446a39e Add Playwright spec for place-multiple checkbox 2026-05-26 19:49:09 +01:00
Anthony Stirling c24370c28a Merge remote-tracking branch 'origin/main' into work-6247
# Conflicts:
#	frontend/editor/src/core/components/viewer/signaturePlacement.test.ts
#	frontend/editor/src/core/components/viewer/signaturePlacement.ts
2026-05-26 19:14:51 +01:00
Anthony Stirling 2a82c9ae19 Add unit-tested helper for placement auto-exit decision 2026-05-26 19:08:36 +01:00
Anthony StirlingandAnthony Stirling b70c7b41e3 default single placement for add image, signature and text tools 2026-04-28 11:03:10 +01:00
21 changed files with 502 additions and 11 deletions
@@ -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.
*
@@ -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() {
@@ -230,6 +230,8 @@ title = "How to add images"
move = "Move Image"
pause = "Pause placement"
place = "Place Image"
placeMultiple = "Stay in placement mode after each placement"
placeMultipleDesc = "Place several images in a row instead of exiting after the first."
resume = "Resume placement"
[addImage.results]
@@ -445,6 +447,8 @@ title = "How to add text"
move = "Move Text"
pause = "Pause placement"
place = "Place Text"
placeMultiple = "Stay in placement mode after each placement"
placeMultipleDesc = "Place several text stamps in a row instead of exiting after the first."
resume = "Resume placement"
[addText.results]
@@ -9280,6 +9284,8 @@ title = "How to add signature"
move = "Move Signature"
pause = "Pause placement"
place = "Place Signature"
placeMultiple = "Stay in placement mode after each placement"
placeMultipleDesc = "Place several signatures in a row instead of exiting after the first."
resume = "Resume placement"
[sign.results]
@@ -8,6 +8,7 @@ import {
Tooltip,
Group,
Box,
Checkbox,
} from "@mantine/core";
import { Button } from "@app/ui/Button";
import { SegmentedControl } from "@app/ui/SegmentedControl";
@@ -34,6 +35,7 @@ import {
AddSignatureResult,
} from "@app/hooks/tools/sign/useSavedSignatures";
import { SavedSignaturesSection } from "@app/components/tools/sign/SavedSignaturesSection";
import { shouldPausePlacementAfterExit } from "@app/components/tools/sign/placementMode";
import { buildSignaturePreview } from "@app/utils/signaturePreview";
type SignatureDrafts = {
@@ -90,7 +92,13 @@ const SignSettings = ({
defaultSignatureSource,
}: SignSettingsProps) => {
const { t } = useTranslation();
const { isPlacementMode, signaturesApplied, historyApiRef } = useSignature();
const {
isPlacementMode,
signaturesApplied,
historyApiRef,
placeMultiple,
setPlaceMultiple,
} = useSignature();
const { activeFileIndex } = useViewer();
const [historyAvailability, setHistoryAvailability] = useState({
canUndo: false,
@@ -821,6 +829,34 @@ const SignSettings = ({
onParameterChange,
]);
// After a single placement (when "place multiple" is off) the
// SignatureAPIBridge drops out of placement mode. Without pausing here, the
// auto-activate effect below would immediately pull the user back into
// placement mode - so single placement would never stick and the "place
// multiple" checkbox would appear to do nothing.
const wasPlacementModeRef = useRef(isPlacementMode);
useEffect(() => {
const shouldPause = shouldPausePlacementAfterExit({
wasInPlacementMode: wasPlacementModeRef.current,
isInPlacementMode: isPlacementMode,
placeMultiple,
signaturesApplied,
placementEnabled: shouldEnablePlacement,
alreadyPaused: isPlacementManuallyPaused,
});
wasPlacementModeRef.current = isPlacementMode;
if (shouldPause) {
setPlacementManuallyPaused(true);
}
}, [
isPlacementMode,
placeMultiple,
signaturesApplied,
shouldEnablePlacement,
isPlacementManuallyPaused,
]);
useEffect(() => {
if (!shouldEnablePlacement) {
if (isPlacementMode) {
@@ -1197,6 +1233,20 @@ const SignSettings = ({
<Box style={{ marginLeft: "auto" }}>{placementToggleControl}</Box>
</Group>
<Checkbox
checked={placeMultiple}
onChange={(event) => setPlaceMultiple(event.currentTarget.checked)}
label={translate(
"mode.placeMultiple",
"Stay in placement mode after each placement",
)}
description={translate(
"mode.placeMultipleDesc",
"Place several stamps in a row instead of exiting after the first.",
)}
disabled={disabled}
/>
<Alert color={placementAlert.color} title={placementAlert.title}>
<Text size="sm">{placementAlert.message}</Text>
</Alert>
@@ -0,0 +1,71 @@
import { describe, expect, it } from "vitest";
import { shouldPausePlacementAfterExit } from "@app/components/tools/sign/placementMode";
const baseParams = {
wasInPlacementMode: true,
isInPlacementMode: false,
placeMultiple: false,
signaturesApplied: false,
placementEnabled: true,
alreadyPaused: false,
};
describe("shouldPausePlacementAfterExit", () => {
it("pauses after a single placement exits placement mode", () => {
expect(shouldPausePlacementAfterExit(baseParams)).toBe(true);
});
it("does not pause while still in placement mode", () => {
expect(
shouldPausePlacementAfterExit({
...baseParams,
isInPlacementMode: true,
}),
).toBe(false);
});
it("does not pause when placement mode was never active", () => {
expect(
shouldPausePlacementAfterExit({
...baseParams,
wasInPlacementMode: false,
}),
).toBe(false);
});
it("does not pause when 'place multiple' is enabled", () => {
expect(
shouldPausePlacementAfterExit({
...baseParams,
placeMultiple: true,
}),
).toBe(false);
});
it("does not pause once signatures have been applied", () => {
expect(
shouldPausePlacementAfterExit({
...baseParams,
signaturesApplied: true,
}),
).toBe(false);
});
it("does not pause when placement is disabled", () => {
expect(
shouldPausePlacementAfterExit({
...baseParams,
placementEnabled: false,
}),
).toBe(false);
});
it("does not re-pause when already paused", () => {
expect(
shouldPausePlacementAfterExit({
...baseParams,
alreadyPaused: true,
}),
).toBe(false);
});
});
@@ -0,0 +1,39 @@
interface PausePlacementParams {
/** Whether placement mode was active on the previous render. */
wasInPlacementMode: boolean;
/** Whether placement mode is active now. */
isInPlacementMode: boolean;
/** User opted into dropping several stamps in a row. */
placeMultiple: boolean;
/** True once placed signatures have been flattened/applied to the document. */
signaturesApplied: boolean;
/** Whether a signature is configured and placement is allowed. */
placementEnabled: boolean;
/** Whether placement is already manually paused. */
alreadyPaused: boolean;
}
/**
* Whether placement should be paused after the viewer auto-exits placement mode.
*
* The SignatureAPIBridge drops out of placement mode after a single stamp is
* placed (unless "place multiple" is on). Without pausing, SignSettings' own
* auto-activate effect would immediately re-enter placement mode, so single
* placement would never stick and the "place multiple" checkbox would appear to
* do nothing. We only react to the placement-mode exit (the bridge already
* limits auto-exit to stamp placements, never mid-signature ink strokes).
*/
export function shouldPausePlacementAfterExit(
params: PausePlacementParams,
): boolean {
const justExitedPlacement =
params.wasInPlacementMode && !params.isInPlacementMode;
return (
justExitedPlacement &&
!params.placeMultiple &&
!params.signaturesApplied &&
params.placementEnabled &&
!params.alreadyPaused
);
}
@@ -16,6 +16,7 @@ import type {
import type { SignParameters } from "@app/hooks/tools/sign/useSignParameters";
import { useViewer } from "@app/contexts/ViewerContext";
import { useDocumentReady } from "@app/components/viewer/hooks/useDocumentReady";
import { shouldAutoExitPlacement } from "@app/components/viewer/signaturePlacement";
/**
* Connects the PDF signature (stamp/ink) tools to the shared ViewerContext and SignatureContext.
@@ -185,7 +186,16 @@ export const SignatureAPIBridge = forwardRef<
isPlacementMode,
placementPreviewSize,
setSignaturesApplied,
placeMultiple,
setPlacementMode,
} = useSignature();
// Track latest placeMultiple in a ref so the long-lived onAnnotationEvent
// subscription always reads the current value without re-subscribing on every
// toggle change (which would race with mid-flight create events).
const placeMultipleRef = useRef(placeMultiple);
useEffect(() => {
placeMultipleRef.current = placeMultiple;
}, [placeMultiple]);
const { getZoomState, registerImmediateZoomUpdate } = useViewer();
const documentReady = useDocumentReady();
const [currentZoom, setCurrentZoom] = useState(
@@ -555,6 +565,11 @@ export const SignatureAPIBridge = forwardRef<
// Mark signatures as not applied when a new signature is placed
if (event.type === "create") {
setSignaturesApplied(false);
if (shouldAutoExitPlacement(annotation, placeMultipleRef.current)) {
annotationApi.setActiveTool(null);
setPlacementMode(false);
}
}
const directData =
@@ -576,7 +591,13 @@ export const SignatureAPIBridge = forwardRef<
return () => {
unsubscribe?.();
};
}, [annotationApi, storeImageData, setSignaturesApplied, documentReady]);
}, [
annotationApi,
storeImageData,
setSignaturesApplied,
setPlacementMode,
documentReady,
]);
useEffect(() => {
if (!isPlacementMode || !documentReady) {
@@ -0,0 +1,50 @@
import { describe, expect, it } from "vitest";
import { PdfAnnotationSubtype } from "@embedpdf/models";
import { shouldAutoExitPlacement } from "@app/components/viewer/signaturePlacement";
describe("shouldAutoExitPlacement", () => {
it("returns true for a stamp annotation when placeMultiple is false", () => {
expect(
shouldAutoExitPlacement({ type: PdfAnnotationSubtype.STAMP }, false),
).toBe(true);
});
it("returns false for a stamp annotation when placeMultiple is true", () => {
expect(
shouldAutoExitPlacement({ type: PdfAnnotationSubtype.STAMP }, true),
).toBe(false);
});
it("returns false for an ink-stroke annotation regardless of placeMultiple", () => {
expect(
shouldAutoExitPlacement({ type: PdfAnnotationSubtype.INK }, false),
).toBe(false);
expect(
shouldAutoExitPlacement({ type: PdfAnnotationSubtype.INK }, true),
).toBe(false);
});
it("falls back to annotation.object.type when annotation.type is missing", () => {
expect(
shouldAutoExitPlacement(
{ object: { type: PdfAnnotationSubtype.STAMP } },
false,
),
).toBe(true);
});
it("returns false when neither annotation.type nor object.type is present", () => {
expect(shouldAutoExitPlacement({}, false)).toBe(false);
expect(shouldAutoExitPlacement(null, false)).toBe(false);
expect(shouldAutoExitPlacement(undefined, false)).toBe(false);
});
it("returns false for FREETEXT, HIGHLIGHT, and other non-stamp types", () => {
expect(
shouldAutoExitPlacement({ type: PdfAnnotationSubtype.FREETEXT }, false),
).toBe(false);
expect(
shouldAutoExitPlacement({ type: PdfAnnotationSubtype.HIGHLIGHT }, false),
).toBe(false);
});
});
@@ -0,0 +1,23 @@
import { PdfAnnotationSubtype } from "@embedpdf/models";
interface AutoExitCandidate {
type?: unknown;
object?: { type?: unknown };
}
/**
* Whether placement mode should auto-exit after a `create` annotation event.
*
* Only stamp annotations trigger auto-exit. Ink strokes also raise `create`
* events, but a multi-stroke signature would break if we deactivated the tool
* after the first stroke. When `placeMultiple` is true the user has opted in
* to dropping several stamps in a row, so we never auto-exit.
*/
export function shouldAutoExitPlacement(
annotation: AutoExitCandidate | null | undefined,
placeMultiple: boolean,
): boolean {
if (placeMultiple) return false;
const type = annotation?.type ?? annotation?.object?.type ?? null;
return type === PdfAnnotationSubtype.STAMP;
}
@@ -23,6 +23,10 @@ interface SignatureState {
signaturesApplied: boolean;
// Size (in screen units) we want newly placed signatures to use
placementPreviewSize: { width: number; height: number } | null;
// When false (default), placement mode auto-exits after a single stamp is
// dropped so users don't accidentally place duplicates. When true, the user
// opted into staying in placement mode and can drop multiple stamps in a row.
placeMultiple: boolean;
}
// Signature actions interface
@@ -42,6 +46,7 @@ interface SignatureActions {
setPlacementPreviewSize: (
size: { width: number; height: number } | null,
) => void;
setPlaceMultiple: (enabled: boolean) => void;
}
// Combined context interface
@@ -62,6 +67,7 @@ const initialState: SignatureState = {
isPlacementMode: false,
signaturesApplied: true, // Start as true (no signatures placed yet)
placementPreviewSize: null,
placeMultiple: false,
};
// Provider component
@@ -174,6 +180,13 @@ export const SignatureProvider: React.FC<{ children: ReactNode }> = ({
[],
);
const setPlaceMultiple = useCallback((enabled: boolean) => {
setState((prev) => ({
...prev,
placeMultiple: enabled,
}));
}, []);
// No auto-activation - all modes use manual buttons
const contextValue: SignatureContextValue = {
@@ -194,6 +207,7 @@ export const SignatureProvider: React.FC<{ children: ReactNode }> = ({
getImageData,
setSignaturesApplied,
setPlacementPreviewSize,
setPlaceMultiple,
};
return (
@@ -0,0 +1,90 @@
import { test, expect } from "@app/tests/helpers/stub-test-base";
import { uploadFiles, dismissTourTooltip } from "@app/tests/helpers/ui-helpers";
import type { Page } from "@playwright/test";
import path from "path";
const SAMPLE_PDF = path.join(
import.meta.dirname,
"../test-fixtures/sample.pdf",
);
const FIRST_PAGE = '[data-page-index="0"]';
const pauseButton = (page: Page) =>
page.getByRole("button", { name: /pause placement/i });
const resumeButton = (page: Page) =>
page.getByRole("button", { name: /resume placement/i });
/**
* Reviewer report: on the stamp-style tools the "place multiple" checkbox
* "doesn't do anything". Single placement never stuck because, after the
* viewer auto-exited placement mode, SignSettings' auto-activate effect
* immediately re-entered it. These tests drive a real text-stamp placement and
* assert the placement toggle settles into the correct state:
* - box off (default): placement exits after one stamp (Resume offered)
* - box on: placement stays active across stamps (Pause stays offered)
*
* Unit coverage of the decision lives in
* components/tools/sign/placementMode.test.ts; this spec guards the end-to-end
* UX so future refactors don't silently regress it.
*/
test.describe("AddText place-multiple behaviour", () => {
async function enterPlacementMode(page: Page): Promise<void> {
await page.goto("/add-text");
await page.waitForLoadState("domcontentloaded");
await uploadFiles(page, SAMPLE_PDF);
await dismissTourTooltip(page);
// Wait for the PDF to render before configuring the signature. Placement is
// activated on text change and only fires once, so the viewer (and its
// SignatureAPIBridge) must be mounted first or the activation is lost.
await expect(page.locator(FIRST_PAGE).first()).toBeVisible({
timeout: 30_000,
});
// Configuring a text signature auto-activates placement mode.
await page
.getByPlaceholder("Enter the text you want to add")
.fill("Reviewer Test");
// Placement active -> the toggle offers "Pause placement".
await expect(pauseButton(page)).toBeVisible({ timeout: 20_000 });
}
test("single placement (default) exits placement mode", async ({ page }) => {
await enterPlacementMode(page);
await page
.locator(FIRST_PAGE)
.first()
.click({ position: { x: 150, y: 150 } });
// Wait past the 60ms auto-activate window: with the fix the tool stays
// exited; without it placement bounces straight back into "Pause" mode.
await page.waitForTimeout(750);
await expect(resumeButton(page)).toBeVisible();
await expect(pauseButton(page)).toBeHidden();
});
test("'place multiple' keeps placement active after a placement", async ({
page,
}) => {
await enterPlacementMode(page);
await page
.getByRole("checkbox", {
name: /stay in placement mode after each placement/i,
})
.check();
await page
.locator(FIRST_PAGE)
.first()
.click({ position: { x: 150, y: 150 } });
await page.waitForTimeout(750);
// Still placing: Pause stays offered, Resume never appears.
await expect(pauseButton(page)).toBeVisible();
await expect(resumeButton(page)).toBeHidden();
});
});
@@ -0,0 +1,58 @@
import { test, expect } from "@app/tests/helpers/stub-test-base";
import { uploadFiles } from "@app/tests/helpers/ui-helpers";
import path from "path";
const SAMPLE_PDF = path.join(
import.meta.dirname,
"../test-fixtures/sample.pdf",
);
const TOOLS_WITH_PLACEMENT_TOGGLE: Array<{ name: string; url: string }> = [
{ name: "AddImage", url: "/add-image" },
{ name: "AddText", url: "/add-text" },
{ name: "Sign", url: "/sign" },
];
/**
* The "place multiple" checkbox is rendered by SignSettings for the three
* stamp-style tools (AddImage / AddText / Sign). Behaviour contract:
* - Default unchecked: placement mode auto-exits after one stamp
* - Toggling on keeps the user in placement mode across multiple stamps
* Helper logic is unit-tested in signaturePlacement.test.ts; this spec
* verifies the UI contract end-to-end so future SignSettings refactors do
* not silently regress the default UX.
*/
for (const tool of TOOLS_WITH_PLACEMENT_TOGGLE) {
test.describe(`${tool.name} placement toggle`, () => {
test("renders the 'place multiple' checkbox unchecked by default", async ({
page,
}) => {
await page.goto(tool.url);
await page.waitForLoadState("domcontentloaded");
await uploadFiles(page, SAMPLE_PDF);
const placeMultiple = page.getByRole("checkbox", {
name: /stay in placement mode after each placement/i,
});
await expect(placeMultiple).toBeVisible({ timeout: 15_000 });
await expect(placeMultiple).not.toBeChecked();
});
test("toggling the 'place multiple' checkbox flips its state", async ({
page,
}) => {
await page.goto(tool.url);
await page.waitForLoadState("domcontentloaded");
await uploadFiles(page, SAMPLE_PDF);
const placeMultiple = page.getByRole("checkbox", {
name: /stay in placement mode after each placement/i,
});
await expect(placeMultiple).toBeVisible({ timeout: 15_000 });
await placeMultiple.check();
await expect(placeMultiple).toBeChecked();
await placeMultiple.uncheck();
await expect(placeMultiple).not.toBeChecked();
});
});
}
@@ -73,6 +73,8 @@ export const createStampTool = (config: StampToolConfig) => {
signatureApiRef,
getImageData,
setSignaturesApplied,
setPlacementMode,
setPlaceMultiple,
} = useSignature();
const { consumeFiles, selectors } = useFileContext();
const {
@@ -143,6 +145,18 @@ export const createStampTool = (config: StampToolConfig) => {
setSignatureConfig(base.params.parameters);
}, [base.params.parameters, setSignatureConfig]);
// When the tool unmounts (user navigates to a different tool), leave
// placement mode and clear any active stamp/ink tool. Otherwise the
// placement state and the "place signature" cursor leak into whatever the
// user opens next.
useEffect(() => {
return () => {
handleDeactivateSignature();
setPlacementMode(false);
setPlaceMultiple(false);
};
}, [handleDeactivateSignature, setPlacementMode, setPlaceMultiple]);
const handleSaveToSystem = useCallback(async () => {
try {
unregisterUnsavedChangesChecker();
@@ -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>