fix: derive workspace from devcontainer config, support subfolder opening#190
Merged
fix: derive workspace from devcontainer config, support subfolder opening#190
Conversation
…ning When --config points to a devcontainer.json, derive the workspace root from the config location (walking up to find .devcontainer parent). If the path argument is a subdirectory of the workspace root, extract the relative path and append it to the container workspace folder in the VS Code URI, enabling subfolder opening within containers. Fixes #82 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/main.rs">
<violation number="1" location="src/main.rs:104">
P2: When `--config` resolves to an external config, this now derives the workspace root from the config store path and ignores the user’s project path, so `vscli open --config rust-dev ~/projects/my-app` opens the config directory instead of the project. Preserve the path argument when it isn’t under the config-derived root.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Comment on lines
+104
to
+108
| let (workspace_path, subfolder) = if let Some(ref config) = resolved_config { | ||
| workspace_root_from_config(config, &path)? | ||
| } else { | ||
| (path.clone(), None) | ||
| }; |
There was a problem hiding this comment.
P2: When --config resolves to an external config, this now derives the workspace root from the config store path and ignores the user’s project path, so vscli open --config rust-dev ~/projects/my-app opens the config directory instead of the project. Preserve the path argument when it isn’t under the config-derived root.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/main.rs, line 104:
<comment>When `--config` resolves to an external config, this now derives the workspace root from the config store path and ignores the user’s project path, so `vscli open --config rust-dev ~/projects/my-app` opens the config directory instead of the project. Preserve the path argument when it isn’t under the config-derived root.</comment>
<file context>
@@ -70,28 +95,34 @@ fn main() -> Result<()> {
.as_ref()
.and_then(|p| config_store::config_name_from_path(p, &config_store));
+ let (workspace_path, subfolder) = if let Some(ref config) = resolved_config {
+ workspace_root_from_config(config, &path)?
+ } else {
</file context>
Suggested change
| let (workspace_path, subfolder) = if let Some(ref config) = resolved_config { | |
| workspace_root_from_config(config, &path)? | |
| } else { | |
| (path.clone(), None) | |
| }; | |
| let (workspace_path, subfolder) = if let Some(ref config) = resolved_config { | |
| let (root, sub) = workspace_root_from_config(config, &path)?; | |
| let path_abs = path.canonicalize().unwrap_or_else(|_| path.clone()); | |
| if path_abs.starts_with(&root) { | |
| (root, sub) | |
| } else { | |
| (path.clone(), None) | |
| } | |
| } else { | |
| (path.clone(), None) | |
| }; |
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.
Summary
When
--configpoints to a devcontainer.json, derive the workspace root from the config location instead of requiring the path argument to be the project root. If the path argument is a subdirectory of the derived workspace root, the relative path is appended to the container workspace folder in the VS Code URI.Example — open a monorepo subfolder in a devcontainer:
Changes
workspace_root_from_config()walks up from config path to find the.devcontainerparent, then uses its parent as workspace root. Extracts subfolder if path arg is a subdirectory of the root.launch()accepts optionalsubfolder: Option<&Path>parameter, passed through toworkspace.open().open()appends subfolder (with backslash normalization) to the container workspace path in the URI.open()call site to passNonefor subfolder.Handles
.devcontainer/folders (walks up to find it).devcontainer/python/devcontainer.json--config(no behavior change)Supersedes #185. Fixes #82.
Summary by cubic
Derives the workspace root from the
devcontainer.jsonlocation when using--configand allows opening a subfolder inside the container if the given path is within that root. Fixes #82..devcontainerfolder and uses its parent as the workspace root; supports nested configs.--config.Written for commit 71f68cc. Summary will update on new commits.