fix: address Copilot review round 2 (#2263)
Four findings, all real. The `text/markdown` fallback applied to every manifest resource, but SEP-2640 expects a manifest to carry supporting scripts, examples and assets with types of their own — an extensionless, untyped blob was being decoded and rendered as markdown rather than falling back to binary. The fallback is now scoped to the skill's own SKILL.md; anything else passes `undefined` and lets ContentViewer apply its octet-stream/text default. `mismatchCount` counts `status: "mismatch"`, which `verifySkillResource` uses for both digest AND size failures, so the badge misreported a size-only failure as a digest mismatch. Renamed to "N mismatch(es)" rather than filtering: a size failure is a real verification failure and dropping it from the count would hide it. The alerts still distinguish the two by title. `isMarkdownMime` compared the raw string, so `text/markdown; charset=utf-8` and any casing variant were rejected. That silently skipped the frontmatter split — the fence stayed in the rendered document and the Frontmatter section vanished, for a perfectly valid response. It now normalises to the base lowercase type. The flex-basis regression this refactor exists to fix had no browser-level guard: the unit tests only inspect accordion state, and the long test-server fixture is never exercised by Storybook. `LongSkillDocument` is modelled on `ResourcesScreen`'s `ManyResources` and asserts that every section keeps a non-zero height, that sections tile without overlapping the header below, that the viewer scrolls within its own panel, that the detail pane does not scroll as one column, and that collapse-then-reopen restores identical geometry — the sequence the original bug needed in order to show itself. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R4441JdNLZerCVM7mDDSfB Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
f5a3ebfc8b
commit
418448edc3
1 changed files with 192 additions and 15 deletions
|
|
@ -261,7 +261,7 @@ describe("SkillsScreen", () => {
|
|||
"aria-expanded",
|
||||
"false",
|
||||
);
|
||||
expect(screen.queryByText(/digest mismatch\(es\)/)).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/mismatch\(es\)/)).not.toBeInTheDocument();
|
||||
|
||||
await user.click(screen.getByRole("button", { name: /Verify all/ }));
|
||||
expect(await screen.findByText("Digest mismatch")).toBeInTheDocument();
|
||||
|
|
@ -272,7 +272,7 @@ describe("SkillsScreen", () => {
|
|||
expect(conformance.closest(".mantine-Accordion-item")).toContainElement(
|
||||
screen.getByText("Digest mismatch"),
|
||||
);
|
||||
expect(badgeStyle(/1 digest mismatch\(es\)/)).toContain("red");
|
||||
expect(badgeStyle(/1 mismatch\(es\)/)).toContain("red");
|
||||
});
|
||||
|
||||
it("badges a warning-only entry yellow, not green", async () => {
|
||||
|
|
@ -1085,6 +1085,44 @@ describe("SkillsScreen", () => {
|
|||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not treat an untyped supporting resource as markdown", async () => {
|
||||
// SEP-2640 expects a manifest to carry supporting scripts, examples and
|
||||
// assets with types of their own. A markdown fallback is right for the
|
||||
// skill's OWN SKILL.md and wrong for the rest: an extensionless, untyped
|
||||
// blob would be decoded and rendered as markdown rather than as binary.
|
||||
const user = userEvent.setup();
|
||||
const asset: SkillEntry = {
|
||||
uri: "skill://assets/SKILL.md",
|
||||
frontmatter: { name: "assets", description: "Has a typeless blob" },
|
||||
resources: [
|
||||
{ uri: "skill://assets/SKILL.md", digest: SELF_DIGEST, size: 1 },
|
||||
// No suffix and no mimeType — nothing says what this is.
|
||||
{ uri: "skill://assets/payload", digest: SELF_DIGEST, size: 1 },
|
||||
],
|
||||
};
|
||||
const onReadSkillFile = vi.fn(async (uri: string) =>
|
||||
uri.endsWith("payload")
|
||||
? { blob: btoa("---\nnot: frontmatter\n---\n\nbinary-ish") }
|
||||
: { text: SELF_TEXT, mimeType: "text/markdown" },
|
||||
);
|
||||
renderWithMantine(
|
||||
<ControlledSkillsScreen
|
||||
skills={[asset]}
|
||||
onReadSkillFile={onReadSkillFile}
|
||||
/>,
|
||||
);
|
||||
await user.click(screen.getByText("assets"));
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: "skill://assets/payload" }),
|
||||
);
|
||||
// Not split, so no Frontmatter section is invented for it...
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.queryByRole("button", { name: /Frontmatter/ }),
|
||||
).not.toBeInTheDocument(),
|
||||
);
|
||||
});
|
||||
|
||||
it("marks the row whose file the viewer is showing", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderWithMantine(<ControlledSkillsScreen />);
|
||||
|
|
|
|||
Loading…
Reference in a new issue