Skip to content

feat(browser): policy-first link routing, HTML handoff, OSC 8 confirm, and Phase 1c chrome wiring - #285

Merged
Hona merged 1 commit into
devfrom
browser-ui/pr3-links
Nov 20, 2026
Merged

Hona merged 1 commit into
devfrom
browser-ui/pr3-links

Conversation

@Hona

@Hona Hona commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

Routes links from chat Markdown, terminal output, app schemes, and the Files panel through crates/browser-policy (#63002, ours.md §4) and wires WS-1 Phase 1c chrome bindings (#272, UP-109 #65094):

  • App-scheme policy (crates/browser-policy/src/app_links.rs):
    • Validates the original untrimmed string (rejecting control bytes, bidi overrides/isolates, percent-encoded controls, credentials, and denied schemes); routes safe mailto: directly to mail, mailto: with attach/attachment params / editor schemes / non-open obsidian: to copy-only, and permitted conversation app schemes (slack:, figma:, linear:, etc.) to the 500 ms guarded in-pane RefusalBar.
  • Chat Markdown & app-scheme routing (apps/desktop/src/surfaces/browser/links.rs, features/files/src/links.rs, plugins/browser/init.luau):
    • Routes http(s) links to the embedded browser pane when Settings › Browser "Open links in OpenCode" is enabled (unless Shift or middle-click forces the OS browser), refuses credentialed HTTP(S) and out-of-workspace file:// URLs, and forwards the original untrimmed href to policy validation.
    • Drains queued conversation app-link reviews via Browser:TakeAppLinkReview() into the 500 ms guarded RefusalBar.
  • Files panel HTML preview handoff & "Show the file's code" (features/files/src/{ops,view,viewer/toolbar}.rs, apps/desktop/src/plugin_host/native/files.rs):
    • Clicking a workspace .html/.htm file in the Files tree/filter (or a line-less Markdown link) opens it in the browser pane when opens_as_page is true; #L line links open source at that line.
    • Browser ... -> "Show the file's code" opens HTML in raw source mode (PreviewMode::Source), and the Files artifact ... menu adds "Open in browser" to switch back.
  • Terminal plain URLs & OSC 8 hyperlink confirmation (features/terminal-surface/src/{links,osc8}.rs, apps/desktop/src/surfaces/terminal/{mod,story}.rs):
    • Plain http(s) terminal links route through App::route_web_or_app_link (Shift forces OS browser).
    • OSC 8 hyperlinks whose target differs from visible cell text or uses a non-web scheme open a DialogSize::Normal confirmation modal (terminal.osc8, Cancel autofocused) showing the real target URI.
  • WS-1 Phase 1c chrome wiring (apps/desktop/src/plugin_host/native/browser/chrome.rs, plugins/browser/init.luau):
    • Exposes BrowserTab:{Find,StopFinding,FindResult,ReloadIgnoreCache,ClearCacheAsync,Favicon} and renders live site favicons (data:image/* with globe fallback) and live Find match counts.

Verification

  • pwsh scripts/guardrails.ps1 (5/5), pwsh scripts/web.ps1 -Check (wasm32 + web-clock), and cargo check --workspace --all-targets green.
  • Driven live against scratch profile + HARNESS_OPEN_EXTERNAL_LOG (proof/browser-ui/prove-pr3.ts):
    • Chat https:// -> opens embedded pane (externalCount: 0); Shift+click & links=false -> open external browser.
    • Credentialed https://user:pass@..., out-of-workspace file://, mailto:?attachment=, vscode://, javascript:, ms-msdt: -> zero external launches, zero pane opens.
    • Safe mailto: -> external mail handler.
    • Conversation slack://channel?id=C123 -> opens guarded RefusalBar ("From the conversation"); click at 200 ms ignored, click at 750 ms launches slack://channel?id=C123.
    • Files tree click on demo.html -> opens browser pane -> ... -> "Show the file's code" opens HTML source -> artifact ... menu offers "Open in browser".
    • Terminal OSC 8 mismatch confirmation modal -> displays real target URL, Cancel dismisses with zero external launches.
  • Visually inspected light & dark 1x and 1.5x captures (8 PNGs in proof/browser-ui/pr3/).
  • Not proved: Live CEF Find match highlighting and live site favicon decoding against a running CEF sidecar (verified bindings compile and wire cleanly to WS-1 #272).

…, and Phase 1c chrome wiring

Route chat, terminal, app-scheme, and Files-panel links through `crates/browser-policy`
(`#63002`, `ours.md` §4) and wire WS-1 Phase 1c chrome bindings (`#272`, `UP-109` `#65094`):

- **App-scheme policy (`crates/browser-policy/src/app_links.rs`):**
  - Classify non-web links on the original untrimmed string, rejecting control bytes,
    bidi overrides/isolates, percent-encoded controls, credentials, and denied schemes;
    route safe `mailto:` to mail, `mailto:` with attachments / editor schemes / non-open
    `obsidian:` to copy-only, and allowed conversation apps (`slack:`, `figma:`, etc.)
    to the 500 ms guarded in-pane review banner.
- **Chat Markdown & app-scheme routing (`apps/desktop/src/surfaces/browser/links.rs`,
  `features/files/src/links.rs`, `plugins/browser/init.luau`):**
  - Open `http(s)` links in the browser pane when `Settings > Browser` `"Open links in
    OpenCode"` is on (unless Shift or middle-click forces the OS browser), refuse
    credentialed HTTP(S) and out-of-workspace `file://` URLs, and pass untrimmed `href`
    into policy validation.
  - Drain queued conversation app-link reviews via `Browser:TakeAppLinkReview()` into
    the 500 ms guarded `RefusalBar`.
- **Files panel HTML handoff & View source (`features/files/src/{ops,view,viewer/toolbar}.rs`,
  `apps/desktop/src/plugin_host/native/files.rs`):**
  - Open workspace `.html`/`.htm` files from the Files tree/filter in the browser pane
    when `opens_as_page` is true (preserving `#L` line links as source opens).
  - Browser `...` -> `"Show the file's code"` opens HTML in raw source mode (`PreviewMode::Source`),
    and the Files artifact `...` menu offers `"Open in browser"` to jump back.
- **Terminal URL & OSC 8 hyperlink confirmation (`features/terminal-surface/src/{links,osc8}.rs`,
  `apps/desktop/src/surfaces/terminal/{mod,story}.rs`):**
  - Route plain terminal `http(s)` URLs through `App::route_web_or_app_link` (Shift forces
    OS browser).
  - Show a `DialogSize::Normal` confirmation modal (`terminal.osc8`) whenever an OSC 8
    hyperlink's target differs from the visible cell text or uses a non-web scheme.
- **WS-1 Phase 1c chrome wiring (`apps/desktop/src/plugin_host/native/browser/chrome.rs`,
  `plugins/browser/init.luau`):**
  - Expose `BrowserTab:{Find,StopFinding,FindResult,ReloadIgnoreCache,ClearCacheAsync,Favicon}`
    and render live tab favicons (`data:image/*` with globe fallback) and Find match counts.
@Hona
Hona merged commit 5a1a37b into dev Nov 20, 2026
6 checks passed
@Hona
Hona deleted the browser-ui/pr3-links branch November 20, 2026 12:17
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

Hona added a commit that referenced this pull request Nov 20, 2026
…18..UP-122 (#295)

- Fold verified fleet PRs #278, #285, #287, #288, #289, #290, #291, and
  #293 (Rune dc8f7f72: #1301, #1302 focus rescue verified Send+Enter -> effort)
  into docs/upstream-sync/ledger.{json,md}
- Close UP-062 packaged-default regression (#278), UP-095-UI / UP-100 /
  UP-106 / UP-109 / UP-117 (#285, #289), and PRE-08 (#287); reassign
  UP-115, UP-116, UP-075 to BROWSER-UI
- Add separate Reviewed column for browser rows tracking retrospective
  security reviews on merged PRs (#245, #268, #272, #277, #288, #275, #287,
  #285, #289) and pre-merge holds (#274, #280, #281, #283, #286, #292, #294,
  and BROWSER-TOOLS PR 3+)
- Audit upstream anomalyco/opencode bfee96a859..2002222d13 (+6 commits:
  1 skipped, 5 added: UP-118..UP-122) and refine radar routing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant