Repository navigation
[companion] feat: show skill startup diagnostics #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
andrebrait
wants to merge
6
commits into
companion/skill-startup-diagnostics-base
from
feat/skill-startup-diagnostics
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
631be73
feat: show skill startup diagnostics
andrebrait cb98771
feat: dismiss skill startup notices for the session
andrebrait 9fc786c
docs: say the dismissed skill notice returns when its report changes
andrebrait 38c2104
fix: preserve current state and test boundaries after upstream rebase
andrebrait 9dbf567
fix(ui): compact skill warning controls
andrebrait 444e413
fix(ui): restore inline skill warning dismiss button
andrebrait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import "../tests/setup-dom.mjs"; | ||
| import assert from "node:assert/strict"; | ||
| import test, { afterEach } from "node:test"; | ||
| import React from "react"; | ||
| import { cleanup, render, screen, waitFor } from "@testing-library/react/pure.js"; | ||
| import userEvent from "@testing-library/user-event"; | ||
| import { createJiti } from "jiti"; | ||
|
|
||
| const jiti = createJiti(import.meta.url, { jsx: { runtime: "automatic" }, tsconfigPaths: true }); | ||
| const { SkillDiagnosticsDialog, SkillDiagnosticsNotice } = await jiti.import("./SkillDiagnostics.tsx"); | ||
| afterEach(cleanup); | ||
|
|
||
| const snapshot = { | ||
| cwd: "/project", | ||
| showStartupDiagnostics: true, | ||
| diagnostics: [{ | ||
| name: "review", reason: "source-order", | ||
| skills: [ | ||
| { name: "review", filePath: "/first/review/SKILL.md", source: "native:user" }, | ||
| { name: "second/review", filePath: "/second/review/SKILL.md", source: "agents:project" }, | ||
| ], duplicates: [], | ||
| }], | ||
| }; | ||
|
|
||
| test("diagnostic display neutralizes path-spoofing controls without discarding ordinary Unicode", () => { | ||
| const hostile = { | ||
| cwd: "/project\u202E", | ||
| showStartupDiagnostics: true, | ||
| diagnostics: [{ | ||
| name: "調査\u202E", reason: "source-order", | ||
| skills: [{ name: "調査\u202E", filePath: "/技能/\u202Eevil\u0007/SKILL.md", source: "custom:user\u2066", pluginName: "補助\u2069" }], | ||
| duplicates: [{ | ||
| skill: { name: "調査\u202E", filePath: "/mirror\u0085/SKILL.md", source: "custom:user" }, | ||
| retained: { name: "調査\u202E", filePath: "/技能/\u202Eevil\u0007/SKILL.md", source: "custom:user" }, | ||
| }], | ||
| }], | ||
| }; | ||
| render(React.createElement(SkillDiagnosticsDialog, { open: true, onOpenChange: () => {}, snapshot: hostile })); | ||
| const text = screen.getByRole("dialog", { name: "Skill diagnostics" }).textContent; | ||
| assert.doesNotMatch(text, /[\p{Cc}\u202a-\u202e\u2066-\u2069]/u); | ||
| assert.ok(text.includes("/技能/evil/SKILL.md")); | ||
| assert.ok(text.includes("補助")); | ||
| assert.ok(text.includes("調査")); | ||
| }); | ||
|
|
||
| test("losing a diagnostic snapshot closes details instead of reopening them on recovery", async () => { | ||
| const user = userEvent.setup(); | ||
| const props = { snapshot, onDisable: async () => snapshot }; | ||
| const view = render(React.createElement(SkillDiagnosticsNotice, props)); | ||
| await user.click(screen.getByRole("button", { name: "Details" })); | ||
| assert.ok(screen.getByRole("dialog", { name: "Skill diagnostics" })); | ||
| view.rerender(React.createElement(SkillDiagnosticsNotice, { ...props, snapshot: null })); | ||
| view.rerender(React.createElement(SkillDiagnosticsNotice, props)); | ||
| await waitFor(() => assert.equal(screen.queryByRole("dialog", { name: "Skill diagnostics" }) === null, true)); | ||
| assert.ok(screen.getByRole("button", { name: "Details" })); | ||
| }); | ||
|
|
||
| test("dismissing the notice hides that report until the diagnostics change", async () => { | ||
| const user = userEvent.setup(); | ||
| const props = { snapshot, onDisable: async () => snapshot }; | ||
| const view = render(React.createElement(SkillDiagnosticsNotice, props)); | ||
| await user.click(screen.getByRole("button", { name: "Dismiss skill notice" })); | ||
| assert.equal(screen.queryByRole("status"), null); | ||
| view.rerender(React.createElement(SkillDiagnosticsNotice, { ...props, snapshot: structuredClone(snapshot) })); | ||
| assert.equal(screen.queryByRole("status"), null); | ||
| const changed = structuredClone(snapshot); | ||
| changed.diagnostics[0].name = "audit"; | ||
| view.rerender(React.createElement(SkillDiagnosticsNotice, { ...props, snapshot: changed })); | ||
| assert.ok(screen.getByRole("status")); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.