From 704c26f86b118b1f145d069aace83c3650ab3803 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 28 Nov 2026 14:56:48 +0100 Subject: [PATCH] Inspectors: detach and attach with small icons instead of words (#722) The Detach button of the floating window's bar and the Attach button of a detached panel's header become 16 px inline SVG icons in currentColor: a frame with an arrow leaving it to the top right, and an arrow entering it. Their aria-label and title say the whole action; a greyed Detach keeps its name and its tooltip still gives the reason. The class names stay. --- docs/CHANGELOG.md | 1 + docs/DEVELOPER_ENVIRONMENT.md | 15 ++++++---- js/developer/environment/bundles.json | 6 ++-- js/developer/environment/inspector-host.mjs | 8 +++-- js/developer/environment/inspector.mjs | 7 +++-- js/developer/environment/menu.mjs | 33 +++++++++++++++++++++ test/developer/specs/inspector-specs.mjs | 30 ++++++++++++++++++- test/web/developer-specs.mjs | 13 +++++++- 8 files changed, 96 insertions(+), 17 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index aa988f23..d1df8f55 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -41,6 +41,7 @@ these entries stays in the GitHub releases and the Git history. - The test helpers, `webfront_add_jasmine_test` included, export the real `XDG_DATA_HOME` and `XDG_CACHE_HOME` as `WEBFRONT_TEST_REAL_XDG_DATA_HOME` and `WEBFRONT_TEST_REAL_XDG_CACHE_HOME`, so an application under test can keep the throwaway WebKitGTK profile away from the programs it starts ([#664](https://github.com/ambroise-leclerc/WebFront/issues/664), `docs/CONSUMER_TESTING.md`). ### Changed +- Detach and attach an inspector panel with small icons, a frame with an arrow leaving it or entering it, instead of the **Detach** and **Attach** words; their tooltip and accessible name say the action, and a greyed detach icon still says why (#722, `docs/DEVELOPER_ENVIRONMENT.md`). - `wf test` stopped at its time limit or by Ctrl+C says how far its runner got, in its message and in the report's new `stage`: the last step reached, the spec in progress, and the runner files that never finished loading (#690, `docs/DEVELOPER_ENVIRONMENT.md`). - Destroying the handle of a watch (`inspect::Watch`) waits for an operation of the inspectors in progress on another thread: destroy it outside every lock its source takes, or declare the watch with the state it owns (#682, ADR-027, `docs/WATCHES.md`). - `cppFunction` and `Space::cppFunction` take a last, defaulted `std::source_location`, which the inspectors show; existing calls compile unchanged, the explicit `cppFunction` form included (#681, ADR-027). diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 5fd1c4c4..29071f7b 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -448,14 +448,17 @@ environment's `mount`, not to the embedded bootstrap page): 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. The containers follow the access each frontend actually gives, never its name alone: + bridge, since the adapters give the proof of the view to the main frame only. The **detach** icon of its title bar, a frame + with an arrow leaving to the top right (↗, tooltip "Detach this panel to a window of its own"), moves the panel to a + window of its own, and the next opening of that panel goes there again; the **attach** icon of that window's header, an + arrow entering a frame (↙, tooltip "Show this panel in the floating window of the main page"), brings it back to the + floating window, where it then opens. Both icons take the color of the text and carry their action as their accessible + name. The containers follow the access each frontend actually gives, never its name alone: | Frontend of the page | Inspectors | Panel opens in | Detached container | | --- | --- | --- | --- | | WebKitGTK, WKWebView, WebView2 | admitted: the view proves itself | the floating window | 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 | - | CEF | admitted: the view proves itself | the floating window | none: CEF opens no secondary window, and `window.open` there would open a frame without the proof; Detach is greyed, with the reason in its tooltip | + | CEF | admitted: the view proves itself | the floating window | none: CEF opens no secondary window, and `window.open` there would open a frame without the proof; the detach icon is greyed, with the reason in its tooltip | | System browser (default of `webfront::WebFront`) | **refused by default**: the entries are greyed and say how to enable them | none | none | | System browser with `trustLoopbackClients` | admitted: any loopback page | the floating window | 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 | @@ -475,10 +478,10 @@ environment's `mount`, not to the embedded bootstrap page): Every loopback connection is then a local client: it reads the inspectors, and it also passes the `ui.isLocalClient()` check of the application's own callbacks (below). The option is the application's choice; the environment never sets it. - Attach brings the panel back to the page that detached it only, even when other pages of the application are open on + The attach icon 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 + answer. Close that tab, open the panel from the menu of the reloaded page, then use the attach icon 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 diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index a2f9a59c..9cc42493 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -23,9 +23,9 @@ "js/developer/environment/testing.mjs": "48695dc7c368d5f0671a0549a61d06c732e10604c56e98f7254f3c4dd21a792c", "js/developer/environment/terminal.mjs": "e7c3ca8f9833f10e07939277996eb01fb989c986420c96052271ff469fa59062", "js/developer/environment/workspace.mjs": "e82ec4df21ffb2b112550e0212504aba05af4f924b5645c0712f40f8466257fc", - "js/developer/environment/menu.mjs": "b4fe4c38e6b8cc6c1101df842e282ab85e6c6e029b2225738b9d27bc5efbc88d", - "js/developer/environment/inspector-host.mjs": "304a8a6713026939d66088dd0bb68a96ff4ee14e970c6886d61c82ebde611ac5", - "js/developer/environment/inspector.mjs": "183ece8ad6581c458315211b3edea6fa2823c2212d3999e7e9e069a1e78309e5", + "js/developer/environment/menu.mjs": "c51c5158364bb706b113c04d326b9f96b3c7acbf3424e2258c4c4d3e97852287", + "js/developer/environment/inspector-host.mjs": "4b48bd862cc369ba006990303393ca861e2164627013f464f00de9ac893777ea", + "js/developer/environment/inspector.mjs": "f16c37d75aacbd38f81c863ec6abe3b8037c557385d5313712f4cf88fcf97bb9", "js/developer/environment/inspector-packages.mjs": "1c3f6350780b841784f83bc20ead2945157c48a1f136c47e3a7a90d89bea8522", "js/developer/environment/inspector-registry.mjs": "6653afc473fcef677d8b02541085943da3f7d15c5b64d23dafd43c750a9e28d8", "js/developer/environment/inspector-watches.mjs": "f5b8f901b86969bfe349d0e875cce9fba375d922f95f4fb213dc2f690083175e", diff --git a/js/developer/environment/inspector-host.mjs b/js/developer/environment/inspector-host.mjs index 833b1a11..0d2f1ff0 100644 --- a/js/developer/environment/inspector-host.mjs +++ b/js/developer/environment/inspector-host.mjs @@ -5,7 +5,7 @@ // the floating window's place are kept in the project, as the terminal's place is. import {readProject, call} from './io.mjs'; import {clampRect, step, minimumSize, windowControls} from './workspace.mjs'; -import {inspectorPanels as panels, panelTitle, inspectorChannel} from './menu.mjs'; +import {inspectorPanels as panels, panelTitle, inspectorChannel, inspectorMoves, makeMoveButton} from './menu.mjs'; import {createBridgeMonitor, createBridgePublisher} from './inspector-bridge.mjs'; const encoder = new TextEncoder(); @@ -199,6 +199,7 @@ const styles = ` .webfront-inspector-bar button:hover:not([aria-disabled=true]){background:#2f3a50} .webfront-inspector-bar button[aria-disabled=true]{color:#8d97aa;cursor:default} .webfront-inspector-close{font-size:20px!important;line-height:1} +.webfront-inspector-detach>svg{display:block;margin:auto;pointer-events:none} .webfront-inspector-notice{display:flex;gap:8px;align-items:center;padding:6px 12px;background:#3a2f12;color:#f4e3b5;font:12px system-ui} .webfront-inspector-notice[hidden]{display:none} .webfront-inspector-notice button{margin:0 0 0 auto;padding:4px 8px;border:1px solid #f4e3b5;border-radius:4px;background:none;color:inherit;font:inherit;cursor:pointer} @@ -290,7 +291,7 @@ export async function createInspectorHost({bridge, page, inspectorUrl, access, e const detachButton = page.createElement('button'); detachButton.type = 'button'; detachButton.className = 'webfront-inspector-detach'; - detachButton.textContent = 'Detach'; + makeMoveButton(page, detachButton, 'detach'); const closeButton = page.createElement('button'); closeButton.type = 'button'; closeButton.className = 'webfront-inspector-close'; @@ -348,7 +349,8 @@ export async function createInspectorHost({bridge, page, inspectorUrl, access, e panel.setAttribute('aria-label', `WebFront inspector: ${panelTitle(id)}`); const why = reason(); detachButton.setAttribute('aria-disabled', String(Boolean(why))); - detachButton.title = why || 'Open this panel in a window of its own'; + // Greyed, it keeps its name and its tooltip says why it cannot detach. + detachButton.title = why || inspectorMoves.detach; // The frame opens no connection of its own: the page reads ?frame and borrows this page's bridge. const url = urlOf(id, {frame: '1'}); if (frame.getAttribute('src') !== url) { diff --git a/js/developer/environment/inspector.mjs b/js/developer/environment/inspector.mjs index 745a1be4..64f8ee1a 100644 --- a/js/developer/environment/inspector.mjs +++ b/js/developer/environment/inspector.mjs @@ -5,7 +5,7 @@ // tree of each is in inspector-watches.mjs (#682). The panels of the functions and of the browsers are in // inspector-registry.mjs (#681, section 7), the one of the packages in inspector-packages.mjs (#683), the one of the bridge // in the page in inspector-bridge.mjs (#684). -import {inspectorPanels as panels, panelTitle, inspectorChannel as channelName} from './menu.mjs'; +import {inspectorPanels as panels, panelTitle, inspectorChannel as channelName, makeMoveButton} from './menu.mjs'; import {showFunctionsPanel, showBrowsersPanel, registryStyles, periods, formatPeriod, keptPeriod, keepPeriod, createPoller} from './inspector-registry.mjs'; import {showPackagesPanel, packagesStyles} from './inspector-packages.mjs'; import {createWatchTree, createTreeView, watchTreeStyles} from './inspector-watches.mjs'; @@ -194,6 +194,8 @@ header{display:flex;align-items:center;gap:8px;padding:8px 12px;background:#2027 header h1{flex:1 1 auto;margin:0;font-size:14px;font-weight:600} header button{min-height:32px;padding:0 10px;border:1px solid #46536a;border-radius:4px;background:#2f3a50;color:inherit;font:inherit;cursor:pointer} header button:focus-visible{outline:2px solid #d7fa85;outline-offset:1px} +header button.attach{min-width:32px;padding:0 8px} +header button.attach>svg{display:block;margin:auto;pointer-events:none} main{padding:8px 12px} .status{color:#a9b3c4;font-size:12px;margin:4px 0 8px} .status:empty{display:none} @@ -307,8 +309,7 @@ export async function main(view = window) { const attach = page.createElement('button'); attach.type = 'button'; attach.className = 'attach'; - attach.textContent = 'Attach'; - attach.title = 'Show this panel in the floating window of the main page'; + makeMoveButton(page, attach, 'attach'); header.append(attach); // Its own status: the reads of the watches, which clear theirs, never clear why the panel could not be attached. const attachStatus = page.createElement('p'); diff --git a/js/developer/environment/menu.mjs b/js/developer/environment/menu.mjs index e4f36ab3..ca3f3745 100644 --- a/js/developer/environment/menu.mjs +++ b/js/developer/environment/menu.mjs @@ -31,6 +31,39 @@ export const panelTitle = id => inspectorPanels.has(id) ? `${inspectorPanels.get */ export const inspectorChannel = 'webfront-inspector'; +/** What the icon buttons that move a panel say, as their accessible name and their tooltip (#722). */ +export const inspectorMoves = { + detach: 'Detach this panel to a window of its own', + attach: 'Show this panel in the floating window of the main page', +}; + +// A frame open at its top right, and an arrow that leaves it (detach, ↗) or enters it (attach, ↙), drawn in currentColor. +const iconPaths = { + detach: ['M7 3H3v10h10V9', 'M9 3h4v4', 'M13 3 7 9'], + attach: ['M7 3H3v10h10V9', 'M13 3 7 9', 'M7 5v4h4'], +}; +const svgSpace = 'http://www.w3.org/2000/svg'; + +/** + * Makes `button` (of `page`) the icon button `move` ('detach' or 'attach'): a 16 px inline SVG in the color of the text, + * hidden from assistive technologies, the button being named by its aria-label and its tooltip (inspectorMoves). + */ +export function makeMoveButton(page, button, move) { + const svg = page.createElementNS(svgSpace, 'svg'); + const attributes = {viewBox: '0 0 16 16', width: '16', height: '16', fill: 'none', stroke: 'currentColor', 'stroke-width': '1.5', + 'stroke-linecap': 'round', 'stroke-linejoin': 'round', 'aria-hidden': 'true', focusable: 'false'}; + for (const [name, value] of Object.entries(attributes)) svg.setAttribute(name, value); + for (const d of iconPaths[move]) { + const path = page.createElementNS(svgSpace, 'path'); + path.setAttribute('d', d); + svg.append(path); + } + button.replaceChildren(svg); + button.setAttribute('aria-label', inspectorMoves[move]); + button.title = inspectorMoves[move]; + return button; +} + // --- Access to the inspectors ---------------------------------------------------------------------------------- /** The reserved function that says which containers would reach the inspectors; the only one that checks no access. */ diff --git a/test/developer/specs/inspector-specs.mjs b/test/developer/specs/inspector-specs.mjs index a503c7a3..5279cf84 100644 --- a/test/developer/specs/inspector-specs.mjs +++ b/test/developer/specs/inspector-specs.mjs @@ -6,7 +6,7 @@ import {detachedContainer, containerFor, hostReasons, parsePreferences, formatPr preferencesStore, applyPreferenceChanges} from '../../../js/developer/environment/inspector-host.mjs'; import {readDescriptor, readPage, listWatches, listingAttempts, reconcile, watchOpener, createWatchDiscovery, renderWatches, pageBridge, attachAgain, watchesFunction, reloadWhenRestored} from '../../../js/developer/environment/inspector.mjs'; -import {inspectorChannel, inspectorPanels} from '../../../js/developer/environment/menu.mjs'; +import {inspectorChannel, inspectorPanels, inspectorMoves, makeMoveButton} from '../../../js/developer/environment/menu.mjs'; import {LineEditor} from '../../../js/developer/environment/terminal.mjs'; import {memoryBridge} from '../memory-bridge.mjs'; @@ -281,11 +281,39 @@ describe('The inspectors', () => { expect(host.frame.hasAttribute('src')).toBeFalse(); }); + it('draws Detach and Attach as icons named by their action (#722)', () => { + for (const move of ['detach', 'attach']) { + const button = makeMoveButton(document, document.createElement('button'), move); + expect(button.textContent).toBe(''); + expect(button.getAttribute('aria-label')).toBe(inspectorMoves[move]); + expect(button.title).toBe(inspectorMoves[move]); + const svg = button.firstElementChild; + expect(button.children.length).toBe(1); + expect(svg.namespaceURI).toBe('http://www.w3.org/2000/svg'); + expect(svg.getAttribute('stroke')).toBe('currentColor'); + expect(svg.getAttribute('aria-hidden')).toBe('true'); + expect(svg.querySelectorAll('path').length).toBeGreaterThan(1); + } + expect(inspectorMoves.detach).toBe('Detach this panel to a window of its own'); + expect(inspectorMoves.attach).toBe('Show this panel in the floating window of the main page'); + }); + + it('names the Detach icon by its action, and its tooltip too when it can detach', async () => { + const {host} = await testHost({containers: admitted(true)}); + await host.open('cpp.watches'); + expect(host.detachButton.textContent).toBe(''); + expect(host.detachButton.querySelector('svg')).not.toBeNull(); + expect(host.detachButton.getAttribute('aria-label')).toBe(inspectorMoves.detach); + expect(host.detachButton.title).toBe(inspectorMoves.detach); + expect(host.closeButton.getAttribute('aria-label')).toBe('Close the inspector'); + }); + it('greys Detach with the reason when no detached container would reach the inspectors', async () => { const {host, calls, opened} = await testHost({containers: admitted(false, true), embedded: true}); await host.open('cpp.watches'); expect(host.detachButton.getAttribute('aria-disabled')).toBe('true'); expect(host.detachButton.title).toBe(hostReasons.noDetached); + expect(host.detachButton.getAttribute('aria-label')).toBe(inspectorMoves.detach); host.detachButton.click(); await host.saved(); expect(calls.some(([name]) => name === 'webfront.inspector.openWindow')).toBeFalse(); diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index 89568580..cf28f60c 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -177,6 +177,12 @@ try { await eventually(() => /No installed packages/.test(panel()?.querySelector('.status:not(.attach-status)')?.textContent ?? ''), () => `The Packages panel must say that a project without a lock has no package: ${shown()}`, slowly); assert(tree().length === 0, `A project without a lock has no tree: ${shown()}`); + // Detached, the panel offers to go back to the floating window with an icon named by its action (#722). + const attach = panel().querySelector('header button.attach'); + assert(attach && attach.textContent === '' && attach.querySelector('svg[aria-hidden="true"]'), + `A detached panel must offer Attach as an icon: ${attach?.outerHTML}`); + assert(attach.getAttribute('aria-label') === 'Show this panel in the floating window of the main page' && attach.title === attach.getAttribute('aria-label'), + `The Attach icon must be named by its action: ${attach.getAttribute('aria-label')} / ${attach.title}`); await execute(['install', 'react@19.3.1', 'react-dom@19.3.1'], context); lock = await runtime.readLock(webFront); @@ -1038,10 +1044,15 @@ try { assert(shownList.isConnected && frame.isConnected && frame.contentDocument === shownDocument, 'The watch must have disappeared from the list that showed it, still in the inspector'); const detach = floating().querySelector('.webfront-inspector-detach'); + // An icon named by its action, whether it can detach or not (#722). + assert(detach.textContent === '' && detach.querySelector('svg[aria-hidden="true"]') + && detach.getAttribute('aria-label') === 'Detach this panel to a window of its own', + `Detach must be an icon named by its action: ${detach.outerHTML}`); if (secondaryWindow) { // A frontend that opens windows: Detach moves the panel to a native window with its own proven connection. const views = await webFront.cppFunction('test.views')(); - assert(detach.getAttribute('aria-disabled') === 'false', 'A frontend that opens windows must offer to detach the panel'); + assert(detach.getAttribute('aria-disabled') === 'false' && detach.title === detach.getAttribute('aria-label'), + `A frontend that opens windows must offer to detach the panel: ${detach.title}`); detach.click(); await until(() => floating().hidden, 'A detached panel must leave the floating window'); await until(async () => await webFront.cppFunction('test.views')() === views + 1,