Skip to content

Conversation

DavisVaughan
Copy link
Contributor

Addresses #7322

Way back in #2027 I introduced Console to positron.d.ts with the intended purpose of mimicking the TextEditor API, i.e.:

  • Console is similar to TextEditor and is exposed to extension authors
  • Underneath, on the ext host side, we had ExtHostConsole, similar to ExtHostTextEditor
  • Underneath, on the main thread side, we had MainThreadConsole, similar to MainThreadTextEditor
  • An ExtHostConsole mirrors a MainThreadConsole, tied by a simple string id
  • positron.d.ts methods take or return Consoles. With our only ones right now being Console.pasteText(), and positron.window.getConsoleForLanguage(languageId: string): Thenable<Console | undefined>. These were our POC methods for that PR.

I still think this feels like a decent way to handle this API, because it feels like you get a "real" Console object that you can invoke methods on.

But this hasn't proven to be that useful yet. Instead, when we want to do something with a runtime or console we typically go through something like positron.runtime.executeCode(languageId, code), i.e. we never get access to a Console directly, we just invoke a method on whatever Positron deems to be the relevant one.

For simplicity of API, I've decided to just remove the Console API for now in favor of implementing pasteText() in almost the same way we implement executeCode(), i.e. we now go directly through positron.runtime.pasteText(languageId, text). In fact, I've extracted out the "get or start a console/runtime for this language" behavior from executeCode() into a helper so we can use the exact same behavior for pasteText(). This ends up addressing #7322 because this logic always selects the most relevant console, even in the multiconsole world.

The two commits are self contained:

  • The first commit proves that we can successfully switch to the positron.runtime.pasteText(languageId, text) approach
  • The second commit removes all the Console API, since it is no longer required

With the same console selection semantics as `positron.runtime.executeCode()`
It feels like a useful concept, but has not proven useful over `positron.runtime.*`, where we directly work with a console/runtime without referring to it by name
Copy link

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

@DavisVaughan
Copy link
Contributor Author

DavisVaughan commented Jun 17, 2025

If we still want to do #1507, we should probably find an alternative way to do this, and should keep this API.

@DavisVaughan
Copy link
Contributor Author

Closing in favor of #8151

@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant