Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/gui/0_gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ to new work; changes do not alter saved results.

Select **Attacks** in the sidebar to open Chat (`/attack/chat`), the manual conversation
workspace. Select a target and write the messages yourself. You can attach media, transform content with converters,
and branch or edit conversations to try another approach. In an empty new chat, use **Need inspiration? Browse seed prompts**
to find examples already loaded in memory. The **Seed prompts** action below the composer stays available
and branch or edit conversations to try another approach. The small paperclip helper below the composer offers
**Need inspiration? Browse seed prompts** to open examples already loaded in memory. It stays available after each turn and
when sending is disabled, including for a saved conversation. Browsing does not download providers, create an attack, or send a prompt.
When you open a dataset from Chat, **Return to Chat** takes you back to the originating draft or saved conversation,
including unsaved edits, media, and converter work. Unsaved edits still require saving or confirming discard.
Filters, pagination, and the selected example survive the round trip; paging history stays with its dataset.
While viewing dataset detail, the sidebar's **Datasets** action returns to the catalog with its previous filters.
Opening Datasets from another workspace does not select an unrelated Chat destination.
Add an objective and
select a chat scorer if you want automated assessment of responses.
Expand Down
6 changes: 4 additions & 2 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ The visible example page and open detail also check for stored changes each minu
using the same filters and page cursor. Transient background errors keep the
previously loaded content visible with an error message until a check succeeds.
Deleted examples and invalid page cursors still show their explicit recovery state.
**Back to datasets** returns to the catalog search, facets, and sort you came
from. A direct link without that return state goes to `/datasets`.
From dataset detail, the sidebar's **Datasets** action returns to the catalog search,
facets, and sort you came from, or `/datasets` for a direct link. Entering Datasets from
another workspace restores the last dataset view and its paging. When entered from Chat,
**Return to Chat** returns to the originating draft or saved conversation.
On narrow screens, scroll the example table horizontally to read its columns.
Expanded details stack each label above its stored value.

