Skip to content

Leave Markdown files to bb's preview in the Monaco plugin - #5054

Merged
SawyerHood merged 1 commit into
mainfrom
bb/can-you-make-the-built-in-monaco-plugin-no-longe-thr_48xu3943an
Oct 6, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/can-you-make-the-built-in-monaco-plugin-no-longe-thr_48xu3943an

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The built-in Monaco plugin claimed md and markdown along with every other extension in its language map, so Markdown files opened in the editor by default instead of bb's rendered preview.

What changed

  • plugins/monaco-editor/lib/languages.ts: CLAIMED_EXTENSIONS now leaves out md and markdown. The language map still has them, so a Markdown file opened from Monaco's own file tree is still highlighted.
  • mdx stays claimed: bb's preview only renders .md and .markdown, so .mdx would otherwise open as plain read-only source.
  • Monaco is no longer offered for those two extensions under Settings → File openers or in the "Open with" menu. The opener registration has no "offered but not automatic" state, so keeping it selectable would need a new SDK field.
  • README.md and PLUGIN_OVERVIEW.md for the plugin describe the new behavior.

How you verified

  • Added plugins/monaco-editor/lib/languages.test.ts, which asserts the claim excludes md and markdown, keeps mdx, and that languageForPath still maps Markdown paths to markdown.
  • pnpm exec turbo run typecheck test --filter=bb-plugin-monaco-editor passes (5 files, 37 tests).
  • Not checked by opening a Markdown file in the running app.

🤖 Generated with Claude Code

AGENT GENERATED

The built-in Monaco plugin claimed md and markdown, so Markdown opened in
the editor instead of bb's rendered preview. Drop those two extensions from
the opener claim. The language map keeps them, so Markdown opened from the
Monaco file tree is still highlighted, and mdx stays claimed because bb's
preview does not render it.

Co-Authored-By: Claude Code <[email protected]>
@SawyerHood
SawyerHood marked this pull request as ready for review October 6, 2026 21:07
@SawyerHood
SawyerHood merged commit 108cab2 into main Oct 6, 2026
41 checks passed
@SawyerHood
SawyerHood deleted the bb/can-you-make-the-built-in-monaco-plugin-no-longe-thr_48xu3943an branch October 6, 2026 21:07
SawyerHood pushed a commit that referenced this pull request Oct 13, 2026
## Human comments
when i try to open an HTML link, it shows the HTML code, which is
annoying sometimes...the PR fixes this to show the rendered preview by
default, following the same pattern as for markdown files.



https://github.com/user-attachments/assets/6628e44e-1dcc-4b39-b243-e1c4c9a9ce80



- closes #5427

## What was wrong

With File Editor enabled, HTML links opened in Monaco because it claimed
`.html` and `.htm`. BB already has a sandboxed HTML viewer with
Preview/Raw controls. The viewer also did not recognize `.htm`, and
project file previews on the New thread screen did not supply an HTML
content URL.

## What changed

Leave `.html` and `.htm` to BB's built-in preview, following the
existing Markdown exclusion. Recognize `.htm` case-insensitively and
pass the existing project file content URL to the shared preview
surface. Reuse the existing HTML iframe and Preview/Raw controls without
introducing UI components or styling. Update the File Editor
documentation.

As with Markdown, Monaco is no longer offered for `.html` and `.htm` in
Settings → File openers or the Open with menus. Existing HTML-to-Monaco
preferences fall back to BB's preview. HTML remains editable from
Monaco's own file tree; the built-in Raw view is read-only.

This follows [#5054 — Leave Markdown files to BB’s preview in the Monaco
plugin](#5054): extend the same
default-opener behavior to HTML while reusing the existing viewer.

Existing SDK and CLI file-opening paths continue through the shared
opener routing; no new API, CLI flag, or daemon wire changes.

## How you verified

Regression cases failed before the corresponding fixes and pass after:
- Monaco's claimed extensions leave HTML/HTM to BB.
- A `.HTM` document renders and switches through the existing
Preview/Raw controls.
- Project HTML uses the selected host's existing file content route.

Checks:
- `pnpm exec turbo run lint typecheck test
--filter=bb-plugin-monaco-editor` — 47 tests passed.
- `pnpm exec turbo run test --filter=@bb/app --
src/components/secondary-panel/FilePreview.test.tsx
src/components/secondary-panel/ThreadSecondaryPanelTabContent.markdown-images.test.tsx`
— 40 tests passed.
- `pnpm exec turbo run lint typecheck --filter=@bb/app
--filter=@bb/client-core` — passed, app lint has existing warnings and
no errors.
- `pnpm exec turbo run test --filter=@bb/client-core --
test/file-preview.test.ts` — 13 tests passed.
- `git diff --check` — passed.

Live Chromium verification in an isolated source app with File Editor
enabled: opened HTML and HTM through the project file picker, clicked
the page's JavaScript button, switched Raw → Preview and confirmed its
counter state survived, checked Markdown still renders and TypeScript
still opens Monaco, and reloaded the HTML preview. HTML responses
retained `Content-Security-Policy: sandbox allow-scripts`. No native iOS
run.

The TypeScript control emitted a Monaco disposal TypeError when
switching away; no editor runtime code changed and that separate path
was not investigated here.

Independent read-only reviews by GPT-6-Astra (xhigh) and Opus 5.5 (high)
found no blocking defects. They inspected the source and existing
verification evidence; they did not rerun the test suites or browser
checks.

> AGENT GENERATED
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