Commit Graph

8486 Commits

Author SHA1 Message Date
Adrià Arrufat
5eb8e3f8c3 Merge pull request #2705 from lightpanda-io/agent-feedback-fixes
Agent feedback fixes
2026-06-12 15:16:26 +02:00
Adrià Arrufat
bd80045c60 Merge pull request #2723 from lightpanda-io/agent-improve-iterative-save
agent: revise the saved script on repeat /save
2026-06-12 15:15:32 +02:00
Adrià Arrufat
c98c762366 agent: add explicit update mode for script saving
Introduces an `update` save mode that allows the LLM to revise an
existing script. Distinguishes this from `append`, which now performs
a blind append. Updates the save prompts and system instructions
accordingly.
2026-06-12 13:39:22 +02:00
Karl Seguin
1fae856330 Merge pull request #2721 from rohitsux/feat/html-source-reflection
feat(webapi): reflect attributes on HTMLSourceElement
2026-06-12 18:54:18 +08:00
Karl Seguin
67f947f606 Reflect source width/height as unsigned long per spec
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 18:29:46 +08:00
Adrià Arrufat
454594137b agent: revise the saved script on repeat /save
A second /save with nothing recorded and no prompt sent an empty user
message, which Anthropic rejects (HTTP 400: text content blocks must be
non-empty). Bail out early instead, telling the user to run commands or
give a prompt.

When a /save targets an existing script (a remembered save path, or
choosing append for an existing file), feed the file contents back to
the model and ask for the complete updated script, then overwrite. This
makes '/save fix X' actually fix the saved script — previously the
blind regeneration was appended after the buggy one. The --no-llm dump
path keeps its verbatim append semantics.
2026-06-12 11:57:40 +02:00
Karl Seguin
ce4c94a27d webapi: preload onload/onerror callback timing
Prior to adding support for preload/modulepreload, we'd just fire a dummy
load event on the next tick. But now that we have proper handling for these, we
should fire load (or error) when the file is loaded (or failed to load). Our
artificial Frame._to_load becomes a bit more generic...it still supports
synthetic loads (e.g. for images), but it also supports "error" event.

ScriptManage and ScriptManagerBase now queue a load/error event when a preloaded
script completed/errors.
2026-06-12 17:54:01 +08:00
Adrià Arrufat
7f522e4f1a agent.welcome: correct logo color 2026-06-12 10:01:48 +02:00
Karl Seguin
196a73b7ee Reorganize slot code
Move a lot of the Frame.slot* methods to a dedicated slotting.zig file. Frame
is already quite big, and this just helps tidy things up a bit.
2026-06-12 15:58:17 +08:00
Karl Seguin
3996204e87 Fix spurious slotchange event from triggering 2026-06-12 15:03:11 +08:00
Adrià Arrufat
d9db947838 Merge branch 'main' into agent 2026-06-12 08:41:25 +02:00
Rohit
7835f133fe feat(webapi): reflect attributes on HTMLSourceElement
Add the reflected IDL attributes to the existing HTMLSourceElement,
which previously reflected none: src (resolved as a URL like
HTMLEmbedElement.src), srcset, sizes, media, type, width and height.

Mirrors the reflection idiom used by HTMLEmbedElement. width and height
are reflected as strings, matching the sibling HTMLEmbedElement
accessors. Adds element/html/source.html covering parse-from-markup,
property/attribute round-trips and src URL resolution.
2026-06-12 11:04:21 +05:30
Karl Seguin
70a70815e4 Merge pull request #2695 from lightpanda-io/offsetParent
webapi: Implement Element.offsetParent getter
2026-06-12 13:01:00 +08:00
Karl Seguin
5d6e275d02 WebAPI: much better shadowdom slot support
This adds more comprehensive and correct support for slot assignment. The
changes can be broken down into 3 buckets:

1 - Slot.assign is now implemented, and general correctness around finding/
    assigning slots (e.g. Text.assignedSlot)

2 - Event dispatching for "composed" (propagating through the shadowdom) better,
    specifically around the composedPath and slots

3 - The slotchange event is fires at the right time (snapshot before mutation
    fire after mutation).

