Commit Graph

8347 Commits

Author SHA1 Message Date
Adrià Arrufat
4139252feb mcp: replace recording and healing tools with save
Removes recordStart, recordStop, recordComment, scriptStep, and
scriptHeal MCP tools. Introduces a single 'save' tool that lets
the client synthesize and persist the script directly.
2026-06-03 10:01:38 +02:00
Karl Seguin
85d5e47ffc Merge pull request #2620 from lightpanda-io/better_css_name_parser
Better CSS name selector parser
2026-06-03 15:58:40 +08:00
Karl Seguin
5977242429 Merge pull request #2619 from lightpanda-io/redirect_url_lifetime
On redirect, ensure transfer owns the new url
2026-06-03 15:58:28 +08:00
Karl Seguin
bfad022452 Merge pull request #2618 from lightpanda-io/wait_until_networkalmostidle
Add "networkalmostidle" to --wait-until parameter
2026-06-03 15:58:15 +08:00
Karl Seguin
144e4b1191 Merge pull request #2616 from lightpanda-io/worker_module
Support for "module" type workers.
2026-06-03 15:58:01 +08:00
Karl Seguin
7a54da3c1c Merge pull request #2615 from lightpanda-io/ClientDisconnected_nolog
Don't overlog ClientDisconnected
2026-06-03 15:57:46 +08:00
Karl Seguin
0715bb067c Merge pull request #2614 from lightpanda-io/find_frame_popups
page.findFrame searches popups too
2026-06-03 15:57:29 +08:00
Karl Seguin
3b3ec6c1b0 Merge pull request #2612 from lightpanda-io/intercept_count
Improve / fix InterceptLayer.intercepted count tracking
2026-06-03 15:57:15 +08:00
Adrià Arrufat
5f72a15355 style: clean up comments and convert to doc comments 2026-06-03 09:43:43 +02:00
Adrià Arrufat
eaedc94453 agent: stop forcing external stylesheets for LLM 2026-06-03 09:27:56 +02:00
Adrià Arrufat
ee498feb48 agent: expand and highlight env vars in JS mode 2026-06-03 08:58:47 +02:00
Karl Seguin
841543bab0 Merge pull request #2613 from rohitsux/feat/html-embed-reflection
feat(webapi): reflect src, type, width and height on HTMLEmbedElement
2026-06-03 14:57:27 +08:00
Adrià Arrufat
db385cf4db agent: optimize autocomplete and cache providers 2026-06-03 08:52:25 +02:00
Karl Seguin
50186cb328 Merge pull request #2617 from lightpanda-io/http_proxy_liftime
HttpClient dupes CDP-supplied proxy to ensure lifetime
2026-06-03 14:41:04 +08:00
Adrià Arrufat
4ff4da2ede Merge branch 'main' into agent 2026-06-03 08:35:33 +02:00
Karl Seguin
7bb83ed823 Better CSS name selector parser
Applies the same/similar escaping logic as is already applied to identifiers
and values. Importantly, this allows matching for attribute names with a colon,
e.g. "ng:jq" which can be selected with "ng\:jq".

This fixes real issues with rendering Angular 1.x.
2026-06-03 13:10:34 +08:00
Karl Seguin
97b1dae12a On redirect, ensure transfer owns the new url 2026-06-03 12:05:09 +08:00
Karl Seguin
3ff503bb8b Add "networkalmostidle" to --wait-until parameter
Just config hookup, as the `Frame._notified_network_almost_idle` already exists
(and is used by CDP).
2026-06-03 11:50:48 +08:00
Karl Seguin
244bfbdd27 HttpClient dupes CDP-supplied proxy to ensure lifetime
I'm hoping this is the cause of our flaky CI runs. The existing code kept
a reference to the CDD command-owned proxy address. This commit has HttpClient
dupe/own the proxy to ensure the correct lifetime.
2026-06-03 11:37:52 +08:00
Karl Seguin
2fc9d61070 Support for "module" type workers.
Pretty basic, worker started with the {type: 'module'} option has 2 practical
differences:
1 - importScript isn't allowed (TypeError)
2 - the initial script is loaded as a module

Seen in various WPT tests, but also saw this usage on mastodon.
2026-06-03 11:06:24 +08:00
Karl Seguin
24e379f29a Don't overlog ClientDisconnected
Since the CDP rework, error.ClientDisconnected surfaces to the Runner. There's
no reason to log this (especially as at an error level). It's perfectly normal
and has already been logged at the CDP level.
2026-06-03 10:40:29 +08:00
Karl Seguin
1c70fcb8c5 page.findFrame searches popups too
If you run WPT tests, you'll see a fair number of `FrameNotFound`. This
comes from the cdp frameNavigated notification handler and it happens because
our frame lookup only considers iframes, not popups.

