Skip to content

Commit d7d77a1

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/collectors-refactors
Bring in #491 and #490. Main's devframe.ts changes go to the split modules: the TransferState refetch to devframe-refetch-tools.ts and the set-http-rule preset to devframe-http-tools.ts. The tool count is 118. extension/ui is rebuilt in a later commit.
2 parents 93285dd + 261d638 commit d7d77a1

151 files changed

Lines changed: 6221 additions & 28978 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/skills/devtools-commit/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The rules are in `docs/contributing/commit-message-guidelines.md`. Summary:
2222
## Pull requests
2323

2424
- Pull requests are squash merged; the title becomes the commit on `main`, so it must follow the header format.
25-
- A `commit-msg` hook (`scripts/commit-message.mjs`, enabled by `pnpm install`) warns about a bad message as you commit; CI checks the title and every commit in the pull request: a bad title fails the check, and problems in the commits show as warnings. Run `pnpm commit:check` before pushing, and fix flagged messages with `git commit --amend` or a reword rebase.
25+
- A `commit-msg` hook (`scripts/commit-message.mjs`, enabled by `pnpm install`) warns about a bad message as you commit; CI checks the title and every commit in the pull request: a bad title or a bad commit message fails the check. Run `pnpm commit:check` before pushing, and fix flagged messages with `git commit --amend` or a reword rebase.
2626
- Address review feedback with fixup commits (`docs/contributing/using-fixup-commits.md`).
2727
- One feature per pull request, with its tests (including agent tool tests when tools change).
2828
- Rebuild and commit `extension/ui` when `app/` changed.

‎.github/workflows/commit-message.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
env:
3535
BASE: ${{ github.event.pull_request.base.sha }}
3636
HEAD: ${{ github.event.pull_request.head.sha }}
37-
run: node scripts/commit-message.mjs --range "$BASE..$HEAD" --warn
37+
run: node scripts/commit-message.mjs --range "$BASE..$HEAD"

‎app/src/__tests__/app-shell.test.ts‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,85 @@ describe('App tab bar', () => {
321321
});
322322
});
323323

