perf(sse): tee re-parses each OpenCode event 4-5x and broadcasts session.activity per token #718
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
follow-up
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#718
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up from the perf report (second tier).
Symptom: `internal/autoapprove/tee.go:237-295`: global envelope unmarshal → `string(global.Payload)` copy → recursive unmarshal → `typeOnly` unmarshal → `parseSessionRef` 1-2 unmarshals; `dispatchTerminalPart` (:297-358) adds 1-2 more on `message.part.updated` with full tool output. `watcher_session_events.go:22-37` then `json.Marshal`s + `broadcastGlobalEvent`s an `ocman.session.activity` event per `message.part.delta`, and `server/broadcast.go:134-152` `coalesceKey` re-unmarshals inside the hub lock when a subscriber is full. Cost is ~5x payload per event on every `/global/event` stream and every per-tab `/api/session/{id}/events` tee (`events.go:18-63`).
Fix: one `json.Unmarshal` into `{Type string; Directory string; Properties json.RawMessage}` and pass the raw properties down; rate-limit `ocman.session.activity` per session (~250 ms). The frontend now ignores same-minute activity (useSidebarSessions), so the server-side limiter is about wire/CPU, not correctness.