QA chat SSE: no cross-chunk buffer silently drops the metadata frame (sources + confidence)
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- frontend
調査の方向性
apps/web/src/hooks/use-qa-chat.ts から始め、特に 61、68、99-127、152 行付近のストリーム読み取りロジックを確認してください。JSON の途中で分割されたフレーム、CRLF [DONE]、同時送信、abort 動作について、モックしたストリームによるリグレッションテストのカバレッジを追加してください。完了の条件は、メタデータが保持され、終了エラーとパースエラーが目に見える形で処理され、同時送信または中断された送信によって会話の状態が壊れないことです。
索引モデルが issue の本文から書いたものです。
説明
Origin: deferred bucket (d) from the Tier-3 cr-loop review of PR #167 (merged as 55744ca). Flagged independently by four reviewers. Separate subject from that PR, which only swapped this file's fetch for apiFetch.
apps/web/src/hooks/use-qa-chat.ts consumes the /api/qa SSE stream. Four defects, in severity order.
1. No cross-chunk buffer — frames are silently dropped
:99 does chunk.split('\n') per read, with no carry buffer for a partial frame. A ReadableStream read boundary can fall anywhere, so any SSE event split across two reads is parsed as two invalid halves. Both halves land in the empty catch at :127 and vanish.
The event most likely to be split is the largest one — the metadata frame carrying sources and confidence. So the visible symptom is an answer that renders fine but loses its citations, intermittently, with nothing logged. That is the worst possible shape for a bug: it looks like the model just didn't cite anything.
Fix: keep a buffer across reads, split on \n\n, and retain the trailing partial for the next iteration.
2. [DONE] never matches under CRLF
:100-109 compares against [DONE] exactly. With CRLF line endings the token arrives as [DONE]\r, falls through to JSON.parse, and throws — again into the empty catch. Normalise line endings before comparing.
3. The empty catch is what makes 1 and 2 invisible
:127 swallows every parse failure with no logging. Both defects above would be obvious in a single session with any logging at all. Related: #197 — nothing in apps/web uses the structured logger that exists.
4. Concurrent sends corrupt shared state
:68 assigns a new AbortController over the in-flight one without aborting it, so a second send leaves the first stream running and both write the same state. There is also no abort on unmount. Separately, :61 reads conversationHistory from a stale closure, so rapid sends replay incomplete history to the model — and :152 strands the user's message on abort while the error placeholder gets replayed as assistant history.
Test gaps
No coverage for a frame split across chunk boundaries, no CRLF case, no concurrent-send case. A regression test for #1 needs a mocked stream that deliberately splits a frame mid-JSON — worth writing first, since it fails today.
- 主要言語
- TypeScript
- スター
- 13
- フォーク
- 6
- 平均マージ
- 4時間 49分
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CopilotKit/outpost のほかの issue
-
area: docs area: security roadmap: now
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
CopilotKit/outpost#277 ·
-
area: infrastructure roadmap roadmap: later
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
CopilotKit/outpost#179 ·
-
area: ai roadmap roadmap: now
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
CopilotKit/outpost#145 ·
-
area: integrations priority: low roadmap roadmap: later
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
CopilotKit/outpost#124 · コメント 3 件 ·
-
area: integrations priority: low roadmap roadmap: later
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
CopilotKit/outpost#123 · コメント 2 件 ·
CopilotKit/outpost の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
logancyang/obsidian-copilot#3753 ·
メンテナーはふだん 1 日以内に返信
-
area: presentation severity: important
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
voithos-labs/aragonite#763 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
diegosouzapw/OmniRoute#17386 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 72/100
super-productivity/super-productivity#10982 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信