posit-dev / posit-dev/positron

R: Manually runnable hyperlinks can be pasted in the wrong console when multiple are active

Open
#7,322 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Follow up to https://github.com/posit-dev/positron/pull/7313

With the following reprex:

  • Start R console 1
  • Start R console 2
  • Run cli::cli_alert("{.run revdepcheck::cloud_summary()}") in R console 2 and click the hyperlink.
  • The pasted code will incorrectly end up in R console 1.

https://github.com/user-attachments/assets/74cc62b3-d3ef-4f3b-89e0-ce1a284c66e4

This is due to our call to positron.window.getConsoleForLanguage() here:
https://github.com/posit-dev/positron/blob/6af5bd88e7ff43e833efd238a6a9bc077800059a/extensions/positron-r/src/hyperlink.ts#L51

It chooses the wrong console due to how $getSessionIdForLanguage() works, which just chooses the first session id that matches the language id.

$getSessionIdForLanguage() was introduced in https://github.com/posit-dev/positron/pull/7313, but that was to restore the original pre-multi-session-world behavior, since adding multi-session support accidentally broke the feature entirely.

This issue is about further enhancing $getSessionIdForLanguage() to correctly support multi-session, which means that $getSessionIdForLanguage() will need to switch from:

"choose the first session id that matches the language id"

to:

"choose the most recently active (and still alive) session id that matches the language id"

We may need some additional helper to query the most recently active session id for a language, I'm not sure yet.

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 in extensions/positron-r/src/hyperlink.ts at the call to positron.window.getConsoleForLanguage(), then trace $getSessionIdForLanguage() and its session-selection logic. Reproduce the two-console R scenario from the issue; done means a manually runnable hyperlink from the most recently active live R session pastes into that session rather than the first one.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.