This commit includes popup in the search. I don't expect this to change WPT
results.
2026-06-03 10:10:26 +08:00
Rohit
5487174e2b feat(webapi): reflect src, type, width and height on HTMLEmbedElement
Add the reflected attributes src, type, width and height to
HTMLEmbedElement per HTML 4.8.6
(https://html.spec.whatwg.org/multipage/iframe-embed-object.html#htmlembedelement).
src is a URL-reflecting attribute (resolved against the document base,
mirroring HTMLImageElement.src); type, width and height are plain
DOMString reflections. Mirrors the reflection idiom used by
HTMLMarqueeElement / HTMLImageElement.
2026-06-03 06:12:55 +05:30
Karl Seguin
f7a32c05a8 Improve / fix InterceptLayer.intercepted count tracking
The intercept state is currently split and hard to keep consistent and even
just reason about. InterceptLayer keeps the `intercepted` count, but CDP's
`BrowserContext` has its intercepted lookup. This isn't a problem per se, but
you BrowserContext.deinit tries to decrement `InterceptLayer.intercepted` which
is only safe if we can guarantee that the two are in sync. Which we can't.

This commit simplifies the upkeep of `InterceptLayer.intercepted` and uses the
Transfer's state on unpark/deinit to decrement it. The CDP layer no longer
cares about / has to maintain the count.

Driven by this crash report:

BrowserContext.deinit.intercepted
---
value: 0
/home/runner/work/browser/browser/src/lightpanda.zig:279:25: 0x2871842 in deinit (lightpanda)
/home/runner/work/browser/browser/src/cdp/CDP.zig:127:18: 0x28c3f45 in deinit (lightpanda)
/home/runner/work/browser/browser/src/Server.zig:186:21: 0x2827997 in handleConnection (lightpanda)
/home/runner/work/_temp/6dc322a8-c74f-4990-9660-4cc6dcfb9352/zig-x86_64-linux-0.15.2/lib/std/Thread.zig:509:13: 0x269c233 in entryFn (lightpanda)
???:?:?: 0x7fce7ccabd57 in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7fce7ccabd57` was not available, trace may be incomplete

on 1.0.0-nightly.6542+94ba0791
2026-06-03 08:24:47 +08:00
Karl Seguin
3c06e98008 Merge pull request #2611 from rohitsux/feat/html-param-reflection
feat(webapi): reflect name and value on HTMLParamElement
2026-06-03 07:30:28 +08:00
Karl Seguin
f61b110b1c Merge pull request #2608 from lightpanda-io/curl_debug_allocator
Extract ZigToCurlAllocator into it's own file, only use in debug
2026-06-03 06:27:57 +08:00
Karl Seguin
9d4259f2b9 Merge pull request #2607 from lightpanda-io/max_contexts
Switch env.contexts to ArrayList to support having more
2026-06-03 06:27:40 +08:00
Karl Seguin
f4403c93e5 Merge pull request #2606 from lightpanda-io/better_html_attributes_v2
More HTML attributes
2026-06-03 06:27:21 +08:00
Karl Seguin
744ac6729b Merge pull request #2605 from lightpanda-io/uaf_identity
Fix UAF on FinalizerCallback.Identity memory
2026-06-03 06:26:38 +08:00
Karl Seguin
55b2b11999 Merge pull request #2604 from lightpanda-io/better_html_attributes
Various HTML attribute tweaks
2026-06-03 06:26:15 +08:00
Rohit
8116214a42 feat(webapi): reflect name and value on HTMLParamElement
Add the reflected DOMString attributes name and value to the
existing HTMLParamElement, per HTML 15.3
(https://html.spec.whatwg.org/multipage/obsolete.html#htmlparamelement).
Mirrors the reflection idiom used by HTMLTimeElement / HTMLDataElement.

Advances the html/dom/reflection-obsolete.html WPT row.
2026-06-03 00:49:03 +05:30
Adrià Arrufat
993315c770 agent: handle model safety refusals
Updates the `zenai` dependency to support safety finish reasons. Tracks
when a model refuses a request due to safety, prints a specific warning
message, and avoids re-prompting.
2026-06-02 19:39:37 +02:00
Adrià Arrufat
a7c305fae9 terminal: remove multiline prompt prefix 2026-06-02 19:21:19 +02:00
Adrià Arrufat
83d07e2c17 build: bump zenai and update help example 2026-06-02 17:31:47 +02:00
Adrià Arrufat
dbe4176409 terminal: scope kitty keyboard protocol to readline 2026-06-02 15:50:29 +02:00
Adrià Arrufat
31479c422c Merge pull request #2609 from lightpanda-io/agent-save-llm
agent: synthesize scripts on /save using LLM
2026-06-02 15:49:45 +02:00
Adrià Arrufat
db21f658f0 agent: prevent use-after-free in synthesizeSave 2026-06-02 15:26:27 +02:00
Adrià Arrufat
8739fbcb4b agent: synthesize scripts on /save using LLM 2026-06-02 15:23:33 +02:00
Karl Seguin
9ba7dbd9b7 Extract ZigToCurlAllocator into it's own file, only use in debug
Extract ZigToCurlAllocator to its own file and rename it to CurlDebugAllocator
to indicate that it is only used in debug. Also, only use it in debug.

In release mode, this just adds 16 bytes of overhead per allocation that curl
makes. In debug mode, it's the same overhead, but it at least hooks into the
std's DebugAllocator which can detect misuse.
2026-06-02 20:17:30 +08:00
Karl Seguin
2451b41af5 Switch env.contexts to ArrayList to support having more
A lot of WPT tests do something like:

```js
    const frame = document.createElement("iframe");
    t.add_cleanup(() => {
      frame.remove();
    });
    ... run a test
```

But our frame.remove (Element.remove) doesn't destroy the frame/context. It
can't. We don't know what is referencing it. So these WPT tests that create
_thousands_ of these quickly run into TooManyContexts errors.

As a quick solution, we now allow up to 8K contexts to be created when running
WPT tests (`-Dwpt_extensions`). Env.contexts becomes an arraylist rather than
an arary (so avoid having to pay that 8192 * 64 byte penalty for tests that
don't need 8K contexts).

An example of such a test is: /encoding/unsupported-labels.window.html
2026-06-02 19:55:20 +08:00
Adrià Arrufat
3bbe20735f agent: record raw REPL input
- Add `recordRaw` to record raw JS lines in the REPL.
- Only record commands if they succeed without error.
- Fix kitty terminal cursor keys by forcing legacy arrow encoding.
2026-06-02 12:54:37 +02:00
Karl Seguin
8c8bcac053 More HTML attributes
Stacked on https://github.com/lightpanda-io/browser/pull/2604 and driven by
a different WPT test: /html/dom/reflection-metadata.html

Goes from 1527 to 3074 passing cases. Largely just adding more attributes and
adding validation to attributes where necessary.
2026-06-02 18:43:31 +08:00
Karl Seguin
3d00061287 Fix UAF on FinalizerCallback.Identity memory
From a real case involving a modified version of our bing integration. Our
`releaseRef` (release from v8) destroys the FinalizerCallback.Identity but kept
it in the identities list. `releaseRef` now removes it from the list, so that
when FC.deinit is called, it doesn't try to access the freed identity.
2026-06-02 18:05:37 +08:00
Adrià Arrufat
0d86c5a22d terminal: disable highlighting in JS mode 2026-06-02 11:52:52 +02:00
Adrià Arrufat
62a3e73f25 Merge pull request #2603 from lightpanda-io/agent_repl_pimp
agent: improve banner
2026-06-02 11:50:01 +02:00
Karl Seguin
e3e3fc25fe Various HTML attribute tweaks
Aimed at improving WPT /html/dom/reflection-obsolete.html Goes from 923 to 2305
passing cases (the remaining failing cases are all for <frame> which we don't
currently support)

Add accessors to Directory, Font and FrameSet. Add HTMLMarqueeElement.

Font setColor null -> ""

Add new properties to Html (accessKey and autofocus) and improve tabIndex
parsing.
2026-06-02 17:33:37 +08:00
Adrià Arrufat
04ee47c268 Merge branch 'agent' into agent_repl_pimp 2026-06-02 11:23:39 +02:00
Adrià Arrufat
401f73b0f2 agent: echo console logs in REPL
Drains and prints console messages during the REPL loop. This ensures
console output is surfaced in JS mode, where slash commands like
`/consoleLogs` are unreachable.
2026-06-02 11:09:53 +02:00
Francis Bouvier
f54359aef6 agent: improve banner 2026-06-02 10:45:19 +02:00
Adrià Arrufat
8e063f8e83 repl: add JS evaluation mode 2026-06-02 10:19:37 +02:00