A number of WPT tests now pass, and there should be real-world impact for
slot-heavy frameworks (e.g. lit)
2026-06-12 12:53:14 +08:00
Karl Seguin
e1851309f0 Merge pull request #2714 from navidemad/fix-a43-redirect-no-location
http: deliver 3xx responses without a Location header as final responses
2026-06-12 12:44:15 +08:00
Karl Seguin
3686fd2600 Stricter redirect status code check
Single Location header lookup
2026-06-12 11:47:27 +08:00
Karl Seguin
9302b31f2d Merge pull request #2712 from navidemad/fix-b17-has-relative-selectors
selector: support relative :has() arguments (:has(> div), :has(~ p))
2026-06-12 11:30:02 +08:00
Karl Seguin
63665f8180 Merge pull request #2710 from navidemad/websocket-origin-header
websocket: send Origin header on upgrade requests
2026-06-12 11:02:30 +08:00
Karl Seguin
64238b3af4 Merge pull request #2708 from navidemad/fix-document-readystatechange
webapi: fire readystatechange at document on readiness changes
2026-06-12 10:48:11 +08:00
Karl Seguin
e7e605b65b Merge pull request #2694 from rohitsux/feature/centralize-viewport-default
refactor(viewport): source hardcoded 1920x1080 from MediaQuery.Viewport.default
2026-06-12 09:51:37 +08:00
Karl Seguin
10a35af941 Merge pull request #2658 from lightpanda-io/nikneym/rust-url
`URL`: Rework URL web API with rust-url
2026-06-12 09:33:05 +08:00
Karl Seguin
18fcb089cc Merge pull request #2715 from lightpanda-io/improve_name_test
minor: remove 'leak' word from test name
2026-06-12 09:21:54 +08:00
Karl Seguin
2babfad486 minor: Create ViewPort type
Move logic that was added to MediaQuery into its own ViewPort.
2026-06-12 09:19:48 +08:00
Karl Seguin
01ff034bf4 minor: remove 'leak' word from test name
Keep ability to grep for 'leak' meaningful by not having it show up on success.
The assertion is redundant anyways, presumably no test leaks.
2026-06-12 08:58:19 +08:00
Navid EMAD
6665684abe http: deliver 3xx responses without a Location header as final responses
Every 300-399 status was routed into the redirect path, where the missing
Location header fails the transfer with error.LocationNotFound — the old
document is destroyed and nothing replaces it. Per the fetch standard's
HTTP-redirect fetch ("If locationURL is null, then return response") and
RFC 9110 §15.4, a 3xx without Location is a normal final response whose
body must be delivered. Guard both the redirect dispatch and the 3xx
skip-body branch on the header's presence so such responses fall through
to the regular completion path.

Closes #2713
2026-06-12 02:23:10 +02:00
Navid EMAD
25077d8ddc selector: support relative :has() arguments per Selectors Level 4
:has() arguments may start with an explicit combinator (":has(> div)",
":has(~ p)", ":has(+ span)") and are anchored at the element being
matched. Absolutize each argument at parse time by prepending a :scope
anchor segment, then match candidates with :scope bound to the element,
searching the parent's subtree for sibling-anchored arguments. This also
anchors plain arguments at the element, so ":has(span p)" no longer
false-positives when the span is an ancestor of the element.

Closes #2711
2026-06-12 00:57:57 +02:00
Navid EMAD
9b101a7009 websocket: send Origin header on upgrade requests
The WebSocket opening handshake must carry the document's origin in an
Origin header when initiated from a browser client (RFC 6455 §4.1), and
origin-checking endpoints (CSRF protection on WS servers) reject
upgrades that arrive without it. WebSocket.init already assembles extra
upgrade headers (Sec-WebSocket-Protocol, Cookie) but never added Origin.

Serialize the executing document's origin via URL.getOrigin next to the
existing header setup — "null" for opaque origins (about:blank, data:),
matching what Chrome sends. The TestWSServer captures the upgrade's
Origin header and exposes it via a new get-origin command; an
origin_on_upgrade fixture in websocket.html asserts the served page's
origin arrives on the upgrade.

Closes #2709
2026-06-12 00:27:25 +02:00
Navid EMAD
6b90a7be49 webapi: fire readystatechange at document on readiness changes
Per the HTML Standard's "update the current document readiness" steps,
every change to document.readyState must fire a readystatechange event
at the Document - twice during a normal load: when readiness becomes
interactive (before DOMContentLoaded) and when it becomes complete
(before the load event). The readiness flips in Frame.zig updated
_ready_state but never dispatched the event, so page scripts driving
their lifecycle off readystatechange never observed any transition.

Dispatch the event (non-bubbling, non-cancelable, trusted) right after
each flip, mirroring how DOMContentLoaded is emitted.

