Skip to content

Fixing broken link on plugin modal#1162

Merged
aaronpowell merged 1 commit intostagedfrom
1149-website-failed-to-load-file-content
Mar 24, 2026
Merged

Fixing broken link on plugin modal#1162
aaronpowell merged 1 commit intostagedfrom
1149-website-failed-to-load-file-content

Conversation

@aaronpowell
Copy link
Contributor

Plugins don't contain the proper paths, so have to account for that in the modal.

Fixes #1149

Copilot AI review requested due to automatic review settings March 24, 2026 22:39
@aaronpowell aaronpowell linked an issue Mar 24, 2026 that may be closed by this pull request
@aaronpowell aaronpowell merged commit 2528c0e into staged Mar 24, 2026
7 checks passed
@aaronpowell aaronpowell deleted the 1149-website-failed-to-load-file-content branch March 24, 2026 22:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the website plugin modal’s item click handling so plugin item paths (which are stored as directories or generic .md references) map to actual repository files when opening the file viewer modal, addressing the “Failed to load file content” error described in #1149.

Changes:

  • Adjust agent item paths to open .agent.md files instead of .md.
  • Adjust skill item paths to open SKILL.md within the skill directory.

Comment on lines +1183 to 1197
let path = (el as HTMLElement).dataset.path;
const itemType = (el as HTMLElement).dataset.type;

switch (itemType) {
case "agent":
path = path.replace(".md", ".agent.md");
break;
case "skill":
path = `${path}/SKILL.md`;
break;
}

if (path && itemType) {
openFileModal(path, itemType);
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path comes from dataset.path (string | undefined), but it’s used in path.replace(...) / template interpolation before the if (path && itemType) guard. If the attribute is missing (or empty), this will throw at runtime. Consider returning early when either path or itemType is falsy, or guarding inside each case before mutating path.

Suggested change
let path = (el as HTMLElement).dataset.path;
const itemType = (el as HTMLElement).dataset.type;
switch (itemType) {
case "agent":
path = path.replace(".md", ".agent.md");
break;
case "skill":
path = `${path}/SKILL.md`;
break;
}
if (path && itemType) {
openFileModal(path, itemType);
}
const { path, type: itemType } = (el as HTMLElement).dataset;
// Ensure we have both a path and an item type before proceeding
if (!path || !itemType) {
return;
}
let resolvedPath = path;
switch (itemType) {
case "agent":
resolvedPath = resolvedPath.replace(".md", ".agent.md");
break;
case "skill":
resolvedPath = `${resolvedPath}/SKILL.md`;
break;
}
openFileModal(resolvedPath, itemType);

Copilot uses AI. Check for mistakes.
Comment on lines +1183 to +1190
let path = (el as HTMLElement).dataset.path;
const itemType = (el as HTMLElement).dataset.type;

switch (itemType) {
case "agent":
path = path.replace(".md", ".agent.md");
break;
case "skill":
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path munging here doesn’t account for how plugin.json entries are formatted in this repo (they commonly start with ./ and skills often end with a trailing /). As written, skills can become ...//SKILL.md, and the leading ./ prevents matching entries in skills.json/agents.json (e.g., for titles / skill file switcher lookups). Normalize the plugin item path first (strip a leading ./ and any trailing /) and, for agents, replace only a .md suffix (and avoid rewriting paths that are already .agent.md).

Suggested change
let path = (el as HTMLElement).dataset.path;
const itemType = (el as HTMLElement).dataset.type;
switch (itemType) {
case "agent":
path = path.replace(".md", ".agent.md");
break;
case "skill":
const rawPath = (el as HTMLElement).dataset.path || "";
const itemType = (el as HTMLElement).dataset.type;
// Normalize plugin item path:
// - strip leading "./"
// - strip any trailing slashes
let path = rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
switch (itemType) {
case "agent":
// For agents, replace only a final ".md" with ".agent.md",
// and avoid rewriting paths that are already ".agent.md".
if (!/\.agent\.md$/i.test(path)) {
path = path.replace(/\.md$/i, ".agent.md");
}
break;
case "skill":
// For skills, point to the SKILL.md file inside the folder.

Copilot uses AI. Check for mistakes.
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.

[website] Failed to load file content.

2 participants