Skip to content

Commit de7fb16

Browse files
committed
feat: add schema version to diagnostics exports for replay compatibility
1 parent 645d082 commit de7fb16

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ All notable changes to ScriptHunt will be documented in this file.
2121
- Versioned preference storage (schema v2) with automatic migration on load. "Reset Preferences" button in diagnostics clears preferences, source health, caches, and saved searches without deleting favorites or installed scripts. Preference schema version appears in diagnostics export.
2222
- Accessibility regression tests for diagnostics popover (Escape close), saved searches popover visibility, and mobile viewport (375px) verifying no clipped primary controls.
2323
- GitHub rate-limit status now shows searches remaining, budget fraction, reset time, result cap (1,000), and whether code search is enabled (token vs. no-token).
24+
- Diagnostics exports now include `schema: "scripthunt-diagnostics"` and `schemaVersion: 1` for future replay/migration, plus preference schema diagnostics.
2425

2526
## [v0.4.1]
2627

ROADMAP.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
Acceptance: imports recognize ScriptHunt JSON plus at least two manager-style backup shapes via fixtures, show a preview with valid/invalid/skipped counts before committing, preserve include/exclude/update metadata where present, and never import executable code into storage.
1010
Complexity: L
1111

12-
- [ ] P2 - Add diagnostics snapshot replay fixtures
13-
Why: Source/proxy failures are currently copyable but not replayable, making reported failures harder to turn into deterministic regressions without secrets.
14-
Evidence: `index.html:3498`, `tests/adapter.spec.js:136`, Violentmonkey#2263, ScriptCat#1476.
15-
Touches: `index.html` diagnostics schema/sanitizer, `tests/smoke.spec.js`, `tests/fixtures/source-adapters.js`, README diagnostics notes.
16-
Acceptance: diagnostics exports include a schema version and sanitized replay section; a local fixture/test can load a diagnostics snapshot to recreate source status/rate-limit/proxy/cache states; tokens and custom proxy URLs remain redacted.
17-
Complexity: M
1812

1913
## P3
2014

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,6 +3643,8 @@ <h3>Search userscripts everywhere</h3>
36433643

36443644
function buildDiagnosticsPayload() {
36453645
return {
3646+
schema: 'scripthunt-diagnostics',
3647+
schemaVersion: 1,
36463648
app: 'ScriptHunt',
36473649
version: document.querySelector('.version').textContent,
36483650
generatedAt: new Date().toISOString(),

tests/smoke.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,13 @@ test('diagnostics export includes health and excludes secrets', async ({ page })
965965
const payloadText = await page.locator('#diagnosticsOutput').inputValue();
966966
const payload = JSON.parse(payloadText);
967967

968+
expect(payload.schema).toBe('scripthunt-diagnostics');
969+
expect(payload.schemaVersion).toBe(1);
968970
expect(payload.app).toBe('ScriptHunt');
969971
expect(payload.sources.length).toBeGreaterThan(0);
970972
expect(payload.proxyHealth).toBeTruthy();
973+
expect(payload.preferences).toBeTruthy();
974+
expect(payload.preferences.schemaVersion).toBeGreaterThan(0);
971975
expect(payloadText).not.toContain('ghp_secret_should_not_export');
972976
expect(payloadText).not.toContain('secret-proxy.example');
973977
expect(payload.customProxyConfigured).toBe(false);

0 commit comments

Comments
 (0)