Skip to content

Commit 0c9c1c8

Browse files
committed
Fix agent review regressions in navigation, search and telemetry
1 parent 870a554 commit 0c9c1c8

10 files changed

Lines changed: 743 additions & 18 deletions

File tree

‎frontend/docs/validation-review.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Frontend validation and independent review
22

3+
## PR #32 review fixes (2026-10-12)
4+
5+
The seven review findings are addressed. Trace-focused Logs share links retain their encoded time window, and Traces Refresh reloads fixed windows while advancing preset windows with one request per active list/detail. Agents search keeps typing and caret updates synchronous with URL navigation, and searches literal recorded values, including backslashes and quotes.
6+
7+
Captured conversation includes backend datatype-suffixed fields and orders events by their available epoch precision; exact duplicates remain collapsed. Token totals include independently reported sibling branches without repeating model-call rollups, and identify ambiguous disconnected usage as partial.
8+
9+
Each finding received a Sol 6.1 implementation pass, a separate Sol regression review and a dedicated Opus 5.5 review. Follow-up reviews caught and corrected duplicate preset refreshes and loss of event precision from backend timestamp text. Regression coverage includes actual Share links/reload/handoffs, exact refresh request counts, caret/rapid typing/history/dataset changes, literal nested search, typed content, event ordering/deduplication and branch-level token accounting.
10+
11+
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.
12+
313
## In-app agent telemetry setup guide (2026-10-12)
414

