Skip to content

Introduce host-specific capability overrides - #713

Draft
manzt wants to merge 1 commit into
mainfrom
push-mtzpvytoxtwu
Draft

Introduce host-specific capability overrides#713
manzt wants to merge 1 commit into
mainfrom
push-mtzpvytoxtwu

Conversation

@manzt

@manzt manzt commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Positron is built on Code OSS, the open-source core of VS Code, so most of the marimo extension can work there without changes. Positron also adds data-science-specific APIs that can provide a better execution path for some behaviors. For example, positron.window.previewUrl can show documentation in the Positron Viewer instead of using our existing external-browser path.

Checking for Positron at each call site would spread host-specific branches throughout the extension. That would couple otherwise general features to one editor, repeat capability detection, and make each integration harder to test or replace. We instead want to add these enhancements incrementally while keeping the rest of the extension independent of the host.

The proposed foundation moves a host behavior behind a narrow Effect service with a VS Code default, e.g.:

export class WebPreview extends Effect.Service<WebPreview>()("WebPreview", {
  effect: Effect.gen(function* () {
    const code = yield* VsCode;
    return {
      open: Effect.fn("WebPreview.open")(function* (url: string) {
        const uri = yield* code.utils.parseUri(url);
        yield* code.env.openExternal(uri);
      }),
    };
  }),
}) {}

An Effect service can be read here as an injectable interface with a default implementation. Feature code depends on the capability rather than the editor providing it.

At the top level, HostPlatform detects Positron once and substitutes only the implementations for which Positron has a preferred path:

const positron = tryAcquirePositronApi();
return positron
  ? makePositronAdapter(positron)
  : WebPreview.Default;

The rest of the extension can then prefer the shared capability without checking the host:

const preview = yield* WebPreview;
yield* preview.open(url);

Because the base implementations use VS Code APIs, they should continue to work across compatible Code OSS-based editors. Positron, or another compatible host, can selectively replace capabilities where it offers a better experience. This spike implements only web preview so that we can evaluate and communicate the pattern before committing to broader integrations.

@manzt manzt added the enhancement New feature or request label Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Area Lines Branches Functions
Python 74.52% (1491 / 1923) 60.98% (261 / 428)
TypeScript 60.82% (3813 / 6269) 49.34% (1497 / 3034) 59.34% (1118 / 1884)

TypeScript statements: 60.04% (3974 / 6618)

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread extension/src/platform/HostPlatform.ts Outdated
Comment thread extension/src/platform/HostPlatform.ts Outdated
@manzt
manzt force-pushed the push-mtzpvytoxtwu branch 3 times, most recently from 7ba3181 to 3cea298 Compare August 11, 2026 17:52
Positron is built on Code OSS, the open-source core of VS Code, so most
of the marimo extension can work there without changes. Positron also
adds data-science-specific APIs that can provide a better execution path
for some behaviors. For example, `positron.window.previewUrl` can show
documentation in the Positron Viewer instead of using our existing
external-browser path.

Checking for Positron at each call site would spread host-specific
branches throughout the extension. That would couple otherwise general
features to one editor, repeat capability detection, and make each
integration harder to test or replace. We instead want to add these
enhancements incrementally while keeping the rest of the extension
independent of the host.

The proposed foundation moves a host behavior behind a narrow Effect
service with a VS Code default:

```ts
export class WebPreview extends Effect.Service<WebPreview>()("WebPreview", {
  effect: Effect.gen(function* () {
    const code = yield* VsCode;
    return {
      open: Effect.fn("WebPreview.open")(function* (url: string) {
        const uri = yield* code.utils.parseUri(url);
        yield* code.env.openExternal(uri);
      }),
    };
  }),
}) {}
```

An Effect service can be read here as an injectable interface with a
default implementation. Feature code depends on the capability rather
than the editor providing it.

At the top level, `HostPlatform` detects Positron _once_ and substitutes
only the implementations for which Positron has a preferred path:

```ts
const positron = tryAcquirePositronApi();
return positron
  ? makePositronAdapter(positron)
  : WebPreview.Default;
```

The rest of the extension can then prefer the shared capability without
checking the host:

```ts
const preview = yield* WebPreview;
yield* preview.open(url);
```

Because the base implementations use VS Code APIs, they should continue
to work across compatible Code OSS-based editors. Positron, or another
compatible host, can selectively replace capabilities where it offers a
better experience. This spike implements only web preview so that we can
evaluate and communicate the pattern before committing to broader
integrations.
@manzt
manzt force-pushed the push-mtzpvytoxtwu branch from 3cea298 to f84a99c Compare August 11, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant