fix(streaming): polling 稼働中の connect が WebSocket を復活させないようにする - #59
Conversation
Release v0.8.0
Release v0.8.1
フロントはカラムのマウントや復帰のたびに stream_connect を無条件に呼ぶため、
polling モード中でも WS 接続が黙って張り直されていた (notedeck#1004)。
connect の意味を「ストリームを現在のモードで確保する」に揃え、polling が
供給中なら Connected を emit して即 return する。WS へ戻す唯一の経路は
set_mode("realtime")。
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough
ChangesPolling connection guard
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/streaming.rs`:
- Around line 483-487: Update the Connected status path to dispatch the
StreamEvent::Status through EventBus as well as self.emitter by using the
existing emit_both helper with the relevant emitter and event_bus references,
ensuring SSE and event-bus consumers receive the status.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| self.emitter | ||
| .emit(StreamEvent::Status(Box::new(StreamStatusEvent { | ||
| account_id: account_id.to_string(), | ||
| state: StreamConnectionState::Connected, | ||
| }))); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
ast-grep outline src/streaming.rs --items all --match 'StreamingManager|EventBus'
fd -i '^event_bus\.rs$' . -x ast-grep outline {} --items all
rg -n -C 4 --glob '*.rs' 'StreamEvent::Status|StreamStatusEvent|EventBus|FrontendEmitter' .Repository: notedeck-dev/notecli
Length of output: 24227
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Read focused streaming/event_bus/server sections and run read-only behavioral checks.
sed -n '1,90p' src/streaming.rs
sed -n '440,700p' src/streaming.rs
sed -n '1720,1940p' src/streaming.rs
sed -n '720,815p' src/http_server.rs
rg -n --glob '*.rs' 'stream-status|s:.*stream-status|sse_event_type|payload_value|event_bus\.send|EventBusEmitter|StreamStatusEvent' .
python3 - <<'PY'
from pathlib import Path
import re
p=Path('src/streaming.rs')
s=p.read_text()
checks={
'line483_emitter_status': bool(re.search(r'(?ms)$', re.sub(r'//.*','',s)[460:490] )), # placeholder
'emit_both_contains_polling_capture_comment': 'status / polling 由来 capture は従来どおり emitter のみ' in s,
'event_bus_send_is_sse_json_payload': 'let data = serde_json::to_string(&event)?' in p.read_text(),
'status_event_type': 'stream-status' in s and 'Status(Box<StreamStatusEvent>)' in s,
}
for k,v in checks.items():
print(f'{k}={v}')
PY
PYRepository: notedeck-dev/notecli
Length of output: 28534
Connected status を EventBus 経由で配信してください。
このコードパスは self.emitter.emit(...) のみを実行し、EventBus へ送信しません。SSE/イベントバス消費者は StreamEvent::Status を受信できません。Status は emit_both(emitter, &event_bus, ...) に移してください。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/streaming.rs` around lines 483 - 487, Update the Connected status path to
dispatch the StreamEvent::Status through EventBus as well as self.emitter by
using the existing emit_both helper with the relevant emitter and event_bus
references, ensuring SSE and event-bus consumers receive the status.
Source: Coding guidelines
なぜ
notedeck のフロントはカラムのマウントや復帰のたびに
stream_connectを無条件に呼ぶ。polling モード中でもこの呼び出しが WS 接続を張り直してしまい、永続化されたモードと実動作が乖離する (notedeck-dev/notedeck#1004)。何を
StreamingManager::connectの意味を「ストリームを現在のモードで確保する」に揃える。polling タスクがそのアカウントのストリームを供給中なら、Connected を emit して即 return し、WS は張らない。WS へ戻す唯一の経路はset_mode("realtime")。🤖 Generated with Claude Code
Summary by CodeRabbit