515
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.
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
import { expect, test, type Page } from '@playwright/test';
2+
import { STORY_TRACE_ID, storyTraceDetail, storyTraceList } from '../src/features/traces/fixtures';
3+
import { encodeLogView, decodeLogView } from '../src/features/logs/logViewState';
4+
import { initialLogView } from '../src/features/logs/logViewReducer';
5+
6+
const bounds = { startTime: '2026-10-01T09:00:00.000Z', endTime: '2026-10-01T10:00:00.000Z' };
7+
type Window = typeof bounds;
8+
async function mockNavigation(page: Page) {
9+
const queries: Array<Window & { query: string }> = [];
10+
const lists: Array<Window & { serviceName?: string; sortBy: string }> = [];
11+
const details: Array<Window & { traceId: string }> = [];
12+
await page.route('**/api/**', async (route) => {
13+
const path = new URL(route.request().url()).pathname;
14+
if (path.endsWith('/logstream')) return route.fulfill({ json: [{ name: 'events' }] });
15+
if (path.endsWith('/schema'))
16+
return route.fulfill({
17+
json: { fields: ['p_timestamp', 'span_trace_id', 'message'].map((name) => ({ name })) },
18+
});
19+
if (path.endsWith('/info'))
20+
return route.fulfill({
21+
json: { telemetryType: 'traces', logSource: [{ log_source_format: 'otel-traces' }] },
22+
});
23+
if (path.endsWith('/services/traces/list')) {
24+
lists.push(route.request().postDataJSON());
25+
return route.fulfill({
26+
json: { count: 1, records: storyTraceList.slice(0, 1), offset: 0, limit: 25 },
27+
});
28+
}
29+
if (path.endsWith('/services/traces/detail')) {
30+
details.push(route.request().postDataJSON());
31+
return route.fulfill({ json: storyTraceDetail });
32+
}
33+
if (path.endsWith('/query')) {
34+
const query = route.request().postDataJSON();
35+
queries.push(query);
36+
return route.fulfill({
37+
json: query.query.startsWith('SELECT *')
38+
? [
39+
{
40+
p_timestamp: '2026-10-01T09:30:00.000Z',
41+
span_trace_id: STORY_TRACE_ID,
42+
message: 'historical event',
43+
},
44+
]
45+
: [],
46+
});
47+
}
48+
return route.fulfill({ json: {} });
49+
});
50+
return { queries, lists, details };
51+
}
52+
53+
test('trace-focused Share retains its frozen window on open, reload and explorer handoffs', async ({
54+
page,
55+
}) => {
56+
const calls = await mockNavigation(page);
57+
const rows = () => calls.queries.filter((query) => query.query.startsWith('SELECT *'));
58+
await page.goto(
59+
`/logs/explore/events?${new URLSearchParams({ traceId: STORY_TRACE_ID, start: bounds.startTime, end: bounds.endTime })}`,
60+
);
61+
await expect(page.getByRole('button', { name: 'Clear trace filter' })).toBeVisible();
62+
await expect.poll(() => rows().at(-1)).toMatchObject(bounds);
63+
await expect.poll(() => new URL(page.url()).searchParams.has('observe')).toBe(true);
64+
await page.getByRole('button', { name: 'Share / copy link' }).click();
65+
const shared = await page.getByLabel('View link').inputValue();
66+
const params = new URL(shared).searchParams;
67+
expect(decodeLogView(params.get('logView')!).range).toEqual(bounds);
68+
expect(params.get('logTraceId')).toBe(STORY_TRACE_ID);
69+
calls.queries.length = 0;
70+
await page.goto(shared);
71+
await expect.poll(() => rows().at(-1)).toMatchObject(bounds);
72+
expect(rows().at(-1)?.query).toContain(`"span_trace_id" = '${STORY_TRACE_ID}'`);
73+
await expect.poll(() => new URL(page.url()).searchParams.has('logView')).toBe(false);
74+
calls.queries.length = 0;
75+
await page.reload();
76+
await expect.poll(() => rows().at(-1)).toMatchObject(bounds);
77+
await expect(page.getByRole('button', { name: 'Clear trace filter' })).toBeVisible();
78+
await page.getByTestId('sidebar-traces').click();
79+
await expect.poll(() => calls.lists.at(-1)).toMatchObject(bounds);
80+
calls.queries.length = 0;
81+
await page.getByTestId('sidebar-logs').click();
82+
await expect.poll(() => rows().at(-1)).toMatchObject(bounds);
83+
expect(rows().at(-1)?.query).toContain(`"span_trace_id" = '${STORY_TRACE_ID}'`);
84+
});
85+
86+
test('explicit preset handoffs override a shared view while preserving trace focus', async ({
87+
page,
88+
}) => {
89+
const calls = await mockNavigation(page);
90+
const params = new URLSearchParams({
91+
logView: encodeLogView({ ...initialLogView('events'), range: bounds, search: 'historical' }),
92+
logTraceId: STORY_TRACE_ID,
93+
range: '6h',
94+
start: '2026-10-02T04:00:00.000Z',
95+
end: '2026-10-02T10:00:00.000Z',
96+
});
97+
await page.goto(`/logs/explore/events?${params}`);
98+
await expect
99+
.poll(() => calls.queries.filter((query) => query.query.startsWith('SELECT *')).at(-1))
100+
.toMatchObject({
101+
startTime: params.get('start'),
102+
endTime: params.get('end'),
103+
});
104+
await expect(page.getByLabel('Time range', { exact: true })).toHaveValue('6h');
105+
const query = calls.queries.filter((query) => query.query.startsWith('SELECT *')).at(-1)?.query;
106+
expect(query).toContain(STORY_TRACE_ID);
107+
expect(query).toContain('historical');
108+
});
109+
110+
test('Traces Refresh reloads fixed list and open detail, and advances preset bounds', async ({
111+
page,
112+
}) => {
113+
const calls = await mockNavigation(page);
114+
await page.goto(
115+
`/traces/explore/events?${new URLSearchParams({ start: bounds.startTime, end: bounds.endTime, service: 'api-gateway', sort: 'longestFirst' })}`,
116+
);
117+
await expect(page.getByTestId('trace-table')).toBeVisible();
118+
await expect.poll(() => new URL(page.url()).searchParams.has('observe')).toBe(true);
119+
await page.waitForLoadState('networkidle');
120+
const before = calls.lists.length;
121+
const beforeClosedDetail = calls.details.length;
122+
await page.getByRole('button', { name: 'Refresh traces' }).click();
123+
await expect.poll(() => calls.lists.length).toBe(before + 1);
124+
await page.waitForLoadState('networkidle');
125+
expect(calls.lists).toHaveLength(before + 1);
126+
expect(calls.details).toHaveLength(beforeClosedDetail);
127+
expect(calls.lists.at(-1)).toMatchObject({
128+
...bounds,
129+
serviceName: 'api-gateway',
130+
sortBy: 'longestFirst',
131+
});
132+
await page.getByRole('button', { name: `Open trace ${STORY_TRACE_ID}, POST /orders` }).click();
133+
await expect(page.getByRole('dialog', { name: 'Trace detail', exact: true })).toBeVisible();
134+
await expect.poll(() => calls.details.length).toBeGreaterThan(0);
135+
await page.waitForLoadState('networkidle');
136+
const beforeDetail = calls.details.length;
137+
const beforeList = calls.lists.length;
138+
// The modal hides the toolbar; exercise its handler with the detail request retained.
139+
await page
140+
.getByRole('button', { name: 'Refresh traces', includeHidden: true })
141+
.evaluate((button: HTMLButtonElement) => button.click());
142+
await expect.poll(() => calls.lists.length).toBe(beforeList + 1);
143+
await expect.poll(() => calls.details.length).toBe(beforeDetail + 1);
144+
await page.waitForLoadState('networkidle');
145+
expect(calls.lists).toHaveLength(beforeList + 1);
146+
expect(calls.details).toHaveLength(beforeDetail + 1);
147+
expect(calls.lists.at(-1)).toMatchObject(bounds);
148+
expect(calls.details.at(-1)).toMatchObject({ ...bounds, traceId: STORY_TRACE_ID });
149+
await page.getByRole('button', { name: 'Close dialog' }).click();
150+
await expect(page.getByRole('dialog', { name: 'Trace detail', exact: true })).toHaveCount(0);
151+
await expect.poll(() => new URL(page.url()).searchParams.has('traceId')).toBe(false);
152+
// Wait for the closed detail to reach the remembered explorer snapshot before
153+
// testing a handoff; a pending close must not be mistaken for a refresh failure.
154+
await expect
155+
.poll(() => {
156+
const observe = new URL(page.url()).searchParams.get('observe');
157+
if (!observe) return true;
158+
const query = JSON.parse(observe).views.traces?.query;
159+
return query === undefined || new URLSearchParams(query).has('traceId');
160+
})
161+
.toBe(false);
162+
await page.getByLabel('Time range', { exact: true }).selectOption('1h');
163+
await expect.poll(() => new URL(page.url()).searchParams.get('range')).toBe('1h');
164+
await expect.poll(() => calls.lists.at(-1)?.startTime).not.toBe(bounds.startTime);
165+
await page.getByTestId('sidebar-logs').click();
166+
await expect(page.getByLabel('Time range', { exact: true })).toHaveValue('1h');
167+
await page.getByTestId('sidebar-traces').click();
168+
await expect(page.getByTestId('trace-table')).toBeVisible();
169+
await expect(page.getByRole('dialog', { name: 'Trace detail', exact: true })).toHaveCount(0);
170+
await expect(page.getByLabel('Time range', { exact: true })).toHaveValue('1h');
171+
await page.waitForLoadState('networkidle');
172+
expect(calls.lists.at(-1)).toMatchObject({ serviceName: 'api-gateway', sortBy: 'longestFirst' });
173+
const presetBefore = calls.lists.length;
174+
const presetClosedDetail = calls.details.length;
175+
const previousEnd = calls.lists.at(-1)!.endTime;
176+
await page.getByRole('button', { name: 'Refresh traces' }).click();
177+
await expect.poll(() => calls.lists.length).toBe(presetBefore + 1);
178+
await page.waitForLoadState('networkidle');
179+
expect(calls.lists).toHaveLength(presetBefore + 1);
180+
expect(calls.details).toHaveLength(presetClosedDetail);
181+
expect(Date.parse(calls.lists.at(-1)!.endTime)).toBeGreaterThan(Date.parse(previousEnd));
182+
expect(Date.parse(calls.lists.at(-1)!.endTime) - Date.parse(calls.lists.at(-1)!.startTime)).toBe(
183+
3_600_000,
184+
);
185+
await page.getByRole('button', { name: `Open trace ${STORY_TRACE_ID}, POST /orders` }).click();
186+
await expect(page.getByRole('dialog', { name: 'Trace detail', exact: true })).toBeVisible();
187+
// Opening mounts a new Sheet: development StrictMode replays its loading
188+
// effect. Establish a settled baseline; Refresh below must still fetch once.
189+
await expect.poll(() => calls.details.length).toBeGreaterThan(presetClosedDetail);
190+
await page.waitForLoadState('networkidle');
191+
expect(calls.details.at(-1)).toMatchObject({
192+
startTime: calls.lists.at(-1)!.startTime,
193+
endTime: calls.lists.at(-1)!.endTime,
194+
traceId: STORY_TRACE_ID,
195+
});
196+
const presetDetailBefore = calls.details.length;
197+
const presetListBefore = calls.lists.length;
198+
const previousDetailEnd = calls.details.at(-1)!.endTime;
199+
await page
200+
.getByRole('button', { name: 'Refresh traces', includeHidden: true })
201+
.evaluate((button: HTMLButtonElement) => button.click());
202+
await expect.poll(() => calls.lists.length).toBe(presetListBefore + 1);
203+
await expect.poll(() => calls.details.length).toBe(presetDetailBefore + 1);
204+
await page.waitForLoadState('networkidle');
205+
expect(calls.lists).toHaveLength(presetListBefore + 1);
206+
expect(calls.details).toHaveLength(presetDetailBefore + 1);
207+
for (const request of [
208+
...calls.lists.slice(presetListBefore),
209+
...calls.details.slice(presetDetailBefore),
210+
]) {
211+
expect(Date.parse(request.endTime)).toBeGreaterThan(Date.parse(previousDetailEnd));
212+
expect(Date.parse(request.endTime) - Date.parse(request.startTime)).toBe(3_600_000);
213+
}
214+
expect(calls.details.at(-1)).toMatchObject({
215+
startTime: calls.lists.at(-1)!.startTime,
216+
endTime: calls.lists.at(-1)!.endTime,
217+
traceId: STORY_TRACE_ID,
218+
});
219+
});
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { expect, test, type Page } from '@playwright/test';
2+
import { agentDemoFields, agentDemoRows } from '../src/lib/agents';
3+
4+
const bounds = {
5+
start: '2026-10-01T09:00:00.000Z',
6+
end: '2026-10-01T10:00:00.000Z',
7+
};
8+
9+
async function mockAgents(page: Page) {
10+
let queries = 0;
11+
await page.route('**/api/**', async (route) => {
12+
const path = new URL(route.request().url()).pathname;
13+
if (path.endsWith('/logstream'))
14+
return route.fulfill({ json: [{ name: 'agent_telemetry' }, { name: 'other_agents' }] });
15+
if (path.endsWith('/schema'))
16+
return route.fulfill({
17+
json: { fields: [...agentDemoFields, 'message', 'captured'].map((name) => ({ name })) },
18+
});
19+
if (path.endsWith('/query')) {
20+
queries++;
21+
return route.fulfill({
22+
json: agentDemoRows(Date.parse(bounds.end)).map((row) => ({
23+
...row,
24+
message: 'C:\\repo',
25+
captured: { messages: [{ content: 'Say "hello"' }] },
26+
})),
27+
});
28+
}
29+
return route.fulfill({ json: {} });
30+
});
31+
return () => queries;
32+
}
33+
34+
async function openAgents(page: Page, search = '') {
35+
await page.goto(`/agents/agent_telemetry?${new URLSearchParams({ ...bounds, search })}`);
36+
await expect(page.getByRole('button', { name: 'Inspect run Support assistant' })).toBeVisible();
37+
await expect.poll(() => new URL(page.url()).searchParams.has('observe')).toBe(true);
38+
}
39+
40+
test('search preserves the caret and every rapidly typed character without refetching', async ({
41+
page,
42+
}) => {
43+
const queryCount = await mockAgents(page);
44+
await openAgents(page, 'Support');
45+
const before = queryCount();
46+
const input = page.getByLabel('Search agent runs');
47+
await input.focus();
48+
await input.evaluate((node: HTMLInputElement) => node.setSelectionRange(3, 3));
49+
await input.pressSequentially('X');
50+
await expect(input).toHaveValue('SupXport');
51+
await expect.poll(() => input.evaluate((node: HTMLInputElement) => node.selectionStart)).toBe(4);
52+
await input.pressSequentially('Y');
53+
await expect(input).toHaveValue('SupXYport');
54+
await input.fill('');
55+
await input.pressSequentially('Support', { delay: 0 });
56+
await expect(input).toHaveValue('Support');
57+
await expect.poll(() => new URL(page.url()).searchParams.get('search')).toBe('Support');
58+
await expect(page.getByRole('button', { name: 'Inspect run Support assistant' })).toBeVisible();
59+
expect(queryCount()).toBe(before);
60+
expect(new URL(page.url()).searchParams.get('start')).toBe(bounds.start);
61+
expect(new URL(page.url()).searchParams.get('end')).toBe(bounds.end);
62+
});
63+
64+
test('search matches literal nested values without matching column names', async ({ page }) => {
65+
await mockAgents(page);
66+
await openAgents(page);
67+
const input = page.getByLabel('Search agent runs');
68+
for (const value of ['C:\\repo', 'say "HELLO"']) {
69+
await input.fill(value);
70+
await expect(page.getByRole('button', { name: 'Inspect run Support assistant' })).toBeVisible();
71+
}
72+
await input.fill('span_parent_span_id');
73+
await expect(page.getByText('No matching runs', { exact: true })).toBeVisible();
74+
});
75+
76+
test('Back and Forward restore search, and dataset navigation retains the latest edit', async ({
77+
page,
78+
}) => {
79+
const queryCount = await mockAgents(page);
80+
await openAgents(page, 'Support');
81+
const input = page.getByLabel('Search agent runs');
82+
await page.getByRole('button', { name: 'Inspect run Support assistant' }).click();
83+
await expect(page.getByRole('dialog', { name: 'Agent run details' })).toBeVisible();
84+
await page
85+
.getByRole('dialog', { name: 'Agent run details' })
86+
.getByRole('button', { name: 'Close dialog', exact: true })
87+
.click();
88+
// Closing navigates in a transition. Until that commits, Radix still traps
89+
// focus in the sheet; fill() alone can target the background input too early.
90+
await expect(page.getByRole('dialog', { name: 'Agent run details' })).toBeHidden();
91+
await expect.poll(() => new URL(page.url()).searchParams.has('run')).toBe(false);
92+
await input.click();
93+
await expect(input).toBeFocused();
94+
await input.fill('Research');
95+
await expect.poll(() => new URL(page.url()).searchParams.get('search')).toBe('Research');
96+
const before = queryCount();
97+
await page.goBack();
98+
await expect(input).toHaveValue('Support');
99+
await page.goForward();
100+
await expect(input).toHaveValue('Research');
101+
expect(queryCount()).toBe(before);
102+
await input.fill('Support');
103+
await page.getByLabel('Agents dataset').focus();
104+
await expect(
105+
page.getByLabel('Agents dataset').getByRole('option', { name: 'other_agents' }),
106+
).toBeAttached();
107+
await page.getByLabel('Agents dataset').selectOption('other_agents');
108+
await expect(page).toHaveURL(/\/agents\/other_agents\?/);
109+
await expect(input).toHaveValue('Support');
110+
await expect(page.getByRole('button', { name: 'Inspect run Support assistant' })).toBeVisible();
111+
expect(new URL(page.url()).searchParams.get('search')).toBe('Support');
112+
expect(new URL(page.url()).searchParams.get('start')).toBe(bounds.start);
113+
expect(new URL(page.url()).searchParams.get('end')).toBe(bounds.end);
114+
});

0 commit comments

Comments
 (0)