Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ KindPath follows at most ten main-document requests and analyzes only the final

Each destination independently passes public DNS/address validation, destination pinning, verified firewall approval and HTTPS certificate validation. Loading assets is separate from crawling. Source scripts run only in the isolated browser to render the submitted page; captured scripts are never replayed in the app.

The API returns JSON; **Download report JSON** exports the findings, incomplete checks, coverage and limitations without embedding the preview image. Automated results do not establish accessibility conformance. Manual keyboard, screen-reader and usability review is still necessary.
When a scan finishes, select **View report** to move to the results. The API returns JSON. **Download report JSON** near the report heading exports the findings, incomplete checks, coverage and limitations without embedding the preview image. Automated results do not establish accessibility conformance. Manual keyboard, screen-reader and usability review is still necessary.

After five seconds, KindPath can stop unfinished resource loads when the successful main document has fully arrived, its HTML is parsed, and the page has rendered text. Other pages keep the full 15-second loading window. The report is explicitly marked `pageLoadIncomplete: true`, with a partial-coverage notice in the interface and JSON export. An unfinished main document or rejected navigation still fails.

Expand All @@ -43,7 +43,8 @@ A site may return an error, a login/consent page, or different content to the an

Real-page previews use a JPEG rendered in the same isolated visit as the report. This preserves the loaded page's layout, images, fonts, colours and rendered component content without rebuilding its HTML/CSS.

