Skip to content

feat(chat): preview whole HTML pages in code blocks; send them to Slack as .html files - #49288

Merged
AmethystLiang merged 4 commits into
mainfrom
orca-remote-automation/ui-ux-design-d
Nov 25, 2026
Merged

AmethystLiang merged 4 commits into
mainfrom
orca-remote-automation/ui-ux-design-d

Conversation

@orca-remote-automation

@orca-remote-automation orca-remote-automation Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Chat: a code block tagged html whose content is a whole page (it starts with <!doctype html> or <html) gets a Code | Preview toggle on the left of its header, where the "HTML" label was. The wrap and copy buttons stay on the right.

  • Code is the default view.
  • Preview replaces the code with the page, rendered in place in a 200px frame (it scrolls) with a white background and a 1px top border.
  • The frame is sandbox="" (no scripts, opaque origin). The page is sanitized, and a CSP blocks all network loads. This frame setup is now shared with the notebook HTML output.
  • html snippets that aren't whole pages keep the current header.
  • Header: 34px tall, 12px side padding. The pill has 2px padding around 20px segments; it's a new segmented-pill ToggleGroup variant.

Slack: covers the explicit orca bot reply --text path. The CLI marks its reply pagesAsFiles. When that reply goes to a Slack thread and its text holds a whole HTML page:

  1. The host refuses the text post with the listed reply code html_document_as_file. It does this only when the chat is a bot's and Orca Cloud has actions, files.direct and reply.files.
  2. The CLI sends each page as an attached .html file, using the existing --file upload path. Each file is named from the page's <title>; names never repeat and avoid Windows device names.
  3. The rest of the text goes in the same post. Only the blank lines where a page was removed are folded into one.
  4. If the pages can't go as files (more than 10, the temporary file can't be written, or staging fails), nothing has posted yet, so the CLI sends the words inline as before.

Older CLIs never send the flag, so their replies post inline as before. The bot instructions also gain one line: send a whole page with bot reply --file.

Follow-up, not in this PR: the bot's final message, which Orca posts through the text-only replies route. Converting it in that path needs a design review first.

Checked against how comparable products handle this.

Screenshots

Real app: a dev build on an isolated, throwaway profile, cropped to the chat.

Light: Code (default) Light: Preview
light code light preview
Dark: Code Dark: Preview
dark code dark preview
Narrow (block at 320px): Code Narrow: Preview, dark
narrow code narrow preview

Measured in the app: the header is 34px and the pill 24px with 20px segments. The pill's left edge and the code's left edge are both 13px in from the block's outer edge (1px border plus 12px padding). The copy button's right edge and the code's right edge are both 13px in, and the copy button sits at the same 13px in the snippet header below. At 320px the header does not wrap.

Testing

  • pnpm check:changed passes.
  • html-document-fences.test.ts: only whole-page html fences are taken out. Every other line is kept as written, including blank-line runs in other fences. Pages in CRLF text are found.
  • connector-reply-html-page.test.ts: the refusal keeps its code through the RPC error mapping. It fails if the code is removed from the reply codes.
  • I ran bot reply --text with two fenced pages against a stubbed host (script not committed), with the host's refusal going through the real mapRuntimeError and the CLI's RPC failure error:
    • Two pages were staged and uploaded, and one post carried the remaining text with both files.
    • When staging failed, or the reply held 11 pages, the words posted inline without the flag.
  • Real app: the page block's code view is syntax-highlighted (7 token colors) in the screenshots above.

Performance

  • Detecting a whole page is one anchored regex per html code block.
  • The preview frame mounts only after a click on Preview. Its sanitized document is memoized, and re-sanitizing is deferred while a block streams.
  • The Slack check scans the reply text once per bot reply, only for Slack chats.
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​442 $\color{#cf222e}{\Huge{\mathbf{−}}}$​91 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​351

…ck as .html files

Code blocks tagged html that hold a full document get a Code | Preview toggle; Preview renders
the page in a script-free, opaque-origin, no-network frame. A Slack 'bot reply --text' holding a
whole page now posts it as an attached .html file.
m4air added 3 commits November 25, 2026 13:38
…acks and safer page files

- html_document_as_file is a listed connector.reply code, so the CLI sees it (was runtime_error)
- the host refuses only a caller that sends pagesAsFiles, from a bot chat on a cloud with actions
- a page that can't be staged sends the words inline; nothing posts twice
- only the blank lines around a removed page are folded; CRLF fences are found
- page file names never collide and avoid Windows device names
- the preview defers sanitizing while a block streams
- move bot reply output formatting to its own module
@AmethystLiang
AmethystLiang merged commit ee5f77f into main Nov 25, 2026
61 of 62 checks passed
@AmethystLiang
AmethystLiang deleted the orca-remote-automation/ui-ux-design-d branch November 25, 2026 22:29
registered2nd pushed a commit to registered2nd/orca that referenced this pull request Nov 26, 2026
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