Skip to content

Report loaded status from pkg_list#1177

Open
bricestacey wants to merge 1 commit intomainfrom
13184/loaded-status
Open

Report loaded status from pkg_list#1177
bricestacey wants to merge 1 commit intomainfrom
13184/loaded-status

Conversation

@bricestacey
Copy link
Copy Markdown
Contributor

The Positron Packages pane renders a read-only loaded indicator (filled green dot when attached, empty ring when not) using a single new field:

  loaded = paste0("package:", name) %in% search()

The pak/base/renv method branches collapse to a single utils::installed.packages() call. renv overrides .libPaths() in an active project, so the same call works there too. The method parameter stays in the signature for RPC compatibility but is unused.

See posit-dev/positron#13184

The Packages pane renders a read-only loaded indicator (filled green dot
when attached, empty ring when not) using a single new field:

  loaded = paste0("package:", name) %in% search()

The pak/base/renv method branches collapse to a single
utils::installed.packages() call. renv overrides .libPaths() in an
active project, so the same call works there too. The `method`
parameter stays in the signature for RPC compatibility but is unused.

See posit-dev/positron#13184
@bricestacey
Copy link
Copy Markdown
Contributor Author

This PR collapses the implementation between the three package manages into a single implementation. This was the recommendation from #1165 and it feels like a good idea.

This PR is also a minimalist change so as to avoid any distractions trying to land code for the next release. So, this only focuses on the loaded prop.

@bricestacey bricestacey requested a review from jennybc April 28, 2026 21:27
Copy link
Copy Markdown
Member

@jennybc jennybc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made 2 comments, but I'm happy for you to resolve and get this feature in.

version = ip[i, "Version"],
loaded = paste0("package:", name) %in% attached_packages
)
})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the above produces a correct result. But similar to a suggestion in #1165, it's more idiomatic for R and its native vectorization to make these objects first. Then reshape:

    ip      <- utils::installed.packages()
    name    <- ip[, "Package"]
    version <- ip[, "Version"]
    id      <- paste0(name, "-", version)
    loaded  <- paste0("package:", name) %in% search()

    Map(list, id = id, name = name, displayName = name,
        version = version, loaded = loaded)

So, this suggestion is mostly about style, but I'll make it anyway. I guess it might even be a bit more efficient to get the %in% out of the loop, but that's not my main motivation.

name = name,
displayName = name,
version = ip[i, "Version"],
loaded = paste0("package:", name) %in% attached_packages
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call this "attached"? I'm just thinking to head off any confusion about attached vs loaded. Because we clearly mean attached here.

I'm getting at the difference between what search() reports versus loadedNamespaces().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants