Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/webview-accessibility-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Support accessibility regression checks and assistive-technology testing for VS Code webviews.
3 changes: 2 additions & 1 deletion .github/workflows/visual-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- "packages/kilo-vscode/.storybook/**"
- "packages/kilo-vscode/tests/visual-regression*"
- "packages/kilo-vscode/tests/permission-dock-dropdown*"
- "packages/kilo-vscode/tests/accessibility*"
- "packages/kilo-docs/public/img/screenshot-tests/**"
- ".github/workflows/visual-regression.yml"
- name: Check if PR is from a fork
Expand Down Expand Up @@ -277,7 +278,7 @@ jobs:
run: bun run build-storybook
working-directory: packages/kilo-vscode

- name: Generate baselines for new/missing stories
- name: Generate baselines and enforce webview accessibility checks
run: bun run test:visual:update
working-directory: packages/kilo-vscode
env:
Expand Down
6 changes: 6 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/kilo-vscode/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import solidPlugin from "vite-plugin-solid"
const config: StorybookConfig = {
framework: "storybook-solidjs-vite",
stories: ["../webview-ui/src/stories/**/*.stories.@(ts|tsx)"],
addons: ["@storybook/addon-docs"],
addons: ["@storybook/addon-docs", "@storybook/addon-a11y"],
staticDirs: [{ from: "../assets/icons", to: "/icons" }],
refs: {},
viteFinal: async (config) => {
Expand Down
1 change: 1 addition & 0 deletions packages/kilo-vscode/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const preview: Preview = {
theme: "kilo-vscode",
colorScheme: "dark",
vscodeTheme: "dark-modern",
a11y: { manual: true },
},
}

Expand Down
3 changes: 3 additions & 0 deletions packages/kilo-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1015,14 +1015,17 @@
"rebuild-sdk": "bun run --cwd ../sdk/js build",
"storybook": "storybook dev -p 6007",
"build-storybook": "storybook build -o storybook-static",
"test:a11y": "playwright test tests/accessibility.spec.ts",
"test:visual": "playwright test",
"test:visual:update": "playwright test --update-snapshots",
"snapshot:build": "bun script/dev-snapshot.ts build",
"snapshot:install": "bun script/dev-snapshot.ts install",
"extension": "bun script/launch.ts"
},
"devDependencies": {
"@axe-core/playwright": "4.11.3",
"@playwright/test": "1.57.0",
"@storybook/addon-a11y": "10.2.10",
"@storybook/addon-docs": "10.2.10",
"@types/diff": "^6.0.0",
"@types/mocha": "^10.0.10",
Expand Down
10 changes: 7 additions & 3 deletions packages/kilo-vscode/script/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* --wait Block until the VS Code window is closed
* --clean Wipe the user-data and extensions dirs before launching
* --preserve-settings Merge defaults into existing VS Code user settings
* --accessible Enable VS Code accessibility support for assistive-technology testing
*
* Environment:
* VSCODE_EXEC_PATH Path to VS Code executable (same as --app-path)
Expand Down Expand Up @@ -86,6 +87,7 @@ const explicit = opts["app-path"] as string | undefined
const blocking = opts["wait"] === true
const clean = opts["clean"] === true
const preserve = opts["preserve-settings"] === true
const accessible = opts["accessible"] === true

// ---------------------------------------------------------------------------
// VS Code executable detection
Expand Down Expand Up @@ -251,11 +253,11 @@ async function installVsix(path: string, app: string) {
// Settings for isolated instance
// ---------------------------------------------------------------------------

function settings(keep: boolean) {
function settings(keep: boolean, enabled: boolean) {
const dir = join(userDir, "User")
const file = join(dir, "settings.json")
const defaults = {
"editor.accessibilitySupport": "off",
"editor.accessibilitySupport": enabled ? "on" : "off",
"extensions.autoCheckUpdates": false,
"extensions.autoUpdate": false,
"extensions.ignoreRecommendations": true,
Expand All @@ -270,6 +272,7 @@ function settings(keep: boolean) {

mkdirSync(dir, { recursive: true })
const cfg = keep && existsSync(file) ? { ...defaults, ...load(file) } : defaults
if (enabled) cfg["editor.accessibilitySupport"] = "on"
Comment thread
marius-kilocode marked this conversation as resolved.
Resolved

writeFileSync(file, JSON.stringify(cfg, null, 2) + "\n")
}
Expand Down Expand Up @@ -306,7 +309,7 @@ async function launch() {

const app = detect()

settings(preserve)
settings(preserve, accessible)

const args = [workspace, `--extensions-dir=${extDir}`, `--user-data-dir=${userDir}`, "--skip-release-notes"]

Expand Down Expand Up @@ -338,6 +341,7 @@ async function launch() {
console.log(`[launch] Executable: ${app}`)
console.log(`[launch] Workspace: ${workspace}`)
console.log(`[launch] State: ${base}`)
console.log(`[launch] Accessibility support: ${accessible ? "on" : "off"}`)

if (blocking) {
const result = Bun.spawnSync([app, ...args], {
Expand Down
57 changes: 57 additions & 0 deletions packages/kilo-vscode/tests/accessibility.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import AxeBuilder from "@axe-core/playwright"
import { expect, test, type Page } from "@playwright/test"

const GLOBALS = "colorScheme:dark;theme:kilo-vscode;vscodeTheme:dark-modern"
const RULES = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22a", "wcag22aa"]

// Explicitly ratchet in repaired/stable workflows rather than making existing
// untriaged Storybook findings block unrelated webview changes.
const STORIES = [
{ id: "profile--not-logged-in", name: "Profile / not logged in" },
{ id: "profile--logged-in-personal", name: "Profile / personal account" },
{ id: "profile--logged-in", name: "Profile / organization account" },
{ id: "settings--providers-configure", name: "Settings / providers empty state" },
{ id: "marketplace--skills-tab-empty", name: "Marketplace / skills empty state" },
{ id: "marketplace--agents-tab-empty", name: "Marketplace / agents empty state" },
]

function url(id: string) {
return `/iframe.html?id=${id}&viewMode=story&globals=${GLOBALS}`
}

async function open(page: Page, id: string) {
await page.goto(url(id), { waitUntil: "load" })
await page.waitForSelector("#storybook-root *", { state: "attached" })
}

async function scan(page: Page) {
const result = await new AxeBuilder({ page }).include("#storybook-root").withTags(RULES).analyze()
const details = result.violations
.map((item) => `${item.id}: ${item.help}\n${item.nodes.map((node) => ` ${node.target.join(" ")}`).join("\n")}`)
.join("\n")

expect(result.violations, details).toEqual([])
}

test.describe("webview accessibility ratchet", () => {
for (const story of STORIES) {
test(`${story.name} passes automated WCAG checks`, async ({ page }) => {
await open(page, story.id)
await scan(page)
})
}

test("Profile login exposes a keyboard-operable named control", async ({ page }) => {
await open(page, "profile--not-logged-in")

const login = page.getByRole("button", { name: "Login with Kilo Code" })
await page.keyboard.press("Tab")
Comment thread
marius-kilocode marked this conversation as resolved.
Resolved
await expect(login).toBeFocused()

await login.evaluate((node) => {
node.addEventListener("click", () => node.setAttribute("data-keyboard-activated", "true"), { once: true })
})
await page.keyboard.press("Enter")
await expect(login).toHaveAttribute("data-keyboard-activated", "true")
})
})
Loading