Skip to content

Commit 492b551

Browse files
committed
Improve skill folder opening logic in SkillSplitView
Enhanced the logic for determining the correct folder URL to open for a selected skill, adding more robust matching and a fallback path. This ensures the correct folder is opened even in edge cases where skill attributes or custom paths differ.
1 parent 70dfcc9 commit 492b551

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Sources/CodexSkillManager/Skills/SkillSplitView.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,24 @@ struct SkillSplitView: View {
210210

211211
private func openSelectedSkillFolder(platform: SkillPlatform?) {
212212
guard source == .local else { return }
213+
let fallbackURL = FileManager.default.homeDirectoryForCurrentUser
214+
.appendingPathComponent(".codex/skills/public")
215+
let selected = store.selectedSkill
213216
let url: URL
214-
if let platform, let slug = store.selectedSkill?.name {
215-
url = platform.rootURL.appendingPathComponent(slug)
217+
if let platform, let slug = selected?.name {
218+
if let selected, selected.platform == platform {
219+
url = selected.folderURL
220+
} else if let match = store.skills.first(where: {
221+
$0.name == slug && $0.platform == platform && $0.customPath == selected?.customPath
222+
}) {
223+
url = match.folderURL
224+
} else if let match = store.skills.first(where: { $0.name == slug && $0.platform == platform }) {
225+
url = match.folderURL
226+
} else {
227+
url = platform.rootURL.appendingPathComponent(slug)
228+
}
216229
} else {
217-
url = store.selectedSkill?.folderURL
218-
?? FileManager.default.homeDirectoryForCurrentUser
219-
.appendingPathComponent(".codex/skills/public")
230+
url = selected?.folderURL ?? fallbackURL
220231
}
221232
NSWorkspace.shared.open(url)
222233
}

0 commit comments

Comments
 (0)