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:
cliffhall 2026-09-06 00:15:27 -04:00
commit 418448edc3

View file

@ -864,15 +864,27 @@ export function SkillsScreen({
// One effective MIME for the displayed file, inferred the same way the
// Resources screen infers one: servers routinely omit `mimeType` or answer a
// generic `text/plain`, and the URI suffix is the better signal.
const previewMime = useMemo(
() =>
// Whether the viewer is showing the skill's OWN SKILL.md. Compared by
// identity, like every other URI comparison here.
const showingSkillMd =
previewUri !== undefined &&
selectedUri !== undefined &&
skillUriIdentity(previewUri) === skillUriIdentity(selectedUri);
const previewMime = useMemo(() => {
const stated =
preview?.mimeType ??
(previewUri !== undefined ? inferMimeFromUri(previewUri) : undefined) ??
// Skill files are markdown by construction under SEP-2640, so that is the
// right last resort here rather than octet-stream.
"text/markdown",
[preview, previewUri],
);
(previewUri !== undefined ? inferMimeFromUri(previewUri) : undefined);
if (stated !== undefined) return stated;
// Markdown is the right last resort for a skill's OWN `SKILL.md` — SEP-2640
// makes that file markdown by construction. It is the WRONG one for the
// rest of a manifest, which the SEP expects to carry supporting scripts,
// examples and assets with types of their own: an extensionless, untyped
// blob would be decoded and rendered as markdown rather than falling back
// to binary. `undefined` here hands the decision to `ContentViewer`, whose
// own default is octet-stream for a blob and a text heuristic for text.
return showingSkillMd ? "text/markdown" : undefined;
}, [preview, previewUri, showingSkillMd]);
// The displayed file, split once into frontmatter and body. BOTH halves of
// the pane read from this single split, which is what keeps them honest: the
@ -924,7 +936,10 @@ export function SkillsScreen({
//
// Covers a size disagreement as well as a digest one: `verifySkillResource`
// reports both as `mismatch`, the size check simply being the cheaper one
// that runs first.
// that runs first. The badge is therefore labelled "mismatch(es)" rather than
// "digest mismatch(es)" — counting a size failure under a digest label would
// misreport it, and dropping it from the count would hide a real failure.
// The alerts below still distinguish the two by title.
const mismatchCount = Object.values(fileStates).filter(
(state) =>
state.status === "done" && state.verification.status === "mismatch",
@ -1088,7 +1103,7 @@ export function SkillsScreen({
verified result before anything had been checked. */}
{mismatchCount > 0 && (
<CountBadge color="red">
{mismatchCount} digest mismatch(es)
{mismatchCount} mismatch(es)
</CountBadge>
)}
</InlineRow>