-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Dev Container improvements #17348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sgraband
wants to merge
11
commits into
master
Choose a base branch
from
feat/dev-container
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev Container improvements #17348
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7677f3c
fix(dev-container): fix variable resolver to handle variables embedde…
sgraband a9dd135
fix(dev-container): fix MountsContribution to pass through mount options
sgraband 2f28050
fix(dev-container): fix SettingsContribution JSON quoting through shell
sgraband bfa52a8
feat(dev-container): implement portsAttributes support
sgraband 13c65ee
feat(dev-container): add "Attach to Running Container" feature
sgraband 0c27c9b
feat(dev-container): SSH credential injection, git identity sharing, …
sgraband f8d592a
fix(dev-container): auto-reopen in last active dev container after re…
sgraband 588fc5f
feat(dev-container): suggest to reopen workspace in dev container
sgraband dd5bd6b
feat(dev-container): add "Rebuild Container" command
sgraband d5e7233
feat(remote): expose Ports view and display port labels
sgraband a1194b5
fix(dev-container): address review feedback
sgraband File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
93 changes: 93 additions & 0 deletions
93
packages/dev-container/src/electron-browser/dev-container-suggestion-contribution.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // ***************************************************************************** | ||
| // Copyright (C) 2026 EclipseSource and others. | ||
| // | ||
| // This program and the accompanying materials are made available under the | ||
| // terms of the Eclipse Public License v. 2.0 which is available at | ||
| // http://www.eclipse.org/legal/epl-2.0. | ||
| // | ||
| // This Source Code may also be made available under the following Secondary | ||
| // Licenses when the conditions for such availability set forth in the Eclipse | ||
| // Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
| // with the GNU Classpath Exception which is available at | ||
| // https://www.gnu.org/software/classpath/license.html. | ||
| // | ||
| // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
| // ***************************************************************************** | ||
|
|
||
| import { inject, injectable } from '@theia/core/shared/inversify'; | ||
| import { CommandService, MessageService, nls } from '@theia/core'; | ||
| import { FrontendApplicationContribution, LocalStorageService } from '@theia/core/lib/browser'; | ||
| import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service'; | ||
| import { RemoteContainerConnectionProvider } from '../electron-common/remote-container-connection-provider'; | ||
| import { RemoteContainerCommands } from './container-connection-contribution'; | ||
| import { RemoteStatusService } from '@theia/remote/lib/electron-common/remote-status-service'; | ||
|
|
||
| const DONT_SHOW_AGAIN_KEY = 'dev-container.suggestion.dontShowAgain'; | ||
|
|
||
| @injectable() | ||
| export class DevContainerSuggestionContribution implements FrontendApplicationContribution { | ||
|
|
||
| @inject(WorkspaceService) | ||
| protected readonly workspaceService: WorkspaceService; | ||
|
|
||
| @inject(RemoteContainerConnectionProvider) | ||
| protected readonly connectionProvider: RemoteContainerConnectionProvider; | ||
|
|
||
| @inject(MessageService) | ||
| protected readonly messageService: MessageService; | ||
|
|
||
| @inject(CommandService) | ||
| protected readonly commandService: CommandService; | ||
|
|
||
| @inject(RemoteStatusService) | ||
| protected readonly remoteStatusService: RemoteStatusService; | ||
|
|
||
| @inject(LocalStorageService) | ||
| protected readonly storageService: LocalStorageService; | ||
|
|
||
| onStart(): void { | ||
| this.checkForDevContainer(); | ||
| } | ||
|
|
||
| protected async checkForDevContainer(): Promise<void> { | ||
| const containerPort = parseInt(new URLSearchParams(location.search).get('port') ?? '0'); | ||
| if (containerPort > 0) { | ||
| const status = await this.remoteStatusService.getStatus(containerPort); | ||
| if (status?.alive) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| const dontShowAgain = await this.storageService.getData<boolean>(DONT_SHOW_AGAIN_KEY); | ||
| if (dontShowAgain) { | ||
| return; | ||
| } | ||
|
|
||
| await this.workspaceService.ready; | ||
| const workspace = this.workspaceService.workspace; | ||
| if (!workspace) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| const devcontainerFiles = await this.connectionProvider.getDevContainerFiles(workspace.resource.path.toString()); | ||
| if (devcontainerFiles.length > 0) { | ||
| const reopenAction = nls.localize('theia/remote/dev-container/reopenInContainer', 'Reopen in Container'); | ||
| const dontShowAgainAction = nls.localizeByDefault("Don't Show Again"); | ||
| const result = await this.messageService.info( | ||
| nls.localize('theia/remote/dev-container/suggestion', | ||
| 'This workspace has a dev container configuration. Would you like to reopen it in a container?'), | ||
| reopenAction, | ||
| dontShowAgainAction | ||
| ); | ||
| if (result === reopenAction) { | ||
| this.commandService.executeCommand(RemoteContainerCommands.REOPEN_IN_CONTAINER.id); | ||
| } else if (result === dontShowAgainAction) { | ||
| await this.storageService.setData(DONT_SHOW_AGAIN_KEY, true); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| // Silently ignore if we can't check for devcontainer files | ||
| } | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.