Closes #2707
2026-06-11 23:31:36 +02:00
Adrià Arrufat
538b560676 terminal: highlight JS globals in prompt
Adds syntax highlighting for common JS globals (like window, console,
and lp) in cyan, excluding property accesses.
2026-06-11 19:54:29 +02:00
Adrià Arrufat
4d2ebb8d36 agent: update REPL docs for ghost hints and model command
Updates agent documentation to reflect the removal of the status bar
in favor of ghost hints. Also documents the `/model` command and
updates the JS mode prompt examples.
2026-06-11 19:53:49 +02:00
Scott Taylor
79dfdf7465 fix(cdp): let setExtraHTTPHeaders override built-in headers like User-Agent
Network.setExtraHTTPHeaders applied caller headers with a plain
curl_slist append. Requests are seeded with a default `User-Agent:
Lightpanda/1.0`, so a caller-supplied User-Agent produced two
User-Agent entries; libcurl keeps the first and the override was
silently dropped (origins always saw `Lightpanda/1.0`). Other headers
worked because they had no default to collide with.

Add Headers.set, which replaces any existing header with the same
(case-insensitive) name before appending, and use it when applying the
CDP extra headers. This matches Chrome, where Network.setExtraHTTPHeaders
overrides default request headers.

Refs #2704
2026-06-11 12:31:14 -04:00
Adrià Arrufat
aeba63427e script: enforce positional arguments come first
Returns a specific `PositionalMustComeFirst` error when a positional
argument is placed after key-value pairs.
2026-06-11 18:24:44 +02:00
Adrià Arrufat
d292f2b342 agent: pump session during terminal idle
Updates isocline to support idle callbacks and registers a hook to
pump the session's curl multi while waiting for user input. This
prevents connection timeouts. Also refactors the idle pumping logic
into `Session.idleSlice` to share it with the MCP server.
2026-06-11 18:19:51 +02:00
Halil Durak
97cf961d9c Frame: remove incorrect releaseRef calls for Location 2026-06-11 19:18:23 +03:00
Halil Durak
0bb2d1cf53 Frame: change Location reference release order 2026-06-11 19:18:22 +03:00
Halil Durak
e57b2c258e URL: U_ -> U 2026-06-11 19:18:22 +03:00
Halil Durak
728080d2e4 History: prefer setHref instead of new URL in replaceState
This is what spec recommends, `pushState` was updated in commits before.
2026-06-11 19:18:22 +03:00
Halil Durak
a307833e5a URL: introduce url_parse_with_base
This results in creating one less `Box`; hence should be the preferred way when creating a URL object from a base.
2026-06-11 19:18:22 +03:00
Halil Durak
c03569dcb3 Location: update tests 2026-06-11 19:18:21 +03:00
Halil Durak
eb6321c61a Document: remove dead Location accessor
The one coming from `Window` is the single source of truth now.
2026-06-11 19:18:21 +03:00
Halil Durak
d9731ad6d7 Location: acquire and release Location references properly 2026-06-11 19:18:21 +03:00
Halil Durak
0761ede5ab Location: track lifetime of Location
This is a requirement because of URL object.
2026-06-11 19:18:20 +03:00
Halil Durak
0c15d289e0 URL: track lifetime of the URL object
This essentially holds a Rust Box; so, we deinitialize it when there are no references left.
2026-06-11 19:18:20 +03:00
Halil Durak
88db71221d URL: update tests
Also fixes an FTP related test we had.
2026-06-11 19:18:20 +03:00
Halil Durak
2a6a098001 Frame: adapt to new URL implementation for Location
Now that URL initialization heap-allocates and calls extern functions, this can't happen in comptime.
2026-06-11 19:18:20 +03:00
Halil Durak
f5b4370505 Location: expect []const u8 (no-sentinel) for URL-related strings 2026-06-11 19:18:19 +03:00
Halil Durak
0942b16595 URL: migrate search getter/setter, setHref and toString 2026-06-11 19:18:19 +03:00
Halil Durak
6dfeabc999 spread new implementation (phase 1)
Will have to come up with a solution for search getter/setter and URLSearchParams still; We've also encountered with a bug in URLSearchParams, a fix for it will also be included in the second phase.
2026-06-11 19:18:19 +03:00
Halil Durak
12b3d2c9f4 bind & implement more rust-url utilities 2026-06-11 19:18:19 +03:00
Halil Durak
3f006bf912 add rust-url dependency and bindings for it 2026-06-11 19:18:18 +03:00