- **Fit width** shows the desktop-width image inside each comparison panel. **Actual size** supports scrolling to inspect small details. Both panels can scroll vertically.
- The vision presets sit above the snapshots. Open **Fine-tune effects** for intensity, colour and individual strengths.
- **Fit width** shows the desktop-width image inside each comparison panel. **Actual size** supports scrolling to inspect small details. Desktop shows both panels. On phones, switch between **Original** and **Simulated** to compare the same scroll position in the captured image.
- The vision buttons offer **Original**, **Protanopia**, **Deuteranopia**, **Tritanopia**, **Blurred vision**, and **Reduced peripheral vision**. The colour dropdown also offers **Grayscale**. The named colour buttons start at 100% strength, and lower settings interpolate between the [Machado model’s published severity matrices](https://pubmed.ncbi.nlm.nih.gov/19834201/). The previews illustrate possible colour differences. Individual vision varies.
- Effects render inside the sandboxed preview document, alongside its image. Changing effects refreshes only the modified document from the stored capture and can reset its scroll position; it does not rescan the website.
- The original panel stays unchanged. Link areas highlight on hover; navigation and form interaction are disabled. Hover highlights do not reproduce a source site's scripted hover behavior. Visible ads are part of the static image.
Expand Down
125 changes: 104 additions & 21 deletions scripts/preview-browser.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scripts/validate-chrome.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ try {
const before = requests;
const input = page.getByLabel("Your website URL");
const entered = args[index + 1];
const previous = await input.inputValue();
const reportsBeforeEdit = await page.locator(".results").count();
await input.fill(entered);
if (previous !== entered) assert.equal(await page.locator(".results").count(), 0);
assert.equal(await page.locator(".results").count(), reportsBeforeEdit);
if (index === 0) await input.press("Enter");
else await page.getByRole("button", { name: "Scan website", exact: true }).click();
await page.locator(".results").waitFor({ state: "detached" });
Expand Down
37 changes: 22 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import type { FormEvent } from 'react';
import { navigationRejection } from '../scanner/gateway/navigation.mjs';
import { websiteUrl } from '../scanner/gateway/url.mjs';
Expand Down Expand Up @@ -40,15 +40,15 @@ export function App() {
const [busy, setBusy] = useState(false);
const [lastAttempt,setLastAttempt] = useState<string | null>(null);
const [cancelled,setCancelled] = useState(false);
const [fieldError, setFieldError] = useState('');
const [failure, setFailure] = useState<ScanFailureFeedback | null>(null);
const [view, setView] = useState<'findings' | 'preview'>('findings');
const results = useRef<HTMLElement>(null);
// Focus only after React has committed the new report and its result element exists.
useLayoutEffect(() => {
if (!report) return;
results.current?.focus();
results.current?.scrollIntoView({ behavior: 'instant', block: 'start' });
}, [report]);
function viewReport() {
results.current?.focus({ preventScroll: true });
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
results.current?.scrollIntoView({ behavior: reduceMotion ? 'instant' : 'smooth', block: 'start' });
}

const analysisRequest = useRef<AbortController | null>(null);
useEffect(() => () => analysisRequest.current?.abort(), []);
Expand All @@ -58,18 +58,24 @@ export function App() {
setBusy(false); setReport(null); setFailure(null); setCancelled(true);
}
function changeUrl(value: string) {
setUrl(value); setReport(null); setFailure(null); setCancelled(false); setLastAttempt(null); setView('findings');
setUrl(value); setFailure(null); setFieldError(''); setCancelled(false); setLastAttempt(null);
}
async function analyze(value: string) {
if (analysisRequest.current || !capabilitiesReady) return;
setFieldError('');
try {
value = websiteUrl(normalizeWebsiteEntry(value)).href;
} catch (cause) {
setFailure(null); setCancelled(false); setLastAttempt(null);
setFieldError(cause instanceof Error ? cause.message : 'Enter a valid public website URL.');
return;
}
const abort = new AbortController();
analysisRequest.current = abort;
setBusy(true); setFailure(null); setReport(null); setView('findings'); setCancelled(false);
setLastAttempt(value);
let timeout: AbortSignal | undefined;
try {
value = websiteUrl(normalizeWebsiteEntry(value)).href;
setLastAttempt(value);
if (!publicEnabled) throw new Error('Website scanning is unavailable.');
timeout = AbortSignal.timeout(90000);
const response = await fetch('/api/scan-public', {
Expand Down Expand Up @@ -134,15 +140,16 @@ export function App() {
</header>
<main id="main" tabIndex={-1}>
<section className="hero" aria-labelledby="landing-title">
<h1 id="landing-title">A clearer web.<br/><em>For everyone.</em></h1>
<div className="hero-copy">
<h1 id="landing-title">A clearer web.<br/><em>For everyone.</em></h1>
<p>Scan a public webpage for accessibility issues and see how it looks with different vision settings.</p>
<WebsiteForm
activity={busy ? 'Checking the page and preparing your report…' : cancelled ? 'Request cancelled. You can try again shortly.' : report ? 'Report ready.' : ''}
reportReady={report !== null} onViewReport={viewReport}
onCancel={cancel} cancelled={cancelled} canRetry={!busy && !!lastAttempt && (failure?.retryable === true || cancelled)}
onRetry={() => { if (lastAttempt) void analyze(lastAttempt); }}
capabilitiesLoading={!capabilitiesReady} publicScanningEnabled={publicEnabled}
url={url} busy={busy} error={failure?.message ?? ''} onUrlChange={changeUrl} onSubmit={submit}
url={url} busy={busy} fieldError={fieldError} scanError={failure?.message ?? ''} onUrlChange={changeUrl} onSubmit={submit}
/>
</div>
<LandingComparison/>
Expand All @@ -156,9 +163,7 @@ export function App() {
</div>
<span className="demo-badge">Automated page scan</span>
</div>
<div className="notice">Automated results for the final scanned page only. Manual review is still required.</div>
{pageNotice && <p className="notice" role="status">{pageNotice}</p>}
<ScanCoverageNotice report={report}/>
<ReportExports key={`${report.scanId}:${report.generatedAt}`} report={report}/>
<div className="view-switch" role="group" aria-label="Report view">
<button aria-pressed={view === 'findings'} onClick={() => setView('findings')}>Accessibility findings <span>{report.findings.length}</span></button>
Expand All @@ -171,11 +176,13 @@ export function App() {
{report.previewUnavailable ? 'The website image could not be captured.' : 'Website image capture is disabled.'} Your accessibility report and JSON download are still available.
</div>}
</div>
<div className="notice">Automated results for the final scanned page only. Manual review is still required.</div>
<ScanCoverageNotice report={report}/>
</section>}
</main>
<footer>
<span>© 2026 Chenhao Wang</span>
<a href="https://github.com/implexrr/KindPath">GitHub repository <span aria-hidden="true">↗</span></a>
<a href="https://github.com/implexrr/KindPath"><span>GitHub repository <span aria-hidden="true">↗</span></span></a>
</footer>
</>;
}
4 changes: 1 addition & 3 deletions src/components/FindingsReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export function FindingsReport({ report }: { report: Report }) {
<p className="finding-status" role="status">Showing {visible.length} of {report.findings.length} {report.mode === 'demo' ? 'example rules' : 'rules with violations'}.</p>
{report.findings.length === 0 ? <p className="findings-empty">No automated violations were reported. This does not establish accessibility conformance; review the checks below and test manually.</p>
: visible.length === 0 ? <p className="findings-empty">No violations match this severity. Other findings are still in this report.</p>
: visible.map((finding, index) => <article className="finding" key={finding.id}>
<div className="finding-number" aria-hidden="true">{String(index + 1).padStart(2, '0')}</div>
: visible.map(finding => <article className="finding" key={finding.id}>
<div>
<span className={`severity ${finding.severity.toLowerCase()}`}>{finding.severity}</span>
<h4>{finding.title}</h4>
Expand All @@ -64,7 +63,6 @@ export function FindingsReport({ report }: { report: Report }) {
<span aria-hidden="true">✳</span>
<h3>People complete<br/>the picture.</h3>
<p>Automated checks are a starting point. Make room for manual review and feedback from disabled people.</p>
{report.scanner && <p>axe-core {report.scanner.engineVersion} · {report.scanner.passedChecks} checks passed. Zero findings would not establish accessibility conformance.</p>}
{report.limitations && <><h4>Scan limitations</h4><ul>{report.limitations.map(limit => <li key={limit}>{limit}</li>)}</ul></>}
<h4>Try these checks</h4>
<ul>{report.manualChecks.map(check => <li key={check}>{check}</li>)}</ul>
Expand Down
5 changes: 2 additions & 3 deletions src/components/ReportExports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ export function ReportExports({ report }: { report: Report }) {
return () => { if (url) URL.revokeObjectURL(url); };
}, [report]);
return <section className="report-exports" aria-labelledby="export-report-title">
<div><h3 id="export-report-title">Take your report with you</h3>
<p id="export-report-note">Both exports include the full report, regardless of the severity filter. Website previews and visual effects are not included.</p>
<p>To save a PDF, choose the PDF destination in your browser’s print dialog. PDF accessibility tagging depends on your browser; JSON preserves the structured report data.</p></div>
<h3 id="export-report-title" className="visually-hidden">Export report</h3>
<div className="report-export-actions">
{download ? <a className="secondary" href={download.url} download={download.filename} aria-describedby="export-report-note">Download report JSON</a>
: <button type="button" className="secondary" disabled>Preparing JSON download…</button>}
<button type="button" className="secondary" aria-describedby="export-report-note" onClick={() => window.print()}>Print / save as PDF</button>
</div>
<p id="export-report-note">Exports include all findings and exclude website previews. For PDF, choose a PDF destination in the print dialog. PDF accessibility tagging varies by browser.</p>
{error && <p role="alert">{error}</p>}
</section>;
}
66 changes: 46 additions & 20 deletions src/components/SiteVisualPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,56 @@
import { useState } from 'react';
import type { CSSProperties } from 'react';
import type { SitePreview } from '../../shared/types';
import { SnapshotFrame } from './SnapshotFrame';
import { VisionControls } from './VisionControls';
import { VisionFineTuning, VisionPresetControls } from './VisionControls';
import { previewTextFeedback } from './sitePreview';
import { defaultVisionSettings } from './visualEffects';
import { activeVisionPreset, defaultVisionSettings, peripheralMask, visionPresets } from './visualEffects';

export function SiteVisualPreview({ snapshot }: { snapshot: SitePreview }) {
const [settings,setSettings] = useState(defaultVisionSettings);
const [actualSize,setActualSize]=useState(false);
const image=snapshot.kind==='image';
const feedback=image?undefined:previewTextFeedback(snapshot.capturedTextCharacters);
const empty=feedback?.kind==='empty';
const [settings, setSettings] = useState(defaultVisionSettings);
const [actualSize, setActualSize] = useState(false);
const [mobileView, setMobileView] = useState<'original' | 'simulated'>('simulated');
const image = snapshot.kind === 'image';
const feedback = image ? undefined : previewTextFeedback(snapshot.capturedTextCharacters);
const empty = feedback?.kind === 'empty';
const preset = activeVisionPreset(settings);
const presetLabel = preset ? visionPresets[preset].name : 'Custom effects';
const {width, height} = snapshot;
const imageDimensions = image && width && height ? {
'--snapshot-width': `${width}px`,
'--snapshot-height': `${height}px`,
'--snapshot-ratio': height / width,
} as CSSProperties : undefined;
const mobileMask = image && mobileView === 'simulated' ? peripheralMask(settings) : undefined;

return <div className="preview-workspace">
<div className="snapshot-source"><div><h3>Scanned website snapshot</h3>
<p>{empty ? 'This capture is linked to the same browser visit as the report for ' : 'This snapshot was captured in the same browser visit as this report. It is a limited visual approximation of '}{snapshot.url}.</p>
<p>Captured at <time dateTime={snapshot.capturedAt}>{new Date(snapshot.capturedAt).toLocaleTimeString()}</time>.{!empty && <> Scroll within each preview to explore the page. This reflects the scan viewport, not a responsive device preview. Run another scan to update both the report and snapshot.</>}</p>
</div></div>
<p className="snapshot-captured">Captured at <time dateTime={snapshot.capturedAt}>{new Date(snapshot.capturedAt).toLocaleTimeString()}</time></p>
{feedback && <section className="notice preview-quality" aria-label="Preview detail"><h4>{feedback.title}</h4><p>{feedback.message}</p></section>}
{image&&<p className="preview-caption"><label>Preview size <select aria-label="Preview size" value={actualSize?'actual':'fit'} onChange={event=>setActualSize(event.target.value==='actual')}><option value="fit">Fit width</option><option value="actual">Actual size — scroll to explore</option></select></label>{snapshot.truncated&&' · Long page: first 6,000 pixels shown.'}</p>}
{!empty && <><VisionControls settings={settings} onChange={setSettings}/>
<div className="comparison">
<div><h3><span className="status-dot"/>Original snapshot</h3><SnapshotFrame snapshot={snapshot} modified={false} settings={settings} actualSize={actualSize}/></div>
<div><h3><span className="status-dot altered"/>{settings.enabled ? 'With visual effects' : 'Effects paused — original appearance'}</h3><SnapshotFrame snapshot={snapshot} modified settings={settings} actualSize={actualSize}/></div>
</div>
<p className="preview-caption">{image?'This is a static image. Links highlight on hover, but navigation and forms are inactive. Visible advertisements are part of the image.':'Links and form controls are inactive. Visible advertisement text is static; embedded advertisements and tracking are omitted.'}</p></>}
<ul aria-label="Website snapshot limitations">{snapshot.limitations.map(text=><li key={text}>{text}</li>)}</ul>
{!empty && <div className="notice">Educational approximations. Vision varies between people; these effects do not reproduce a medical condition or replace accessibility testing.</div>}
{!empty && <>
<VisionPresetControls settings={settings} onChange={value => { setSettings(value); setMobileView('simulated'); }}/>
<div className="preview-toolbar">
<div className="mobile-view-switch" role="group" aria-label="Snapshot view">
<button type="button" className="secondary" aria-pressed={mobileView === 'original'} onClick={() => setMobileView('original')}>Original</button>
<button type="button" className="secondary" aria-pressed={mobileView === 'simulated'} onClick={() => setMobileView('simulated')}>Simulated</button>
</div>
{image && <div className="preview-size">
<label htmlFor="preview-size">Preview size</label>
<select id="preview-size" value={actualSize ? 'actual' : 'fit'} onChange={event => setActualSize(event.target.value === 'actual')}>
<option value="fit">Fit width</option><option value="actual">Actual size</option>
</select>
</div>}
</div>
{image && snapshot.truncated && <p className="preview-caption">Long page: first 6,000 pixels shown.</p>}
<div className={image ? 'snapshot-comparison image-comparison' : 'snapshot-comparison'} data-mobile-view={mobileView} data-actual-size={actualSize} style={imageDimensions}>
<div className="comparison" tabIndex={image ? 0 : undefined} role={image ? 'region' : undefined} aria-label={image ? 'Snapshot images' : undefined}>
<div className="original-pane"><h3><span className="status-dot"/>Original snapshot</h3><SnapshotFrame snapshot={snapshot} modified={false} settings={settings} actualSize={actualSize}/></div>
<div className="simulated-pane"><h3><span className="status-dot altered"/>Simulated preview <span className="active-preset">· {presetLabel}</span></h3><SnapshotFrame snapshot={snapshot} modified settings={settings} actualSize={actualSize}/></div>
</div>
{mobileMask && <div className="field-mask mobile-field-mask" aria-hidden="true" style={mobileMask}/>}
</div>
<VisionFineTuning settings={settings} onChange={value => { setSettings(value); setMobileView('simulated'); }}/>
<p className="preview-caption">{image ? 'This is a static image. Links highlight on hover, but navigation and forms are inactive. Visible advertisements are part of the image.' : 'Links and form controls are inactive. Visible advertisement text is static; embedded advertisements and tracking are omitted.'}</p>
</>}
<ul className="snapshot-limitations" aria-label="Website snapshot limitations">{snapshot.limitations.map(text => <li key={text}>{text}</li>)}</ul>
</div>;
}
Loading
Loading