Skip to content

Add "Current File" option to project picker in status bar#1396

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-current-file-option-to-project-picker
Draft

Add "Current File" option to project picker in status bar#1396
Copilot wants to merge 2 commits intomainfrom
copilot/add-current-file-option-to-project-picker

Conversation

Copy link
Contributor

Copilot AI commented Mar 25, 2026

When clicking the status bar with projects registered, pickProjectMany() only shows existing projects — no way to scope an environment to just the active file. Per-file environment selection is completely lost.

Changes

  • src/common/pickers/projects.ts — New pickProjectWithCurrentFile() single-select picker with discriminated result types. When a Python file is active, injects two items above the project list:

    • $(file) Set for current file — bypasses project selection, passes file URI directly to env picker
    • $(add) Add current file as project... — quick-creates a project at the file's parent dir via addPythonProjectGivenResource, then opens env picker for it
  • src/features/envCommands.tssetEnvironmentCommand (context === undefined branch) now checks activeTextEditor() for a Python file. If present, uses the enriched picker; otherwise falls back to the existing pickProjectMany multi-select flow.

  • src/common/localize.ts — Localized strings for the new picker items and section headers.

  • Tests — 14 new unit tests covering the picker item construction, all three result paths (currentFile / addProject / project selection), cancellation, and fallback to pickProjectMany when no Python file is active or editor is untitled.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh issue list --state open --limit 5 --json number,title,labels (http block)

If you need me to access, download, or install something from one of these locations, you can either:


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

When the user clicks the status bar and a Python file is active,
inject two special items at the top of the project picker:
- "Set for current file" — scopes environment to just the active file URI
- "Add current file as project..." — creates a project at the file's
  parent directory, then opens the environment picker for it

This restores the per-file environment selection that was lost when
projects were introduced.

Co-authored-by: eleanorjboyd <[email protected]>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/79de8f9f-18f1-483a-b8e3-146947202da5
Copilot AI changed the title [WIP] Add "Current File" option to project picker when clicking status bar Add "Current File" option to project picker in status bar Mar 25, 2026
Copilot AI requested a review from eleanorjboyd March 25, 2026 18:59
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.

"Current File" option in the project picker

2 participants