Skip to content

Commit 6ca2886

Browse files
authored
fix(hub): show hub messages and toasts, readable sidebar badges, and fixes from a hands-on check (#381)
Refs #340, #378.
1 parent d0b7593 commit 6ca2886

30 files changed

Lines changed: 551 additions & 50 deletions

‎app/src/__tests__/hub-rail-style.test.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,43 @@ describe('styleHubRail', () => {
6767
expect(css).toMatch(/\[style\*="239, 68, 68"\] \{\s*background-color: #dc2626 !important;/);
6868
});
6969

70+
it('keeps group sidebar badges at full opacity and colours them from the dock title', () => {
71+
const dock = makeDock();
72+
const base = document.createElement('style');
73+
// hub-ui's own rules for the classes the group sidebar uses.
74+
base.textContent =
75+
'.op60 { opacity: 0.6; } .bg-gray-6 { background-color: rgb(75, 85, 99); } .text-white { color: rgb(255, 255, 255); }';
76+
const sidebar = document.createElement('div');
77+
sidebar.className = 'devframes-group-sidebar';
78+
const button = (label: string) =>
79+
`<button aria-label="${label}" class="relative op60"><svg></svg><div class="absolute bg-gray-6 text-white">1</div></button>`;
80+
sidebar.innerHTML = [
81+
button('Angular (1 new, with errors)'),
82+
button('NgRx (2 new, with warnings)'),
83+
button('Analog (3 new)'),
84+
button('Show more'),
85+
].join('');
86+
dock.shadowRoot!.append(base, sidebar);
87+
styleHubRail(document, 'light');
88+
89+
const buttons = [...sidebar.querySelectorAll('button')];
90+
const style = (el: Element) => getComputedStyle(el);
91+
expect(buttons.map((b) => style(b).opacity)).toEqual(['1', '1', '1', '1']);
92+
expect(buttons.map((b) => style(b.querySelector('svg')!).opacity)).toEqual([
93+
'0.6',
94+
'0.6',
95+
'0.6',
96+
'0.6',
97+
]);
98+
expect(buttons.map((b) => style(b.querySelector('.absolute')!).backgroundColor)).toEqual([
99+
'rgb(220, 38, 38)',
100+
'rgb(220, 38, 38)',
101+
'rgb(37, 99, 235)',
102+
'rgb(75, 85, 99)',
103+
]);
104+
expect(style(buttons[0].querySelector('.absolute')!).color).toBe('rgb(255, 255, 255)');
105+
});
106+
70107
it('retries when the shadow host is not yet in the DOM', () => {
71108
vi.useFakeTimers();
72109
styleHubRail(document, 'dark');

‎app/src/hub-rail-style.ts‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,43 @@ function activeDockStyle(theme: 'dark' | 'light'): string {
3737
background-color: #dc2626 !important;
3838
color: #ffffff !important;
3939
}
40+
/* The group sidebar (the tools of the open group) fades a whole inactive
41+
button with op60, badge included, and draws every badge bg-gray-6
42+
whatever its variant. Fade the icon only: white on bg-gray-6 (#4b5563)
43+
is 7.6:1. The sidebar drops the variant, so the colour comes from the
44+
title Pangular gives a dock with a badge, "Angular (2 new, with errors)",
45+
which hub-ui puts in aria-label: blue-600 for new items, red-600 with
46+
errors or warnings, as on the rail. Other badges stay grey. */
47+
.devframes-group-sidebar button.op60 {
48+
opacity: 1;
49+
}
50+
.devframes-group-sidebar button > * {
51+
transition: opacity 0.2s, filter 0.2s;
52+
}
53+
.devframes-group-sidebar button.op60 > :not(.absolute) {
54+
opacity: 0.6;
55+
}
56+
.devframes-group-sidebar button.op60:hover > :not(.absolute),
57+
.devframes-group-sidebar button.op60:focus-visible > :not(.absolute) {
58+
opacity: 1;
59+
}
60+
.devframes-group-sidebar .absolute.bg-gray-6 {
61+
background-color: #4b5563;
62+
color: #ffffff;
63+
}
64+
.devframes-group-sidebar button[aria-label$=" new)"] > .absolute {
65+
background-color: #2563eb;
66+
}
67+
.devframes-group-sidebar button[aria-label$=" new, with errors)"] > .absolute {
68+
background-color: #dc2626;
69+
}
70+
.devframes-group-sidebar button[aria-label$=" new, with warnings)"] > .absolute {
71+
background-color: #dc2626;
72+
}
73+
.devframes-group-sidebar button:focus-visible {
74+
outline: 2px solid ${accent};
75+
outline-offset: 2px;
76+
}
4077
.devframes-dock-entry button:focus-visible {
4178
outline: 2px solid ${accent};
4279
outline-offset: 2px;
@@ -52,7 +89,8 @@ function activeDockStyle(theme: 'dark' | 'light'): string {
5289
}
5390
@media (prefers-reduced-motion: reduce) {
5491
.devframes-dock-entry button,
55-
.devframes-dock-entry button > * {
92+
.devframes-dock-entry button > *,
93+
.devframes-group-sidebar button > * {
5694
transition: none;
5795
}
5896
}

‎apps/docs/src/content/getting-started/cli.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ npx @pangular-inspector/devtools mcp --print-config --port 4000 --base /__devfra
191191
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------- |
192192
| `--print-config` | Print the client config and exit. |
193193
| `--host <host>` | Host of the server that runs your app, for the HTTP config. The default is `localhost`. |
194-
| `--port <port>` | Port of that server. The default is 9999, the standalone CLI. |
194+
| `--port <port>` | Port of that server, from 1 to 65535. The default is 9999, the standalone CLI. |
195195
| `--base <path>` | The hub base, such as `/__devframes/` for the Express hub and the Vite plugin. With it, the HTTP config sends the MCP token. |
196196
| `--https` | The server is behind TLS, so the HTTP config uses `https://`. |
197197

‎apps/docs/src/content/getting-started/overlay.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The floating button follows the path the overlay connected to. If that path is `
107107

108108
### One overlay per page
109109

110-
Only one overlay runs on a page. Importing `@pangular-inspector/devtools/overlay` already starts one on the default URLs. When you call `initOverlay`, it stops the running overlay first, the auto-started one included, and then starts yours. The page never ends up with two connections.
110+
Only one overlay runs on a page. Importing `@pangular-inspector/devtools/overlay` starts one on the default URLs, on the next task after the import. If `initOverlay` runs before that task, only that overlay starts. The [Vite plugin](./vite.md) does this. If you call `initOverlay` later, it stops the running overlay first, the auto-started one included. Then it starts yours. The page never ends up with two connections.
111111

112112
An overlay that was stopped or replaced before it connected does not report its connection error.
113113

‎apps/docs/src/content/getting-started/popup-and-hub.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,19 @@ The tooltip comes back when the app stops reporting and its data expires. The An
145145

146146
### Messages and badges
147147

148-
The hub keeps a list of messages. Pangular Inspector posts to it when something happens in the app:
148+
The hub keeps a list of messages, which the **Messages** dock lists and filters. Pangular Inspector posts to it when something happens in the app:
149149

150-
| Message | Level | Category | Posted when |
151-
| -------------------------------------------- | ----- | ----------- | ---------------------------------------------------------------------------------------------------------------------- |
152-
| `Agent ran <tool>` | info | `agent` | An [action tool](../agents/tools.md#action-tools) that changes the app or the server finishes, such as `set-http-rule` |
153-
| The NG error, such as `NG01203: ...` | error | `runtime` | A page reports a forms setup error (`NG01xxx`) |
154-
| `Navigation failed (NG04002): ...` | error | `runtime` | A page reports a failed navigation |
155-
| `Hydration mismatch at <app-cart>` | error | `hydration` | A page reports a node that failed to hydrate, with the expected and actual node |
156-
| The hydration message, such as `NG0505: ...` | warn | `hydration` | A page logs an `NG05xx` hydration message |
150+
| Message | Level | Category | Posted when |
151+
| -------------------------------------------- | ----- | ----------- | -------------------------------------------------------------------------------------------------------- |
152+
| `Agent ran <tool>` | info | `agent` | An [action tool](../agents/tools.md#action-tools) changes the app or the server, such as `set-http-rule` |
153+
| The NG error, such as `NG01203: ...` | error | `runtime` | A page reports a forms setup error (`NG01xxx`) |
154+
| `Navigation failed (NG04002): ...` | error | `runtime` | A page reports a failed navigation |
155+
| `Hydration mismatch at <app-cart>` | error | `hydration` | A page reports a node that failed to hydrate, with the expected and actual node |
156+
| The hydration message, such as `NG0505: ...` | warn | `hydration` | A page logs an `NG05xx` hydration message |
157157

158-
Each message names the pages it came from (also as `page:<pageId>` labels) and has an **Open in Pangular** action that opens the dock that shows it. An error opens a toast the first time it shows up. When the same item comes back, from the same page after a reload or from another tab, the first message counts it (`(3 times)`) instead of posting it again. A call that only reads, like `change-detection` without `record`, posts nothing. Text in messages is masked like the rest of the panel. An agent message shows the first line of the tool's answer and the `page` argument, not the other arguments.
158+
Each message names the pages it came from (also as `page:<pageId>` labels) and has an **Open in Pangular** action that opens the dock that shows it. An error opens a toast the first time it shows up. When the same item comes back, from the same page after a reload or from another tab, the first message counts it (`(3 times)`) instead of posting it again. A call that only reads, like `change-detection` without `record`, posts nothing, and neither does a call that changed nothing: no page to act on, a refusal from the page or the config, or an argument to fix, such as `navigate` answering `No router state has been reported`. Text in messages is masked like the rest of the panel. An agent message shows the first line of the tool's answer that says what happened, past the untrusted-data notice, and the `page` argument, not the other arguments.
159159

160-
A dock shows how many items it has that you have not seen yet: NgRx writes on **NgRx**, Analog writes on **Analog**, and everything else on **Angular**. The **Pangular** group shows the total. The badge is red while one of them is an error or a warning. Opening a dock clears its count, and opening **All tools** clears every count. The count is also part of the dock name that screen readers and the tooltip use, for example `Angular (2 new, with errors)`. When the unseen items hold warnings, such as an NG05xx hydration message, but no error, the name ends in `with warnings` instead.
160+
A dock shows how many items it has that you have not seen yet: NgRx writes on **NgRx**, Analog writes on **Analog**, and everything else on **Angular**. The **Pangular** group shows the total. The badge is red while one of them is an error or a warning. Opening a dock clears its count, and opening **All tools** clears every count. The tools sidebar of the open group shows the same counts, in the same colours. The count is also part of the dock name that screen readers and the tooltip use, for example `Angular (2 new, with errors)`. When the unseen items hold warnings, such as an NG05xx hydration message, but no error, the name ends in `with warnings` instead.
161161

162162
Messages follow the config. An inspector that is off posts nothing (forms errors need `inspectors.forms`, failed navigations `inspectors.router`, hydration messages `inspectors.http`), and an agent tool turned off with `agent.tools`, `agent.readOnly` or `actions` posts nothing either. See [Configuration](./configuration.md).
163163

‎apps/docs/src/content/getting-started/vite.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default defineConfig({
4242

4343
### The overlay loads itself
4444

45-
The plugin adds a module script to every HTML page the dev server transforms, at the end of `<body>`. The script imports `@pangular-inspector/devtools/overlay`, which starts the overlay and the floating button. `vite build` skips the plugin, so the overlay stays out of your production bundle. See [Load the overlay yourself](#load-the-overlay-yourself) to turn it off.
45+
The plugin adds a module script to every HTML page the dev server transforms, at the end of `<body>`. The script imports `@pangular-inspector/devtools/overlay`, which adds the floating button, and starts the overlay with the hub's path (`/__devframes/pangular/` by default), so the overlay connects there without trying the other default paths first. `vite build` skips the plugin, so the overlay stays out of your production bundle. See [Load the overlay yourself](#load-the-overlay-yourself) to turn it off.
4646

4747
### Where to find it
4848

@@ -64,7 +64,7 @@ The plugin applies to `vite serve` only. `vite build` is not affected, so nothin
6464

6565
It adds the overlay to the HTML that Vite transforms, including the template an Analog SSR render starts from. It works under a Vite `base`. A page whose HTML already imports `@pangular-inspector/devtools/overlay` gets no second script.
6666

67-
An app that still imports the overlay in `main.ts` gets one overlay, not two: Vite resolves both imports to the same module, which runs once.
67+
An app that still imports the overlay in `main.ts` gets one overlay, not two: Vite resolves both imports to the same module, and starting the overlay with the hub's path replaces any overlay that is already running.
6868

6969
### Mounts the hub
7070

‎apps/docs/src/content/inspectors/components.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ The server launches the editor on the machine it runs on. It picks the editor in
182182
| An editor already running | VS Code, Cursor, WebStorm and other IDEs |
183183
| `VISUAL`, then `EDITOR` | `EDITOR=vim` |
184184

185-
If the host installs the `@devframes/service-open` service, its `editor` option takes over.
185+
If the host installs the `@devframes/service-open` service (the Messages devframe in the hub brings it in), the server tries it first so its `editor` option applies. That service only opens files under the workspace root, so when it refuses a file, such as one in a served app outside the workspace, the server opens it the way the table above describes.
186186

187187
The server only opens regular files inside the project. Paths outside the workspace root and the served app, symlinks that point outside them, folders and missing files are refused, and the button says why. See [Open in editor](../security.md#open-in-editor).
188188

‎apps/docs/src/content/security.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ The panel and the overlay can ask the server to open a source file in your edito
165165
- It resolves the path against the workspace root, the directory the server runs in and the served app. A path that leaves all of them, with `..` or as an absolute path, is refused.
166166
- It follows symlinks and refuses the file when its real path is outside those directories.
167167
- It opens regular files only. Folders and missing files are refused.
168+
- Only a path that passed these checks reaches a launcher: the `@devframes/service-open` service when the host has it, and devframe's `launch-editor` when the service is missing or refuses the path.
168169
- Line and column must be positive whole numbers, or they are left out.
169170

170171
The request names a file and a line, never a command. The editor comes from the server's environment. Agent tools can't open files.

extension/ui/assets/browser-agent-rpc-BXhoSh1z-CeUhVYZt.js renamed to extension/ui/assets/browser-agent-rpc-BXhoSh1z-BhKkMIUU.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)