Introduce host-specific capability overrides - #713
Draft
manzt wants to merge 1 commit into
Draft
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Coverage Report
TypeScript statements: 60.04% (3974 / 6618) |
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
manzt
force-pushed
the
push-mtzpvytoxtwu
branch
3 times, most recently
from
August 11, 2026 17:52
7ba3181 to
3cea298
Compare
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
force-pushed
the
push-mtzpvytoxtwu
branch
from
August 11, 2026 20:05
3cea298 to
f84a99c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.previewUrlcan 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.:
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,
HostPlatformdetects Positron once and substitutes only the implementations for which Positron has a preferred path:The rest of the extension can then prefer the shared capability without checking the host:
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.