The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(dashboard): preserve explicit facet selections across loads (#955)
Rudy Mizrahi Celekli808a32199c16
diff --git a/cli/beacon/internal/endpoint/dashboard/static/app.js b/cli/beacon/internal/endpoint/dashboard/static/app.jsindex 9a56d651..5b284b77 100644--- a/cli/beacon/internal/endpoint/dashboard/static/app.js+++ b/cli/beacon/internal/endpoint/dashboard/static/app.js@@ -113,10 +113,22 @@ function hydrateFiltersFromURL() {if (!params.has(field)) continue;const value = params.get(field);if (field === "limit") ensureLimitOption(input, value);+ ensureFacetOption(input, value);input.value = value;}}+// Dynamic facet options may not have loaded yet, or may be absent from a+// filtered summary. Preserve explicit query values until the user clears them.+function ensureFacetOption(select, value) {+ if (!(select instanceof HTMLSelectElement) || !["harness", "model", "repository"].includes(select.name) || !value) return;+ if (Array.from(select.options).some((option) => option.value === value)) return;+ const option = document.createElement("option");+ option.value = value;+ option.textContent = select.name === "harness" ? harnessLabel(value) : select.name === "repository" ? repositoryOptionLabel(value) : value;+ select.append(option);+}+// The limit control is a fixed <select>; a URL like ?limit=5 would otherwise// silently deselect it and the query would fall back to the server default,// so add the requested limit as a selectable option.@@ -2082,7 +2094,8 @@ function renderHarnessSelect(values) {...values.map((item) => `<option value="${escapeHTML(item.name)}">${escapeHTML(harnessLabel(item.name))} (${escapeHTML(item.count)})</option>`),];select.innerHTML = options.join("");- select.value = values.some((item) => item.name === current) ? current : "";+ ensureFacetOption(select, current);+ select.value = current;}function renderModelSelect(values) {@@ -2094,7 +2107,8 @@ function renderModelSelect(values) {...values.map((item) => `<option value="${escapeHTML(item.name)}">${escapeHTML(item.name)} (${escapeHTML(item.count)})</option>`),];select.innerHTML = options.join("");- select.value = values.some((item) => item.name === current) ? current : "";+ ensureFacetOption(select, current);+ select.value = current;}function renderRepositorySelect(values) {@@ -2105,10 +2119,8 @@ function renderRepositorySelect(values) {`<option value="">All repositories</option>`,...values.map((item) => `<option value="${escapeHTML(item.name)}">${escapeHTML(repositoryOptionLabel(item.name))} (${escapeHTML(item.count)})</option>`),];- if (current && !values.some((item) => item.name === current)) {- options.push(`<option value="${escapeHTML(current)}">${escapeHTML(repositoryOptionLabel(current))}</option>`);- }select.innerHTML = options.join("");+ ensureFacetOption(select, current);select.value = current;}diff --git a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/activity-facet-selection.spec.ts b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/activity-facet-selection.spec.tsnew file mode 100644index 00000000..b4e8e859--- /dev/null+++ b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/activity-facet-selection.spec.ts@@ -0,0 +1,92 @@+import { expect, test, type Page } from '@playwright/test';++// Independent records: the API fixture filters records using request parameters,+// and only then builds summary buckets. It does not model select/URL behavior.+const sessions = [+ { id: 'session-alpha', harness: 'codex_cli', model: 'model-alpha', repository: '/workspace/alpha', original_prompt: 'cat', event_count: 1 },+ { id: 'session-beta', harness: 'claude_code', model: 'model-beta', repository: '/workspace/beta', original_prompt: 'dog', event_count: 1 },+];+async function fixture(page: Page) {+ const requests: URL[] = [];+ await page.route('**/api/**', async (route) => {+ const url = new URL(route.request().url());+ requests.push(url);+ const rows = sessions.filter((row) => ['harness', 'model', 'repository'].every((key) =>+ !url.searchParams.get(key) || row[key as keyof typeof row] === url.searchParams.get(key)) &&+ (!url.searchParams.get('q') || row.original_prompt.includes(url.searchParams.get('q')!)));+ const counts = (key: 'harness' | 'model' | 'repository') => rows.map((row) => ({ name: row[key], count: 1 }));+ const json = url.pathname === '/api/summary' ? {+ total_events: rows.length, active_sessions: rows.length,+ top_harnesses: counts('harness'), top_models: counts('model'), top_repositories: counts('repository'),+ } : url.pathname === '/api/sessions' ? { sessions: rows } : url.pathname === '/api/events' ? { events: [] } : {};+ await route.fulfill({ json });+ });+ return requests;+}+async function settled(page: Page) {+ await expect(page.locator('#events tr')).not.toHaveCount(0);+ await expect(page.locator('#events')).not.toContainText('Loading');+ await page.evaluate(() => new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))));+}+async function submit(page: Page) {+ const response = page.waitForResponse((r) => new URL(r.url()).pathname === '/api/sessions');+ await page.locator('[name="q"]').press('Enter');+ await (await response).finished();+ await settled(page);+}+for (const [facet, value] of [['harness', 'codex_cli'], ['model', 'model-alpha'], ['repository', '/workspace/alpha']]) {+ test(`bookmarked ${facet} reaches the first requests`, async ({ page }) => {+ const requests = await fixture(page);+ await page.goto(`/?range=all&session_state=&${facet}=${encodeURIComponent(value)}`);+ await settled(page);+ for (const path of ['/api/summary', '/api/sessions']) {+ expect(requests.find((url) => url.pathname === path)?.searchParams.get(facet)).toBe(value);+ }+ await expect(page.locator(`[name="${facet}"]`)).toHaveValue(value);+ await expect(page.locator('#events tr[data-session-id]')).toHaveCount(1);+ await expect(page.locator('#events tr')).toHaveAttribute('data-session-id', 'session-alpha');+ });+}+for (const [facet, value] of [['harness', 'codex_cli'], ['model', 'model-alpha'], ['repository', '/workspace/alpha']]) {+ test(`empty results preserve ${facet} across the real poll and explicit clear`, async ({ page }) => {+ const requests = await fixture(page);+ await page.goto('/?range=all&session_state=');+ await settled(page);+ await page.locator(`[name="${facet}"]`).selectOption(value);+ await page.locator('[name="q"]').fill('dog');+ await submit(page);+ const afterEmpty = await page.locator(`[name="${facet}"]`).inputValue();+ const count = requests.filter((url) => url.pathname === '/api/sessions').length;+ // Use the production ten-second setInterval without replacing timers.+ await expect.poll(() => requests.filter((url) => url.pathname === '/api/sessions').length, { timeout: 13000 }).toBeGreaterThan(count);+ await settled(page);+ expect.soft(afterEmpty).toBe(value);+ expect.soft(requests.filter((url) => url.pathname === '/api/sessions').at(-1)?.searchParams.get(facet)).toBe(value);+ expect.soft(await page.locator(`[name="${facet}"]`).inputValue()).toBe(value);+ await expect.soft(page.locator('#events')).toContainText('No sessions match');+ await page.locator(`[name="${facet}"]`).selectOption('');+ await submit(page);+ await expect(page.locator('#events tr')).toHaveAttribute('data-session-id', 'session-beta');+ expect(requests.filter((url) => url.pathname === '/api/sessions').at(-1)?.searchParams.has(facet)).toBe(false);+ });+}+test('overview chart navigation retains its harness on the first sessions request', async ({ page }) => {+ const requests = await fixture(page);+ await page.goto('/overview.html');+ await page.locator('[data-activity-harness="codex_cli"]').click();+ await settled(page);+ expect(requests.find((url) => url.pathname === '/api/sessions')?.searchParams.get('harness')).toBe('codex_cli');+ await expect(page.locator('[name="harness"]')).toHaveValue('codex_cli');+});+test('sessions select submission retains populated labels without duplicate options', async ({ page }) => {+ const requests = await fixture(page);+ await page.goto('/?range=all&session_state=');+ await settled(page);+ await page.locator('[name="harness"]').selectOption('codex_cli');+ await submit(page);+ await expect(page.locator('#events tr')).toHaveAttribute('data-session-id', 'session-alpha');+ expect(requests.filter((url) => url.pathname === '/api/sessions').at(-1)?.searchParams.get('harness')).toBe('codex_cli');+ await expect(page.locator('#harness-filter option[value="codex_cli"]')).toHaveCount(1);+ await expect(page.locator('#harness-filter option[value="codex_cli"]')).toHaveText('Codex CLI (1)');+ await expect(page.locator('#model-filter option[value="model-alpha"]')).toHaveText('model-alpha (1)');+});diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 8710bc98..24a2c64b 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -24,6 +24,7 @@ Stay up to date with the latest changes to the Agent Beacon CLI.- **Memory candidate and evaluation search finds older matches** · `beacon memory candidates list` and `beacon memory evaluations list` with `--query` paged before matching, so a page could come back empty or skip matches whenever newer records that didn't match filled it. Searches now page over matching records, as `beacon memory list` already did.- **Splunk and Falcon HEC forwarding redacts secrets** · With direct Splunk HEC or Falcon LogScale HEC forwarding configured, credentials in prompts, tool output and other telemetry reached the SIEM unredacted, while the local runtime log redacted them. The collector now redacts secrets before telemetry fans out to those exporters, with the same rules as the local log. Installs without HEC forwarding are unchanged.- **Dashboard session IDs are real links** · Session IDs in the dashboard's session list only responded to a row click, so they couldn't be reached with Tab or opened in a new tab. Each ID is now a link: Tab and Enter open the session, and modifier-click or middle-click opens it in another tab. Clicking elsewhere in the row still opens it.+- **Dashboard harness and model filters stick** · A bookmarked or shared dashboard URL with a harness or model filter loaded unfiltered, because the filter was applied before its options had loaded, and a search with no results cleared the selected harness or model, so the next refresh broadened the view. Selections now hold until you choose All.- **Dashboard output tokens count reasoning once** · The local dashboard's token view added reasoning tokens to output, but `gen_ai.usage.output_tokens` already includes them, so models that report reasoning had their output and total tokens overstated. Output and the total now count reasoning once, the split bar no longer shows reasoning as a separate segment, and a note below it gives the reasoning count included in output. `beacon token-usage` already counted it this way.---