Expand Down
44 changes: 38 additions & 6 deletions frontend/e2e/datasets.seeded.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ test.describe("dataset examples against the real backend @seeded", () => {
.screenshot({ path: testInfo.outputPath("provider-metadata.png") });
await page.screenshot({ path: testInfo.outputPath("provider-description.png"), fullPage: true });

await page.getByRole("link", { name: "Back to datasets", exact: true }).click();
await expect(page.getByRole("link", { name: "Back to datasets", exact: true })).toHaveCount(0);
await page.goBack();
await expect(page.getByRole("link", { name: provider.name, exact: true })).toBeVisible();
await expect(page).toHaveURL((url: URL) => url.searchParams.get("view") === "available"
&& url.searchParams.get("q") === provider.name);
Expand All @@ -128,7 +129,7 @@ test.describe("dataset examples against the real backend @seeded", () => {
if (outgoing.method() === "POST") postRequests.push(new URL(outgoing.url()).pathname);
});
await page.goto("/attack/chat");
await page.getByRole("button", { name: "Browse seed prompts", exact: true }).click();
await page.getByRole("button", { name: "Need inspiration? Browse seed prompts", exact: true }).click();
await expect(page).toHaveURL(/\/datasets$/);
await page.getByRole("link", { name: "jailbreak_templates", exact: true }).click();
await page.getByRole("link", { name: "Return to Chat" }).click();
Expand All @@ -146,7 +147,7 @@ test.describe("dataset examples against the real backend @seeded", () => {
await page.goto(path);
await expect(page.getByTestId("target-resolution-legacy-banner")).toBeVisible();
const origin = page.url();
await page.getByRole("button", { name: "Browse seed prompts from composer" }).click();
await page.getByRole("button", { name: "Need inspiration? Browse seed prompts" }).click();
await page.getByRole("link", { name: "jailbreak_templates", exact: true }).click();
await page.getByRole("link", { name: "Return to Chat" }).click();
await expect(page).toHaveURL(origin);
Expand All @@ -155,6 +156,35 @@ test.describe("dataset examples against the real backend @seeded", () => {
});

for (const width of [390, 1280]) {
test(`keeps the helper as the sole browse action after sending at ${width}px @seeded`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
await page.goto('/attack/chat');
await page.getByRole('combobox', { name: 'Objective target', exact: true }).selectOption('browser_offline');
const helper = page.getByRole('button', { name: 'Need inspiration? Browse seed prompts', exact: true });
await expect(helper).toBeVisible();
await expect(page.getByText('Seed prompts', { exact: true })).toHaveCount(0);
await page.getByPlaceholder('Type prompt here').fill('A persistent helper should remain after this turn.');
await page.getByRole('button', { name: 'Send message', exact: true }).click();
await expect(page.getByText('Offline browser response.', { exact: true }).first()).toBeVisible();
await helper.click();
await expect(page.getByRole('heading', { name: 'Datasets', exact: true })).toBeVisible();
await page.getByRole('button', { name: 'Return to Chat', exact: true }).click();
await expect(helper).toBeVisible();
await expect(page.getByText('Offline browser response.', { exact: true }).first()).toBeVisible();
});

test(`opens the catalog from bookmarked dataset detail at ${width}px @seeded`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
for (const key of ['dataset:named:jailbreak_templates', 'missing']) {
await page.goto(`/datasets/detail?selection_key=${encodeURIComponent(key)}`);
await expect(page.getByRole('heading', { name: key === 'missing' ? 'Dataset not found' : 'jailbreak_templates', exact: true })).toBeVisible();
await expect(page.getByRole('link', { name: 'Back to datasets', exact: true })).toHaveCount(0);
await page.getByRole('button', { name: 'Datasets', exact: true }).click();
await expect(page).toHaveURL(/\/datasets$/);
await expect(page.getByRole('link', { name: 'jailbreak_templates', exact: true })).toBeVisible();
}
});

test(`keeps a nonempty draft and target on a keyboard round trip at ${width}px @seeded`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
const mutations: string[] = [];
Expand All @@ -165,7 +195,8 @@ test.describe("dataset examples against the real backend @seeded", () => {
const target = page.getByRole('combobox', { name: 'Objective target', exact: true });
await target.selectOption('browser_offline');
await page.getByPlaceholder('Type prompt here').fill('Keep my nonempty browser draft.');
const browse = page.getByRole('button', { name: 'Browse seed prompts from composer' });
await expect(page.getByRole('button', { name: 'Need inspiration? Browse seed prompts', exact: true })).toBeVisible();
const browse = page.getByRole('button', { name: 'Need inspiration? Browse seed prompts' });
await browse.focus();
await page.keyboard.press('Enter');
await page.getByRole('textbox', { name: 'Search datasets' }).fill('jailbreak');
Expand All @@ -175,7 +206,7 @@ test.describe("dataset examples against the real backend @seeded", () => {
await expect(page.getByPlaceholder('Type prompt here')).toHaveValue('Keep my nonempty browser draft.');
await expect(page.getByPlaceholder('Type prompt here')).toBeFocused();
await expect(target).toHaveValue('browser_offline');
await page.getByRole('button', { name: 'Browse seed prompts from composer' }).click();
await page.getByRole('button', { name: 'Need inspiration? Browse seed prompts' }).click();
await expect(page.getByRole('textbox', { name: 'Search datasets' })).toHaveValue('jailbreak');
expect(mutations).toEqual([]);
});
Expand Down Expand Up @@ -220,7 +251,8 @@ test.describe("dataset examples against the real backend @seeded", () => {
expect(before.ok()).toBe(true);
sourceMessages = await before.json();
await page.goto(`/attack/chat/${source.attack_result_id}/conversations/${source.conversation_id}`);
await page.getByRole('button', { name: 'Browse seed prompts from composer' }).click();
await expect(page.getByText('Preserve existing saved history.', { exact: true })).toBeVisible();
await page.getByRole('button', { name: 'Need inspiration? Browse seed prompts' }).click();
} else {
await page.goto('/datasets');
await expect(page.getByRole('button', { name: 'Return to Chat' })).toHaveCount(0);
Expand Down
9 changes: 7 additions & 2 deletions frontend/e2e/datasets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,20 @@ test.describe("dataset example table", () => {
&& params.get("selection_key") === DATASET.selection_key;
})).toBe(true);

await page.getByRole("link", { name: "Back to datasets" }).click();
await expect(page.getByRole("link", { name: "Back to datasets" })).toHaveCount(0);
let historySteps = 0;
while (new URL(page.url()).pathname === "/datasets/detail" && historySteps < 4) {
await page.goBack();
historySteps += 1;
}
await expect(page).toHaveURL(/\/datasets\?/);
await expect(page).toHaveURL(/q=harm(?:&|$)/);
await expect(page).toHaveURL(/modality=text/);
await expect(page).toHaveURL(new RegExp(`harm_category=${encodeURIComponent(LONG_HARM_CATEGORY)}`));
await expect(page).toHaveURL(/sort=name/);
await expect(page.getByRole("table", { name: "Examples" })).toHaveCount(0);

await page.goBack();
for (let entry = 0; entry < historySteps; entry++) await page.goForward();
await expect(page.getByRole("region", { name: "Example detail" })).toBeVisible();
await page.reload();
await expect(page.getByRole("region", { name: "Example detail" })).toBeVisible();
Expand Down
61 changes: 60 additions & 1 deletion frontend/src/App.drafts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,65 @@ describe('App draft handoff with the real chat and composer', () => {
expect(URL.revokeObjectURL).toHaveBeenCalledWith(url)
})

it.each([
['/datasets/detail?selection_key=example-dataset', 'Example dataset'],
['/datasets/detail?selection_key=missing', 'Dataset not found'],
['/datasets/detail', 'Dataset not found'],
])('should open the catalog from directly entered dataset detail %s', async (path: string, heading: string) => {
const user = userEvent.setup()
renderChat(path)
await screen.findByRole('heading', { name: heading })
expect(screen.queryByRole('link', { name: 'Back to datasets' })).not.toBeInTheDocument()

await visitDatasets(user)

expect(screen.getByLabelText('Current route')).toHaveTextContent(/^\/datasets$/)
expect(screen.getByRole('link', { name: 'Example dataset' })).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Return to Chat' })).not.toBeInTheDocument()
})

it('should preserve catalog filters and the Chat draft when Datasets returns from detail', async () => {
const user = userEvent.setup()
renderChat()
await user.type(await screen.findByPlaceholderText('Type prompt here'), 'Keep my browsing draft')
await user.click(screen.getByRole('button', { name: 'Need inspiration? Browse seed prompts' }))
await user.type(await screen.findByRole('textbox', { name: 'Search datasets' }), 'Example')
await user.selectOptions(screen.getByRole('combobox', { name: 'Dataset view' }), 'available')
await user.click(screen.getByRole('link', { name: 'Example dataset', exact: true }))
await screen.findByRole('heading', { name: 'Example dataset' })

await visitDatasets(user)

expect(screen.getByRole('textbox', { name: 'Search datasets' })).toHaveValue('Example')
expect(screen.getByRole('combobox', { name: 'Dataset view' })).toHaveValue('available')
await user.click(screen.getByRole('button', { name: 'Return to Chat', exact: true }))
await waitFor(() => expect(screen.getByPlaceholderText('Type prompt here')).toHaveValue('Keep my browsing draft'))
})

it('should restore dataset detail and paging when entering from another workspace', async () => {
const user = userEvent.setup()
render(<MemoryRouter initialEntries={[{
pathname: '/datasets/detail', search: '?selection_key=example-dataset&cursor=page-2',
state: {
catalogPath: '/datasets?q=example&sort=name', seedCursors: [null], cursorGeneration: '',
chatOrigin: { path: '/attack/chat', attackId: null, conversationId: null },
},
}]}><App /></MemoryRouter>)
await screen.findByRole('heading', { name: 'Example dataset' })
await waitFor(() => expect(screen.getByRole('button', { name: 'Previous page' })).toBeEnabled())
expect(screen.getByRole('link', { name: 'Return to Chat' })).toBeInTheDocument()
await user.click(screen.getByRole('button', { name: 'Home', exact: true }))
await screen.findByRole('heading', { name: 'Home' })

await user.click(screen.getByRole('button', { name: 'Datasets', exact: true }))

await screen.findByRole('heading', { name: 'Example dataset' })
expect(screen.getByRole('button', { name: 'Previous page' })).toBeEnabled()
expect(screen.queryByRole('link', { name: 'Return to Chat' })).not.toBeInTheDocument()
await visitDatasets(user)
expect(screen.getByRole('textbox', { name: 'Search datasets' })).toHaveValue('example')
})

it('should retain dataset return state and cursor history across the round trip', async () => {
const user = userEvent.setup()
render(<MemoryRouter initialEntries={[{
Expand All @@ -1378,7 +1437,7 @@ describe('App draft handoff with the real chat and composer', () => {
await returnToChat(user)
await user.click(screen.getByRole('button', { name: 'Datasets', exact: true }))
await screen.findByRole('heading', { name: 'Example dataset' })
expect(screen.getByRole('link', { name: 'Back to datasets' })).toHaveAttribute('href', '/datasets?q=example&sort=name')
expect(screen.queryByRole('link', { name: 'Back to datasets' })).not.toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Previous page' })).toBeEnabled()
})

Expand Down
9 changes: 8 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ import { ChatDraftProvider, useChatDraftHandoff } from './hooks/useChatDraftHand
import {
attackConversationRoutePath,
attackRoutePath,
catalogPathFromNavigationState,
chatOriginFromNavigationState,
DATASET_DETAIL_PATH,
DATASETS_PATH,
isChatPath,
Expand Down Expand Up @@ -693,7 +695,12 @@ function AppContent({ operatorAlias }: { operatorAlias: string | null }) {
return
}
if (view === 'datasets') {
if (isChatPath(location.pathname)) {
if (matchPath(DATASET_DETAIL_PATH, location.pathname)) {
const chatOrigin = chatOriginFromNavigationState(location.state)
navigate(catalogPathFromNavigationState(location.state), {
state: chatOrigin ? { chatOrigin } : null,
})
} else if (isChatPath(location.pathname)) {
const previousState = lastDatasetsLocation.current.state
const inheritedState = previousState !== null && typeof previousState === 'object' ? previousState : {}
navigate(lastDatasetsLocation.current.path || VIEW_PATHS.datasets, {
Expand Down
Loading
Loading