Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0206564
Report browser disconnections and give applications a timer sender [#…
ambroise-leclerc Oct 22, 2026
c76d8d8
Make the environment's terminal complete and add webfront::Commands […
ambroise-leclerc Oct 22, 2026
92f1305
Keep keys typed during a completion and start the prompt on a fresh l…
ambroise-leclerc Oct 22, 2026
0a6d9a0
Let the test terminal fit its element before resizing it [#308]
ambroise-leclerc Oct 22, 2026
8435881
Cut output that is not UTF-8 at the piece limit instead of looping [#…
ambroise-leclerc Oct 22, 2026
10fecf2
Release closed connections, pace command output and report stopped co…
ambroise-leclerc Oct 22, 2026
d6fdd4e
Complete quoted paths, share the history and restart the session afte…
ambroise-leclerc Oct 22, 2026
e205ffa
Pace printed output between its pieces [#308]
ambroise-leclerc Oct 22, 2026
c0730d9
Draw tall lines a screen at a time, interrupt replayed commands and p…
ambroise-leclerc Oct 23, 2026
e39b830
Share links under a lock, keep the command context alive and refuse a…
ambroise-leclerc Oct 23, 2026
3c9ab73
Keep keys typed during a command and never replace an unreadable hist…
ambroise-leclerc Oct 23, 2026
a455f03
Wake paced output on writes, ignore shutdown closures and free sessio…
ambroise-leclerc Oct 23, 2026
79c49a6
Load the terminal in parallel, keep early keys and state an exit code…
ambroise-leclerc Oct 23, 2026
be07be0
Pass a WebLinkId to the link of the writes test [#308]
ambroise-leclerc Oct 23, 2026
a2ca90c
Make writesAtMost safe from start to link end, own the command's stop…
ambroise-leclerc Oct 23, 2026
0f90ca3
Keep a CRLF split between output pieces and complete project paths on…
ambroise-leclerc Oct 23, 2026
b72dcfd
Move the shared path and tarball helpers into the developer environme…
ambroise-leclerc Oct 23, 2026
f214911
Remove the terminal component and the wf tool manager [#313]
ambroise-leclerc Oct 23, 2026
6a96a62
Let a print task outlive its context and pin the terminal's reserved …
ambroise-leclerc Oct 23, 2026
0b9ba24
End a terminal command whose connection closes [#308]
ambroise-leclerc Oct 23, 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
11 changes: 0 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,8 @@ js/core/fallback/index.html text eol=lf
js/core/fallback/webfront-fallback.mjs text eol=lf
include/webfront/system/FallbackIndexHtmlData.hpp text eol=lf
include/webfront/system/FallbackModuleData.hpp text eol=lf
js/developer/components/terminal/* text eol=lf
js/developer/components/tools/* text eol=lf
include/webfront/system/ToolManagerModuleData.hpp text eol=lf
third_party/xterm/* text eol=lf
include/webfront/system/TerminalIndexHtmlData.hpp text eol=lf
include/webfront/system/TerminalModuleData.hpp text eol=lf
include/webfront/system/XtermModuleData.hpp text eol=lf
include/webfront/system/XtermCssData.hpp text eol=lf
include/webfront/system/XtermFitAddonData.hpp text eol=lf

# The fake npm registry of the browser integration test: its packuments are served byte for byte.
test/web/registry/* text eol=lf
test/web/registry/tarballs/* binary

# Serialisation
*.json text
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/DeveloperDistribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches: [develop, master]
paths:
- 'js/developer/environment/**'
- 'js/developer/components/tools/**'
- 'js/developer/tools/starters/pi/**'
- 'examples/life/ui/**'
- 'js/developer/tools/**'
Expand All @@ -17,7 +16,6 @@ on:
branches: [develop, master]
paths:
- 'js/developer/environment/**'
- 'js/developer/components/tools/**'
- 'js/developer/tools/starters/pi/**'
- 'examples/life/ui/**'
- 'js/developer/tools/**'
Expand Down
8 changes: 3 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@ The README introduces WebFront through the Game of Life walkthrough, demonstrati

## Repository map

- `include/webfront/`: public header-only library, included as `<webfront/...>`. `WebFront.hpp` is the main orchestration API.
- `include/webfront/`: public header-only library, included as `<webfront/...>`. `WebFront.hpp` is the main orchestration API; `Commands.hpp` adds an application's C++ commands to the developer environment's terminal.
- `include/webfront/http/`: HTTP and WebSocket protocol implementation.
- `include/webfront/weblink/`: bridge message encoding and routing.
- `include/webfront/system/`: layered virtual filesystems and embedded web resources.
- `include/webfront/frontend/`: system-browser, CEF, optional Windows WebView2 and macOS WKWebView frontend adapters.
- `include/webfront/components/`: opt-in UI components (`Terminal.hpp`, `ToolManager.hpp`); their assets are served by embedded providers such as `include/webfront/system/TerminalFS.hpp`, and installed tools by `include/webfront/system/PackageFS.hpp` from `ToolStore.hpp`'s project directory.
- `examples/`: only Hello World (`hello-world/`) and Game of Life (`life/`, with console, developer and embedded stages).
- `js/core/`: readable browser bridge, fallback and bootstrap loader compiled into `include/webfront/`, plus the embedding CMake modules; `js/developer/`: developer environment, terminal/`wf` components, build and vendoring tools. Production C++ remains header-only in `include/webfront/`.
- `js/core/`: readable browser bridge, fallback and bootstrap loader compiled into `include/webfront/`, plus the embedding CMake modules; `js/developer/`: developer environment (its terminal and `wf`), build and vendoring tools. Production C++ remains header-only in `include/webfront/`.
- `js/developer/tools/starters/pi/`, `test/fixtures/`, `test/web/fixtures/`: retained package and regression fixtures, not public example applications.
- `test/unit/`: Catch2 unit tests; `test/web/`: Jasmine real-browser integration test; `test/fuzz/`, `test/fixtures/`; `test/cmake/`: CMake test scripts and sub-projects. The `RepositoryLayout` CTest case pins the tracked root.
- `cmake/`: build modules (frontends, CEF, CPM, compiler options); `.github/`: workflows, `.github/CONTRIBUTING.md`.
- `.devcontainer/`: devcontainer and its Dockerfile; `docs/`: documentation, `docs/CHANGELOG.md`, `docs/Doxyfile.in`.
- `third_party/xterm/`: vendored xterm.js distribution embedded by the terminal component; refresh it only with `cmake/UpdateXterm.cmake`.
- `docs/PROJECT_STATUS.md`: evidence-based status snapshot and known limitations.
- `docs/adr/README.md`: architecture decision index, Git history, tradeoffs and implementation rules; read the relevant ADRs before changing their contracts.
- `docs/UI_COMPONENTS.md`: UI component architecture, the terminal component and the planned `wf` tool manager.
- `docs/UI_COMPONENTS.md`: what replaced the removed terminal component and `wf` tool manager, with the migration to `webfront::Commands`.
- `docs/ISSUE_AUDIT.md`: recommendations for the current GitHub backlog.

The historical `webfront/` prototype and the former top-level `webtest/` are gone: use `test/unit/` for current C++ tests and `test/web/` for browser tests. Do not revive legacy code without a specific issue and regression coverage.
Expand Down
39 changes: 0 additions & 39 deletions cmake/UpdateXterm.cmake

This file was deleted.

23 changes: 22 additions & 1 deletion docs/ASYNC_EXECUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@ auto handle = app.spawn(showSquareRoot(ui));
handle.requestStop();
```

`ui.writesAtMost(limit)` returns a sender completing once at most `limit` frames
wait for the network on that browser's connection, woken by the write that brings
them down (no polling), or at once when the browser is gone. A closing connection
or a released link also completes it, after the closure was reported; it observes
the task's stop token. It paces output to a browser that reads slower than written.

`app.resumeAfter(duration)` and `ui.resumeAfter(duration)` return a sender that
completes on the server context once the duration has elapsed. Awaited in a task,
it observes the task's stop token: `TaskHandle::requestStop()` or shutdown
completes it stopped at once, so a waiting coroutine never delays shutdown.
`app.subscribeUIClosed(handler)` calls the handler on the server thread when a
browser closes its connection or the connection fails (a failed write included),
for as long as the returned `UISubscription` lives; shutdown, which stops every
connection itself, notifies no handler. The connection is then released by a task
on the server context; a call made meanwhile on another thread keeps the link alive
until it returns (`findLink` shares it). Afterwards, an untyped `jsFunction` call to that UI is
dropped, a typed call returns a future that throws `Browser connection closed`,
a `jsFunctionSender` completes with an error when started, and `addScript` throws
`ConnectionError`. The 16-bit identifier of a released connection is reused only
after 65,536 later connections.

`app.spawn(task)` and `ui.spawn(task)` may be called from any thread while the
application object remains alive, including concurrently with stop/shutdown.
Coroutine bodies and their resumptions execute on the server context. Synchronize
Expand Down Expand Up @@ -120,7 +141,7 @@ context. Neither sender calls nor future calls have a delivery acknowledgement
for the write queue or an automatic response deadline. An unsuccessful write
that does not report closure can leave a call pending until disconnection;
sender waits can also be ended by task cancellation or application shutdown.
Timeout composition remains future work.
Timeout composition with `resumeAfter` remains future work.

Cancellation before start sends no frame. Cancellation after dispatch stops
waiting locally; JavaScript already running continues, and its late response
Expand Down
30 changes: 30 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,32 @@
end with code 1. Nothing is written (`noEmit`). Ctrl+C and the time limit terminate a running compilation after
the 2 s grace period. The local registry fixture serves typescript 5.9.3 and 6.0.3, typed and `@types` packages.

- The environment's terminal (developer distribution 0.5.0, #308) becomes WebFront's complete terminal: built-in
`help`, `clear`, `history` and `exit`, streamed output, Ctrl+C for every command, per-project persistent history,
multi-line paste run line by line, multi-row redraw, CJK and emoji widths shared with xterm.js, exit codes and
completion of commands, `wf` subcommands, manifest scripts, entries, providers and project paths.
`webfront::Commands` (`<webfront/Commands.hpp>`) adds an application's C++ commands to it: coroutines spawned per
browser session through the bridge functions `webfront.commands.list`, `.start` and `.cancel`, streaming their
output, stopped by Ctrl+C, the browser's disconnection or shutdown; the terminal does not wait for a stopped
command; `co_await context.print(text)` waits for a slow browser. New `app.resumeAfter(duration)`/
`ui.resumeAfter(duration)` timer sender, `app.subscribeUIClosed(handler)`, `app.connectedBrowsers()`, `UI::id()`,
`UI::pendingWrites()`, `UI::writesAtMost(limit)` (woken by the write that drains the queue), `app.findLink(id)` and
`json::Reader::array`. `cppFunction` returns false when the name was
already registered, and `hasCppFunction(name)` tells whether it is.

### Removed

- **Breaking:** the terminal component and the `wf` tool manager (#313): `webfront::Terminal`, `terminal::Shell`,
`webfront::ToolManager`, `fs::TerminalFS`, `fs::ToolManagerFS`, `fs::ToolStore`, `fs::PackageFS`, their embedded
modules, the embedded xterm.js copy, `third_party/xterm` and `cmake/UpdateXterm.cmake`. The developer environment's
terminal and `webfront::Commands` replace them; `docs/UI_COMPONENTS.md` describes the migration. xterm.js is a
locked dependency of the environment archive. `fs::tools::safeRelativePath` becomes `fs::safeRelativePath`
(`<webfront/system/SafePath.hpp>`).

### Changed

- **Breaking:** `BasicWF::getLink(id)`, whose reference could outlive a released connection, is replaced by
`findLink(id)`, which shares the link with the caller (null once the browser is gone).
- `DeveloperBootstrapOptions::registry` is now `std::optional<std::string>`: unset, the manifest's registry
applies; set, it must be HTTPS or a same-origin path and takes precedence over the manifest. The environment
configuration gains `registryExplicit`; earlier environments keep reading `registry`.
Expand All @@ -57,6 +81,12 @@

### Fixed

- A browser's disconnection is now reported and its connection released: `WebLink` emits its `closed` event once when
the browser closes the connection or it fails. The event was never emitted before, so nothing observed
disconnections and every closed connection (socket, buffers) stayed until the application was destroyed. `BasicWF`
now releases it by a task on the server context; afterwards untyped `jsFunction` calls to that browser are
dropped, typed ones fail and `jsFunctionSender` reports an error when started, instead of throwing
`std::out_of_range`.
- Linux CEF builds: the runtime files, resources and locales are copied once per destination directory by a shared
copy target, instead of by every CEF target's post-build step, which made parallel builds fail intermittently
("Error copying directory ... locales"). The destination is the target's output directory
Expand Down
75 changes: 73 additions & 2 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,78 @@ wf check
terminated with `worker.terminate()` after the two-second grace period. The exit code is 130 (Ctrl+C) or 124 (time
limit), and the terminal stays usable.

## The terminal and the application's commands

The terminal of the environment (developer distribution 0.5.0, #308) is the only WebFront terminal; it is served
from the environment archive with xterm.js, never from a C++ header. It runs `wf` commands, the application's C++
commands and its own: `help`, `clear` (screen and scrollback), `history` (`history -c` clears it) and
`exit [code]`, which ends the session and closes the window; when the browser keeps a window that a script did not
open, Enter starts a new session. No system shell is exposed.

- **Editing:** left/right, Home/End (Ctrl+A/Ctrl+E), Backspace/Delete, Ctrl+U/Ctrl+K, Ctrl+L, up/down through the
history. A line wider than the terminal wraps over several rows and is redrawn in place; a line taller than the
terminal is drawn a screen of rows at a time around the cursor, since rows that left the screen cannot be rewritten. The editor moves over
grapheme clusters: CJK characters and emoji (ZWJ sequences, flags, skin tones, presentation selector) take two
cells, combining marks none. The same widths are registered in xterm.js, so both always agree.
- **History:** kept per project in `.webfront/developer/history.json` (500 lines), restored by the next terminal. Each
line is added to the file as it is, with a conditional publication tried again on conflict, so terminals of several
pages on the same project keep each other's lines. A history file that cannot be read is never replaced.
- **Typing ahead and paste:** keys typed or pasted while a command runs are applied after it, line by line; a last
line without a line break waits on the prompt. Ctrl+C drops the keys still waiting.
- **Completion (Tab):** command names, `wf` subcommands, the manifest's scripts after `wf run`, its entries and
providers after `wf preview` and `wf embed`, and project paths, also when the word is escaped (`my\ dir/`) or
quoted (`"my dir/`); the completion is written the same way and closes the quote. Several candidates are completed
to their common prefix, or listed.
- **Exit codes:** a failed command prints `Error: <message>`, with `(exit code N)` when N is not 1. Ctrl+C gives 130.
- **Output streams** while a command runs, for `wf` and C++ commands alike, without a size limit: C++ output is
sent in pieces below the 65,535-byte limit of bridge strings.

An application adds its own commands with `webfront::Commands` (`<webfront/Commands.hpp>`), which replaces
`terminal::Shell` of the removed terminal component ([migration](UI_COMPONENTS.md)). A command is a coroutine:

```cpp
#include <webfront/Commands.hpp>

webfront::NativeApp app{projectDirectory};
webfront::Commands commands{app};
commands.add("count", "Count to N, once a second", [](webfront::Commands<webfront::NativeApp>::Context context) -> webfront::Task {
using namespace std::chrono_literals;
for (int i = 1; i <= std::stoi(context.args().at(0)); ++i) {
co_await context.print(std::to_string(i) + "\n");
co_await context.ui().resumeAfter(1s);
}
});
app.bootstrap("developer");
app.show();
```

The terminal discovers the commands through the bridge (`webfront.commands.list`) and runs each one in the session
of its browser with `webfront.commands.start`. In C++, the command is spawned like `ui.spawn` on the server thread:

- `context.write(text)` streams output with fire-and-forget calls; `co_await context.print(text)` sends it piece by
piece and, after each piece, suspends the command while more than 32 frames wait for a browser that reads slower
(`ui.writesAtMost`, woken by the write that drains the queue); each wait is a point where Ctrl+C stops it.
`context.args()` holds the words after the command name, split like a shell line; `context.exit(code)` sets the
exit code. A command that returns once asked to stop reports 130, whatever it returned.
- Ctrl+C sends `webfront.commands.cancel`: the command's stop token is requested, which the senders it awaits
observe (`ui.resumeAfter`, `ui.jsFunctionSender`, ...); loops check `context.stopRequested()`. The terminal does
not wait for the command to end: the prompt returns at once and the next command runs, while the first one
unwinds. Its late output and exit report are ignored.
- The browser's disconnection stops its commands, and the application's shutdown drains them with its other tasks.
In the terminal, a command whose connection closes ends at once with an error (exit code 1): its exit report can
no longer arrive.
- An exception thrown by a command is printed as an error, with exit code 1.
- Each connected browser has its own session: a command in one browser neither delays nor is stopped by another.
- A command must not block the server thread, which serves every browser: a handler that does not return
`webfront::Task` does not compile. Long computations belong on another thread.

A second `webfront::Commands` on the same application throws `std::logic_error` and registers nothing. A copy of a
`Context` may outlive its command (a detached task): its stop token stays valid and its writes are dropped once the
browser is gone. The names `wf`, `clear`, `exit`,
`help` and `history` are reserved. `context.write` has no flow control: a command
writing large output with it, faster than the browser reads, grows the connection's write queue; use
`context.print` for such output.

## Dependencies, storage and limitations

- `wf install` accepts exact versions, registry tags and semver ranges, resolves ordinary
Expand All @@ -348,8 +420,7 @@ wf check
Preview/embed consume the locked local files without resolving versions again.
- Unpacked packages are cached by name, version and integrity under `.webfront/developer/packages/`,
each with a record of its files' digests. A failed install can leave unused cached packages, but the lock
file remains unchanged. A lock naming more than 512 packages is refused. The tools
installed by the existing `ToolManager` keep their separate store and `webfront-tools.lock.json`.
file remains unchanged. A lock naming more than 512 packages is refused.
- Published environment/preview resources are served under `/webfront/developer/`. The protected
`/WebFront.js` remains the library's version. Sources, staging and cached archives are not HTTP
routes. Project reads and publications reject traversal and escaping symlinks. This does not
Expand Down
Loading
Loading