Repository navigation
feat(browser): WebKit browser in Rex panes, with point-and-ask for agents - #57
DeepanshuMishraa wants to merge 6 commits into
Conversation
- Convert local HTML pages to terminal-friendly markdown - Show inline data images and render SVGs at display width
- Add `leaf storage [drive or folder]`: a dithered disk map, category meters and donut in the Rex or terminal theme, and ranked findings labelled junk, unused, in use or review, with where most of each sits. - Scan in parallel with getattrlistbulk on macOS (read_dir + fstatat on Linux): ~1.8M files in ~9s, blocks on disk, hard links counted once, no symlinks or drive crossing. - Recognise caches, build output, package stores, Xcode data and what AI agents leave behind; never mark app bundles or installed tools' deps. - Browse, reveal, ask the agent pane, delete or clear a category's junk after a confirmation; switch drives; `--json` prints it for agents. - Add Rex palette action "Leaf: Analyze Storage", README, skill and changelog notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Tell folders macOS protects (EPERM) apart from other accounts' (EACCES). - Detect Full Disk Access by listing ~/Library/Safari, Mail or Messages, and only point to the setting when the terminal lacks it. - With access granted, report the rest as skipped (protected by macOS, or other accounts') instead of nagging; `a` says so too. - List unreadable folders and why in `--json`, with full_disk_access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Leaf: Open Browser (or `leaf browser [url]`) splits a pane and keeps a native WebKit window exactly over it. Nothing is installed in Applications: build.rs compiles src/browser.swift on macOS, leaf embeds it and unpacks it once per version into ~/Library/Caches/leaf. - Follows the pane through splits, resizes, zoom and tab switches, using session.view fractions, Rex's chrome settings and the Rex window frame; refreshes on session events, ignoring client connect noise - Stays just above the Rex window at normal level, not over other apps - Exits when its pane closes or leaf goes away - Minimal toolbar, progress bar, error page, find, zoom, downloads, uploads, JS dialogs, Safari user agent, page title as pane label - Edit menu so copy and paste work; Rex key bindings are forwarded - Builds for the target arch; without swiftc, leaf builds without the browser (CI fails instead) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Accept amounts with cents, prefill Dodo checkout with name and email - Keep the sponsor wall under one KV key, rebuilt on each payment - Show a returning sponsor right away; set the real SPONSORS KV id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Click the pointer button (or shift+cmd+c), pick elements with React Grab, type a question and press enter: leaf sends the elements' HTML and, on React development builds, their components and source files to the agent picked with Leaf: Choose Agent…, in its pane or a new one. - React Grab 0.2.0 vendored (MIT) and loaded into a page only when pointing starts, telemetry off; reuses a page's own React Grab - The question is typed in a native composer, so a page can't send anything to the agent by itself; picks only count right after a real click or key in the browser - The helper and `leaf browser` talk in JSON lines; leaf builds the prompt (tested) and delivers it with agent::deliver - The composer names the agent a question would go to, asked live: the picked one, else the one open in a pane (agent::current) - Failed sends keep the composer and copy the prompt to the clipboard Browser fixes: - Hidden during Mission Control instead of shown as its own window - Steps aside while Rex animates panes, then fades back in place - Gives way to Rex's palette and other Rex windows over the pane - Close button in the toolbar; macOS 13 check before launching Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
38 issues found across 32 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/plugin.rs">
<violation number="1" location="src/plugin.rs:39">
P3: The install message advertises the browser without its platform limits, although the action fails in remote sessions and the browser requires macOS 13+. Qualify this line so users on Leaf’s other supported environments do not expect the action to work.</violation>
</file>
<file name="CHANGELOG.md">
<violation number="1" location="CHANGELOG.md:5">
P3: Rewrite this sentence so the release note does not imply that find, zoom, and downloads follow the page title; only the pane label does.</violation>
<violation number="2" location="CHANGELOG.md:5">
P2: Qualify this entry as macOS 13+; `leaf browser` exits without opening anything on Linux or on macOS versions below 13, so the current release note misleads supported Leaf users about availability.</violation>
<violation number="3" location="CHANGELOG.md:8">
P3: Include `in use` in the listed statuses: fresh temporary findings are explicitly labeled `in use`, so this sentence currently claims an incomplete set of labels shown by the storage screen.</violation>
</file>
<file name="site/src/sponsors.js">
<violation number="1" location="site/src/sponsors.js:75">
P2: This list-then-overwrite rebuild can permanently hide sponsors when webhook deliveries overlap or KV listing lags a recent write. Serialize wall updates through a Durable Object/queue, or rebuild from authoritative payment keys without allowing stale snapshots to overwrite newer walls.</violation>
</file>
<file name="src/prmedia.rs">
<violation number="1" location="src/prmedia.rs:1077">
P2: `decode` now enlarges SVGs whose declared width is fractional, because `ceil(size.width())` becomes a larger target for `draw_svg`. Preserve the native-size/no-upscale path for `decode` (or pass the unrounded SVG width) so decoded dimensions retain the SVG’s aspect ratio and match layout.</violation>
</file>
<file name="src/junk.rs">
<violation number="1" location="src/junk.rs:366">
P2: This treats every directory named `lib` as a global package prefix. A normal project such as `~/lib` consequently loses its `node_modules` finding; restrict the global-prefix check to known global installation paths instead of the basename alone.</violation>
<violation number="2" location="src/junk.rs:530">
P2: Selecting a known folder such as `~/Library/Caches` starts it as `Other`, so storage reports its contents in the wrong category and misses the folder's cache semantics. Classify arbitrary scan roots before falling back to `Other`.</violation>
<violation number="3" location="src/junk.rs:592">
P2: `status` waits 360 days for unclassified folders, although storage defines `unused` as six months. Ordinary user-data folders therefore stay unlabelled and are omitted from the unused filter for another six months; use `old(UNUSED_DAYS)` here.</violation>
</file>
<file name="site/public/index.html">
<violation number="1" location="site/public/index.html:1294">
P2: The return handler treats `processing` and other non-success statuses as successful sponsorships. Handle only `status === "succeeded"` as success and show a pending message while payment processing continues.</violation>
</file>
<file name="src/browser.swift">
<violation number="1" location="src/browser.swift:758">
P2: Bare numeric local addresses are sent to DuckDuckGo instead of being opened. Make the port optional for IPv4, IPv6, and localhost inputs while retaining the existing host-with-port handling.</violation>
<violation number="2" location="src/browser.swift:923">
P2: Navigating while the composer is open leaves old picks attached to the new document, so the next send can contain mixed elements with the previous page’s URL and title. Clear the composer when a new document commits.</violation>
<violation number="3" location="src/browser.swift:1161">
P2: The message handler accepts arbitrary page-script messages as React Grab picks; a hostile page can inject false context after any user interaction. Use an authenticated bridge or otherwise distinguish messages produced by the injected picker from page JavaScript.</violation>
</file>
<file name="README.md">
<violation number="1" location="README.md:164">
P3: `v` opens the drive-selection modal; it does not switch drives immediately. Say that it opens or picks from the drive picker so users know a second selection is required.</violation>
<violation number="2" location="README.md:164">
P3: The storage scan does not measure those top-level roots in parallel; `start_roots` processes each root synchronously and only parallelizes child directories. Replace this with a claim about using parallel workers.</violation>
<violation number="3" location="README.md:166">
P3: Not every listed item has a label or verdict: ordinary folders have no finding and show file count/age, while status is optional. Qualify this sentence to distinguish classified findings from ordinary folders.</violation>
</file>
<file name="site/src/worker.js">
<violation number="1" location="site/src/worker.js:15">
P3: This dispatch ignores the endpoint's GET-only contract, so POST, PUT, and DELETE requests receive a successful sponsor list. Restrict the route to GET/HEAD or return 405 for other methods.</violation>
</file>
<file name="src/html.rs">
<violation number="1" location="src/html.rs:68">
P2: HTML data-URI schemes are case-insensitive, but this path only embeds lowercase `data:` URLs. Normalize the URI scheme before passing converted HTML images to markdown localization, otherwise uppercase `DATA:` images silently disappear.</violation>
</file>
<file name="build.rs">
<violation number="1" location="build.rs:11">
P2: Cargo does not rerun this probe when Swift/Xcode becomes available. After an initial build without `xcrun`, a later ordinary `cargo build` can keep embedding the empty helper until the target is cleaned or rebuilt from a fresh package; make toolchain availability or a toolchain stamp an input to this build step.</violation>
</file>
<file name="src/browser.rs">
<violation number="1" location="src/browser.rs:96">
P2: The prompt concatenates untrusted page content directly into the agent's instruction text. A malicious page can inject instructions into the picked HTML or component context; pass the context as clearly delimited untrusted data and keep the agent instructions outside that data boundary.</violation>
<violation number="2" location="src/browser.rs:218">
P2: This cleanup deletes resources from older browser processes that may still be running. Because React Grab is loaded on demand, an existing browser opened before a Leaf update can remain visible but fail when the user first presses Point at Element; keep old helper directories until no process uses them, or avoid deleting them here.</violation>
</file>
<file name="src/main.rs">
<violation number="1" location="src/main.rs:541">
P2: `storage_command` silently ignores extra drive/path arguments, so a typo such as `leaf storage /tmp /var` reports the wrong location. Reject more than one positional target before scanning.</violation>
<violation number="2" location="src/main.rs:564">
P2: This branch accepts regular files as storage folders, but the scanner can only enumerate directories; `leaf storage FILE --json` therefore returns empty categories/items with a successful exit. Reject non-directory targets before setting `folder.</violation>
</file>
<file name="src/storageview.rs">
<violation number="1" location="src/storageview.rs:857">
P2: Deleting a browsed folder that contains a listed descendant leaves its unlisted bytes in `Progress`: removing the descendant sets `counted`, so this subtraction is skipped. The storage totals and disk map remain overstated until a rescan; track and remove the target’s unlisted remainder separately.</violation>
<violation number="2" location="src/storageview.rs:862">
P2: Deleting a nested listed item also subtracts its bytes from every surviving ancestor’s `own`, although `own` explicitly excludes separately listed children. The ancestor row then underreports space and can sort incorrectly; reduce `own` only when the deleted path was not separately listed.</violation>
<violation number="3" location="src/storageview.rs:889">
P2: Opening another folder drops the previous Browse receiver without cancelling its worker. Rapid navigation therefore leaves abandoned scans traversing entire directories and consuming threads and I/O; cancel the old Browse progress before replacing or leaving it.</violation>
<violation number="4" location="src/storageview.rs:2234">
P2: Folder JSON scans only the selected folder but reports the containing drive's full `used` value, making the result internally inconsistent. Report the folder's measured bytes or include the folder scope explicitly.</violation>
</file>
<file name="src/dirscan.rs">
<violation number="1" location="src/dirscan.rs:116">
P2: A `parse` failure returns `Ok(out)`, silently ending the directory scan and undercounting storage. Return an `InvalidData` error instead of treating a partial batch as complete.</violation>
<violation number="2" location="src/dirscan.rs:199">
P2: The Linux scan discards iterator, type, and metadata errors, so a directory that becomes unreadable midway is reported as successfully scanned. Propagate these errors instead of silently undercounting its files.</violation>
</file>
<file name="src/volume.rs">
<violation number="1" location="src/volume.rs:80">
P3: `list` does not order non-internal drives by name as documented; this path-length tie-breaker changes the drive order whenever mount paths have different lengths. Remove the mount-length comparison so the name comparison is the next key.</violation>
<violation number="2" location="src/volume.rs:169">
P2: A Linux network share mounted at a custom path such as `/srv/shared` is marked `internal`, so the drive is sorted with and colored like the computer's own disk. Mark recognized network filesystem kinds as non-internal regardless of their mount path.</violation>
<violation number="3" location="src/volume.rs:227">
P2: Linux shares opened through GVFS are filtered out, so common Files-mounted SMB and SFTP shares do not appear in storage at all. Treat `fuse.gvfsd-fuse` as a supported network filesystem instead of excluding it as virtual.</violation>
</file>
<file name="site/src/sponsor.js">
<violation number="1" location="site/src/sponsor.js:38">
P2: `cents` has no upper bound, so typos or automated requests can create provider-rejected or unexpectedly enormous checkout amounts. Restore the previous $10,000 ceiling in cents.</violation>
<violation number="2" location="site/src/sponsor.js:68">
P2: This public endpoint has no abuse control, so a bot can create checkout sessions repeatedly and exhaust the shared Dodo API quota, denying legitimate sponsors. Add an edge/IP rate limit or challenge before calling Dodo.</violation>
</file>
<file name="src/markdown.rs">
<violation number="1" location="src/markdown.rs:67">
P3: Mixed-case `data:` schemes are misclassified as local paths. Match the scheme case-insensitively before parsing the media type.</violation>
<violation number="2" location="src/markdown.rs:76">
P2: Percent-encoded binary data URIs are corrupted before decoding. `percent_decode` converts invalid UTF-8 bytes through `String::from_utf8_lossy`; decode `%XX` escapes directly into `Vec<u8>` for non-base64 image data.</violation>
<violation number="3" location="src/markdown.rs:115">
P3: Each inline data image is parsed and decoded twice during localization: once in `is_embedded` and again in `id`. Parse it once and pass the result into the image-ID path.</violation>
<violation number="4" location="src/markdown.rs:275">
P2: Inline raster images are fully decoded just to measure them, then decoded again to render. Read dimensions from an image header for `image_size` and leave pixel decoding to `decode`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
|
||
| ## Unreleased | ||
|
|
||
| - **Leaf: Open Browser** (or `leaf browser [url]`) opens a WebKit browser in a Rex pane beside you, built into leaf: nothing is installed in Applications. It follows the pane through splits, resizes, zoom and tab switches, steps aside for Rex's palette and Mission Control, and keeps Rex's shortcuts working. Find, zoom, downloads, and the pane's label follows the page title. |
There was a problem hiding this comment.
P2: Qualify this entry as macOS 13+; leaf browser exits without opening anything on Linux or on macOS versions below 13, so the current release note misleads supported Leaf users about availability.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At CHANGELOG.md, line 5:
<comment>Qualify this entry as macOS 13+; `leaf browser` exits without opening anything on Linux or on macOS versions below 13, so the current release note misleads supported Leaf users about availability.</comment>
<file context>
@@ -1,5 +1,12 @@
+## Unreleased
+
+- **Leaf: Open Browser** (or `leaf browser [url]`) opens a WebKit browser in a Rex pane beside you, built into leaf: nothing is installed in Applications. It follows the pane through splits, resizes, zoom and tab switches, steps aside for Rex's palette and Mission Control, and keeps Rex's shortcuts working. Find, zoom, downloads, and the pane's label follows the page title.
+- Point at any part of a page and ask your agent about it. The pointer button (or `shift+cmd+c`) picks elements with [React Grab](https://github.com/aidenybai/react-grab), including the React components and source files behind them on development builds; type a question and press `enter`. It goes to the agent picked with **Leaf: Choose Agent…**, in its pane or a new one beside the browser.
+
</file context>
| - **Leaf: Open Browser** (or `leaf browser [url]`) opens a WebKit browser in a Rex pane beside you, built into leaf: nothing is installed in Applications. It follows the pane through splits, resizes, zoom and tab switches, steps aside for Rex's palette and Mission Control, and keeps Rex's shortcuts working. Find, zoom, downloads, and the pane's label follows the page title. | |
| - **Leaf: Open Browser** (or `leaf browser [url]`) opens a WebKit browser in a Rex pane beside you on macOS 13+, built into leaf: nothing is installed in Applications. It follows the pane through splits, resizes, zoom and tab switches, steps aside for Rex's palette and Mission Control, and keeps Rex's shortcuts working. Find, zoom, downloads, and the pane's label follows the page title. |
| const payment = { name, github, cents, at: event.timestamp ?? null }; | ||
| await env.SPONSORS.put(`payment:${data.payment_id}`, "", { metadata: payment }); | ||
| // KV listings lag new writes, so this payment is passed in rather than trusted to show up. | ||
| await rebuild(env, { [`payment:${data.payment_id}`]: payment }); |
There was a problem hiding this comment.
P2: This list-then-overwrite rebuild can permanently hide sponsors when webhook deliveries overlap or KV listing lags a recent write. Serialize wall updates through a Durable Object/queue, or rebuild from authoritative payment keys without allowing stale snapshots to overwrite newer walls.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At site/src/sponsors.js, line 75:
<comment>This list-then-overwrite rebuild can permanently hide sponsors when webhook deliveries overlap or KV listing lags a recent write. Serialize wall updates through a Durable Object/queue, or rebuild from authoritative payment keys without allowing stale snapshots to overwrite newer walls.</comment>
<file context>
@@ -0,0 +1,119 @@
+ const payment = { name, github, cents, at: event.timestamp ?? null };
+ await env.SPONSORS.put(`payment:${data.payment_id}`, "", { metadata: payment });
+ // KV listings lag new writes, so this payment is passed in rather than trusted to show up.
+ await rebuild(env, { [`payment:${data.payment_id}`]: payment });
+ return json(200, { ok: true });
+};
</file context>
| } | ||
| let tree = svg(bytes)?; | ||
| let size = tree.size(); | ||
| draw_svg(&tree, size.width().min(MAX_SVG_SIDE).ceil() as u32) |
There was a problem hiding this comment.
P2: decode now enlarges SVGs whose declared width is fractional, because ceil(size.width()) becomes a larger target for draw_svg. Preserve the native-size/no-upscale path for decode (or pass the unrounded SVG width) so decoded dimensions retain the SVG’s aspect ratio and match layout.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/prmedia.rs, line 1077:
<comment>`decode` now enlarges SVGs whose declared width is fractional, because `ceil(size.width())` becomes a larger target for `draw_svg`. Preserve the native-size/no-upscale path for `decode` (or pass the unrounded SVG width) so decoded dimensions retain the SVG’s aspect ratio and match layout.</comment>
<file context>
@@ -1072,18 +1072,31 @@ pub(crate) fn decode(bytes: &[u8]) -> Option<RgbaImage> {
}
+ let tree = svg(bytes)?;
+ let size = tree.size();
+ draw_svg(&tree, size.width().min(MAX_SVG_SIDE).ceil() as u32)
+}
+
</file context>
| category: System, | ||
| finding: Some(LOGS), | ||
| }, | ||
| _ => Role::Area { |
There was a problem hiding this comment.
P2: Selecting a known folder such as ~/Library/Caches starts it as Other, so storage reports its contents in the wrong category and misses the folder's cache semantics. Classify arbitrary scan roots before falling back to Other.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/junk.rs, line 530:
<comment>Selecting a known folder such as `~/Library/Caches` starts it as `Other`, so storage reports its contents in the wrong category and misses the folder's cache semantics. Classify arbitrary scan roots before falling back to `Other`.</comment>
<file context>
@@ -0,0 +1,762 @@
+ category: System,
+ finding: Some(LOGS),
+ },
+ _ => Role::Area {
+ category: Other,
+ list: true,
</file context>
| } | ||
|
|
||
| if (params.has("sponsor")) { | ||
| const bad = status === "failed" || status === "cancelled"; |
There was a problem hiding this comment.
P2: The return handler treats processing and other non-success statuses as successful sponsorships. Handle only status === "succeeded" as success and show a pending message while payment processing continues.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At site/public/index.html, line 1294:
<comment>The return handler treats `processing` and other non-success statuses as successful sponsorships. Handle only `status === "succeeded"` as success and show a pending message while payment processing continues.</comment>
<file context>
@@ -859,6 +1099,214 @@ <h2>Open your next <span class="hl" style="--hl: var(--hl-yellow)">paper</span>
+ }
+
+ if (params.has("sponsor")) {
+ const bad = status === "failed" || status === "cancelled";
+ const toast = document.createElement("div");
+ toast.className = `toast${bad ? " bad" : ""}`;
</file context>
|
|
||
| ## Storage | ||
|
|
||
| `leaf storage` shows what fills a drive, and clears what's safe to clear. It measures the startup disk's home folder, apps, `/Library`, Homebrew and temporary folders in parallel, a few seconds for millions of files. On macOS it reads whole batches of a folder's entries in one `getattrlistbulk` call. Space is counted as blocks on disk, so cloud-only and sparse files count for what they really take, and hard links count once. `leaf storage /Volumes/USB` measures another drive, `leaf storage ~/Code` one folder, and `v` switches drives. It works on macOS and Linux. |
There was a problem hiding this comment.
P3: The storage scan does not measure those top-level roots in parallel; start_roots processes each root synchronously and only parallelizes child directories. Replace this with a claim about using parallel workers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At README.md, line 164:
<comment>The storage scan does not measure those top-level roots in parallel; `start_roots` processes each root synchronously and only parallelizes child directories. Replace this with a claim about using parallel workers.</comment>
<file context>
@@ -155,6 +159,20 @@ In kitty, Ghostty, WezTerm, iTerm2 and other terminals that show pictures, the b
+## Storage
+
+`leaf storage` shows what fills a drive, and clears what's safe to clear. It measures the startup disk's home folder, apps, `/Library`, Homebrew and temporary folders in parallel, a few seconds for millions of files. On macOS it reads whole batches of a folder's entries in one `getattrlistbulk` call. Space is counted as blocks on disk, so cloud-only and sparse files count for what they really take, and hard links count once. `leaf storage /Volumes/USB` measures another drive, `leaf storage ~/Code` one folder, and `v` switches drives. It works on macOS and Linux.
+
+The disk map at the top is the whole drive, dithered in your Rex or terminal theme's colors, with one band per category: Apps, Developer, AI agents, Media, Documents, Caches, Trash, Other files and System data. Pick a category with `tab` or `1`–`9` and its findings are listed biggest first. Each one shows a label, a verdict, where most of its space is ("mostly in Chrome/Default/Cache/Cache_Data/"), and when it last changed:
</file context>
| `leaf storage` shows what fills a drive, and clears what's safe to clear. It measures the startup disk's home folder, apps, `/Library`, Homebrew and temporary folders in parallel, a few seconds for millions of files. On macOS it reads whole batches of a folder's entries in one `getattrlistbulk` call. Space is counted as blocks on disk, so cloud-only and sparse files count for what they really take, and hard links count once. `leaf storage /Volumes/USB` measures another drive, `leaf storage ~/Code` one folder, and `v` switches drives. It works on macOS and Linux. | |
| `leaf storage` shows what fills a drive, and clears what's safe to clear. It measures the startup disk's home folder, apps, `/Library`, Homebrew and temporary folders using parallel workers, a few seconds for millions of files. On macOS it reads whole batches of a folder's entries in one `getattrlistbulk` call. Space is counted as blocks on disk, so cloud-only and sparse files count for what they really take, and hard links count once. `leaf storage /Volumes/USB` measures another drive, `leaf storage ~/Code` one folder, and `v` opens the drive picker. It works on macOS and Linux. |
| async fetch(request, env) { | ||
| const url = new URL(request.url); | ||
| if (url.pathname === "/api/sponsor") return sponsor(request, env); | ||
| if (url.pathname === "/api/sponsors") return list(env); |
There was a problem hiding this comment.
P3: This dispatch ignores the endpoint's GET-only contract, so POST, PUT, and DELETE requests receive a successful sponsor list. Restrict the route to GET/HEAD or return 405 for other methods.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At site/src/worker.js, line 15:
<comment>This dispatch ignores the endpoint's GET-only contract, so POST, PUT, and DELETE requests receive a successful sponsor list. Restrict the route to GET/HEAD or return 405 for other methods.</comment>
<file context>
@@ -1,12 +1,19 @@
async fetch(request, env) {
const url = new URL(request.url);
+ if (url.pathname === "/api/sponsor") return sponsor(request, env);
+ if (url.pathname === "/api/sponsors") return list(env);
+ if (url.pathname === "/api/dodo-webhook") return webhook(request, env);
const agent = request.headers.get("user-agent") ?? "";
</file context>
| if (url.pathname === "/api/sponsors") return list(env); | |
| if (url.pathname === "/api/sponsors") { | |
| if (request.method !== "GET" && request.method !== "HEAD") { | |
| return new Response(null, { status: 405, headers: { allow: "GET, HEAD" } }); | |
| } | |
| return list(env); | |
| } |
| volumes.sort_by(|a, b| { | ||
| b.internal | ||
| .cmp(&a.internal) | ||
| .then(a.mount.as_os_str().len().cmp(&b.mount.as_os_str().len())) |
There was a problem hiding this comment.
P3: list does not order non-internal drives by name as documented; this path-length tie-breaker changes the drive order whenever mount paths have different lengths. Remove the mount-length comparison so the name comparison is the next key.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/volume.rs, line 80:
<comment>`list` does not order non-internal drives by name as documented; this path-length tie-breaker changes the drive order whenever mount paths have different lengths. Remove the mount-length comparison so the name comparison is the next key.</comment>
<file context>
@@ -0,0 +1,274 @@
+ volumes.sort_by(|a, b| {
+ b.internal
+ .cmp(&a.internal)
+ .then(a.mount.as_os_str().len().cmp(&b.mount.as_os_str().len()))
+ .then(a.name.cmp(&b.name))
+ });
</file context>
| for (event, range) in Parser::new_ext(markdown, render::MARKDOWN).into_offset_iter() { | ||
| match event { | ||
| Event::Start(Tag::Image { dest_url, .. }) if is_relative(&dest_url) => { | ||
| Event::Start(Tag::Image { dest_url, .. }) if is_embedded(&dest_url) => { |
There was a problem hiding this comment.
P3: Each inline data image is parsed and decoded twice during localization: once in is_embedded and again in id. Parse it once and pass the result into the image-ID path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/markdown.rs, line 115:
<comment>Each inline data image is parsed and decoded twice during localization: once in `is_embedded` and again in `id`. Parse it once and pass the result into the image-ID path.</comment>
<file context>
@@ -52,35 +53,71 @@ fn is_relative(href: &str) -> bool {
for (event, range) in Parser::new_ext(markdown, render::MARKDOWN).into_offset_iter() {
match event {
- Event::Start(Tag::Image { dest_url, .. }) if is_relative(&dest_url) => {
+ Event::Start(Tag::Image { dest_url, .. }) if is_embedded(&dest_url) => {
edits.push((range, format!("", id(&dest_url))))
}
</file context>
|
|
||
| /// The bytes of a `data:image/…` URI, base64 or percent-encoded. | ||
| fn data_uri(href: &str) -> Option<Vec<u8>> { | ||
| let rest = href.strip_prefix("data:")?; |
There was a problem hiding this comment.
P3: Mixed-case data: schemes are misclassified as local paths. Match the scheme case-insensitively before parsing the media type.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/markdown.rs, line 67:
<comment>Mixed-case `data:` schemes are misclassified as local paths. Match the scheme case-insensitively before parsing the media type.</comment>
<file context>
@@ -52,35 +53,71 @@ fn is_relative(href: &str) -> bool {
+
+/// The bytes of a `data:image/…` URI, base64 or percent-encoded.
+fn data_uri(href: &str) -> Option<Vec<u8>> {
+ let rest = href.strip_prefix("data:")?;
+ let (meta, data) = rest.split_once(',')?;
+ if !meta.to_ascii_lowercase().starts_with("image/") {
</file context>
| let rest = href.strip_prefix("data:")?; | |
| let rest = href | |
| .get(..5) | |
| .filter(|prefix| prefix.eq_ignore_ascii_case("data:")) | |
| .and_then(|_| href.get(5..))?; |
|
Superseded by #58, which is based on main and has only the browser commits. |
What
A WebKit browser that lives in a Rex pane, built into leaf. Nothing is installed in Applications. Point at anything on a page and ask your coding agent about it.
leaf browser [url]) splits a pane and keeps a native WebKit window exactly over it. It follows the pane through splits, resizes, zoom and tab switches. It hides during Mission Control and while Rex animates panes, and gives way to Rex's palette.shift+cmd+c, then pick elements with React Grab. Type a question and pressenter. It goes to the agent picked with Leaf: Choose Agent…, either in that agent's pane or in a new pane beside the browser. The composer names the agent live.How
build.rscompilessrc/browser.swiftfor the target arch (macOS 13+), and leaf embeds it. On first use, leaf unpacks it to~/Library/Caches/leaf/webkit-<hash>, replacing older copies. Withoutswiftc, leaf builds without the browser; in CI that's a build failure.session.viewfractions, Rex's chrome settings from its preferences, and the window-server frame of the Rex window. Refreshes are driven by session events, ignoring client connect events, which used to cause a feedback loop.leaf browserexchange JSON lines over stdin and stdout. Rust builds the prompt (unit tested) and sends it withagent::deliver.vendor/react-grab(MIT). It's loaded only when pointing starts, with telemetry off.Safety
Any page can call into injected JS. So a pick only adds context to a native composer, and only
enterin that composer sends anything to the agent. Picks are accepted only right after a real click or key in the browser window.Testing
cargo test: 697 pass. Clippy shows no new warnings.Note
This branch is based on
feat/storage, so it also includes these commits, which aren't onmainyet:e759c87(reader),a10658fand3621bf0(storage), andccb5d1a(sponsor checkout on the site).🤖 Generated with Claude Code
Summary by cubic
Adds a WebKit browser that opens in a Rex pane, embedded in leaf. Point at elements on a page and ask your agent about them. Also includes
leaf storageand saved HTML pages read as markdown.New Features
leaf storageshows what fills a drive, with junk to clear.Written for commit c0441a0. Summary will update on new commits.