posit-dev / posit-dev/positron

Ark: Extend `IOPub` with a `PromptState` message type rather than using the UI comm

Open
#3,441 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lang: r
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 11h
Merged PRs (30d)
206

Description

See https://github.com/posit-dev/amalthea/pull/383#discussion_r1631412986

Currently we send prompt updates to the frontend using a custom UI message called PromptState:
https://github.com/posit-dev/amalthea/blob/e7f8b98c5e4deebeb28120a584f7599e307ffbbd/crates/ark/src/interface.rs#L603

We do this because there isn't a good way in the Jupyter protocol for the backend to initiate a prompt configuration change, but that is fairly common in R (an interactive command can update the prompt global option, possibly in a dynamic way like Gabor's prompt R package).

With https://github.com/posit-dev/amalthea/pull/383, we lost the ability to immediately update the frontend prompt state after sourcing a user's .Rprofile, instead it is updated after the first execute_request comes through a little later (i.e. the first time code is run in the console). This is a little awkward.

Knowing that .Rprofile is a somewhat common place to put prompt updates, @lionel- and I thought that we could send over a UiFrontendEvent::PromptState message right after sourcing the .Rprofile, that would enable the frontend to update the prompt quickly. The problem is, the UI comm isn't typically connected yet! What is connected at that point is the IOPub socket, so we could send this message through there instead using an "extension" to the protocol in the form of a custom PromptState message.

We'd update both the R and Python side to use this rather than the UI comm, and update the frontend code accordingly. I'll label this as an R issue though, as it is mostly for R.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with crates/ark/src/interface.rs around the existing UI PromptState message, then trace the IOPub and UI comm paths described in the issue. Review how the R, Python, and frontend sides handle PromptState after sourcing .Rprofile. Done means prompt updates use the IOPub message and reach the frontend immediately.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter, python, r, typescript
Domain
api, backend, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.