Skip to content

Commit 7bf9a6a

Browse files
committed
Prevent stale Logs handoffs from replacing newer navigation
1 parent 0c9c1c8 commit 7bf9a6a

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎frontend/docs/validation-review.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Each finding received a Sol 6.1 implementation pass, a separate Sol regression r
1010

1111
Final validation through the Swamp `blacksmith-test` workflow passed formatting, TypeScript/production build, **2,314 unit tests** (14 skipped), **95 relevant application browser tests**, and **24 production-build browser tests**. Browser tests ran with four workers and zero retries. Earlier runs exposed two test synchronization assumptions around modal closure and development StrictMode mount requests; the corrected tests retain the original behavior and exact Refresh assertions. The full application suite, Storybook and live exporter/ingestion checks were not repeated for these fixes.
1212

13+
The subsequent full GitHub PR check passed, but the duplicate push check exposed a rapid-navigation race: an obsolete Logs handoff cleanup could replace a newer Traces route. The captured browser trace showed Traces opening, then returning to the consumed Logs URL without another click. Logs now checks the current browser pathname and search before consuming a handoff; browser-history detection also works when the component first mounts after navigation has moved on. A separate rapid-handoff test checks the final Traces route after requests settle. Sol 6.1 and Opus 5.5 independently confirmed the cause and reviewed the guard.
14+
15+
Swamp Blacksmith validation of that follow-up passed formatting, TypeScript/build, the unit suite, **80 navigation executions** (four tests repeated 20 times), **96 relevant application browser tests**, and **24 production browser tests**, with zero browser retries.
16+
1317
## In-app agent telemetry setup guide (2026-10-12)
1418

1519
Agents now has a **Set up telemetry** panel, also linked from the **Get started** connection step and the Agents empty state. It generates copyable Claude Code JSON, Codex TOML and a coding-agent brief using an editable collector base URL. Content flags default off and reset when changing providers; the guide explains that metadata and some tool snippets may still be exported. It links to collector ingestion setup, documents required span mappings and distinguishes receiving telemetry from complete run compatibility.

‎frontend/e2e/agents-review-navigation.spec.ts‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ test('Traces Refresh reloads fixed list and open detail, and advances preset bou
163163
await expect.poll(() => new URL(page.url()).searchParams.get('range')).toBe('1h');
164164
await expect.poll(() => calls.lists.at(-1)?.startTime).not.toBe(bounds.startTime);
165165
await page.getByTestId('sidebar-logs').click();
166-
await expect(page.getByLabel('Time range', { exact: true })).toHaveValue('1h');
166+
await expect(page.locator('.logs-page')).toBeVisible();
167+
await expect(page.locator('.logs-page').getByLabel('Time range', { exact: true })).toHaveValue(
168+
'1h',
169+
);
167170
await page.getByTestId('sidebar-traces').click();
171+
await expect(page).toHaveURL(/\/traces\/explore\/events\?/);
168172
await expect(page.getByTestId('trace-table')).toBeVisible();
169173
await expect(page.getByRole('dialog', { name: 'Trace detail', exact: true })).toHaveCount(0);
170174
await expect(page.getByLabel('Time range', { exact: true })).toHaveValue('1h');
@@ -217,3 +221,23 @@ test('Traces Refresh reloads fixed list and open detail, and advances preset bou
217221
traceId: STORY_TRACE_ID,
218222
});
219223
});
224+
225+
test('rapid Logs handoffs cannot replace a newer Traces navigation', async ({ page }) => {
226+
await mockNavigation(page);
227+
await page.goto(
228+
`/traces/explore/events?${new URLSearchParams({ start: bounds.startTime, end: bounds.endTime, service: 'api-gateway' })}`,
229+
);
230+
await expect(page.getByTestId('trace-table')).toBeVisible();
231+
await expect.poll(() => new URL(page.url()).searchParams.has('observe')).toBe(true);
232+
// Browser history changes before the outgoing Traces DOM necessarily commits.
233+
// Return immediately, while Logs can still have a handoff effect pending.
234+
await page.getByTestId('sidebar-logs').click();
235+
await expect(page).toHaveURL(/\/logs\/explore\/events\?/);
236+
await page.getByTestId('sidebar-traces').click();
237+
await expect(page).toHaveURL(/\/traces\/explore\/events\?/);
238+
await expect(page.getByTestId('trace-table')).toBeVisible();
239+
await page.waitForLoadState('networkidle');
240+
await expect(page).toHaveURL(/\/traces\/explore\/events\?/);
241+
await expect(page.getByRole('button', { name: 'Refresh traces' })).toBeVisible();
242+
await expect(page.locator('.logs-page')).toHaveCount(0);
243+
});

‎frontend/src/features/logs/LogsPage.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export function LogsPage() {
5656
const dataset = currentDataset || datasets.data?.[0]?.name || '';
5757
const location = useLocation();
5858
const initialLocationKey = useRef(location.key);
59+
// BrowserRouter initializes idx even when this render trails a newer URL;
60+
// MemoryRouter previews have no browser history index to synchronize with.
61+
const browserRouter = useRef(
62+
typeof window !== 'undefined' && typeof window.history.state?.idx === 'number',
63+
);
5964
const navigationType = useNavigationType();
6065
const [params] = useSearchParams();
6166
const schema = useAsync(
@@ -230,6 +235,14 @@ export function LogsPage() {
230235
}
231236
// Consume handoffs once so subsequent edits are not overwritten by navigation.
232237
useEffect(() => {
238+
// Router renders can lag behind browser history. A pending Logs handoff
239+
// must not replace a newer navigation when its consumption effect runs.
240+
if (
241+
browserRouter.current &&
242+
(window.location.pathname !== appPath(location.pathname) ||
243+
window.location.search !== location.search)
244+
)
245+
return;
233246
const classicApplied = !!link && appliedLink === link;
234247
const nativeApplied =
235248
(params.has('logView') || nativeNavigation) && appliedView === location.key && !linkError;

0 commit comments

Comments
 (0)