Skip to content

Add client-side Server-Sent Events parser#288

Merged
JE-Chen merged 1 commit into
devfrom
feat/sse-client-batch
Jun 21, 2026
Merged

Add client-side Server-Sent Events parser#288
JE-Chen merged 1 commit into
devfrom
feat/sse-client-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

Adds a client-side SSE (text/event-stream) parser. The MCP HTTP transport emits SSE, but nothing consumed it — a streaming LLM/agent/chatops endpoint left http_request with a raw, unparsed blob.

  • SSEParser.feed(chunk) — incremental WHATWG event-stream parsing; buffers partial trailing lines across calls; returns events completed by a blank line. close() flushes a final event when the stream ends without one.
  • parse_event_stream(text) — one-shot for a complete blob (flushes the trailing event).
  • SSEEvent(event, data, id, retry)event defaults to "message"; id/retry persist across events per spec.

Handles comments (:), the single leading-space rule, multi-line data, and CR/LF/CRLF line endings.

Layers

  • Headless core: utils/sse_client/ (pure stdlib re, zero PySide6).
  • Facade: 3 symbols + __all__.
  • Executor: AC_parse_sse.
  • MCP: ac_parse_sse (read-only).
  • Script Builder: under Data.
  • Tests: test/unit_test/headless/test_sse_client_batch.py (11 tests, no Qt/network).
  • Docs: v80_features_doc.rst (EN + Zh) + toctrees + 3 README What's-new sections.

Verification

  • pytest test/unit_test/headless/test_sse_client_batch.py → 11 passed.
  • ruff check je_auto_control/ clean; pylint 10.00/10; bandit clean; radon CC clean.
  • Package stays Qt-free.

The MCP HTTP transport emits SSE, but nothing consumed it: a streaming
text/event-stream endpoint left http_request with a raw blob. Add a
WHATWG event-stream parser (event/data/id/retry, comments, leading-space
rule, blank-line dispatch) with incremental feed for chunks and a
one-shot parse_event_stream. Wired through facade, executor
(AC_parse_sse), MCP, and the Script Builder with a headless test batch
and EN/Zh docs.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 45 complexity · 0 duplication

Metric Results
Complexity 45
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 35c53ba into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/sse-client-batch branch June 21, 2026 14:42
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant