Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9b6df71
Detachable inspector host and discovery of the watches (#680)
ambroise-leclerc Nov 25, 2026
5f0105a
List the watches again when they change between pages, and attach a p…
ambroise-leclerc Nov 25, 2026
4338ae4
Listen for detached panels at load, and clear a read error once reads…
ambroise-leclerc Nov 25, 2026
9cf1494
Give each host page an identifier of its own, and name its tabs by it…
ambroise-leclerc Nov 25, 2026
68e2e18
Keep one chain of watch reads, and show watch names with visible cont…
ambroise-leclerc Nov 25, 2026
1c4f700
Build the watch tests with MSVC, and give WKWebView time to release a…
ambroise-leclerc Nov 25, 2026
41b0352
Merge develop into 680-inspecteur-detachable
ambroise-leclerc Nov 25, 2026
3569fae
Answer the review of #692 (#680)
ambroise-leclerc Nov 25, 2026
9824273
Guard developer writes and finish inspector saves on the server (#680)
ambroise-leclerc Nov 26, 2026
664349b
Keep the command header self-contained (#680)
ambroise-leclerc Nov 26, 2026
8ff1c3b
Merge develop into 680-inspecteur-detachable
ambroise-leclerc Nov 26, 2026
19841c8
Exercise developer writes from admitted browser sessions (#680)
ambroise-leclerc Nov 26, 2026
8dceb1f
Fix MSVC warnings and Windows macro collisions (#680)
ambroise-leclerc Nov 26, 2026
b255cab
Keep unreadable inspector choices, refuse a page budget too small, re…
ambroise-leclerc Nov 26, 2026
2fa3578
Reload a restored inspector page, and offer no tab under an embedded …
ambroise-leclerc Nov 26, 2026
bed092c
Close a native inspector window that opens after its panel was attach…
ambroise-leclerc Nov 26, 2026
e30f19c
Borrow the host's bridge in the floating inspector's frame (#680)
ambroise-leclerc Nov 26, 2026
3626717
Let the host page close the window of a panel attached again (#680)
ambroise-leclerc Nov 26, 2026
55c0ac5
Close a native inspector window that opens after its floating window …
ambroise-leclerc Nov 26, 2026
1c664a4
Cancel every pending native opening of a panel when its floating wind…
ambroise-leclerc Nov 26, 2026
d658276
Let only a panel's latest opening close its window, and keep a watch …
ambroise-leclerc Nov 26, 2026
8b26b40
Decide whether a panel's native window stays once all its openings ha…
ambroise-leclerc Nov 26, 2026
530d1ca
Merge remote-tracking branch 'origin/develop' into 680-inspecteur-det…
ambroise-leclerc Nov 26, 2026
170e020
Answer the review of #692 (#680)
ambroise-leclerc Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ these entries stays in the GitHub releases and the Git history.

## Unreleased

### Breaking
- A custom frontend whose `open()` takes `const ViewLaunch&` declares `static bool providesViewProof()`, `true` when it gives the proof to its view and `false` otherwise, or the developer environment no longer compiles with it: undeclared, its proven view would leave project writes and C++ commands unguarded (#680, ADR-027, `docs/FRONTENDS.md`).
- `cppFunction` (and `Space::cppFunction`) refuses the names starting with `webfront.inspector.`, reserved to the inspectors, with `std::invalid_argument`: rename such a function, and its `webFront.cppFunction(...)` calls in the page, to a name of your own (#680, ADR-027).

### Added
- Open the inspectors from the WebFront tab's menu of the developer environment: each panel shows in a floating window of the page and can be detached to a native secondary window (WebKitGTK, WKWebView, WebView2) or, with `trustLoopbackClients`, a tab of the system browser; the choice and the place are kept per project (#680, ADR-027, `docs/DEVELOPER_ENVIRONMENT.md`).
- Declare what the inspectors show with `app.watch(name, source)`, whose handle removes the watch when it is destroyed; the Watches panel follows their registrations and removals. Outside the developer environment and in a distribution build, `watch` registers nothing (#680, ADR-027).
- Embed a plain interface directory (HTML, JavaScript, CSS, vendored files) from CMake with `webfront_embed_directory(app ui CLASS AppUI)`, without the developer environment: the build regenerates the provider when a file changes, and `fs::DocumentRootFirstFSWith<AppUI>` lets a development root serve in front of it (#675, `docs/EMBEDDED_ASSETS.md`).
- Set from the configuration `Referrer-Policy` (`contentPolicy.referrerPolicy`: `"no-referrer"` forbids explicitly that a capability in your URLs leaves in `Referer`), `X-Content-Type-Options: nosniff` (`noSniff`) and the `Cache-Control` of HTML pages (`htmlCacheControl`), on files, route and generated replies unless a reply sets its own (#674, `docs/CONTENT_POLICY.md`).
- Keep a capability carried by your URLs out of WebFront's logs with `app.addSecretPrefix("/s/")`: the segment after the prefix is logged as `*` (`/s/*/index.html`) for files, routes, WebSocket upgrades and their failures, whose error messages are not logged (#673, `docs/HTTP_ASSETS.md`).
Expand All @@ -32,6 +38,9 @@ these entries stays in the GitHub releases and the Git history.
- `DeveloperBrowserIntegration-workspace` gives the relaunched bootstrap page the same 60 s to start as the first one, instead of 10 s, which a loaded runner exceeded while the page verified its cached environment (#660).
- Applications started from the terminal of a Snap-packaged editor (VSCodium) now run on WebKitGTK without cleaning the environment by hand; `WEBFRONT_KEEP_SNAP_ENVIRONMENT=1` opts out (#662, `docs/WEBKITGTK.md`).

### Security
- Require an admitted client for developer project writes and native terminal commands when the frontend proves its view (ADR-027, #680).

## [1.2.0] - 2026-11-24

WebFront 1.2 ships with developer environment 1.2.0. The application itself becomes the MCP server that a coding agent drives
Expand Down
30 changes: 28 additions & 2 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,34 @@ environment's `mount`, not to the embedded bootstrap page):
embedded frontend (WebKitGTK, WKWebView, WebView2, CEF), which proves itself at the handshake, or any loopback page when
the application sets `WebFrontConfig::trustLoopbackClients`. With the system browser, which never receives that proof,
the entries are therefore unavailable by default, and the menu says to choose an embedded frontend or to set
`trustLoopbackClients`, knowing that any local process can then read the state of the application. The inspector panels
themselves come with the next versions of the environment; until then an admitted page's entries say so.
`trustLoopbackClients`, knowing that any local process can then read the state of the application.

**The inspector** is one page of the environment, `/webfront/developer/environment/inspector.html?panel=<id>`, that talks
to C++ through the bridge. An entry of the menu opens its panel where the project keeps it: at first, and whenever its
detached container is unavailable, in a **floating window** of the page (moved and resized like the terminal's window,
with the mouse or with the arrow keys on its title bar), whose frame opens no connection of its own and borrows the page's
bridge, since the adapters give the proof of the view to the main frame only. **Detach** moves the panel to a window of its
own, and the next opening of that panel goes there again; **Attach**, in that window, brings it back to the floating
window, where it then opens:

| Frontend of the page | Detached container |
| --- | --- |
| WebKitGTK, WKWebView, WebView2 | a native secondary window (`webfront.inspector.openWindow`, `openSecondaryWindow`), which carries the proof of the view; opening the panel again brings it to the front, and closing the main window closes it |
| System browser with `trustLoopbackClients` | a tab of the system browser (`window.open`), with its own loopback connection; when the pop-up blocker refuses it, the panel stays in the floating window and a message offers to try again; the tab closes when the page that opened it is gone |
| CEF, or an embedded view without secondary windows | none: Detach is greyed, with the reason in its tooltip (`window.open` there would open a frame without the proof) |

Attach brings the panel back to the page that detached it only, even when other pages of the application are open on
the same origin. A page keeps its identifier across a reload through Web Locks; in a browser without them, a reloaded
page has a new one, and a tab detached before the reload asks the old page in vain: it says that the main page did not
answer. Close that tab, open the panel from the menu of the reloaded page, then use Attach in the window it opens. The project keeps the detached panels and the floating window's place in
`.webfront/developer/inspector-window.json`. A save that reaches C++ completes or releases its transaction there,
even when its page closes. A page closed before the save reaches C++ may lose its latest choice.
With a frontend that proves its view, developer file writes and starting or cancelling native terminal commands
also require an admitted page. The system browser keeps origin-based access to those operations.
The **Watches** panel lists the application's watches (`app.watch(name, source)`, declared after `bootstrap()`): their
name, the kind of their root and where they were declared. It asks C++ for the revision of their table every 250 ms
(Pause stops it), reads the list again when it changed, and adds or removes the watches that appeared or disappeared.
Their contents, and the other panels, come with the next versions of the environment.

The tab is a button (`aria-expanded`, `aria-haspopup="menu"`, 44 px target), its menu a `menu` of `menuitem`s of 44 px,
and the window a non-modal dialog. The interface stays in the preview
Expand Down
6 changes: 4 additions & 2 deletions docs/FRONTENDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ A frontend is a type with:
| `static void initialize()` | Called once successfully per frontend type, before the first `BasicWF` listener is created. A thrown exception aborts construction; the next construction retries. |
| `static void open(std::string_view port, std::string_view file)` | Called by `show()` / `openAndRun()` on the calling thread, while the HTTP server runs on its own thread. |
| `static void open(address, port, page, const ContentPolicy&)` (optional) | Preferred overload receiving the per-application [content policy](CONTENT_POLICY.md). |
| `static void open(address, port, page, const ContentPolicy&, const WindowOptions&, const ViewLaunch&)` (optional) | Richest overload: also receives the [view association](#view-association) proof of this launch. |
| `static void open(address, port, page, const ContentPolicy&, const WindowOptions&, const ViewLaunch&)` (optional) | Richest overload: also receives the [view association](#view-association) proof of this launch. A frontend that offers it declares `static bool providesViewProof()`. |
| `static bool providesViewProof()` (required with the `ViewLaunch` overload) | `true` when the frontend gives the proof to its view, `false` when it does not (the system browser, which receives `ViewLaunch` only for the origin). While it is `true`, the developer environment's project writes and the terminal's C++ commands are refused to a page that is not a local client (ADR-027, section 2). A frontend with the `ViewLaunch` overload that leaves it undeclared fails to compile where WebFront checks it; any other frontend counts as `false`. |
| `static constexpr Action action` | What `BasicWF` does once `open()` returns. |
| `static void launch(address, port, page)` (optional) | Opens the interface and returns without waiting for it (the system browser spawns its opener command and does not wait for it to end). `BasicWF::start()` requires it; only a frontend without a window loop offers it (the system browser). A `launch(address, port, page, const ContentPolicy&)` overload is preferred when present; neither receives window options or the view-association proof. |
| `static constexpr bool endsOnRequest` (optional) | `false` when `requestClose()` cannot end every session (`NativeOrBrowserFrontend` with the plain system browser as fallback); `webfront::UIThread` then refuses the frontend. |
Expand Down Expand Up @@ -55,7 +56,8 @@ on a command line or in a URL.
- `NativeOrBrowserFrontend` passes the proof to the native window only.
- The association does not protect against a script admitted into the view (ADR-008): it shares the authority of the bridge
and could read the property before `WebFront.js`. An adapter that cannot inject a script simply does not implement the overload.
- A custom frontend that wants services restricted to its own view implements the overload and applies
- A custom frontend that wants services restricted to its own view implements the overload, declares
`providesViewProof()` returning `true`, and applies
`webfront::detail::viewSecretScript(secret, origin)` (or the engine's equivalent) at the start of the document. The helper
returns an empty script, hence no association, unless the secret is lowercase hexadecimal and the origin a plain http origin;
give it `webfront::detail::browserOrigin(address, port)` (lowercase, without port 80), which `ViewLaunch::origin` already is.
Expand Down
45 changes: 43 additions & 2 deletions docs/adr/ADR-027-inspecteurs-de-l-etat-de-l-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

| Version | Date | État | Auteur | Évolution | Révision Git |
| --- | --- | --- | --- | --- | --- |
| 1.1 | 2026-11-25 | Proposée | Ambroise Leclerc | Hôte détachable (#680) : `webfront.inspector.embedded()` dit à la page hôte si elle peut tourner dans un frontend intégré (vue prouvée, ou frontend actif qui transmet la preuve), ce qui décide de l'onglet du navigateur système ; `webfront.inspector.closeWindow(panneau, hôte)` ferme la fenêtre d'un panneau rattaché ; une fenêtre par panneau et par page hôte, qui seule le rattache ; choix et place conservés dans `inspector-window.json`, lus avec le jeton de leurs octets par `webfront.inspector.readPreferences()`. | À renseigner après intégration. |
| 1.0 | 2026-11-25 | Proposée | Ambroise Leclerc | Décision initiale (#678, épique #677) : inspecteurs réservés à l'environnement développeur, accès réservé aux vues prouvées sauf autorisation explicite, nœuds d'arbre sur les types existants du pont, lecture et différences paginées, opérations entières sous le verrou ou sur l'exécuteur de l'application, modification à la demande de l'application, page unique `inspector.html` dans un conteneur choisi sur l'accès effectif. | À renseigner après intégration. |

## État et portée
Expand Down Expand Up @@ -218,7 +219,8 @@ appels sont :
- `webfront.inspector.reset(observateur)` : vide la mémoire de l'observateur pour cette connexion (ci-dessous) ;
- `webfront.inspector.limits()` : les bornes de cette section, dont `maxWriteTextBytes`.

Le nombre vaut 200 par défaut et 1 000 au plus. C++ réduit chaque page pour qu'elle tienne dans `responseBudget` et
Le nombre est un argument de chaque appel, puisque le pont n'a pas d'argument facultatif : l'inspecteur demande 200
par défaut, et C++ le ramène à 1 000 au plus (0 ne demande que la révision, pour `watches`). C++ réduit chaque page pour qu'elle tienne dans `responseBudget` et
rend le `suivant` qui reprend là où elle s'arrête : aucun appel ne lève `BufferOverflowException` ni ne dépasse
`maxMessageSize`, quel que soit l'état observé. Les seuls échecs d'un appel valide sont les refus typés de cette
décision (`webfront.inspector.*`).
Expand Down Expand Up @@ -652,7 +654,9 @@ booléens, et aucun état de l'application.
| `host` | la connexion de la page hôte est admise (section 2) |
| `newConnections` | une nouvelle connexion non prouvée serait admise : l'application a choisi `trustLoopbackClients` |

La page se charge dans le premier conteneur qui convient :
Un panneau s'ouvre là où le projet le garde : dans la fenêtre flottante tant qu'il est rattaché, ce qui est son état
initial, et dans son conteneur détaché une fois détaché, tant que ce conteneur reste disponible (sinon la fenêtre
flottante sert de repli). L'ordre qui suit choisit le conteneur d'un panneau **détaché** :

1. **Fenêtre native secondaire** si `secondaryWindow`, donc seulement depuis une page hôte admise (WebKitGTK,
WKWebView, WebView2). La fonction réservée `webfront.inspector.openWindow` appelle `openSecondaryWindow`, qui
Expand All @@ -670,6 +674,43 @@ La page se charge dans le premier conteneur qui convient :
4. **Aucun** sinon (navigateur système sans `trustLoopbackClients`) : les entrées du menu sont désactivées et disent
pourquoi (section 2).

La page hôte ne sait pas d'elle-même si elle tourne dans le navigateur système : `containers()` décrit l'accès, pas la
vue. Elle le demande à `webfront.inspector.embedded()`, qui vérifie l'accès comme les autres fonctions et répond vrai
quand l'appelant est une vue prouvée (`UI::isEmbeddedView()`) **ou** quand le frontend actif transmet la preuve à ses
vues. La preuve désigne une vue prouvée, pas l'endroit où tourne une page qui ne l'a pas : sous un tel frontend, une page
admise sans preuve (un cadre d'une vue intégrée, avec `trustLoopbackClients`) peut se trouver dans une vue intégrée, et
on ne lui propose pas d'onglet. Un échec compte aussi comme une vue intégrée, ce qui n'essaie jamais d'onglet.

Chaque page hôte a un **identifiant** (1 à 64 lettres, chiffres, `-` ou `_`), gardé dans le stockage de session de son
onglet pour qu'un rechargement le garde. Ce stockage étant copié dans une page qu'elle ouvre, l'identifiant n'est repris
que par la page qui en détient le verrou (Web Locks, exclusif pour l'origine, libéré quand la page disparaît) ; sans
Web Locks, chaque chargement en tire un nouveau. Le nom de l'onglet d'un panneau détaché nomme aussi l'hôte, pour qu'une
autre page du même groupe de navigation ne réutilise pas son onglet. Un panneau détaché a sa propre fenêtre, nommée par la page `inspector.html?panel=<id>&host=<hôte>` :
`openWindow(panneau, hôte, largeur, hauteur)` n'accepte que les panneaux du menu et un identifiant valide, et
`webfront.inspector.closeWindow(panneau, hôte)` ferme celle d'un panneau rattaché de nouveau. Les deux s'exécutent sur
le thread de l'interface, où `openSecondaryWindow` et `requestClose(page)` ne retiennent pas le thread du serveur. Une
fenêtre détachée demande son rattachement par un `BroadcastChannel` de même origine, en nommant son hôte : seule la page
qui l'a détachée le prend, les autres pages de l'application ouvertes sur la même origine l'ignorent. C'est cette page
qui ferme la fenêtre, quand elle le peut : une fenêtre native par `closeWindow` sur sa propre connexion, et un nouveau
détachement n'ouvre la fenêtre qu'une fois cette fermeture terminée ; un onglet qu'elle a ouvert, par sa référence. Une
fermeture demandée par la fenêtre elle-même pourrait sinon refermer celle qu'un détachement fait entre-temps vient de
réutiliser. Un onglet dont elle n'a pas la référence (ouvert avant un rechargement) se ferme lui-même après la réponse,
et le détachement suivant ouvre un onglet sous un autre nom plutôt que de réutiliser celui-ci.

La liste des observateurs se lit page après page sous la révision de la première ; une page qui répond `changé` fait
recommencer la liste, pour qu'un observateur retiré entre deux pages ne reste pas affiché sous la nouvelle révision.

Le choix de chaque panneau et la place de la fenêtre flottante sont écrits comme des **changements** du fichier du
projet, relu au moment de l'écriture et validé seulement s'il n'a pas changé depuis (sinon l'écriture recommence) :
plusieurs pages d'un même projet ne défont pas leurs choix. `webfront.inspector.readPreferences()` lit le fichier et
son jeton sous un même verrou du store, le jeton étant calculé sur les octets rendus : un contenu qui change puis revient
entre la lecture et la sauvegarde ne valide pas des choix lus sur un autre contenu. Un fichier absent donne des choix
vides avec le jeton de son absence ; un fichier présent mais illisible fait échouer l'écriture plutôt que de l'écraser.
Un détachement ou un rattachement est écrit aussitôt, la place après une courte pause. Un seul appel admis à
`webfront.inspector.savePreferences` écrit la version conditionnelle, et C++ libère sa transaction en cas d'échec ; un
changement non écrit est repris par l'écriture suivante, après les changements plus récents du même panneau ou de la
place, qui l'emportent. Si la page ferme avant que cet appel arrive, le dernier changement peut être perdu.

La même règle désactive « Détacher » quand aucun conteneur détaché ne donnerait l'accès.

Chaque panneau a une action « Détacher / Rattacher », désactivée avec sa raison quand aucun conteneur détaché n'est
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ verification evidence remain in [PROJECT_STATUS](../PROJECT_STATUS.md).
| [ADR-024](ADR-024-tls-integre.md) | Optional integrated TLS 1.3 server | Proposed | 2026-11-21 | 1.0 |
| [ADR-025](ADR-025-mcp-http-dans-l-application.md) | The application serves MCP over Streamable HTTP on its own loopback listener, with a session Bearer token, strict Host/Origin checks, per-instance discovery and no automation in distribution builds; the webfront-agent launcher is removed; amends ADR-019 | Accepted (delivery in progress) | 2026-11-21 | 1.3 — 2026-11-22 |
| [ADR-026](ADR-026-configuration-mcp-persistante.md) | Stable MCP client configuration with explicit development security modes | Accepted | 2026-11-22 | 1.2 — 2026-11-22 |
| [ADR-027](ADR-027-inspecteurs-de-l-etat-de-l-application.md) | Application state inspectors in the developer environment only: reserved `webfront.inspector.*` functions refused to unproven views unless the application trusts loopback clients, tree nodes on existing bridge types with paged reads and paged differences, observer operations run whole under the application's lock or on its executor, writes only when the application provides them, one `inspector.html` page in the first container that grants access | Proposed | 2026-11-25 | 1.0 — 2026-11-25 |
| [ADR-027](ADR-027-inspecteurs-de-l-etat-de-l-application.md) | Application state inspectors in the developer environment only: reserved `webfront.inspector.*` functions refused to unproven views unless the application trusts loopback clients, tree nodes on existing bridge types with paged reads and paged differences, observer operations run whole under the application's lock or on its executor, writes only when the application provides them, one `inspector.html` page, shown in a floating window of the page and, for a detached panel only, in the first container that grants access (a native secondary window, else a system-browser tab) | Proposed | 2026-11-25 | 1.1 — 2026-11-25 |

Numbering follows the reading topics; milestones and individual file histories provide
the chronology, which does not follow the numerical order.
Expand Down
Loading
Loading