Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(notes): stabilize tag removal and browser fixture cleanup (#7276)

LearningCircuit654daebdddf6
diff --git a/changelog.d/+notes-ui-fixture-cleanup.misc.md b/changelog.d/+notes-ui-fixture-cleanup.misc.md
new file mode 100644
index 0000000000..3ddbe95ea1
--- /dev/null
+++ b/changelog.d/+notes-ui-fixture-cleanup.misc.md
@@ -0,0 +1 @@
+Repair notes UI synthesis fixtures, cleanup after error-page navigation, and editor readiness checks so retries and keyboard interactions remain reliable.
diff --git a/changelog.d/7276.bugfix.md b/changelog.d/7276.bugfix.md
new file mode 100644
index 0000000000..b739e69e06
--- /dev/null
+++ b/changelog.d/7276.bugfix.md
@@ -0,0 +1 @@
+Keep note tag controls in place when the tag input loses focus, so clicking a tag's remove button works immediately after adding a tag.
diff --git a/src/local_deep_research/web/templates/pages/note_detail.html b/src/local_deep_research/web/templates/pages/note_detail.html
index cf3b112366..1572ed85b0 100644
--- a/src/local_deep_research/web/templates/pages/note_detail.html
+++ b/src/local_deep_research/web/templates/pages/note_detail.html
@@ -949,7 +949,10 @@
color: var(--error-color);
}
- .ldr-add-tag-input {
+ /* Outrank the shared input[type="text"] rule in both focus states.
+ * Otherwise blur expands the input to a full row, moving a neighboring
+ * remove button between pointerdown and click. */
+ .ldr-note-tags-container .ldr-add-tag-input {
background: transparent;
border: 1px dashed var(--border-color);
border-radius: 16px;
@@ -960,7 +963,7 @@
transition: all 0.2s ease;
}
- .ldr-add-tag-input:focus {
+ .ldr-note-tags-container .ldr-add-tag-input:focus {
outline: none;
border-color: var(--accent-primary);
border-style: solid;
diff --git a/tests/ui_tests/playwright/tests/helpers/api-client.js b/tests/ui_tests/playwright/tests/helpers/api-client.js
index d40197e9a1..2407d1acfe 100644
--- a/tests/ui_tests/playwright/tests/helpers/api-client.js
+++ b/tests/ui_tests/playwright/tests/helpers/api-client.js
@@ -6,9 +6,9 @@
* does NOT inherit storageState cookies and would 401 on every call.
*
* CSRF tokens are read from the page's <meta name="csrf-token"> tag, which
- * Flask renders into base.html on every page load. The client makes sure a
- * page is on an LDR URL before reading the token; if the page is on
- * about:blank, it navigates to '/notes/' first.
+ * the app renders into base.html. If the page is blank or lacks the tag
+ * (for example, a standalone error page), the client navigates to the
+ * authenticated '/notes/' page before reading the token.
*/
const { runId } = require('./test-data');
@@ -33,13 +33,17 @@ class NotesApiClient {
async _csrf() {
await this._ensureOnLdrPage();
+ await this.page.waitForLoadState('domcontentloaded');
// Use .first(): some pages momentarily render two identical
// <meta name="csrf-token"> tags, which trips Playwright strict mode.
// Both carry the same token, so the first is always correct.
- const token = await this.page
- .locator('meta[name="csrf-token"]')
- .first()
- .getAttribute('content');
+ const meta = this.page.locator('meta[name="csrf-token"]').first();
+ // Error pages can omit base.html and its token. Check without an
+ // auto-wait so fixture cleanup does not exhaust the afterEach timeout.
+ if (await meta.count() === 0) {
+ await this.page.goto('/notes/');
+ }
+ const token = await meta.getAttribute('content');
if (!token) throw new Error('No CSRF token meta tag on current page');
return token;
}
diff --git a/tests/ui_tests/playwright/tests/helpers/pages/note-detail-page.js b/tests/ui_tests/playwright/tests/helpers/pages/note-detail-page.js
index bdcdbebf6d..2ecf3c79ec 100644
--- a/tests/ui_tests/playwright/tests/helpers/pages/note-detail-page.js
+++ b/tests/ui_tests/playwright/tests/helpers/pages/note-detail-page.js
@@ -123,6 +123,9 @@ class NoteDetailPage {
async enterEditMode() {
await this.editBtn.click();
await expect(this.editMode).toBeVisible();
+ // The editor focuses its title after becoming visible. Wait for that
+ // transition before directing keystrokes to another field.
+ await expect(this.titleInput).toBeFocused();
}
async exitEditMode() {
diff --git a/tests/ui_tests/playwright/tests/notes/notes-crud.spec.js b/tests/ui_tests/playwright/tests/notes/notes-crud.spec.js
index 2e2df932a5..f946ad54af 100644
--- a/tests/ui_tests/playwright/tests/notes/notes-crud.spec.js
+++ b/tests/ui_tests/playwright/tests/notes/notes-crud.spec.js
@@ -152,6 +152,9 @@ test.describe('Edit existing note on detail page', () => {
await detail.goto(id);
await detail.enterEditMode();
await detail.addTag('hello-tag');
+ // Click directly from the focused input: blurring it must not move the
+ // remove button out from under the pointer before the click completes.
+ await expect(detail.addTagInput).toBeFocused();
await detail.removeTag('hello-tag');
// removeTag() only proves the chip disappeared from the edit-mode DOM;
diff --git a/tests/ui_tests/playwright/tests/notes/notes-error-handling.spec.js b/tests/ui_tests/playwright/tests/notes/notes-error-handling.spec.js
index de7014f392..d7b81752e7 100644
--- a/tests/ui_tests/playwright/tests/notes/notes-error-handling.spec.js
+++ b/tests/ui_tests/playwright/tests/notes/notes-error-handling.spec.js
@@ -82,12 +82,14 @@ test.describe('Error handling — save failure', () => {
// Click save directly — clickSave() would wait for read mode, which must
// NOT happen on failure.
- await detail.saveBtn.click();
- // Give the failed request time to resolve.
- await page.waitForResponse(
+ // Arm the listener first: the mocked response can arrive before click()
+ // resolves, so registering it afterwards can miss the failed request.
+ const failedSave = page.waitForResponse(
(r) => r.url().includes(`/notes/api/notes/${id}`) && r.request().method() === 'PUT',
{ timeout: 10000 },
);
+ await detail.saveBtn.click();
+ await failedSave;
// The edit is not silently lost: editor stays open with the typed text.
await expect(detail.editMode).toBeVisible();
diff --git a/tests/ui_tests/playwright/tests/notes/notes-fixture-cleanup.spec.js b/tests/ui_tests/playwright/tests/notes/notes-fixture-cleanup.spec.js
new file mode 100644
index 0000000000..e700d1dbbd
--- /dev/null
+++ b/tests/ui_tests/playwright/tests/notes/notes-fixture-cleanup.spec.js
@@ -0,0 +1,35 @@
+/** Fixture cleanup must also work when a test finishes on an error page. */
+
+import { test, expect } from '@playwright/test';
+
+const { NotesApiClient } = require('../helpers/api-client');
+const { noteTitle } = require('../helpers/test-data');
+
+let api;
+
+test.beforeEach(async ({ page }) => {
+ api = new NotesApiClient(page);
+});
+
+test.afterEach(async () => {
+ await api.cleanupTestNotes();
+});
+
+test('cleanup removes fixtures after a 404 page without CSRF metadata', async ({ page }) => {
+ const noteId = await api.createNote({
+ title: noteTitle('cleanup-after-404'),
+ content: 'This fixture must not survive to poison a retry.',
+ });
+
+ const response = await page.goto('/notes/not-a-note-id');
+ expect(response.status()).toBe(404);
+ await expect(page.locator('meta[name="csrf-token"]')).toHaveCount(0);
+
+ await api.cleanupTestNotes();
+
+ // Check the stored note as well as the list: swallowed cleanup errors
+ // must not let this regression pass with a surviving fixture.
+ const deleted = await page.request.get(`/notes/api/notes/${noteId}`);
+ expect(deleted.status()).toBe(404);
+ expect(await api.listMyTestNotes()).toEqual([]);
+});
diff --git a/tests/ui_tests/playwright/tests/notes/notes-synthesize-mocked.spec.js b/tests/ui_tests/playwright/tests/notes/notes-synthesize-mocked.spec.js
index 172fb56d2b..1611ba12f8 100644
--- a/tests/ui_tests/playwright/tests/notes/notes-synthesize-mocked.spec.js
+++ b/tests/ui_tests/playwright/tests/notes/notes-synthesize-mocked.spec.js
@@ -17,6 +17,7 @@
import { test, expect } from '@playwright/test';
const { NotesPage } = require('../helpers/pages/notes-page');
+const { NoteDetailPage } = require('../helpers/pages/note-detail-page');
const { NotesApiClient } = require('../helpers/api-client');
const { noteTitle } = require('../helpers/test-data');
const { capture } = require('../helpers/screenshot');
@@ -200,6 +201,11 @@ test.describe('Synthesize — create (mocked)', () => {
test('create navigates to the new note id', async ({ page }, testInfo) => {
const list = new NotesPage(page);
await _seedTwoNotesAndOpenModal(page, list);
+ // Keep the LLM call mocked, with a real destination that can render
+ // the created note and participate in normal fixture cleanup.
+ const title = noteTitle('synth-created');
+ const content = 'Synthesized fixture content';
+ const noteId = await api.createNote({ title, content });
// /synthesize (not /preview) — the more specific /preview route must
// be registered FIRST when both are active in the same spec, but
@@ -214,15 +220,18 @@ test.describe('Synthesize — create (mocked)', () => {
contentType: 'application/json',
body: JSON.stringify({
success: true,
- result: { note_id: 'synth-mock-id-123' },
+ result: { note_id: noteId },
}),
});
});
- // The createSynthesizedNote() handler navigates to /notes/<id> via
- // URLValidator.safeAssign — the URL update is the success signal.
+ // The createSynthesizedNote() handler navigates via URLValidator.safeAssign.
+ // Verify the destination loads the note, including its API-backed content.
await list.synthesisCreateBtn.click();
- await page.waitForURL(/\/notes\/synth-mock-id-123$/, { timeout: 10000 });
+ await page.waitForURL(`**/notes/${noteId}`, { timeout: 10000 });
+ const detail = new NoteDetailPage(page);
+ await expect(detail.titleDisplay).toHaveText(title);
+ await expect(detail.contentRendered).toHaveText(content);
await capture(page, 'synthesize-navigated', testInfo);
await page.unroute(CREATE_ROUTE);