Return description and author for installed packages#1165
Open
bricestacey wants to merge 2 commits intomainfrom
Open
Return description and author for installed packages#1165bricestacey wants to merge 2 commits intomainfrom
bricestacey wants to merge 2 commits intomainfrom
Conversation
Extend .ps.rpc.pkg_list to return `description` and `author` alongside the existing fields so Positron's Packages pane card view can render them. Both are normalized for display: descriptions collapse whitespace so multi-line text fits on one line, and author strips trailing `<email>` markers from Maintainer values. All three methods (pak / base / renv) populate the new fields. base and renv share a helper that wraps utils::installed.packages() so the lib lookup only differs by `lib.loc`. See posit-dev/positron#12925
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jennybc
requested changes
Apr 23, 2026
Member
There was a problem hiding this comment.
Some high-level thoughts:
- It's not immediately obvious to me why a pak variant is needed when listing installed packages and perhaps enriching with some information from DESCRIPTION. My instinct is that someone choosing or accepting a pak lifestyle re: packages pane operations is really (and probably only?) about installation. I suspect this can be simplified to using something like
.ps.pkg_list_installed()for pak/base/renv and just feeding thelib.locin the renv case. - I'd lean more into R's native vectorization. I think there's a lot of explicit iteration that can be eliminated. I gather some sort of row-by-row move is needed eventually to get this into the needed shape, but I think we can do that all at once at the last moment. Something along these lines:
.ps.pkg_list_installed <- function(lib.loc = NULL) {
ip <- utils::installed.packages(
lib.loc = lib.loc,
fields = c("Description", "Maintainer")
)
pkgs <- ip[, "Package"]
vers <- ip[, "Version"]
description <- trimws(gsub(
"\\s+",
" ",
ifelse(is.na(ip[, "Description"]), "", ip[, "Description"]),
perl = TRUE
))
maintainer <- trimws(gsub(
"\\s*<[^>]+>",
"",
gsub(
"\\s+",
" ",
ifelse(is.na(ip[, "Maintainer"]), "", ip[, "Maintainer"]),
perl = TRUE
),
perl = TRUE
))
ids <- paste0(pkgs, "-", vers)
Map(
function(id, pkg, ver, description, maintainer) {
list(
id = id,
name = pkg,
displayName = pkg,
version = ver,
description = description,
maintainer = maintainer
)
},
ids,
pkgs,
vers,
description,
maintainer
)
}
Member
|
Here's a slightly cleaner version of my suggestion: .ps.pkg_list_installed <- function(lib.loc = NULL) {
ip <- utils::installed.packages(
lib.loc = lib.loc,
fields = c("Description", "Maintainer")
)
name <- ip[, "Package"]
version <- ip[, "Version"]
id <- paste0(name, "-", version)
description <- trimws(gsub(
"\\s+",
" ",
ifelse(is.na(ip[, "Description"]), "", ip[, "Description"]),
perl = TRUE
))
maintainer <- trimws(gsub(
"\\s*<[^>]+>",
"",
gsub(
"\\s+",
" ",
ifelse(is.na(ip[, "Maintainer"]), "", ip[, "Maintainer"]),
perl = TRUE
),
perl = TRUE
))
Map(
list,
id = id,
name = name,
displayName = name,
version = version,
description = description,
maintainer = maintainer
)
}The |
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.
Extend .ps.rpc.pkg_list to return
descriptionandauthoralongside the existing fields so Positron's Packages pane card view can render them. Both are normalized for display: descriptions collapse whitespace so multi-line text fits on one line, and author strips trailing<email>markers from Maintainer values.All three methods (pak / base / renv) populate the new fields. base and renv share a helper that wraps utils::installed.packages() so the lib lookup only differs by
lib.loc.See posit-dev/positron#12925