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

fix(media): omit saved examinations history when examining specific items

Adam Eivyd23e0a5854a3
diff --git a/client/src/components/media/PromptFromMedia.jsx b/client/src/components/media/PromptFromMedia.jsx
index fe7a50964f..25a433bb84 100644
--- a/client/src/components/media/PromptFromMedia.jsx
+++ b/client/src/components/media/PromptFromMedia.jsx
@@ -72,6 +72,7 @@ export default function PromptFromMedia({
initialSource = null,
disabled = false,
alwaysOpen = false,
+ showHistory = !initialSource && !setPrompt,
onResult,
}) {
const navigate = useNavigate();
@@ -124,7 +125,7 @@ export default function PromptFromMedia({
const { data: history, error: historyError, updateData: setHistory } = useSocketResource(
({ signal }) => listMediaPromptExaminations(historyOffset, { silent: true, signal }),
- { events: HISTORY_EVENTS, resourceKey: historyOffset, enabled: isOpen },
+ { events: HISTORY_EVENTS, resourceKey: historyOffset, enabled: isOpen && showHistory },
);
useEffect(() => {
@@ -211,11 +212,13 @@ export default function PromptFromMedia({
}
if (onResult) onResult(data);
if (data.examinationId) {
- setHistoryOffset(0);
- setHistory((previous) => ({
- items: [{ id: data.examinationId, createdAt: new Date().toISOString(), source }, ...(previous?.items || []).filter((entry) => entry.id !== data.examinationId)].slice(0, 20),
- hasMore: previous?.hasMore || previous?.items.length >= 20,
- }));
+ if (showHistory) {
+ setHistoryOffset(0);
+ setHistory((previous) => ({
+ items: [{ id: data.examinationId, createdAt: new Date().toISOString(), source }, ...(previous?.items || []).filter((entry) => entry.id !== data.examinationId)].slice(0, 20),
+ hasMore: previous?.hasMore || previous?.items.length >= 20,
+ }));
+ }
if (alwaysOpen && !initialSource && !setPrompt) navigate(`/media/prompt/${data.examinationId}`);
}
};
@@ -262,22 +265,24 @@ export default function PromptFromMedia({
{isOpen && (
<div className={alwaysOpen ? 'space-y-3' : 'p-3 bg-port-bg/70 border border-port-border rounded-lg space-y-3'}>
- <details className="space-y-2">
- <summary className="text-sm text-white cursor-pointer min-h-[36px]">Saved examinations</summary>
- <p className="text-xs text-gray-400">Each analysis saves both requested prompts. Reopen a reference to render either without analyzing again.</p>
- {historyError && <p role="alert" className="text-xs text-port-warning">Could not load examination history.</p>}
- {history?.items.map((entry) => (
- <button key={entry.id} type="button" disabled={running} onClick={() => navigate(`/media/prompt/${entry.id}`)}
- className="block text-left text-xs text-port-accent break-all min-h-[36px]">
- {entry.source.filename || entry.source.videoId} · {formatDateTime(entry.createdAt)}
- </button>
- ))}
- {history && !history.items.length && <p className="text-xs text-gray-400">No saved examinations yet.</p>}
- <div className="flex gap-3 text-xs text-port-accent">
- {historyOffset > 0 && <button type="button" onClick={() => setHistoryOffset((value) => Math.max(0, value - 20))}>Previous examinations</button>}
- {history?.hasMore && <button type="button" onClick={() => setHistoryOffset((value) => value + 20)}>Older examinations</button>}
- </div>
- </details>
+ {showHistory && (
+ <details className="space-y-2">
+ <summary className="text-sm text-white cursor-pointer min-h-[36px]">Saved examinations</summary>
+ <p className="text-xs text-gray-400">Each analysis saves both requested prompts. Reopen a reference to render either without analyzing again.</p>
+ {historyError && <p role="alert" className="text-xs text-port-warning">Could not load examination history.</p>}
+ {history?.items.map((entry) => (
+ <button key={entry.id} type="button" disabled={running} onClick={() => navigate(`/media/prompt/${entry.id}`)}
+ className="block text-left text-xs text-port-accent break-all min-h-[36px]">
+ {entry.source.filename || entry.source.videoId} · {formatDateTime(entry.createdAt)}
+ </button>
+ ))}
+ {history && !history.items.length && <p className="text-xs text-gray-400">No saved examinations yet.</p>}
+ <div className="flex gap-3 text-xs text-port-accent">
+ {historyOffset > 0 && <button type="button" onClick={() => setHistoryOffset((value) => Math.max(0, value - 20))}>Previous examinations</button>}
+ {history?.hasMore && <button type="button" onClick={() => setHistoryOffset((value) => value + 20)}>Older examinations</button>}
+ </div>
+ </details>
+ )}
{detailError && <p role="alert" className="text-xs text-port-warning">{detailError}</p>}
<div className="flex flex-wrap items-center gap-2">
<button
@@ -487,6 +492,7 @@ export function PromptFromMediaModal({ item, open, onClose, kindDefault = 'both'
kindDefault={kindDefault}
initialSource={item}
alwaysOpen
+ showHistory={false}
onResult={onResult}
/>
</div>
diff --git a/client/src/components/media/PromptFromMedia.test.jsx b/client/src/components/media/PromptFromMedia.test.jsx
index 0c54096d21..ec9dd62f03 100644
--- a/client/src/components/media/PromptFromMedia.test.jsx
+++ b/client/src/components/media/PromptFromMedia.test.jsx
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { MemoryRouter, Routes, Route, Link } from 'react-router';
-import PromptFromMedia from './PromptFromMedia';
+import PromptFromMedia, { PromptFromMediaModal } from './PromptFromMedia';
import * as api from '../../services/apiMediaJobs';
vi.mock('../../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn(), emit: vi.fn() } }));
@@ -147,7 +147,7 @@ describe('PromptFromMedia', () => {
});
it('skips the disclosure toggle when hosted as an always-open card', async () => {
- renderPanel({ alwaysOpen: true, initialSource: null });
+ renderPanel({ alwaysOpen: true, initialSource: null, showHistory: true });
await screen.findByText('No saved examinations yet.');
expect(screen.queryByRole('button', { name: /toggle prompt from media/i })).toBeNull();
expect(screen.getByRole('button', { name: /pick image/i })).toBeInTheDocument();
@@ -175,7 +175,7 @@ it('does not duplicate a saved examination already received through history refr
items: [{ id: 'saved', source: { filename: 'still.png' }, createdAt: '2026-01-01T00:00:00Z' }], hasMore: false,
});
api.promptFromMedia.mockResolvedValueOnce({ imagePrompt: 'Mountains', examinationId: 'saved' });
- renderPanel();
+ renderPanel({ showHistory: true });
await screen.findByText(/still.png ·/);
fireEvent.click(screen.getByRole('button', { name: 'Create prompt' }));
await screen.findByDisplayValue('Mountains');
@@ -197,3 +197,20 @@ it('clears the saved examination when returning to the analyzer index', async ()
expect(screen.queryByRole('button', { name: 'Clear selected media' })).toBeNull();
expect(screen.getByRole('button', { name: 'Create prompt' })).toBeDisabled();
});
+
+it('omits saved examinations when initialSource is passed by default', () => {
+ renderPanel();
+ expect(screen.queryByText('Saved examinations')).toBeNull();
+ expect(api.listMediaPromptExaminations).not.toHaveBeenCalled();
+});
+
+it('omits saved examinations in PromptFromMediaModal', () => {
+ render(
+ <MemoryRouter>
+ <PromptFromMediaModal item={INITIAL} open onClose={vi.fn()} />
+ </MemoryRouter>,
+ );
+ expect(screen.getByText('Prompt from this')).toBeInTheDocument();
+ expect(screen.queryByText('Saved examinations')).toBeNull();
+ expect(api.listMediaPromptExaminations).not.toHaveBeenCalled();
+});
diff --git a/client/src/pages/PromptFromMediaPage.jsx b/client/src/pages/PromptFromMediaPage.jsx
index 0fd33ce8e5..8782363064 100644
--- a/client/src/pages/PromptFromMediaPage.jsx
+++ b/client/src/pages/PromptFromMediaPage.jsx
@@ -12,7 +12,7 @@ export default function PromptFromMediaPage() {
</div>
</div>
<div className="bg-port-card border border-port-border rounded-xl p-4">
- <PromptFromMedia kindDefault="both" alwaysOpen />
+ <PromptFromMedia kindDefault="both" alwaysOpen showHistory />
</div>
</div>
);