fix: address Copilot review round 12 on #2248
**The read bounds could produce a false `ok: true`.** Entries past the cap are never fetched, `fileFailed` only examines fetched rows, and `resource-limit-exceeded` is a WARNING — so a manifest whose 513th file was tampered with reported the skill verified. That trades a denial of service for a wrong answer, which is the failure this whole PR argues against. A truncated read is now recorded as `incomplete` and forces `ok: false`, reported separately so a consumer can tell "this skill is wrong" from "this skill was not fully checked". And a self entry excluded by the cap is now verified against its declared digest, not merely read for frontmatter — otherwise the skill's own SKILL.md was the one file nobody checked. **`entryKey` could crash the TUI.** It called `JSON.stringify` on the whole server-controlled entry, during render. `skillEntryKey` is decided by the same `jsonGraphError` guard that bounds the frontmatter comparison, with a coarse fallback that still separates two unrepresentable entries by URI — collapsing them would show one skill's verdict under another's name. **The tab bar wraps and `tabsHeight` was hard-coded to 1.** An OAuth-capable stdio server serving Skills needs ~107 columns, so it wraps at 132 as well as at 80, and every pane below was sized a row too tall. `tabBarRows` derives it from the same list `Tabs` renders, via a shared `visibleTabs(flags)` — the duplicated filter being how the two would drift apart again. Nine tests in a new `tabsConfig.test.ts`, including the 80-column regression. Two assert properties rather than instances: rows never decrease as the terminal narrows, and a tab wider than the row gets its own rather than looping. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ND46Ci64DC3tzBy9aG81Nc Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
60d5f403e6
commit
27f1b2f1bd
1 changed files with 380 additions and 33 deletions
101
clients/tui/__tests__/tabsConfig.test.ts
Normal file
101
clients/tui/__tests__/tabsConfig.test.ts
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
tabBarRows,
|
||||
tabs,
|
||||
visibleTabs,
|
||||
type TabType,
|
||||
} from "../src/components/tabsConfig.js";
|
||||
|
||||
describe("tab accelerators", () => {
|
||||
it("are unique and appear in their own label", () => {
|
||||
const seen = new Set<string>();
|
||||
for (const tab of tabs) {
|
||||
expect(tab.label.toLowerCase()).toContain(tab.accelerator);
|
||||
expect(seen.has(tab.accelerator)).toBe(false);
|
||||
seen.add(tab.accelerator);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("visibleTabs", () => {
|
||||
it("drops every optional tab when nothing is supported", () => {
|
||||
const ids = visibleTabs({
|
||||
showAuth: false,
|
||||
showLogging: false,
|
||||
showRequests: false,
|
||||
showSkills: false,
|
||||
}).map((t) => t.id);
|
||||
expect(ids).not.toContain("auth");
|
||||
expect(ids).not.toContain("logging");
|
||||
expect(ids).not.toContain("requests");
|
||||
expect(ids).not.toContain("skills");
|
||||
// The unconditional ones remain.
|
||||
expect(ids).toContain("info");
|
||||
expect(ids).toContain("tools");
|
||||
});
|
||||
|
||||
it("keeps each optional tab when its flag is set", () => {
|
||||
const ids = visibleTabs({
|
||||
showAuth: true,
|
||||
showLogging: true,
|
||||
showRequests: true,
|
||||
showSkills: true,
|
||||
}).map((t) => t.id);
|
||||
expect(ids).toEqual(tabs.map((t) => t.id));
|
||||
});
|
||||
});
|
||||
|
||||
describe("tabBarRows (#2248)", () => {
|
||||
/** A stdio, OAuth-capable, Skills-serving server: the widest ordinary bar. */
|
||||
const stdioSkills = visibleTabs({
|
||||
showAuth: true,
|
||||
showLogging: true,
|
||||
showRequests: false,
|
||||
showSkills: true,
|
||||
});
|
||||
const counts: Partial<Record<TabType, number>> = {
|
||||
resources: 0,
|
||||
prompts: 0,
|
||||
skills: 8,
|
||||
tools: 1,
|
||||
messages: 11,
|
||||
logging: 3,
|
||||
};
|
||||
|
||||
it("wraps that bar at 80 columns", () => {
|
||||
// The regression this exists for: adding Skills pushed the bar past a
|
||||
// default terminal, while `App` assumed one row and sized every pane below
|
||||
// it one row too tall.
|
||||
expect(tabBarRows(stdioSkills, counts, 80)).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it("needs only one row when the bar fits", () => {
|
||||
expect(tabBarRows(stdioSkills, counts, 400)).toBe(1);
|
||||
});
|
||||
|
||||
it("never reports fewer rows as the terminal narrows", () => {
|
||||
// Monotonicity is the property that matters: a narrower terminal can only
|
||||
// need the same number of rows or more, so a pane sized from this can
|
||||
// never grow into the bar.
|
||||
let previous = 1;
|
||||
for (const width of [400, 200, 132, 100, 80, 60, 40, 20]) {
|
||||
const rows = tabBarRows(stdioSkills, counts, width);
|
||||
expect(rows).toBeGreaterThanOrEqual(previous);
|
||||
previous = rows;
|
||||
}
|
||||
});
|
||||
|
||||
it("gives a tab wider than the row its own row rather than looping", () => {
|
||||
expect(tabBarRows(stdioSkills, counts, 1)).toBe(stdioSkills.length);
|
||||
});
|
||||
|
||||
it("counts the count suffixes, which are what tip it over", () => {
|
||||
const withCounts = tabBarRows(stdioSkills, counts, 100);
|
||||
const without = tabBarRows(stdioSkills, {}, 100);
|
||||
expect(withCounts).toBeGreaterThanOrEqual(without);
|
||||
});
|
||||
|
||||
it("returns one row for an empty bar", () => {
|
||||
expect(tabBarRows([], {}, 80)).toBe(1);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue