-
Notifications
You must be signed in to change notification settings - Fork 5
fix: harden session routing and nested worktrees #485
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
Changes from 2 commits
de32882
c097fb8
d377fba
49fecc3
b9c066a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,9 @@ use serde_json::{Map, Value}; | |
|
|
||
| use crate::sessions::SessionMessageRecord; | ||
| use crate::sessions::shared::{ | ||
| StoredCursor, TranscriptLocation, TranscriptLocationMetadataKeys, append_location_metadata, | ||
| append_tool_calls_metadata, append_usage_metadata, content_storage_text_and_tools, | ||
| path_belongs_to_project, title_from_messages, | ||
| ProjectMembership, ProjectRootMatcherCache, StoredCursor, TranscriptLocation, | ||
| TranscriptLocationMetadataKeys, append_location_metadata, append_tool_calls_metadata, | ||
| append_usage_metadata, content_storage_text_and_tools, title_from_messages, | ||
| }; | ||
| use crate::sessions::source::{ | ||
| ParsedTranscript, SessionDraft, TranscriptSource, read_changed_with_companion, | ||
|
|
@@ -46,6 +46,7 @@ pub struct ClineLikeSource { | |
| provider: &'static str, | ||
| storage_roots: Vec<PathBuf>, | ||
| user_registered_roots: Option<Vec<PathBuf>>, | ||
| project_matchers: ProjectRootMatcherCache, | ||
| } | ||
|
|
||
| impl ClineLikeSource { | ||
|
|
@@ -78,6 +79,7 @@ impl ClineLikeSource { | |
| .join("User/globalStorage/saoudrizwan.claude-dev/tasks"), | ||
| ], | ||
| user_registered_roots: None, | ||
| project_matchers: ProjectRootMatcherCache::default(), | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -89,6 +91,7 @@ impl ClineLikeSource { | |
| .join("User/globalStorage/rooveterinaryinc.roo-cline/tasks"), | ||
| ], | ||
| user_registered_roots: None, | ||
| project_matchers: ProjectRootMatcherCache::default(), | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -101,6 +104,7 @@ impl ClineLikeSource { | |
| home.join(".kilocode/cli/global/tasks"), | ||
| ], | ||
| user_registered_roots: None, | ||
| project_matchers: ProjectRootMatcherCache::default(), | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -137,15 +141,15 @@ impl TranscriptSource for ClineLikeSource { | |
| let metadata = read_task_metadata(task_dir)?; | ||
| let location_cwd = if let Some(roots) = &self.user_registered_roots { | ||
| let paths = metadata_project_paths(&metadata); | ||
| if paths | ||
| .iter() | ||
| .any(|path| roots.iter().any(|root| path_belongs_to_project(path, root))) | ||
| { | ||
| if paths.iter().any(|path| { | ||
| self.project_matchers.membership_against_roots(path, roots) | ||
| != ProjectMembership::NoMatch | ||
| }) { | ||
| return None; | ||
| } | ||
| paths.into_iter().next()? | ||
| } else { | ||
| metadata_project_location(&metadata, project_root)? | ||
| metadata_project_location(&metadata, project_root, &self.project_matchers)? | ||
| }; | ||
|
|
||
| let document: Value = match serde_json::from_str(&changed.contents) { | ||
|
|
@@ -310,10 +314,24 @@ fn read_task_metadata(task_dir: &Path) -> Option<Value> { | |
| None | ||
| } | ||
|
|
||
| fn metadata_project_location(metadata: &Value, project_root: &Path) -> Option<PathBuf> { | ||
| metadata_project_paths(metadata) | ||
| .into_iter() | ||
| .find(|path| path_belongs_to_project(path, project_root)) | ||
| fn metadata_project_location( | ||
| metadata: &Value, | ||
| project_root: &Path, | ||
| project_matchers: &ProjectRootMatcherCache, | ||
| ) -> Option<PathBuf> { | ||
| let mut matched = None; | ||
| for path in metadata_project_paths(metadata) { | ||
| match project_matchers.membership(&path, project_root) { | ||
| ProjectMembership::Match => { | ||
| if matched.is_none() { | ||
| matched = Some(path); | ||
| } | ||
| } | ||
| ProjectMembership::NoMatch => {} | ||
| ProjectMembership::Unknown => return None, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Cline metadata contains both a path that definitively belongs to Useful? React with 👍 / 👎. |
||
| }; | ||
| } | ||
| matched | ||
| } | ||
|
|
||
| fn metadata_project_paths(value: &Value) -> Vec<PathBuf> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing
[workspace]here changes the scope of the subsequentinclude = [...], so Cargo interprets it as the unsupportedworkspace.includekey and the package loses its explicit whitelist. As a result,cargo packageomits the gitignored dashboarddistassets that the whitelist deliberately ships, leaving published builds to attempt an npm rebuild or fail when npm/assets are unavailable; move the workspace table below the package-specific keys.Useful? React with 👍 / 👎.