324+
describe('App scroll memory', () => {
325+
it('brings each tab back to where it was scrolled', async () => {
326+
connection.answers = [true];
327+
const fixture = TestBed.createComponent(App);
328+
document.body.appendChild(host(fixture));
329+
await settle(fixture);
330+
331+
const main = host(fixture).querySelector<HTMLElement>('main')!;
332+
// jsdom has no layout, so scrollTop is a plain value here.
333+
let top = 0;
334+
Object.defineProperty(main, 'scrollTop', {
335+
configurable: true,
336+
get: () => top,
337+
set: (value: number) => (top = value),
338+
});
339+
const buttons = () => [...host(fixture).querySelectorAll<HTMLButtonElement>('nav button')];
340+
// An earlier test can leave another tab in the URL.
341+
buttons()[0].click();
342+
await settle(fixture);
343+
344+
main.scrollTop = 240;
345+
main.dispatchEvent(new Event('scroll'));
346+
buttons()[1].click();
347+
await settle(fixture);
348+
expect(main.scrollTop).toBe(0);
349+
350+
main.scrollTop = 80;
351+
main.dispatchEvent(new Event('scroll'));
352+
buttons()[0].click();
353+
await settle(fixture);
354+
expect(main.scrollTop).toBe(240);
355+
356+
buttons()[1].click();
357+
await settle(fixture);
358+
expect(main.scrollTop).toBe(80);
359+
fixture.destroy();
360+
});
361+
});
362+
363+
describe('App scroll memory while content loads', () => {
364+
it('keeps the saved position when the restore is clamped by short content', async () => {
365+
connection.answers = [true];
366+
const fixture = TestBed.createComponent(App);
367+
document.body.appendChild(host(fixture));
368+
await settle(fixture);
369+
370+
const main = host(fixture).querySelector<HTMLElement>('main')!;
371+
let top = 0;
372+
let max = 1000;
373+
Object.defineProperty(main, 'scrollTop', {
374+
configurable: true,
375+
get: () => top,
376+
set: (value: number) => (top = Math.max(0, Math.min(value, max))),
377+
});
378+
const buttons = () => [...host(fixture).querySelectorAll<HTMLButtonElement>('nav button')];
379+
buttons()[0].click();
380+
await settle(fixture);
381+
main.scrollTop = 240;
382+
main.dispatchEvent(new Event('scroll'));
383+
buttons()[1].click();
384+
await settle(fixture);
385+
386+
// The first tab comes back before its content has grown: the restore stops at 50.
387+
max = 50;
388+
buttons()[0].click();
389+
await settle(fixture);
390+
expect(main.scrollTop).toBe(50);
391+
main.dispatchEvent(new Event('scroll'));
392+
393+
buttons()[1].click();
394+
await settle(fixture);
395+
max = 1000;
396+
buttons()[0].click();
397+
await settle(fixture);
398+
expect(main.scrollTop).toBe(240);
399+
fixture.destroy();
400+
});
401+
});
402+
324403
describe('App counts launcher setting', () => {
325404
it('sends the stored counts launcher to the popup once the panel connects', async () => {
326405
localStorage.setItem('pangular-pref:pill', 'true');
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { Component, signal } from '@angular/core';
2+
import { TestBed } from '@angular/core/testing';
3+
import { afterEach, describe, expect, it } from 'vitest';
4+
import { AppState, type StateKind } from '../ui/app-state';
5+
6+
@Component({
7+
imports: [AppState],
8+
template: `
9+
<app-state
10+
[kind]="kind()"
11+
[retrying]="retrying()"
12+
(retry)="retries = retries + 1"
13+
(clear)="clears = clears + 1"
14+
>
15+
Can't read the data.
16+
<p detail>Check that the dev server is running.</p>
17+
</app-state>
18+
`,
19+
})
20+
class Host {
21+
readonly kind = signal<StateKind>('loading');
22+
readonly retrying = signal(false);
23+
retries = 0;
24+
clears = 0;
25+
}
26+
27+
async function mount(kind: StateKind) {
28+
const fixture = TestBed.createComponent(Host);
29+
fixture.componentInstance.kind.set(kind);
30+
document.body.append(fixture.nativeElement as HTMLElement);
31+
await fixture.whenStable();
32+
const state = (fixture.nativeElement as HTMLElement).querySelector('app-state')!;
33+
return { fixture, state };
34+
}
35+
36+
const buttons = (state: Element) => [...state.querySelectorAll('button')];
37+
38+
afterEach(() => {
39+
document.body.innerHTML = '';
40+
});
41+
42+
describe('app-state', () => {
43+
it('is a status with a spinner while loading, and has no button', async () => {
44+
const { state } = await mount('loading');
45+
expect(state.getAttribute('role')).toBe('status');
46+
expect(state.getAttribute('data-kind')).toBe('loading');
47+
expect(state.querySelector('.spinner')?.getAttribute('aria-hidden')).toBe('true');
48+
expect(buttons(state)).toEqual([]);
49+
});
50+
51+
it('is an alert with Retry on an error, and holds Retry while one runs', async () => {
52+
const { fixture, state } = await mount('error');
53+
expect(state.getAttribute('role')).toBe('alert');
54+
expect(state.querySelector('.message')!.textContent!.trim()).toBe("Can't read the data.");
55+
expect(state.querySelector('[detail]')!.textContent).toContain('dev server');
56+
const [retry] = buttons(state);
57+
expect(retry.textContent!.trim()).toBe('Retry');
58+
retry.click();
59+
expect(fixture.componentInstance.retries).toBe(1);
60+
61+
fixture.componentInstance.retrying.set(true);
62+
await fixture.whenStable();
63+
expect(retry.textContent!.trim()).toBe('Retrying…');
64+
expect(retry.getAttribute('aria-disabled')).toBe('true');
65+
retry.click();
66+
expect(fixture.componentInstance.retries).toBe(1);
67+
});
68+
69+
it('is a status that explains how to get data when empty', async () => {
70+
const { state } = await mount('empty');
71+
expect(state.getAttribute('role')).toBe('status');
72+
expect(buttons(state)).toEqual([]);
73+
});
74+
75+
it('offers Clear filters on no match, and is not a live region', async () => {
76+
const { fixture, state } = await mount('no-match');
77+
expect(state.hasAttribute('role')).toBe(false);
78+
const [clear] = buttons(state);
79+
expect(clear.textContent!.trim()).toBe('Clear filters');
80+
clear.click();
81+
expect(fixture.componentInstance.clears).toBe(1);
82+
});
83+
});
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import { Injector, runInInjectionContext, signal } from '@angular/core';
2+
import { TestBed, type ComponentFixture } from '@angular/core/testing';
3+
import type { DevframeRpcClient } from 'devframe/client';
4+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
5+
import { RouteTimeline } from '../pages/route-timeline';
6+
import type { NavigationRecord, RouterPage } from '../pages/router-types';
7+
import { LiveFeed } from '../ui/live-feed';
8+
9+
interface Entry {
10+
id: number;
11+
}
12+
13+
function feed(scope = signal('p1')) {
14+
const source = signal<Entry[]>([{ id: 1 }, { id: 2 }]);
15+
const live = runInInjectionContext(TestBed.inject(Injector), () => {
16+
return new LiveFeed<Entry>({
17+
name: 'test',
18+
source,
19+
key: (entry) => entry.id,
20+
newest: 'last',
21+
scope,
22+
});
23+
});
24+
return { source, live, scope };
25+
}
26+
27+
beforeEach(() => localStorage.clear());
28+
afterEach(() => {
29+
document.body.innerHTML = '';
30+
TestBed.resetTestingModule();
31+
});
32+
33+
describe('LiveFeed', () => {
34+
it('passes the live list through until it is paused', () => {
35+
const { source, live } = feed();
36+
expect(live.items()).toEqual([{ id: 1 }, { id: 2 }]);
37+
source.set([{ id: 1 }, { id: 2 }, { id: 3 }]);
38+
expect(live.items().length).toBe(3);
39+
expect(live.newestKey()).toBe(3);
40+
expect(live.paused()).toBe(false);
41+
expect(live.pending()).toBe(0);
42+
});
43+
44+
it('holds the entries while paused, counts the new ones and shows them on resume', () => {
45+
const { source, live } = feed();
46+
live.pause();
47+
source.set([{ id: 2 }, { id: 3 }, { id: 4 }]);
48+
expect(live.items()).toEqual([{ id: 1 }, { id: 2 }]);
49+
expect(live.pending()).toBe(2);
50+
live.toggle();
51+
expect(live.paused()).toBe(false);
52+
expect(live.items()).toEqual([{ id: 2 }, { id: 3 }, { id: 4 }]);
53+
});
54+
55+
it('stays paused on another page, holding that page’s entries', () => {
56+
const { source, live, scope } = feed();
57+
live.pause();
58+
source.set([{ id: 9 }]);
59+
scope.set('p2');
60+
expect(live.paused()).toBe(true);
61+
expect(live.items()).toEqual([{ id: 9 }]);
62+
source.set([{ id: 9 }, { id: 10 }]);
63+
expect(live.pending()).toBe(1);
64+
});
65+
66+
it('saves Follow newest per feed', () => {
67+
const { live } = feed();
68+
expect(live.follow()).toBe(false);
69+
live.setFollow(true);
70+
expect(localStorage.getItem('pangular-pref:follow:test')).toBe('true');
71+
expect(feed().live.follow()).toBe(true);
72+
});
73+
});
74+
75+
describe('the router timeline live controls', () => {
76+
function nav(id: number, url: string): NavigationRecord {
77+
return { id, url, trigger: 'imperative', startedAt: id, endedAt: id + 1, outcome: 'succeeded' };
78+
}
79+
function page(navigations: NavigationRecord[]): RouterPage {
80+
return { pageId: 'p1', reportedAt: 1, changedAt: 1, snapshot: null, navigations };
81+
}
82+
async function settle(fixture: ComponentFixture<unknown>) {
83+
for (let i = 0; i < 3; i++) {
84+
await new Promise((resolve) => setTimeout(resolve));
85+
await fixture.whenStable();
86+
}
87+
}
88+
const client = {
89+
connectionMeta: {},
90+
scope: () => ({ rpc: { call: () => Promise.resolve(null) } }),
91+
} as unknown as DevframeRpcClient;
92+
93+
it('holds the navigations while paused and shows the held count', async () => {
94+
const fixture = TestBed.createComponent(RouteTimeline);
95+
fixture.componentRef.setInput('page', page([nav(1, '/a'), nav(2, '/b')]));
96+
fixture.componentRef.setInput('rpc', client);
97+
document.body.append(fixture.nativeElement as HTMLElement);
98+
await settle(fixture);
99+
const root = fixture.nativeElement as HTMLElement;
100+
const urls = () => [...root.querySelectorAll('.navs .head .url')].map((e) => e.textContent);
101+
expect(urls()).toEqual(['/b', '/a']);
102+
103+
const pause = root.querySelector<HTMLButtonElement>('app-live-controls button')!;
104+
pause.click();
105+
fixture.componentRef.setInput('page', page([nav(1, '/a'), nav(2, '/b'), nav(3, '/c')]));
106+
await settle(fixture);
107+
expect(urls()).toEqual(['/b', '/a']);
108+
expect(root.querySelector('.pending')!.textContent!.trim()).toBe('1 new');
109+
expect(pause.getAttribute('aria-describedby')).toBe(root.querySelector('.pending')!.id);
110+
111+
pause.click();
112+
await settle(fixture);
113+
expect(urls()).toEqual(['/c', '/b', '/a']);
114+
});
115+
});

‎app/src/__tests__/live-route-apps.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function routerPage(extra: Partial<RouterPage> = {}): RouterPage {
1010
return {
1111
pageId: 'p1',
1212
reportedAt: 1,
13+
changedAt: 1,
1314
snapshot: { url: '/home', queryParams: {}, fragment: null, root },
1415
navigations: [
1516
{

‎app/src/__tests__/live-route-pinned.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function routerPage(pageId: string): RouterPage {
99
return {
1010
pageId,
1111
reportedAt: 1,
12+
changedAt: 1,
1213
snapshot: {
1314
url: `/${pageId}`,
1415
queryParams: {},

‎app/src/__tests__/native-controls.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ describe('browser-only controls', () => {
100100
});
101101

102102
it.each(['angular-native', 'nativescript'])(
103-
'hides the picker and the live views for a %s page, and keeps recording and the tree',
103+
'offers the device picker, hides the live views for a %s page, and keeps recording and the tree',
104104
async (platform) => {
105105
const fixture = await render(platform);
106106
const host = fixture.nativeElement as HTMLElement;
107107
expect(buttons(fixture)).not.toContain('Pick component on page');
108+
expect(buttons(fixture)).toContain('Pick component on device');
108109
expect(buttons(fixture)).toContain('Record');
109110
expect(host.querySelector('#cd-heading')).not.toBeNull();
110111
expect(buttons(fixture)).not.toContain('Flash checks');

0 commit comments

Comments
 (0)