Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat([issue-1764]): gallery Clean runs SynthID-disrupting resize-squeeze; label it honestly

[._.]/ Adam Eivy56c6f229c96f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 42bdd05886..c1742c02e5 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -12,6 +12,10 @@
- **[issue-2158] Your Tribe now nudges you about messages you never replied to — with a reply ready to draft.** Beyond the existing "you haven't talked in a while" cadence reminders, PortOS now reads your activity timeline (iMessage and Signal) to spot inbound messages from people in your Tribe that you never answered, and surfaces them both as a proactive alert ("You never replied to 'dinner Friday?' — 3 days ago") and in a new **Waiting on a reply** panel on the Tribe → Care Queue tab. Each one has a **Draft reply** button that writes a reply grounded in the actual conversation and files it to your Messages drafts for review — it uses your configured AI provider only when you click, and nothing is ever sent automatically (iMessage/Signal drafts are review-only, so you copy and send them from your messaging app). Threads you've already answered, ones too fresh to nag about, and ones too old to still be worth a reply are all filtered out; only 1:1 conversations with people in your Tribe (not group chats, not every contact) can trigger a nudge. (Email is intentionally out of scope for now — inbox-only sync can't see whether you already replied, so it isn't nudged.)
+## Image cleaning
+
+- **[issue-1764] "Clean" on a gallery image now runs a resize-squeeze that disrupts SynthID — and the Image Cleaner labels the option clearly.** Clicking **Clean** in the media-history image viewer (and the other gallery lightboxes) used to run a metadata-strip + denoise pass that, by design, did nothing to SynthID — the invisible watermark in gpt-image / Imagen / Gemini renders. It now runs a CPU resize-squeeze instead: a downscale→upscale round-trip that still strips the C2PA provenance chunk (via re-encode) and additionally perturbs SynthID's resolution-dependent carriers. In hands-on testing against OpenAI's SynthID detector this made the detector fail to return a positive — so it's a genuine best-effort disruption, though it's detector-dependent and never a guaranteed removal (the UI says so). The same option is now clearly labeled **CPU resize-squeeze** in the Dev Tools → Image Cleaner page (previously the misleading "CPU light pass" under a "Diffusion" heading), so you can apply it to any uploaded image. No GPU required; heavy visible degradation is not needed for the effect.
+
## Added
- [issue-2763] **Layered Intelligence now reasons from a proposal playbook instead of proposing blind.** Every LI run's prompt now carries a standing **Proposal Playbook** — a distilled rule set for *what* to propose that's present from the very first run, before any per-app outcome data has accumulated. It encodes a Scope Selection Guide (prioritize high-merge scopes like `loop-meta` and `app-data-gap`; only file an `app-improvement` when it clearly serves a named goal), a Success Pattern Catalog and a Rejection Pattern Catalog (a NOT_PLANNED close means a roadmap conflict, so check goals and committed backlog *first*), Task Type Selection Rules (avoid the loop's own chronically-failing self-improvement work; prefer shapes an agent reliably finishes like plan-task / test-coverage / performance), and a Goal Alignment Check against PortOS's core goals and documented non-goals. It's authored as a reviewable markdown file that ships with the code and is injected verbatim into the reasoning prompt; where a live per-app outcome report in the same prompt has real numbers that contradict a general rule, the live data wins. Applies to every app the loop reasons about.
diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsx
index b9186272a9..5d1990e8de 100644
--- a/client/src/components/media/MediaLightbox.jsx
+++ b/client/src/components/media/MediaLightbox.jsx
@@ -41,7 +41,7 @@ const SAVED_INDICATOR_MS = 1500;
// so preventDefault here still cancels the browser's default text behavior. The
// editable-target check is shared with useKeyboardShortcuts (imported above).
-const CLEAN_TOOLTIP = 'Re-encode and denoise: removes the C2PA metadata chunk (when present) and reduces visible AI-generation artifacts. Does NOT defeat SynthID — gpt-image / Imagen / Gemini renders remain detectable by their vendor watermark checkers. Saves a new image alongside the original.';
+const CLEAN_TOOLTIP = 'Resize-squeeze (CPU, no GPU): a downscale→upscale round-trip that removes the C2PA metadata chunk (via re-encode) and perturbs SynthID’s resolution-dependent carriers. Best-effort SynthID disruption — in testing it made OpenAI’s SynthID detector fail to return a positive, but it is detector-dependent and never a guaranteed removal. Saves a new image alongside the original.';
// Three lineage cases:
// - auto-cleaned (replaced in place): "Auto-cleaned (aggressive)"
diff --git a/client/src/hooks/useMediaPreviewActions.js b/client/src/hooks/useMediaPreviewActions.js
index 2ab8fd749e..78a5ad65c1 100644
--- a/client/src/hooks/useMediaPreviewActions.js
+++ b/client/src/hooks/useMediaPreviewActions.js
@@ -1,7 +1,7 @@
import { useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import toast from '../components/ui/Toast';
-import { cleanGalleryImage, extractLastFrame, removeImageWatermark } from '../services/apiImageVideo';
+import { regenerateGalleryImage, extractLastFrame, removeImageWatermark } from '../services/apiImageVideo';
import { VIDEO_TILING_ENUM_SET } from '../lib/videoTilingOptions';
// Common image render-setting params shared by the image branch of Remix and by
@@ -143,15 +143,20 @@ export default function useMediaPreviewActions({ onCleanComplete = null } = {})
navigate(`/media/video?${params}`);
}, [navigate]);
- // Clean: re-encode + denoise via the gallery clean endpoint to strip C2PA
- // provenance and reduce AI artifacts. Returns the resulting gallery item so
- // consumers can splice it into local state. `onCleanComplete` is the
- // consumer-specific post-step (add-to-collection / prepend-to-history /
- // etc.) — fired AFTER the success toast so a failing post-step still shows
- // the user the clean succeeded server-side.
+ // Clean: run the CPU resize-squeeze (light regen). This downscale→upscale
+ // resolution shift re-encodes to PNG — so it still strips the C2PA provenance
+ // chunk and ancillary metadata as a side effect — AND perturbs SynthID's
+ // resolution-dependent carriers (issue #1764: validated best-effort against
+ // OpenAI's SynthID detector — it makes the detector fail to return a positive;
+ // best-effort/detector-dependent, never a guaranteed removal). This replaces
+ // the old metadata+denoise "aggressive" clean, which did NOT touch SynthID.
+ // The light method is synchronous and returns the new gallery variant directly
+ // (no FLUX runner / GPU needed). `onCleanComplete` is the consumer-specific
+ // post-step (add-to-collection / prepend-to-history / etc.) — fired AFTER the
+ // success toast so a failing post-step still shows the user it succeeded.
const handleClean = useCallback(async (img) => {
if (!img?.filename) throw new Error('Missing filename');
- const cleaned = await cleanGalleryImage(img.filename, { silent: true }).catch((err) => {
+ const cleaned = await regenerateGalleryImage(img.filename, { method: 'light' }).catch((err) => {
toast.error(err.message || 'Failed to clean image');
throw err;
});
diff --git a/client/src/hooks/useMediaPreviewActions.test.jsx b/client/src/hooks/useMediaPreviewActions.test.jsx
index be86e969b8..a2ca3c1fc0 100644
--- a/client/src/hooks/useMediaPreviewActions.test.jsx
+++ b/client/src/hooks/useMediaPreviewActions.test.jsx
@@ -6,12 +6,12 @@ const navigate = vi.fn();
vi.mock('react-router-dom', () => ({ useNavigate: () => navigate }));
vi.mock('../components/ui/Toast', () => ({ default: { error: vi.fn(), success: vi.fn() } }));
vi.mock('../services/apiImageVideo', () => ({
- cleanGalleryImage: vi.fn(),
+ regenerateGalleryImage: vi.fn(),
extractLastFrame: vi.fn(),
removeImageWatermark: vi.fn(),
}));
-import { removeImageWatermark } from '../services/apiImageVideo';
+import { removeImageWatermark, regenerateGalleryImage } from '../services/apiImageVideo';
const parseNav = () => {
const url = navigate.mock.calls.at(-1)?.[0] || '';
@@ -78,3 +78,24 @@ describe('useMediaPreviewActions.handleRemoveWatermark', () => {
expect(removeImageWatermark).not.toHaveBeenCalled();
});
});
+
+describe('useMediaPreviewActions.handleClean', () => {
+ beforeEach(() => regenerateGalleryImage.mockReset());
+
+ it('runs the CPU resize-squeeze (light regen), not the aggressive denoise clean', async () => {
+ const variant = { filename: 'cat_regen-light.png', regenMethod: 'light-spatial' };
+ regenerateGalleryImage.mockResolvedValue(variant);
+ const onCleanComplete = vi.fn();
+ const { result } = renderHook(() => useMediaPreviewActions({ onCleanComplete }));
+ const returned = await result.current.handleClean({ filename: 'cat.png' });
+ expect(regenerateGalleryImage).toHaveBeenCalledWith('cat.png', { method: 'light' });
+ expect(onCleanComplete).toHaveBeenCalledWith(variant);
+ expect(returned).toBe(variant);
+ });
+
+ it('throws when the image has no filename', async () => {
+ const { result } = renderHook(() => useMediaPreviewActions());
+ await expect(result.current.handleClean({})).rejects.toThrow('Missing filename');
+ expect(regenerateGalleryImage).not.toHaveBeenCalled();
+ });
+});
diff --git a/client/src/pages/ImageClean.jsx b/client/src/pages/ImageClean.jsx
index c530bb0ed3..2d42e3b50d 100644
--- a/client/src/pages/ImageClean.jsx
+++ b/client/src/pages/ImageClean.jsx
@@ -374,8 +374,8 @@ export default function ImageClean() {
},
{
key: 'diffusion',
- label: 'Diffusion pass — disrupt SynthID',
- hint: 'Lossy, best-effort — round-trips the pixels to perturb SynthID\'s watermark carriers. This is the only step that touches SynthID, and it disrupts — never guarantees removal. Blurs fine text (use the ignore-zone mask to preserve regions).',
+ label: 'Disrupt SynthID (resize-squeeze / diffusion)',
+ hint: 'Lossy, best-effort — the only step that touches SynthID. Pick a sub-mode below: a CPU resize-squeeze (downscale→upscale, no GPU) or a GPU FLUX round-trip. Both perturb SynthID\'s resolution-dependent carriers and disrupt — never guarantee removal. Blurs fine text (use the ignore-zone mask to preserve regions).',
},
];
@@ -483,7 +483,7 @@ export default function ImageClean() {
<Zap size={16} className="text-port-accent" />
<span className="text-sm font-medium text-white">Diffusion sub-mode</span>
</div>
- {/* Sub-mode selector — GPU (hardware-gated) vs CPU light pass. */}
+ {/* Sub-mode selector — GPU FLUX round-trip (hardware-gated) vs CPU resize-squeeze. */}
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
<button
type="button"
@@ -512,9 +512,10 @@ export default function ImageClean() {
: 'border-port-border hover:border-port-accent/50'
}`}
>
- <span className="flex items-center gap-2 text-sm text-white"><Cpu size={14} /> CPU light pass</span>
+ <span className="flex items-center gap-2 text-sm text-white"><Cpu size={14} /> CPU resize-squeeze</span>
<span className="block text-xs text-gray-500 mt-1">
- Always available, synchronous. Best-effort spatial round-trip — lower reliability than the GPU pass.
+ Always available, synchronous, no GPU. Downscale→upscale round-trip that shifts SynthID&apos;s
+ resolution-dependent carriers. Best-effort and detector-dependent — never guaranteed removal.
</span>
</button>
</div>