Skip to content

Commit 1e53d72

Browse files
docs: PR review fixes for api-reference, CONTRIBUTING, and markdown tests
1 parent 62f3eb8 commit 1e53d72

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Useful flags:
5050
pytest -q # full suite + coverage (see pyproject.toml)
5151
pytest tests/test_api_integration.py -v
5252
pytest tests/test_search.py -v
53-
pytest tests/test_api_routes.py -v # when present on branch
53+
pytest tests/test_api_routes.py -v
5454
pytest tests/test_error_codes.py -v
5555
```
5656

docs/api-reference.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Most `/api/*` error responses use this shape:
3131
|----------|--------|------|
3232
| `GET /api/projects/<project_name>/sessions` | 400 | `[]` (empty JSON array) when `project_name` fails path validation |
3333

34+
*Legacy response shape — not the long-term contract. New clients should not treat bare `[]` as the intended error format; migration to structured `{error, code}` with `INVALID_PATH` is planned.*
35+
3436
All other documented error paths below use the structured envelope.
3537

3638
Extra fields may appear for specific codes (for example `since` on invalid bulk-export mode).
@@ -172,7 +174,7 @@ Lists sessions in one project with summary fields for the workspace sidebar. Ski
172174

173175
| Status | `code` | When |
174176
|--------|--------|------|
175-
| 400 || Invalid `project_name` (path escape). **Body is `[]`**, not a structured error — documented behavior |
177+
| 400 || Invalid `project_name` (path escape). **Body is `[]`** (legacy — see [Error envelope](#error-envelope) exception); not a structured error |
176178

177179
```bash
178180
curl -s "http://127.0.0.1:5000/api/projects/F--boost-capy/sessions" | jq '.[0]'
@@ -316,7 +318,7 @@ Read-only snapshot of bulk-export state persisted under `~/.claude-code-chat-bro
316318
|-------|------|-------------|
317319
| `last_export_time` | string \| null | ISO timestamp of last completed bulk export |
318320
| `last_export_session_count` | integer | Sessions in last bulk export run |
319-
| `export_count` | integer | Same as `last_export_session_count` (alias for UI) |
321+
| `export_count` | integer | **Legacy alias** — same value as `last_export_session_count`; prefer `last_export_session_count` in new integrations (kept for SPA backwards compatibility) |
320322

321323
```json
322324
{

static/js/shared/markdown.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
1+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
22
import DOMPurify from 'dompurify';
33
import { marked } from 'marked';
44
import { cleanContent, renderMarkdown } from './markdown.js';
@@ -29,14 +29,20 @@ describe('renderMarkdown', () => {
2929
});
3030

3131
it('sanitizes script tags from parsed output', () => {
32+
const sanitizeSpy = vi.spyOn(DOMPurify, 'sanitize');
3233
const html = renderMarkdown('# Hello\n\n<script>alert(1)</script>');
34+
expect(sanitizeSpy).toHaveBeenCalled();
3335
expect(html).not.toContain('<script');
3436
expect(html).not.toMatch(/alert\s*\(/);
37+
sanitizeSpy.mockRestore();
3538
});
3639

3740
it('strips event handlers from parsed output', () => {
41+
const sanitizeSpy = vi.spyOn(DOMPurify, 'sanitize');
3842
const html = renderMarkdown('<img src=x onerror=alert(1)>');
43+
expect(sanitizeSpy).toHaveBeenCalled();
3944
expect(html).not.toMatch(/onerror/i);
45+
sanitizeSpy.mockRestore();
4046
});
4147

4248
it('falls back to inline code when marked is unavailable', () => {

0 commit comments

Comments
 (0)